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

Merge pull request #392 from DutchRPW/master

Money related stuff
This commit is contained in:
Ted John
2014-08-31 12:21:26 +01:00
14 changed files with 97 additions and 33 deletions

View File

@@ -236,6 +236,7 @@
#define RCT2_ADDRESS_OBJECTIVE_CURRENCY 0x013580FC
#define RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS 0x01358100
#define RCT2_ADDRESS_BALANCE_HISTORY 0x0135812C
#define RCT2_ADDRESS_CURRENT_EXPENDITURE 0x0135832C
#define RCT2_ADDRESS_CURRENT_PROFIT 0x01358330
#define RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY 0x0135833C
#define RCT2_ADDRESS_CURRENT_PARK_VALUE 0x0135853C

View File

@@ -155,7 +155,7 @@ static int award_is_deserved_best_value(int awardType, int activeAwardTypes)
return 0;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_DISAPPOINTING))
return 0;
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & (PARK_FLAGS_11 | PARK_FLAGS_PARK_FREE_ENTRY))
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & (PARK_FLAGS_NO_MONEY | PARK_FLAGS_PARK_FREE_ENTRY))
return 0;
if (RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, money16) < MONEY(10, 00))
return 0;
@@ -205,7 +205,7 @@ static int award_is_deserved_worse_value(int awardType, int activeAwardTypes)
{
if (activeAwardTypes & (1 << PARK_AWARD_BEST_VALUE))
return 0;
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
return 0;
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16) == MONEY(0, 00))
return 0;

View File

@@ -57,7 +57,7 @@ void finance_payment(money32 amount, rct_expenditure_type type)
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(new_money);
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[type] -= amount;
if (RCT2_ADDRESS(0x00988E60, uint32)[type] & 1)
RCT2_GLOBAL(0x0135832C, money32) -= amount;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) -= amount; // Cumulative amount of money spent this day
RCT2_GLOBAL(0x009A9804, uint32) |= 1; // money diry flag
@@ -74,7 +74,7 @@ void finance_pay_wages()
rct_peep* peep;
uint16 spriteIndex;
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
return;
FOR_ALL_STAFF(spriteIndex, peep)
@@ -89,7 +89,7 @@ void finance_pay_research()
{
uint8 level;
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
return;
level = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8);
@@ -106,7 +106,7 @@ void finance_pay_interest()
sint16 current_interest = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, sint16);
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)
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
return;
finance_payment(tempcost, RCT_EXPENDITURE_TYPE_INTEREST);
@@ -127,7 +127,7 @@ void finance_pay_ride_upkeep()
ride->var_196 = 25855; // durability?
}
if (ride->status != RIDE_STATUS_CLOSED && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) {
if (ride->status != RIDE_STATUS_CLOSED && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
sint16 upkeep = ride->upkeep_cost;
if (upkeep != -1) {
ride->var_154 -= upkeep;
@@ -158,11 +158,10 @@ void finance_init() {
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = 0;
}
RCT2_GLOBAL(0x0135832C, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0;
RCT2_GLOBAL(0x01358334, uint32) = 0;
RCT2_GLOBAL(0x01358334, money32) = 0;
RCT2_GLOBAL(0x01358338, uint16) = 0;
RCT2_GLOBAL(0x013573DC, money32) = MONEY(10000,00); // Cheat detection
@@ -185,6 +184,58 @@ void finance_init() {
sub_69E869();
}
/**
*
* rct2: 0x0069E79A
*/
void finance_update_daily_profit()
{
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 7 * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32);
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) = 0; // Reset daily expenditure
money32 current_profit = 0;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
{
// Staff costs
uint16 sprite_index;
rct_peep *peep;
FOR_ALL_STAFF(sprite_index, peep) {
uint8 staff_type = peep->staff_type;
current_profit -= wage_table[peep->staff_type];
}
// Research costs
uint8 level = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8);
current_profit -= research_cost_table[level];
// Loan costs
money32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32);
current_profit -= current_loan / 600;
// Ride costs
rct_ride *ride;
int i;
FOR_ALL_RIDES(i, ride) {
if (ride->status != RIDE_STATUS_CLOSED && ride->upkeep_cost != -1) {
current_profit -= 2 * ride->upkeep_cost;
}
}
}
// This is not equivalent to / 4 due to rounding of negative numbers
current_profit = current_profit >> 2;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) += current_profit;
// These are related to weekly profit graph
RCT2_GLOBAL(0x1358334, money32) += RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32);
RCT2_GLOBAL(0x1358338, uint16) += 1;
window_invalidate_by_id(WC_FINANCES, 0);
}
void sub_69E869()
{
// This subroutine is loan related and is used for cheat detection

View File

@@ -41,6 +41,7 @@ void finance_pay_interest();
void finance_pay_ride_upkeep();
void finance_reset_history();
void finance_init();
void finance_update_daily_profit();
void sub_69E869();
#endif

View File

@@ -1303,7 +1303,7 @@ void handle_shortcut_command(int shortcutIndex)
break;
case SHORTCUT_SHOW_FINANCIAL_INFORMATION:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C))
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800))
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
window_finances_open();
break;
case SHORTCUT_SHOW_RESEARCH_INFORMATION:

View File

@@ -103,7 +103,7 @@ void park_init()
RCT2_GLOBAL(RCT2_ADDRESS_LAND_COST, uint16) = MONEY(90, 00);
RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCTION_RIGHTS_COST, uint16) = MONEY(40,00);
RCT2_GLOBAL(0x01358774, uint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_11 | PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_NO_MONEY | PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
park_reset_history();
finance_reset_history();
award_reset();
@@ -427,7 +427,7 @@ static int park_calculate_guest_generation_probability()
probability /= 4;
// Check if money is enabled
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
// Penalty for overpriced entrance fee relative to total ride value
money16 entranceFee = RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16);
if (entranceFee > totalRideValue) {

View File

@@ -35,11 +35,11 @@ enum {
PARK_FLAGS_PREF_LESS_INTENSE_RIDES = (1 << 6),
PARK_FLAGS_FORBID_MARKETING_CAMPAIGN = (1 << 7),
PARK_FLAGS_PREF_MORE_INTENSE_RIDES = (1 << 8),
PARK_FLAGS_11 = (1 << 11), // appears to be a copy of PARK_FLAGS_NO_MONEY
PARK_FLAGS_NO_MONEY = (1 << 11),
PARK_FLAGS_DIFFICULT_GUEST_GENERATION = (1 << 12),
PARK_FLAGS_PARK_FREE_ENTRY = (1 << 13),
PARK_FLAGS_DIFFICULT_PARK_RATING = (1 << 14),
PARK_FLAGS_NO_MONEY = (1 << 17),
PARK_FLAGS_NO_MONEY_SCENARIO = (1 << 17), // equivalent to PARK_FLAGS_NO_MONEY, but used in scenario editor
PARK_FLAGS_18 = (1 << 18)
};

View File

@@ -142,7 +142,7 @@ void scenario_load(const char *path)
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES);
// Read ?
sawyercoding_read_chunk(file, (uint8*)0x0135832C);
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_EXPENDITURE);
// Read ?
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_PARK_VALUE);
@@ -226,8 +226,8 @@ void scenario_load_and_play(const rct_scenario_basic *scenario)
RCT2_GLOBAL(0x009DEB7C, sint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) &= 0xFFFFF7FF;
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) & 0x20000)
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) |= 0x800;
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) & PARK_FLAGS_NO_MONEY_SCENARIO)
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) |= PARK_FLAGS_NO_MONEY;
RCT2_CALLPROC_EBPSAFE(0x00684AC3);
RCT2_CALLPROC_EBPSAFE(0x006DFEE4);
news_item_init_queue();
@@ -279,9 +279,9 @@ void scenario_load_and_play(const rct_scenario_basic *scenario)
strcat((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, ".SV6");
memset((void*)0x001357848, 0, 56);
RCT2_GLOBAL(0x0135832C, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32) = 0;
RCT2_GLOBAL(0x01358334, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0;
RCT2_GLOBAL(0x01358334, money32) = 0;
RCT2_GLOBAL(0x01358338, uint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = 0x80000000;
RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0;
@@ -577,7 +577,7 @@ void scenario_update()
if ((current_days_in_month * next_month_tick) >> 16 != (current_days_in_month * month_tick) >> 16) {
// daily checks
RCT2_CALLPROC_EBPSAFE(0x0069E79A); // daily profit update
finance_update_daily_profit(); // daily profit update
RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop
get_local_time();
RCT2_CALLPROC_EBPSAFE(0x0066A13C); // objective 6 dragging

View File

@@ -204,8 +204,8 @@ typedef struct {
money32 balance_history[128];
// SC6[11]
uint32 dword_0135832C;
uint32 current_profit;
money32 current_expenditure;
money32 current_profit;
uint32 dword_01358334;
uint16 word_01358338;
uint8 pad_0135833A[2];

View File

@@ -160,7 +160,7 @@ static void window_game_bottom_toolbar_mouseup()
switch (widgetIndex) {
case WIDX_LEFT_OUTSET:
case WIDX_MONEY:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800))
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
window_finances_open();
break;
case WIDX_GUESTS:
@@ -316,7 +316,7 @@ static void window_game_bottom_toolbar_invalidate()
}
// Hide money if there is no money
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800) {
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) {
window_game_bottom_toolbar_widgets[WIDX_MONEY].type = WWT_EMPTY;
window_game_bottom_toolbar_widgets[WIDX_GUESTS].top = 1;
window_game_bottom_toolbar_widgets[WIDX_GUESTS].bottom = 17;
@@ -399,7 +399,7 @@ static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, r
y = window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].top + w->y + 4;
// Draw money
if (!(RCT2_GLOBAL(0x0013573E4, uint32) & 0x800)) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
RCT2_GLOBAL(0x013CE952, int) = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32));
gfx_draw_string_centred(
dpi,

View File

@@ -468,7 +468,7 @@ static void window_new_ride_refresh_widget_sizing(rct_window *w)
window_new_ride_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].type = WWT_GROUPBOX;
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_GROUP].type = WWT_GROUPBOX;
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_FLATBTN;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11))
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
window_new_ride_widgets[WIDX_RESEARCH_FUNDING_BUTTON].type = WWT_FLATBTN;
width = 300;
@@ -944,7 +944,7 @@ static void window_new_ride_paint_ride_information(rct_window *w, rct_drawpixeli
}
// Price
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
// Get price of ride
int unk2 = RCT2_GLOBAL(0x0097CC68 + (item.type * 2), uint8);
money32 price = RCT2_GLOBAL(0x0097DD78 + (item.type * 4), uint16);

View File

@@ -578,6 +578,7 @@ static void window_park_set_page(rct_window *w, int page);
static void window_park_anchor_border_widgets(rct_window *w);
static void window_park_set_pressed_tab(rct_window *w);
static void window_park_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w);
static void window_park_set_disabled_tabs(rct_window *w);
/**
*
@@ -597,7 +598,7 @@ rct_window *window_park_open()
w->list_information_type = -1;
w->var_48C = -1;
w->var_492 = 0;
RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, (int)w, 0, 0);
window_park_set_disabled_tabs(w);
w->colours[0] = 1;
w->colours[1] = 19;
w->colours[2] = 19;
@@ -605,6 +606,16 @@ rct_window *window_park_open()
return w;
}
/**
*
* rct2: 0x00667F8B
*/
void window_park_set_disabled_tabs(rct_window *w)
{
// Disable price tab if money is disabled
w->disabled_widgets = (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) ? (1 << WIDX_TAB_4) : 0;
}
#pragma region Entrance page
/**
@@ -1924,7 +1935,7 @@ static void window_park_set_page(rct_window *w, int page)
w->var_020 = RCT2_GLOBAL(0x0097BAE0 + (page * 4), uint32);
w->event_handlers = window_park_page_events[page];
w->widgets = window_park_page_widgets[page];
RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, (int)w, 0, 0);
window_park_set_disabled_tabs(w);
window_invalidate(w);
RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0);

View File

@@ -500,7 +500,7 @@ void window_peep_disable_widgets(rct_window* w){
if (!(w->disabled_widgets & (1 << WIDX_PICKUP)))
window_invalidate(w);
}
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11){
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
disabled_widgets |= (1 << WIDX_TAB_4); //Disable finance tab if no money
}
w->disabled_widgets = disabled_widgets;

View File

@@ -565,7 +565,7 @@ void window_staff_paint() {
rct2_free(sprite_dpi);
}
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
RCT2_GLOBAL(0x013CE952, uint32) = RCT2_ADDRESS(0x00992A00, uint16)[selectedTab];
gfx_draw_string_left(dpi, 1858, (void*)0x013CE952, 0, w->x + 0xA5, w->y + 0x20);
}