1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 04:53:12 +01:00

finish implementing income tab on ride window apart from command events

This commit is contained in:
IntelOrca
2014-09-06 00:58:02 +01:00
parent 651a5a35ea
commit 13fd5de6ce
5 changed files with 97 additions and 17 deletions

View File

@@ -130,7 +130,7 @@ void finance_pay_ride_upkeep()
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;
ride->total_profit -= upkeep;
ride->var_14D |= 2;
finance_payment(upkeep, RCT2_EXPENDITURE_TYPE_RIDE_UPKEEP);
}

View File

@@ -132,13 +132,13 @@ typedef struct {
uint8 var_14D;
uint8 pad_14E[0x02];
uint32 total_customers; // 0x150
uint32 var_154;
money32 total_profit; // 0x154
uint16 var_158;
uint8 pad_15A;
uint8 num_riders; // 0x15B
uint8 pad_15C[0x24];
sint16 build_date; // 0x180
sint16 upkeep_cost; // 0x182
money16 upkeep_cost; // 0x182
uint16 race_winner; // 0x184
uint8 pad_186[0x06];
uint8 var_18C;
@@ -157,9 +157,9 @@ typedef struct {
uint32 var_1A4;
uint8 pad_1A8[6];
uint8 var_1AE;
uint8 connected_message_throttle;
uint32 pad_1B0;
sint32 profit; // 0x1B4
uint8 connected_message_throttle; // 0x1AF
money32 income_per_hour; // 0x1B0
money32 profit; // 0x1B4
uint8 queue_time[4]; // 0x1B8
uint8 var_1BC;
uint8 pad_1BD[0x0B];
@@ -173,7 +173,7 @@ typedef struct {
// Example value for wild mouse ride is d5 (before it's been constructed)
// I tried searching the IDA file for "1F4" but couldn't find places where
// this is written to.
uint16 totalAirTime; // 0x1F4
uint16 total_air_time; // 0x1F4
uint8 pad_1F6[0x0a];
uint16 queue_length[4]; // 0x200
uint8 pad_208[0x58];

View File

@@ -179,7 +179,7 @@ rating_tuple per_ride_rating_adjustments(rct_ride *ride, ride_rating excitement,
// more detail: https://gist.github.com/kevinburke/d951e74e678b235eef3e
uint16 ridetype_var = RCT2_GLOBAL(0x0097D4F2 + ride->type * 8, uint16);
if (ridetype_var & 0x80) {
uint16 ax = ride->totalAirTime;
uint16 ax = ride->total_air_time;
if (rideType->var_008 & 0x800) {
// 65e86e
ax = ax - 96;

View File

@@ -549,11 +549,16 @@ enum {
STR_PLAY_MUSIC = 1849,
STR_SELECT_MUSIC_TIP = 1850,
STR_RUNNING_COST_PER_HOUR = 1851,
STR_RUNNING_COST_UNKNOWN = 1852,
STR_BUILT_THIS_YEAR = 1853,
STR_BUILT_LAST_YEAR = 1854,
STR_BUILT_YEARS_AGO = 1855,
STR_PROFIT_PER_ITEM_SOLD = 1856,
STR_LOSS_PER_ITEM_SOLD = 1857,
STR_COST_PER_MONTH = 1858,
STR_HANDYMAN_PLURAL = 1859,
STR_MECHANIC_PLURAL = 1860,
STR_SECURITY_GUARD_PLURAL = 1861,
@@ -564,6 +569,9 @@ enum {
STR_ENTERTAINER_SINGULAR = 1866,
STR_STAFF_LIST_COUNTER = 1867,
STR_INCOME_PER_HOUR = 1873,
STR_PROFIT_PER_HOUR = 1874,
STR_INSPECT_RIDES = 1876,
STR_FIX_RIDES = 1877,
STR_INSPECTION = 1878,

View File

@@ -2502,7 +2502,7 @@ static void window_ride_measurements_paint()
y += 10;
// Total 'air' time
totalAirTime = ride->totalAirTime * 3;
totalAirTime = ride->total_air_time * 3;
gfx_draw_string_left(dpi, STR_TOTAL_AIR_TIME, &totalAirTime, 0, x, y);
y += 10;
}
@@ -2544,7 +2544,7 @@ static void window_ride_measurements_paint()
*/
static void window_ride_income_toggle_primary_price(rct_window *w)
{
RCT2_CALLPROC_X(0x006ADEFD, 0, 0, 0, 0, (int)w, 0, 0);
}
/**
@@ -2553,7 +2553,7 @@ static void window_ride_income_toggle_primary_price(rct_window *w)
*/
static void window_ride_income_toggle_secondary_price(rct_window *w)
{
RCT2_CALLPROC_X(0x006AE06E, 0, 0, 0, 0, (int)w, 0, 0);
}
/**
@@ -2562,7 +2562,7 @@ static void window_ride_income_toggle_secondary_price(rct_window *w)
*/
static void window_ride_income_increase_primary_price(rct_window *w)
{
RCT2_CALLPROC_X(0x006AE1E4, 0, 0, 0, 0, (int)w, 0, 0);
}
/**
@@ -2571,7 +2571,7 @@ static void window_ride_income_increase_primary_price(rct_window *w)
*/
static void window_ride_income_decrease_primary_price(rct_window *w)
{
RCT2_CALLPROC_X(0x006AE237, 0, 0, 0, 0, (int)w, 0, 0);
}
/**
@@ -2580,7 +2580,7 @@ static void window_ride_income_decrease_primary_price(rct_window *w)
*/
static void window_ride_income_increase_secondary_price(rct_window *w)
{
RCT2_CALLPROC_X(0x006AE269, 0, 0, 0, 0, (int)w, 0, 0);
}
/**
@@ -2589,7 +2589,7 @@ static void window_ride_income_increase_secondary_price(rct_window *w)
*/
static void window_ride_income_decrease_secondary_price(rct_window *w)
{
RCT2_CALLPROC_X(0x006AE28D, 0, 0, 0, 0, (int)w, 0, 0);
}
/**
@@ -2623,7 +2623,7 @@ static void window_ride_income_mouseup()
window_ride_income_toggle_primary_price(w);
break;
case WIDX_SECONDARY_PRICE_SAME_THROUGHOUT_PARK:
window_ride_income_toggle_primary_price(w);
window_ride_income_toggle_secondary_price(w);
break;
}
}
@@ -2808,11 +2808,83 @@ static void window_ride_income_paint()
{
rct_window *w;
rct_drawpixelinfo *dpi;
rct_ride *ride;
rct_ride_type *rideEntry, **rideEntries = (rct_ride_type**)0x009ACFA4;
rct_string_id stringId;
money32 profit, costPerHour;
int x, y, primaryItem, secondaryItem;
window_paint_get_registers(w, dpi);
window_draw_widgets(w, dpi);
window_ride_draw_tab_images(dpi, w);
ride = GET_RIDE(w->number);
rideEntry = rideEntries[ride->subtype];
x = w->x + window_ride_income_widgets[WIDX_PAGE_BACKGROUND].left + 4;
y = w->y + window_ride_income_widgets[WIDX_PAGE_BACKGROUND].top + 29;
// Primary item profit / loss per item sold
primaryItem = (sint8)rideEntry->shop_item;
if (primaryItem != -1) {
profit = ride->price;
stringId = STR_PROFIT_PER_ITEM_SOLD;
profit -= primaryItem < 32 ?
RCT2_GLOBAL(0x00982164 + (primaryItem * 8), uint16) :
RCT2_GLOBAL(0x00982144 + (primaryItem * 8), uint16);
if (profit < 0) {
profit *= -1;
stringId = STR_LOSS_PER_ITEM_SOLD;
}
gfx_draw_string_left(dpi, stringId, &profit, 0, x, y);
}
y += 39;
// Secondary item profit / loss per item sold
secondaryItem = RCT2_GLOBAL(0x0097D7CB + (ride->type * 4), uint8);
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO))
secondaryItem = (sint8)rideEntry->shop_item_secondary;
if (secondaryItem != -1) {
profit = ride->price_secondary;
stringId = STR_PROFIT_PER_ITEM_SOLD;
profit -= primaryItem < 32 ?
RCT2_GLOBAL(0x00982164 + (primaryItem * 8), uint16) :
RCT2_GLOBAL(0x00982144 + (primaryItem * 8), uint16);
if (profit < 0) {
profit *= -1;
stringId = STR_LOSS_PER_ITEM_SOLD;
}
gfx_draw_string_left(dpi, stringId, &profit, 0, x, y);
}
y += 15;
// Income per hour
if (ride->income_per_hour != MONEY32_UNDEFINED) {
gfx_draw_string_left(dpi, STR_INCOME_PER_HOUR, &ride->income_per_hour, 0, x, y);
y += 10;
}
// Running cost per hour
costPerHour = ride->upkeep_cost * 16;
stringId = ride->upkeep_cost == 0xFFFF ? STR_RUNNING_COST_UNKNOWN : STR_RUNNING_COST_PER_HOUR;
gfx_draw_string_left(dpi, stringId, &costPerHour, 0, x, y);
y += 10;
// Profit per hour
if (ride->profit != MONEY32_UNDEFINED) {
gfx_draw_string_left(dpi, STR_PROFIT_PER_HOUR, &ride->profit, 0, x, y);
y += 10;
}
y += 5;
// Total profit
gfx_draw_string_left(dpi, STR_TOTAL_PROFIT, &ride->total_profit, 0, x, y);
}
#pragma endregion