1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Merge cases with identical calls

This commit is contained in:
Ted John
2016-10-08 21:49:28 +01:00
parent 04a468c9a0
commit 23246c2d3f
3 changed files with 30 additions and 2 deletions

View File

@@ -333,6 +333,16 @@ private:
if (calls[direction].size() == 0) continue;
WriteLine(tabs, "case %d:", direction);
for (int d2 = direction + 1; d2 < 4; d2++)
{
if (CompareFunctionCalls(calls[direction], calls[d2]))
{
// Clear identical other direction calls and add case for it
calls[d2].clear();
WriteLine(tabs, "case %d:", d2);
}
}
for (auto call : calls[direction])
{
GenerateCalls(tabs + 1, call, height);
@@ -406,6 +416,24 @@ private:
}
}
bool CompareFunctionCalls(const std::vector<function_call> &a, const std::vector<function_call> &b)
{
if (a.size() != b.size()) return false;
for (size_t i = 0; i < a.size(); i++)
{
if (!CompareFunctionCall(a[i], b[i]))
{
return false;
}
}
return true;
}
bool CompareFunctionCall(const function_call a, const function_call &b)
{
return assertFunctionCallEquals(a, b);
}
const char * GetFunctionCallName(int function)
{
const char * functionNames[] = {

View File

@@ -32,7 +32,6 @@ extern const utf8string TrackNames[256];
extern const utf8string FlatTrackNames[256];
static uint8 callCount;
static bool assertFunctionCallEquals(function_call expected, function_call actual);
static function_call calls[256];
void intercept_clear_calls()
@@ -267,7 +266,7 @@ static void canonicalizeFunctionCall(function_call *call) {
call->function = PAINT_98196C;
}
static bool assertFunctionCallEquals(function_call expected, function_call actual) {
bool assertFunctionCallEquals(function_call expected, function_call actual) {
canonicalizeFunctionCall(&actual);
canonicalizeFunctionCall(&expected);

View File

@@ -83,6 +83,7 @@ extern "C"
bool testVerticalTunnels(uint8 rideType, uint8 trackType);
void intercept_clear_calls();
int intercept_get_calls(function_call * buffer);
bool assertFunctionCallEquals(function_call expected, function_call actual);
int generatePaintCode(uint8 rideType);
#ifdef __cplusplus