diff --git a/src/finance.c b/src/finance.c index dc6276455d..ad0626a52f 100644 --- a/src/finance.c +++ b/src/finance.c @@ -26,9 +26,21 @@ #include "ride.h" #include "window.h" -// monthly cost -const int wage_table[4] = { 500, 800, 600, 550 }; -const int research_cost_table[4] = { 0, 1000, 2000, 4000 }; +// Monthly staff wages +const money32 wage_table[4] = { + MONEY(50,00), // Handyman + MONEY(80,00), // Mechanic + MONEY(60,00), // Security guard + MONEY(55,00) // Entertainer +}; + +// Monthly research funding costs +const money32 research_cost_table[4] = { + MONEY( 0,00), // No funding + MONEY(100,00), // Minimum funding + MONEY(200,00), // Normal funding + MONEY(400,00) // Maximum funding +}; /** * @@ -36,17 +48,16 @@ const int research_cost_table[4] = { 0, 1000, 2000, 4000 }; * @param amount (eax) * @param type passed via global var 0x0141F56C, our type is that var/4. **/ -void finance_payment(int amount, rct_expenditure_type type) +void finance_payment(money32 amount, rct_expenditure_type type) { - int test = RCT2_GLOBAL(0x13CA740, uint32); - sint32 cur_money = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)); - sint32 new_money = cur_money - amount; + money32 cur_money = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)); + money32 new_money = cur_money - amount; //overflow check RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(new_money); - RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, sint32)[type] -= amount; + RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[type] -= amount; if (RCT2_ADDRESS(0x00988E60, uint32)[type] & 1) - RCT2_GLOBAL(0x0135832C, sint32) -= amount; + RCT2_GLOBAL(0x0135832C, money32) -= amount; RCT2_GLOBAL(0x009A9804, uint32) |= 1; // money diry flag @@ -93,14 +104,14 @@ void finance_pay_research() **/ void finance_pay_interest() { - sint32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32); + money32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32); sint16 current_interest = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, sint16); - sint64 tempcost = (current_loan * 5 * current_interest) >> 14; // (5*interest)/2^14 is pretty close to + money32 tempcost = (current_loan * 5 * current_interest) >> 14; // (5 * interest) / 2^14 is pretty close to if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800) return; - finance_payment((sint32)tempcost, RCT_EXPENDITURE_TYPE_INTEREST); + finance_payment(tempcost, RCT_EXPENDITURE_TYPE_INTEREST); } /** @@ -139,28 +150,28 @@ void finance_pay_ride_upkeep() void finance_init() { for (short i = 0; i < 56; i++) { - RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, uint32)[i] = 0; + RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = 0; } RCT2_GLOBAL(0x0135832C, uint32) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, uint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0; RCT2_GLOBAL(0x01358334, uint32) = 0; RCT2_GLOBAL(0x01358338, uint16) = 0; - RCT2_GLOBAL(0x013573DC, sint32) = 100000; // Cheat detection + RCT2_GLOBAL(0x013573DC, money32) = MONEY(10000,00); // Cheat detection - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(100000); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32) = 100000; - RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, sint32) = 200000; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(MONEY(10000,00)); + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) = MONEY(10000,00); + RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, money32) = MONEY(20000,00); RCT2_GLOBAL(0x013587D0, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, uint8) = 10; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, sint32) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, sint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, money32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, money32) = MONEY32_UNDEFINED; RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, uint32) = 0; @@ -169,14 +180,15 @@ void finance_init() { sub_69E869(); } -void sub_69E869() { +void sub_69E869() +{ // This subroutine is loan related and is used for cheat detection sint32 value = 0x70093A; - value -= RCT2_GLOBAL(0x013573DC, sint32); // Cheat detection + value -= RCT2_GLOBAL(0x013573DC, money32); // Cheat detection value = ror32(value, 5); - value -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32); + value -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32); value = ror32(value, 7); - value += RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, sint32); + value += RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, money32); value = ror32(value, 3); RCT2_GLOBAL(0x013587C4, sint32) = value; } \ No newline at end of file diff --git a/src/finance.h b/src/finance.h index c6ff44ab93..fb63ae127f 100644 --- a/src/finance.h +++ b/src/finance.h @@ -23,8 +23,6 @@ #include "rct2.h" -#define CURRENCY(whole, fraction) ((whole) * 10 + ((fraction) / 10)) - typedef int rct_expenditure_type; enum { @@ -35,7 +33,7 @@ enum { }; -void finance_payment(int amount, rct_expenditure_type type); +void finance_payment(money32 amount, rct_expenditure_type type); void finance_pay_wages(); void finance_pay_research(); void finance_pay_interest(); diff --git a/src/park.c b/src/park.c index 7fc5d11c55..5031d7640b 100644 --- a/src/park.c +++ b/src/park.c @@ -71,7 +71,7 @@ void park_init() for (i = 0; i < 56; i++) RCT2_ADDRESS(0x01357BD0, sint32)[i] = -1; - RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16) = CURRENCY(10, 00); + RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16) = MONEY(10, 00); RCT2_GLOBAL(0x013573F2, sint16) = -1; RCT2_GLOBAL(0x013573F8, sint16) = -1; RCT2_GLOBAL(0x01357CF2, uint16) = 127; @@ -111,9 +111,9 @@ void park_reset_awards_and_history() // Reset finance history for (i = 0; i < 128; i++) { - RCT2_ADDRESS(RCT2_ADDRESS_BALANCE_HISTORY, uint32)[i] = 0x80000000; - RCT2_ADDRESS(RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY, uint32)[i] = 0x80000000; - RCT2_ADDRESS(RCT2_ADDRESS_PARK_VALUE_HISTORY, uint32)[i] = 0x80000000; + RCT2_ADDRESS(RCT2_ADDRESS_BALANCE_HISTORY, money32)[i] = MONEY32_UNDEFINED; + RCT2_ADDRESS(RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY, money32)[i] = MONEY32_UNDEFINED; + RCT2_ADDRESS(RCT2_ADDRESS_PARK_VALUE_HISTORY, money32)[i] = MONEY32_UNDEFINED; } // Reset awards @@ -278,56 +278,65 @@ int calculate_park_rating() return result; } +money32 calculate_ride_value(rct_ride *ride) +{ + if (ride->type == RIDE_TYPE_NULL) + return 0; + if (ride->reliability == 0xFFFF) + return 0; + + // Reliability * (...) + return (ride->reliability * 10) * ( + ride->var_124 + ride->var_126 + ride->var_128 + ride->var_12A + + ride->var_12C + ride->var_12E + ride->age + ride->running_cost + + ride->var_134 + ride->var_136 + + *((uint8*)(0x0097D21E + (ride->type * 8))) * 4 + ); +} + /** * * rct2: 0x0066A3F6 */ -int calculate_park_value() +money32 calculate_park_value() { - int result, value, i; + int i; + money32 result; rct_ride* ride; + // Sum ride values result = 0; for (i = 0; i < 255; i++) { ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); - if (ride->type == RIDE_TYPE_NULL) - continue; - if (ride->reliability == 0xFFFF) - continue; - value = 0; - value += ride->var_124 + ride->var_126 + ride->var_128 + ride->var_12A; - value += ride->var_12C + ride->var_12E + ride->age + ride->running_cost; - value += ride->var_134 + ride->var_136; - value += *((uint8*)(0x0097D21E + (ride->type * 8))) * 4; - value *= ride->reliability * 10; - result += value; + result += calculate_ride_value(ride); } - result += RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) * 70; + // +7.00 per guest + result += RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) * MONEY(7, 00); return result; } /** - * + * Calculate the company value. + * Cash + Park Value - Loan + * * rct2: 0x0066A498 */ -int calculate_company_value() +money32 calculate_company_value() { - int result; - - result = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)); - result += RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32); - result -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32); - - return result; + return + DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)) + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) - + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32); } /** * * rct2: 0x00667104 */ -void reset_park_entrances() { +void reset_park_entrances() +{ RCT2_GLOBAL(0x013573D4, uint16) = 0; for (short i = 0; i < 4; i++) { diff --git a/src/park.h b/src/park.h index 177e4755a5..b9663c56fb 100644 --- a/src/park.h +++ b/src/park.h @@ -74,8 +74,8 @@ void park_reset_awards_and_history(); int park_calculate_size(); int calculate_park_rating(); -int calculate_park_value(); -int calculate_company_value(); +money32 calculate_park_value(); +money32 calculate_company_value(); void reset_park_entrances(); #endif diff --git a/src/peep.h b/src/peep.h index 529eef7d16..266eb2bded 100644 --- a/src/peep.h +++ b/src/peep.h @@ -353,7 +353,7 @@ typedef struct { uint8 intensity; // 0x43 uint8 nausea_tolerance; // 0x44 uint8 pad_45; - uint16 paid_on_drink; // 0x46 + money16 paid_on_drink; // 0x46 uint8 pad_48[0x10]; uint32 item_extra_flags; // 0x58 uint8 photo2_ride_ref; // 0x5C @@ -368,8 +368,8 @@ typedef struct { uint8 pad_6D[0x0F]; uint8 rides_been_on[32]; // 0x7C uint32 id; // 0x9C - sint32 cash_in_pocket; // 0xA0 - sint32 cash_spent; // 0xA4 + money32 cash_in_pocket; // 0xA0 + money32 cash_spent; // 0xA4 uint8 pad_A8; sint32 time_in_park; // 0xA9 uint8 pad_AD[0x3]; @@ -381,10 +381,10 @@ typedef struct { uint32 flags; // 0xC8 uint8 var_CC; uint8 pad_CD[0x17]; - uint16 paid_to_enter; // 0xE4 - uint16 paid_on_rides; // 0xE6 - uint16 paid_on_food; // 0xE8 - uint16 paid_on_souvenirs; // 0xEA + money16 paid_to_enter; // 0xE4 + money16 paid_on_rides; // 0xE6 + money16 paid_on_food; // 0xE8 + money16 paid_on_souvenirs; // 0xEA uint8 no_of_food; // 0xEC uint8 no_of_drinks; // 0xED uint8 no_of_souvenirs; // 0xEE diff --git a/src/rct2.c b/src/rct2.c index 52b4f666ff..ccbd24d64d 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -45,6 +45,8 @@ #include "track.h" #include "viewport.h" +typedef struct tm tm_t; + void print_launch_information(); void rct2_init_directories(); @@ -85,19 +87,19 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta void print_launch_information() { + char buffer[32]; + time_t timer; + tm_t* tmInfo; + // Print version information printf("Starting %s v%s\n", OPENRCT2_NAME, OPENRCT2_VERSION); printf(" %s (%s)\n", OPENRCT2_PLATFORM, OPENRCT2_ARCHITECTURE); printf(" %s\n\n", OPENRCT2_TIMESTAMP); // Print current time - time_t timer; - char buffer[32]; - struct tm* tm_info; - - time(&timer); - tm_info = localtime(&timer); - strftime(buffer, 25, "%Y/%m/%d %H:%M:%S", tm_info); + time(&timer); + tmInfo = localtime(&timer); + strftime(buffer, sizeof(buffer), "%Y/%m/%d %H:%M:%S", tmInfo); printf("Time: %s\n", buffer); // TODO Print other potential information (e.g. user, hardware) diff --git a/src/rct2.h b/src/rct2.h index a379e74a2b..a872cc25fc 100644 --- a/src/rct2.h +++ b/src/rct2.h @@ -64,6 +64,26 @@ typedef unsigned long long uint64; #define OPENRCT2_PLATFORM "Windows" #define OPENRCT2_TIMESTAMP __DATE__ " " __TIME__ +// Represent fixed point numbers +typedef sint16 fixed16_1dp; +typedef sint16 fixed16_2dp; +typedef sint32 fixed32_1dp; +typedef sint32 fixed32_2dp; + +// Money is stored as a multiple of 0.10. +typedef fixed16_1dp money16; +typedef fixed32_1dp money32; + +// Construct a fixed point number. +#define FIXED_XDP(x, whole, fraction) ((whole) * (10 * x) + (fraction)) +#define FIXED_1DP(whole, fraction) FIXED_XDP(1, whole, fraction) +#define FIXED_2DP(whole, fraction) FIXED_XDP(2, whole, fraction) + +// Construct a money value in the format MONEY(10,70) to represent 10.70. Fractional part must be two digits. +#define MONEY(whole, fraction) ((whole) * 10 + ((fraction) / 10)) + +#define MONEY32_UNDEFINED ((money32)0x80000000) + void rct2_finish(); enum { diff --git a/src/ride.h b/src/ride.h index 62293c08a2..ba6814d20f 100644 --- a/src/ride.h +++ b/src/ride.h @@ -61,7 +61,7 @@ typedef struct { sint16 running_cost; // 0x132 sint16 var_134; sint16 var_136; - sint16 price; // 0x138 + money16 price; // 0x138 uint8 pad_13A[0x06]; sint16 excitement; // 0x140 sint16 intensity; // 0x142 @@ -81,7 +81,7 @@ typedef struct { uint8 pad_198; uint8 var_199; uint8 pad_19A[0x1A]; - sint32 profit; // 0x1B4 + money32 profit; // 0x1B4 uint8 queue_time[4]; // 0x1B8 uint8 pad_1BC[0x12]; uint16 guests_favourite; // 0x1CE diff --git a/src/scenario.c b/src/scenario.c index 895e83aa59..9e4d557af7 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -484,9 +484,9 @@ void scenario_load_and_play(rct_scenario_basic *scenario) window_park_objective_open(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, sint16) = calculate_park_rating(); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint16) = calculate_park_value(); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, sint16) = calculate_company_value(); - RCT2_GLOBAL(0x013587D0, sint16) = RCT2_GLOBAL(0x013573DC, sint16) - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint16); + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) = calculate_park_value(); + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, money32) = calculate_company_value(); + RCT2_GLOBAL(0x013587D0, money32) = RCT2_GLOBAL(0x013573DC, money32) - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(RCT2_GLOBAL(0x013573DC, sint32)); sub_69E869(); // (loan related) diff --git a/src/window_footpath.c b/src/window_footpath.c index ec2e3ac941..be584cde20 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -152,7 +152,7 @@ static void* window_footpath_events[] = { window_footpath_emptysub }; -sint32 _window_footpath_cost; +money32 _window_footpath_cost; static void window_footpath_show_footpath_types_dialog(rct_window *w, rct_widget *widget, int showQueues); static void window_footpath_set_provisional_path_at_point(int x, int y); @@ -832,7 +832,7 @@ static int window_footpath_set_provisional_path(int type, int x, int y, int z, i // Try and show provisional path cost = game_do_command(x, (slope << 8) | 121, y, (type << 8) | z, 17, 0, 0); - if (cost != 0x80000000) { + if (cost != MONEY32_UNDEFINED) { RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_Z, uint8) = z & 0xFF; @@ -888,7 +888,7 @@ static void window_footpath_place_path_at_point(int x, int y) // Try and place path cost = game_do_command(x, (presentType << 8) | 1, y, (selectedType << 8) | z, 17, 0, 0); - if (cost == 0x80000000) { + if (cost == MONEY32_UNDEFINED) { RCT2_GLOBAL(RCT2_ADDRESS_PATH_ERROR_OCCURED, uint8) = 1; } else if (RCT2_GLOBAL(0x00F3EFD9, uint32) != 0) { // bp = 0x009DEA62 @@ -918,7 +918,7 @@ static void window_footpath_remove() // RCT2_CALLPROC_EBPSAFE(0x006A7863); - _window_footpath_cost = 0x80000000; + _window_footpath_cost = MONEY32_UNDEFINED; RCT2_CALLPROC_EBPSAFE(0x006A7831); x = RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_FROM_X, uint16) / 32; diff --git a/src/window_land.c b/src/window_land.c index 0d6624e8d3..0e092a771b 100644 --- a/src/window_land.c +++ b/src/window_land.c @@ -137,8 +137,8 @@ void window_land_open() RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_EDGE, uint8) = 255; _selectedFloorTexture = 0; _selectedWallTexture = 0; - RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, sint32) = 0x80000000; - RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, sint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, money32) = MONEY32_UNDEFINED; + RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, money32) = MONEY32_UNDEFINED; window->colours[0] = 24; window->colours[1] = 24; window->colours[2] = 24; @@ -393,7 +393,8 @@ static void window_land_paint() { rct_window *w; rct_drawpixelinfo *dpi; - int x, y, price, numTiles; + int x, y, numTiles; + money32 price; #ifdef _MSC_VER __asm mov w, esi @@ -425,12 +426,12 @@ static void window_land_paint() y = w->y + window_land_widgets[WIDX_PREVIEW].bottom + 5; // Draw raise cost amount - if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, uint32) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, uint32) != MONEY32_UNDEFINED && RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, uint32) != 0) gfx_draw_string_centred(dpi, 984, x, y, 0, (void*)RCT2_ADDRESS_LAND_RAISE_COST); y += 10; // Draw lower cost amount - if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, uint32) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, uint32) != MONEY32_UNDEFINED && RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, uint32) != 0) gfx_draw_string_centred(dpi, 985, x, y, 0, (void*)RCT2_ADDRESS_LAND_LOWER_COST); y += 50; diff --git a/src/window_park.c b/src/window_park.c index e22df34d2e..a87c9d0ee4 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -2095,13 +2095,13 @@ static void window_park_objective_paint() y += 5; // Objective outcome - if (RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) != 0x80000000) { - if (RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) == 0x80000001) { + if (RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, money32) != MONEY32_UNDEFINED) { + if (RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, money32) == 0x80000001) { // Objective failed gfx_draw_string_left_wrapped(dpi, NULL, x, y, 222, 2789, 0); } else { // Objective completed - RCT2_GLOBAL(0x013CE952, int) = RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32); + RCT2_GLOBAL(0x013CE952, int) = RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, money32); gfx_draw_string_left_wrapped(dpi, (void*)0x013CE952, x, y, 222, 2788, 0); } } diff --git a/src/window_ride_list.c b/src/window_ride_list.c index be78d9da0b..b365ee8eec 100644 --- a/src/window_ride_list.c +++ b/src/window_ride_list.c @@ -607,7 +607,7 @@ static void window_ride_list_scrollpaint() break; case INFORMATION_TYPE_PROFIT: formatSecondary = 0; - if (ride->profit != 0x80000000) { + if (ride->profit != MONEY32_UNDEFINED) { formatSecondary = STR_PROFIT_LABEL; RCT2_GLOBAL(0x013CE952 + 2, sint32) = ride->profit; } diff --git a/src/window_water.c b/src/window_water.c index 17a9fc21fb..3300255a67 100644 --- a/src/window_water.c +++ b/src/window_water.c @@ -102,8 +102,8 @@ void window_water_open() window_init_scroll_widgets(window); window_push_others_below(window); - RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) = 0x80000000; - RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) = MONEY32_UNDEFINED; + RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) = MONEY32_UNDEFINED; window->colours[0] = 24; window->colours[1] = 24; window->colours[2] = 24; @@ -236,12 +236,12 @@ static void window_water_paint() // Draw raise cost amount x = (window_water_widgets[WIDX_PREVIEW].left + window_water_widgets[WIDX_PREVIEW].right) / 2 + w->x; y = window_water_widgets[WIDX_PREVIEW].bottom + w->y + 5; - if (RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) != MONEY32_UNDEFINED && RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) != 0) gfx_draw_string_centred(dpi, 984, x, y, 0, (void*)RCT2_ADDRESS_WATER_RAISE_COST); y += 10; // Draw lower cost amount - if (RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) != MONEY32_UNDEFINED && RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) != 0) gfx_draw_string_centred(dpi, 985, x, y, 0, (void*)RCT2_ADDRESS_WATER_LOWER_COST); }