You've already forked OpenRCT2-Unity
mirror of
https://github.com/izzy2lost/OpenRCT2-Unity.git
synced 2026-03-10 12:38:22 -07:00
Merge pull request #3474 from Gymnasiast/housekeeping
Clean up some magic values and refactor a bit
This commit is contained in:
@@ -310,6 +310,7 @@
|
||||
#define RCT2_ADDRESS_INITIAL_CASH 0x013573DC
|
||||
#define RCT2_ADDRESS_CURRENT_LOAN 0x013573E0
|
||||
#define RCT2_ADDRESS_MAXIMUM_LOAN 0x013580F0
|
||||
#define RCT2_ADDRESS_LOAN_HASH 0x013587C4
|
||||
#define RCT2_ADDRESS_PARK_FLAGS 0x013573E4
|
||||
#define RCT2_ADDRESS_PARK_ENTRANCE_FEE 0x013573E8
|
||||
#define RCT2_ADDRESS_GUESTS_IN_PARK 0x01357844
|
||||
@@ -336,6 +337,8 @@
|
||||
#define RCT2_ADDRESS_AWARD_LIST 0x01358760
|
||||
#define RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED 0x013587F8
|
||||
#define RCT2_ADDRESS_CURRENT_INTEREST_RATE 0x0135934A
|
||||
#define RCT2_ADDRESS_SAME_PRICE_THROUGHOUT 0x01358838
|
||||
#define RCT2_ADDRESS_SAME_PRICE_THROUGHOUT_EXTENDED 0x0135934C
|
||||
|
||||
#define RCT2_ADDRESS_GUEST_INITIAL_CASH 0x013580F4
|
||||
#define RCT2_ADDRESS_GUEST_INITIAL_HAPPINESS 0x013580E9
|
||||
@@ -483,6 +486,8 @@
|
||||
|
||||
#define RCT2_ADDRESS_WINDOW_MAP_SELECTED_TAB 0x014209E4
|
||||
|
||||
#define RCT2_ADDRESS_GAME_VERSION_NUMBER 0x0013587BC
|
||||
|
||||
#define RCT2_ADDRESS_OS_TIME_MINUTE 0x01424654
|
||||
#define RCT2_ADDRESS_OS_TIME_HOUR 0x01424656
|
||||
#define RCT2_ADDRESS_OS_TIME_DAY 0x01424304
|
||||
|
||||
@@ -304,8 +304,8 @@ static int editor_read_s6(const char *path)
|
||||
if (rw != NULL) {
|
||||
if (!sawyercoding_validate_checksum(rw)) {
|
||||
SDL_RWclose(rw);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
|
||||
log_error("failed to load scenario, invalid checksum");
|
||||
return 0;
|
||||
@@ -392,8 +392,8 @@ static int editor_read_s6(const char *path)
|
||||
}
|
||||
|
||||
log_error("failed to find scenario file.");
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
20
src/game.c
20
src/game.c
@@ -83,6 +83,8 @@ int game_command_playerid = -1;
|
||||
|
||||
rct_string_id gGameCommandErrorTitle;
|
||||
rct_string_id gGameCommandErrorText;
|
||||
uint8 gErrorType;
|
||||
uint16 gErrorStringId;
|
||||
|
||||
int game_command_callback_get_index(GAME_COMMAND_CALLBACK_POINTER* callback)
|
||||
{
|
||||
@@ -390,14 +392,14 @@ void game_logic_update()
|
||||
// Update windows
|
||||
//window_dispatch_update_all();
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) != 0) {
|
||||
if (gErrorType != ERROR_TYPE_NONE) {
|
||||
rct_string_id title_text = STR_UNABLE_TO_LOAD_FILE;
|
||||
rct_string_id body_text = RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16);
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) == 254) {
|
||||
title_text = RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16);
|
||||
rct_string_id body_text = gErrorStringId;
|
||||
if (gErrorType == ERROR_TYPE_GENERIC) {
|
||||
title_text = gErrorStringId;
|
||||
body_text = 0xFFFF;
|
||||
}
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 0;
|
||||
gErrorType = ERROR_TYPE_NONE;
|
||||
|
||||
window_error_open(title_text, body_text);
|
||||
}
|
||||
@@ -417,7 +419,7 @@ static int game_check_affordability(int cost)
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint32) = cost;
|
||||
|
||||
gGameCommandErrorText = 827;
|
||||
gGameCommandErrorText = STR_NOT_ENOUGH_CASH_REQUIRES;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
@@ -745,7 +747,7 @@ int game_load_sv6(SDL_RWops* rw)
|
||||
if (!sawyercoding_validate_checksum(rw)) {
|
||||
log_error("invalid checksum");
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gGameCommandErrorTitle = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
return 0;
|
||||
}
|
||||
@@ -930,7 +932,7 @@ bool game_load_save(const utf8 *path)
|
||||
SDL_RWops* rw = SDL_RWFromFile(path, "rb");
|
||||
if (rw == NULL) {
|
||||
log_error("unable to open %s", path);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gGameCommandErrorTitle = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
return false;
|
||||
}
|
||||
@@ -998,7 +1000,7 @@ void game_load_init()
|
||||
scenery_set_default_placement_configuration();
|
||||
window_new_ride_init_vars();
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_UPDATE_TICKS, uint16) = 0;
|
||||
if (RCT2_GLOBAL(0x0013587C4, uint32) == 0) // this check is not in scenario play
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LOAN_HASH, uint32) == 0) // this check is not in scenario play
|
||||
finance_update_loan_hash();
|
||||
|
||||
load_palette();
|
||||
|
||||
@@ -112,6 +112,12 @@ enum {
|
||||
GAME_PAUSED_SAVING_TRACK = 1 << 2,
|
||||
};
|
||||
|
||||
enum {
|
||||
ERROR_TYPE_NONE = 0,
|
||||
ERROR_TYPE_GENERIC = 254,
|
||||
ERROR_TYPE_FILE_LOAD = 255
|
||||
};
|
||||
|
||||
typedef void (GAME_COMMAND_POINTER)(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);
|
||||
|
||||
typedef void (GAME_COMMAND_CALLBACK_POINTER)(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
|
||||
@@ -123,6 +129,8 @@ extern int game_command_playerid;
|
||||
|
||||
extern rct_string_id gGameCommandErrorTitle;
|
||||
extern rct_string_id gGameCommandErrorText;
|
||||
extern uint8 gErrorType;
|
||||
extern uint16 gErrorStringId;
|
||||
|
||||
extern GAME_COMMAND_POINTER* new_game_command_table[67];
|
||||
|
||||
|
||||
@@ -1614,6 +1614,7 @@ enum {
|
||||
|
||||
STR_THIS_RIDE_CANNOT_BE_MODIFIED = 3046,
|
||||
STR_LOCAL_AUTHORITY_FORBIDS_DEMOLITION_OR_MODIFICATIONS_TO_THIS_RIDE = 3047,
|
||||
STR_MARKETING_CAMPAIGNS_FORBIDDEN_BY_LOCAL_AUTHORITY = 3048,
|
||||
|
||||
STR_GOLF_HOLE_A = 3049,
|
||||
STR_GOLF_HOLE_B = 3050,
|
||||
|
||||
@@ -260,7 +260,7 @@ void finance_update_loan_hash()
|
||||
value = ror32(value, 7);
|
||||
value += gMaxBankLoan;
|
||||
value = ror32(value, 3);
|
||||
RCT2_GLOBAL(0x013587C4, sint32) = value;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LOAN_HASH, sint32) = value;
|
||||
}
|
||||
|
||||
void finance_set_loan(money32 loan)
|
||||
|
||||
@@ -168,7 +168,7 @@ void game_command_start_campaign(int* eax, int* ebx, int* ecx, int* edx, int* es
|
||||
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_MARKETING;
|
||||
if (gParkFlags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN) {
|
||||
gGameCommandErrorText = 3048;
|
||||
gGameCommandErrorText = STR_MARKETING_CAMPAIGNS_FORBIDDEN_BY_LOCAL_AUTHORITY;
|
||||
*ebx = MONEY32_UNDEFINED;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -503,8 +503,8 @@ void set_load_objects_fail_reason()
|
||||
format_string(string_buffer, STR_MISSING_OBJECT_DATA_ID, 0);
|
||||
|
||||
object_create_identifier_name(string_buffer, object);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 0xFF;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = 3165;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = 3165;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -516,8 +516,8 @@ void set_load_objects_fail_reason()
|
||||
expansionNameId = STR_OBJECT_FILTER_TT;
|
||||
break;
|
||||
default:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 0xFF;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = STR_REQUIRES_AN_ADDON_PACK;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_REQUIRES_AN_ADDON_PACK;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -525,8 +525,8 @@ void set_load_objects_fail_reason()
|
||||
|
||||
format_string(string_buffer, STR_REQUIRES_THE_FOLLOWING_ADDON_PACK, &expansionNameId);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 0xFF;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = 3165;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = 3165;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
src/rct1.c
10
src/rct1.c
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "addresses.h"
|
||||
#include "config.h"
|
||||
#include "game.h"
|
||||
#include "localisation/string_ids.h"
|
||||
#include "rct1.h"
|
||||
#include "util/sawyercoding.h"
|
||||
#include "util/util.h"
|
||||
@@ -31,8 +33,8 @@ bool rct1_read_sc4(const char *path, rct1_s4 *s4)
|
||||
bool success;
|
||||
|
||||
if (!readentirefile(path, (void**)&buffer, (int*)&length)) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = 3011;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -61,8 +63,8 @@ bool rct1_read_sv4(const char *path, rct1_s4 *s4)
|
||||
bool success;
|
||||
|
||||
if (!readentirefile(path, (void**)&buffer, (int*)&length)) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = 3011;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ money32 ride_calculate_income_per_hour(rct_ride *ride)
|
||||
priceMinusCost = ride->price;
|
||||
|
||||
currentShopItem = entry->shop_item;
|
||||
if (currentShopItem != 255) {
|
||||
if (currentShopItem != SHOP_ITEM_NONE) {
|
||||
priceMinusCost -= get_shop_item_cost(currentShopItem);
|
||||
}
|
||||
|
||||
@@ -363,11 +363,11 @@ money32 ride_calculate_income_per_hour(rct_ride *ride)
|
||||
RCT2_GLOBAL(0x0097D7CB + (ride->type * 4), uint8) :
|
||||
entry->shop_item_secondary;
|
||||
|
||||
if (currentShopItem != 255) {
|
||||
if (currentShopItem != SHOP_ITEM_NONE) {
|
||||
priceMinusCost += ride->price_secondary;
|
||||
priceMinusCost -= get_shop_item_cost(currentShopItem);
|
||||
|
||||
if (entry->shop_item != 255)
|
||||
if (entry->shop_item != SHOP_ITEM_NONE)
|
||||
priceMinusCost /= 2;
|
||||
}
|
||||
|
||||
@@ -5831,12 +5831,12 @@ static money32 shop_item_get_common_price(rct_ride *forRide, int shopItem)
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
static bool shop_item_has_common_price(int shopItem)
|
||||
bool shop_item_has_common_price(int shopItem)
|
||||
{
|
||||
if (shopItem < 32) {
|
||||
return RCT2_GLOBAL(0x01358838, uint32) & (1u << shopItem);
|
||||
return RCT2_GLOBAL(RCT2_ADDRESS_SAME_PRICE_THROUGHOUT, uint32) & (1u << shopItem);
|
||||
} else {
|
||||
return RCT2_GLOBAL(0x0135934C, uint32) & (1u << (shopItem - 32));
|
||||
return RCT2_GLOBAL(RCT2_ADDRESS_SAME_PRICE_THROUGHOUT_EXTENDED, uint32) & (1u << (shopItem - 32));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6001,14 +6001,14 @@ foundRideEntry:
|
||||
ride->price = RideData4[ride->type].price;
|
||||
ride->price_secondary = RideData4[ride->type].price_secondary;
|
||||
|
||||
if (rideEntry->shop_item == 255) {
|
||||
if (rideEntry->shop_item == SHOP_ITEM_NONE) {
|
||||
if (!(gParkFlags & PARK_FLAGS_PARK_FREE_ENTRY)) {
|
||||
ride->price = 0;
|
||||
}
|
||||
} else {
|
||||
ride->price = DefaultShopItemPrice[rideEntry->shop_item];
|
||||
}
|
||||
if (rideEntry->shop_item_secondary != 255) {
|
||||
if (rideEntry->shop_item_secondary != SHOP_ITEM_NONE) {
|
||||
ride->price_secondary = DefaultShopItemPrice[rideEntry->shop_item_secondary];
|
||||
}
|
||||
|
||||
@@ -6017,7 +6017,7 @@ foundRideEntry:
|
||||
}
|
||||
|
||||
if (ride->type == RIDE_TYPE_TOILETS) {
|
||||
if (RCT2_GLOBAL(0x01358838, uint32) & (1 << 31)) {
|
||||
if (shop_item_has_common_price(SHOP_ITEM_ADMISSION)) {
|
||||
money32 price = ride_get_common_price(ride);
|
||||
if (price != MONEY32_UNDEFINED) {
|
||||
ride->price = (money16)price;
|
||||
@@ -6025,7 +6025,7 @@ foundRideEntry:
|
||||
}
|
||||
}
|
||||
|
||||
if (rideEntry->shop_item != 255) {
|
||||
if (rideEntry->shop_item != SHOP_ITEM_NONE) {
|
||||
if (shop_item_has_common_price(rideEntry->shop_item)) {
|
||||
money32 price = shop_item_get_common_price(ride, rideEntry->shop_item);
|
||||
if (price != MONEY32_UNDEFINED) {
|
||||
@@ -6034,7 +6034,7 @@ foundRideEntry:
|
||||
}
|
||||
}
|
||||
|
||||
if (rideEntry->shop_item_secondary != 255) {
|
||||
if (rideEntry->shop_item_secondary != SHOP_ITEM_NONE) {
|
||||
if (shop_item_has_common_price(rideEntry->shop_item_secondary)) {
|
||||
money32 price = shop_item_get_common_price(ride, rideEntry->shop_item_secondary);
|
||||
if (price != MONEY32_UNDEFINED) {
|
||||
@@ -6542,17 +6542,17 @@ void game_command_set_ride_price(int *eax, int *ebx, int *ecx, int *edx, int *es
|
||||
}
|
||||
|
||||
if (!secondary_price) {
|
||||
shop_item = 0x1F;
|
||||
shop_item = SHOP_ITEM_ADMISSION;
|
||||
if (ride->type != RIDE_TYPE_TOILETS) {
|
||||
shop_item = rideEntry->shop_item;
|
||||
if (shop_item == 0xFF) {
|
||||
if (shop_item == SHOP_ITEM_NONE) {
|
||||
ride->price = price;
|
||||
window_invalidate_by_class(WC_RIDE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Check same price in park flags
|
||||
if ((shop_item < 32 ? RCT2_GLOBAL(0x01358838, uint32) & (1 << shop_item) : RCT2_GLOBAL(0x0135934C, uint32) & (1 << (shop_item - 32))) == 0) {
|
||||
if (!shop_item_has_common_price(shop_item)) {
|
||||
ride->price = price;
|
||||
window_invalidate_by_class(WC_RIDE);
|
||||
return;
|
||||
@@ -6560,7 +6560,7 @@ void game_command_set_ride_price(int *eax, int *ebx, int *ecx, int *edx, int *es
|
||||
}
|
||||
else {
|
||||
shop_item = rideEntry->shop_item_secondary;
|
||||
if (shop_item == 0xFF) {
|
||||
if (shop_item == SHOP_ITEM_NONE) {
|
||||
shop_item = RCT2_GLOBAL(0x0097D7CB + (ride->type * 4), uint8);
|
||||
if ((ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) == 0) {
|
||||
ride->price_secondary = price;
|
||||
@@ -6569,7 +6569,7 @@ void game_command_set_ride_price(int *eax, int *ebx, int *ecx, int *edx, int *es
|
||||
}
|
||||
}
|
||||
// Check same price in park flags
|
||||
if ((shop_item < 32 ? RCT2_GLOBAL(0x01358838, uint32) & (1 << shop_item) : RCT2_GLOBAL(0x0135934C, uint32) & (1 << (shop_item - 32))) == 0) {
|
||||
if (!shop_item_has_common_price(shop_item)) {
|
||||
ride->price_secondary = price;
|
||||
window_invalidate_by_class(WC_RIDE);
|
||||
return;
|
||||
@@ -6584,7 +6584,7 @@ void game_command_set_ride_price(int *eax, int *ebx, int *ecx, int *edx, int *es
|
||||
|
||||
rideEntry = get_ride_entry(ride->subtype);
|
||||
|
||||
if (ride->type != RIDE_TYPE_TOILETS || shop_item != 0x1F) {
|
||||
if (ride->type != RIDE_TYPE_TOILETS || shop_item != SHOP_ITEM_ADMISSION) {
|
||||
if (rideEntry->shop_item == shop_item) {
|
||||
ride->price = price;
|
||||
window_invalidate_by_number(WC_RIDE, rideId);
|
||||
@@ -6596,8 +6596,8 @@ void game_command_set_ride_price(int *eax, int *ebx, int *ecx, int *edx, int *es
|
||||
}
|
||||
// If the shop item is the same or an on-ride photo
|
||||
if (rideEntry->shop_item_secondary == shop_item ||
|
||||
(rideEntry->shop_item_secondary == 0xFF &&
|
||||
(shop_item == 0x3 || shop_item == 0x20 || shop_item == 0x21 || shop_item == 0x22))) {
|
||||
(rideEntry->shop_item_secondary == SHOP_ITEM_NONE &&
|
||||
(shop_item == SHOP_ITEM_PHOTO || shop_item == SHOP_ITEM_PHOTO2 || shop_item == SHOP_ITEM_PHOTO3 || shop_item == SHOP_ITEM_PHOTO4))) {
|
||||
|
||||
ride->price_secondary = price;
|
||||
window_invalidate_by_number(WC_RIDE, rideId);
|
||||
|
||||
@@ -820,6 +820,7 @@ enum {
|
||||
SHOP_ITEM_LEMONADE,
|
||||
SHOP_ITEM_EMPTY_BOX,
|
||||
SHOP_ITEM_EMPTY_BOTTLE,
|
||||
SHOP_ITEM_ADMISSION = 31,
|
||||
SHOP_ITEM_PHOTO2 = 32,
|
||||
SHOP_ITEM_PHOTO3,
|
||||
SHOP_ITEM_PHOTO4,
|
||||
@@ -842,7 +843,8 @@ enum {
|
||||
SHOP_ITEM_EMPTY_JUICE_CUP,
|
||||
SHOP_ITEM_ROAST_SAUSAGE,
|
||||
SHOP_ITEM_EMPTY_BOWL_BLUE,
|
||||
SHOP_ITEM_COUNT = 56
|
||||
SHOP_ITEM_COUNT = 56,
|
||||
SHOP_ITEM_NONE = 255
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -976,6 +978,7 @@ void ride_set_name(int rideIndex, const char *name);
|
||||
void game_command_set_ride_name(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
void game_command_set_ride_setting(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
int ride_get_refund_price(int ride_id);
|
||||
bool shop_item_has_common_price(int shopItem);
|
||||
void game_command_create_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
void game_command_callback_ride_construct_new(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
|
||||
void game_command_callback_ride_construct_placed_front(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
|
||||
|
||||
@@ -117,8 +117,8 @@ int scenario_load(const char *path)
|
||||
if (rw != NULL) {
|
||||
if (!sawyercoding_validate_checksum(rw) && !gConfigGeneral.allow_loading_with_incorrect_checksum) {
|
||||
SDL_RWclose(rw);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
|
||||
log_error("failed to load scenario, invalid checksum");
|
||||
return 0;
|
||||
@@ -197,8 +197,8 @@ int scenario_load(const char *path)
|
||||
}
|
||||
|
||||
log_error("failed to find scenario file.");
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -876,7 +876,7 @@ int scenario_write_available_objects(FILE *file)
|
||||
|
||||
static void sub_677552()
|
||||
{
|
||||
RCT2_GLOBAL(0x0013587BC, uint32) = 0x31144;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_VERSION_NUMBER, uint32) = 201028;
|
||||
RCT2_GLOBAL(0x001358778, uint32) = RCT2_GLOBAL(0x009E2D28, uint32);
|
||||
}
|
||||
|
||||
|
||||
@@ -260,10 +260,10 @@ typedef struct {
|
||||
uint16 word_01358774;
|
||||
uint8 pad_01358776[2];
|
||||
uint32 dword_01358778[17];
|
||||
uint32 dword_013587BC;
|
||||
uint32 game_version_number;
|
||||
uint32 dword_013587C0;
|
||||
uint32 dword_013587C4;
|
||||
uint16 dword_013587C8;
|
||||
uint32 loan_hash;
|
||||
uint16 ride_count;
|
||||
uint8 pad_013587CA[6];
|
||||
uint32 dword_013587D0;
|
||||
uint8 pad_013587D4[4];
|
||||
@@ -275,7 +275,7 @@ typedef struct {
|
||||
uint16 map_size_minus_2;
|
||||
uint16 map_size;
|
||||
uint16 map_max_xy;
|
||||
uint32 word_01358838;
|
||||
uint32 same_price_throughout;
|
||||
uint16 suggested_max_guests;
|
||||
uint16 park_rating_warning_days;
|
||||
uint8 word_01358840;
|
||||
@@ -287,7 +287,7 @@ typedef struct {
|
||||
char scenario_description[256];
|
||||
uint8 current_interest_rate;
|
||||
uint8 pad_0135934B;
|
||||
uint32 dword_0135934C;
|
||||
uint32 same_price_throughout_extended;
|
||||
uint16 park_entrance_x[4];
|
||||
uint16 park_entrance_y[4];
|
||||
uint16 park_entrance_z[4];
|
||||
|
||||
@@ -5435,6 +5435,33 @@ static void window_ride_graphs_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi
|
||||
|
||||
#pragma region Income
|
||||
|
||||
static void update_same_price_throughout_flags(uint32 shop_item)
|
||||
{
|
||||
uint32 newFlags;
|
||||
|
||||
if (shop_item == SHOP_ITEM_PHOTO || shop_item == SHOP_ITEM_PHOTO2 || shop_item == SHOP_ITEM_PHOTO3 || shop_item == SHOP_ITEM_PHOTO4) {
|
||||
newFlags = RCT2_GLOBAL(RCT2_ADDRESS_SAME_PRICE_THROUGHOUT, uint32);
|
||||
newFlags ^= (1 << SHOP_ITEM_PHOTO);
|
||||
game_do_command(0, 1, 0, (0x2 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
|
||||
newFlags = RCT2_GLOBAL(RCT2_ADDRESS_SAME_PRICE_THROUGHOUT_EXTENDED, uint32);
|
||||
newFlags ^= (SHOP_ITEM_PHOTO2 - 32) | (SHOP_ITEM_PHOTO3 - 32) | (SHOP_ITEM_PHOTO4 - 32);
|
||||
game_do_command(0, 1, 0, (0x3 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
}
|
||||
else {
|
||||
if (shop_item < 32) {
|
||||
newFlags = RCT2_GLOBAL(RCT2_ADDRESS_SAME_PRICE_THROUGHOUT, uint32);
|
||||
newFlags ^= (1u << shop_item);
|
||||
game_do_command(0, 1, 0, (0x2 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
}
|
||||
else {
|
||||
newFlags = RCT2_GLOBAL(RCT2_ADDRESS_SAME_PRICE_THROUGHOUT_EXTENDED, uint32);
|
||||
newFlags ^= (1u << (shop_item - 32));
|
||||
game_do_command(0, 1, 0, (0x3 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006ADEFD
|
||||
@@ -5443,41 +5470,23 @@ static void window_ride_income_toggle_primary_price(rct_window *w)
|
||||
{
|
||||
rct_ride *ride;
|
||||
rct_ride_entry *ride_type;
|
||||
uint32 newFlags, shop_item;
|
||||
uint32 shop_item;
|
||||
money16 price;
|
||||
|
||||
ride = get_ride(w->number);
|
||||
ride_type = get_ride_entry(ride->subtype);
|
||||
|
||||
if (ride->type == RIDE_TYPE_TOILETS) {
|
||||
shop_item = 0x1F;
|
||||
shop_item = SHOP_ITEM_ADMISSION;
|
||||
}
|
||||
else {
|
||||
shop_item = ride_type->shop_item;
|
||||
if (shop_item == 0xFFFF)
|
||||
return;
|
||||
}
|
||||
if (shop_item == 0x3 || shop_item == 0x20 || shop_item == 0x21 || shop_item == 0x22) {
|
||||
newFlags = RCT2_GLOBAL(0x01358838, uint32);
|
||||
newFlags ^= (1 << 0x3);
|
||||
game_do_command(0, 1, 0, (0x2 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
|
||||
newFlags = RCT2_GLOBAL(0x0135934C, uint32);
|
||||
newFlags ^= (1 << 0x0) | (1 << 0x1) | (1 << 0x2);
|
||||
game_do_command(0, 1, 0, (0x3 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
}
|
||||
else {
|
||||
if (shop_item < 32) {
|
||||
newFlags = RCT2_GLOBAL(0x01358838, uint32);
|
||||
newFlags ^= (1u << shop_item);
|
||||
game_do_command(0, 1, 0, (0x2 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
}
|
||||
else {
|
||||
newFlags = RCT2_GLOBAL(0x0135934C, uint32);
|
||||
newFlags ^= (1u << (shop_item - 32));
|
||||
game_do_command(0, 1, 0, (0x3 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
}
|
||||
}
|
||||
update_same_price_throughout_flags(shop_item);
|
||||
|
||||
price = ride->price;
|
||||
game_do_command(0, 1, 0, w->number, GAME_COMMAND_SET_RIDE_PRICE, price, 0);
|
||||
}
|
||||
@@ -5490,7 +5499,7 @@ static void window_ride_income_toggle_secondary_price(rct_window *w)
|
||||
{
|
||||
rct_ride *ride;
|
||||
rct_ride_entry *ride_type;
|
||||
uint32 newFlags, shop_item;
|
||||
uint32 shop_item;
|
||||
money16 price;
|
||||
|
||||
ride = get_ride(w->number);
|
||||
@@ -5500,27 +5509,8 @@ static void window_ride_income_toggle_secondary_price(rct_window *w)
|
||||
if (shop_item == 0xFF)
|
||||
shop_item = RCT2_GLOBAL(0x0097D7CB + (ride->type * 4), uint8);
|
||||
|
||||
if (shop_item == 0x3 || shop_item == 0x20 || shop_item == 0x21 || shop_item == 0x22) {
|
||||
newFlags = RCT2_GLOBAL(0x01358838, uint32);
|
||||
newFlags ^= (1 << 0x3);
|
||||
game_do_command(0, 1, 0, (0x2 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
update_same_price_throughout_flags(shop_item);
|
||||
|
||||
newFlags = RCT2_GLOBAL(0x0135934C, uint32);
|
||||
newFlags ^= (1 << 0x0) | (1 << 0x1) | (1 << 0x2);
|
||||
game_do_command(0, 1, 0, (0x3 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
}
|
||||
else {
|
||||
if (shop_item < 32) {
|
||||
newFlags = RCT2_GLOBAL(0x01358838, uint32);
|
||||
newFlags ^= (1u << shop_item);
|
||||
game_do_command(0, 1, 0, (0x2 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
}
|
||||
else {
|
||||
newFlags = RCT2_GLOBAL(0x0135934C, uint32);
|
||||
newFlags ^= (1u << (shop_item - 32));
|
||||
game_do_command(0, 1, 0, (0x3 << 8), GAME_COMMAND_SET_PARK_OPEN, newFlags, shop_item);
|
||||
}
|
||||
}
|
||||
price = ride->price_secondary;
|
||||
game_do_command(0, 1, 0, (1 << 8) | w->number, GAME_COMMAND_SET_RIDE_PRICE, price, 0);
|
||||
}
|
||||
@@ -5726,7 +5716,7 @@ static void window_ride_income_invalidate(rct_window *w)
|
||||
w->disabled_widgets &= ~(1 << WIDX_PRIMARY_PRICE);
|
||||
|
||||
//If the park doesn't have free entry, lock the admission price, unless the cheat to unlock all prices is activated.
|
||||
if ((!(gParkFlags & PARK_FLAGS_PARK_FREE_ENTRY) && rideEntry->shop_item == 255 && ride->type != RIDE_TYPE_TOILETS)
|
||||
if ((!(gParkFlags & PARK_FLAGS_PARK_FREE_ENTRY) && rideEntry->shop_item == SHOP_ITEM_NONE && ride->type != RIDE_TYPE_TOILETS)
|
||||
&& (!gCheatsUnlockAllPrices))
|
||||
{
|
||||
w->disabled_widgets |= (1 << WIDX_PRIMARY_PRICE);
|
||||
@@ -5741,30 +5731,24 @@ static void window_ride_income_invalidate(rct_window *w)
|
||||
if (ride->price == 0)
|
||||
window_ride_income_widgets[WIDX_PRIMARY_PRICE].image = STR_FREE;
|
||||
|
||||
primaryItem = 31;
|
||||
if (ride->type == RIDE_TYPE_TOILETS || ((primaryItem = (sint8)rideEntry->shop_item) != -1)) {
|
||||
primaryItem = SHOP_ITEM_ADMISSION;
|
||||
if (ride->type == RIDE_TYPE_TOILETS || ((primaryItem = rideEntry->shop_item) != SHOP_ITEM_NONE)) {
|
||||
window_ride_income_widgets[WIDX_PRIMARY_PRICE_SAME_THROUGHOUT_PARK].type = WWT_CHECKBOX;
|
||||
if (primaryItem < 32) {
|
||||
if (RCT2_GLOBAL(0x01358838, uint32) & (1u << primaryItem))
|
||||
w->pressed_widgets |= (1 << WIDX_PRIMARY_PRICE_SAME_THROUGHOUT_PARK);
|
||||
|
||||
if (primaryItem != 31)
|
||||
window_ride_income_widgets[WIDX_PRIMARY_PRICE_LABEL].image = 1960 + primaryItem;
|
||||
}
|
||||
else {
|
||||
primaryItem -= 32;
|
||||
if (RCT2_GLOBAL(0x0135934C, uint32) & (1u << primaryItem))
|
||||
w->pressed_widgets |= (1 << WIDX_PRIMARY_PRICE_SAME_THROUGHOUT_PARK);
|
||||
if (shop_item_has_common_price(primaryItem))
|
||||
w->pressed_widgets |= (1 << WIDX_PRIMARY_PRICE_SAME_THROUGHOUT_PARK);
|
||||
|
||||
window_ride_income_widgets[WIDX_PRIMARY_PRICE_LABEL].image = 2100 + primaryItem;
|
||||
}
|
||||
|
||||
if (primaryItem < SHOP_ITEM_ADMISSION)
|
||||
window_ride_income_widgets[WIDX_PRIMARY_PRICE_LABEL].image = 1960 + primaryItem;
|
||||
else if (primaryItem > SHOP_ITEM_ADMISSION)
|
||||
window_ride_income_widgets[WIDX_PRIMARY_PRICE_LABEL].image = 2068 + primaryItem;
|
||||
}
|
||||
|
||||
// Get secondary item
|
||||
secondaryItem = RCT2_GLOBAL(0x0097D7CB + (ride->type * 4), uint8);
|
||||
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO)) {
|
||||
if ((secondaryItem = (sint8)rideEntry->shop_item_secondary) != -1) {
|
||||
if ((secondaryItem = rideEntry->shop_item_secondary) != SHOP_ITEM_NONE) {
|
||||
// Set secondary item label
|
||||
stringId = 1960 + secondaryItem;
|
||||
if (stringId >= 1992)
|
||||
@@ -5774,7 +5758,7 @@ static void window_ride_income_invalidate(rct_window *w)
|
||||
}
|
||||
}
|
||||
|
||||
if (secondaryItem == -1) {
|
||||
if (secondaryItem == SHOP_ITEM_NONE) {
|
||||
// Hide secondary item widgets
|
||||
window_ride_income_widgets[WIDX_SECONDARY_PRICE_LABEL].type = WWT_EMPTY;
|
||||
window_ride_income_widgets[WIDX_SECONDARY_PRICE].type = WWT_EMPTY;
|
||||
@@ -5784,14 +5768,8 @@ static void window_ride_income_invalidate(rct_window *w)
|
||||
} else {
|
||||
// Set same price throughout park checkbox
|
||||
w->pressed_widgets &= ~(1 << WIDX_SECONDARY_PRICE_SAME_THROUGHOUT_PARK);
|
||||
if (secondaryItem < 32) {
|
||||
if (RCT2_GLOBAL(0x01358838, uint32) & (1u << secondaryItem))
|
||||
w->pressed_widgets |= (1 << WIDX_SECONDARY_PRICE_SAME_THROUGHOUT_PARK);
|
||||
} else {
|
||||
secondaryItem -= 32;
|
||||
if (RCT2_GLOBAL(0x0135934C, uint32) & (1u << secondaryItem))
|
||||
w->pressed_widgets |= (1 << WIDX_SECONDARY_PRICE_SAME_THROUGHOUT_PARK);
|
||||
}
|
||||
if (shop_item_has_common_price(secondaryItem))
|
||||
w->pressed_widgets |= (1 << WIDX_SECONDARY_PRICE_SAME_THROUGHOUT_PARK);
|
||||
|
||||
// Show widgets
|
||||
window_ride_income_widgets[WIDX_SECONDARY_PRICE_LABEL].type = WWT_24;
|
||||
@@ -5833,8 +5811,8 @@ static void window_ride_income_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
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) {
|
||||
primaryItem = rideEntry->shop_item;
|
||||
if (primaryItem != SHOP_ITEM_NONE) {
|
||||
profit = ride->price;
|
||||
|
||||
stringId = STR_PROFIT_PER_ITEM_SOLD;
|
||||
@@ -5851,9 +5829,9 @@ static void window_ride_income_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
// 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;
|
||||
secondaryItem = rideEntry->shop_item_secondary;
|
||||
|
||||
if (secondaryItem != -1) {
|
||||
if (secondaryItem != SHOP_ITEM_NONE) {
|
||||
profit = ride->price_secondary;
|
||||
|
||||
stringId = STR_PROFIT_PER_ITEM_SOLD;
|
||||
@@ -6059,7 +6037,7 @@ static void window_ride_customer_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
|
||||
// Primary shop items sold
|
||||
shopItem = get_ride_entry_by_ride(ride)->shop_item;
|
||||
if (shopItem != 0xFF) {
|
||||
if (shopItem != SHOP_ITEM_NONE) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = ShopItemStringIds[shopItem].plural;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = ride->no_primary_items_sold;
|
||||
gfx_draw_string_left(dpi, STR_ITEMS_SOLD, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, x, y);
|
||||
@@ -6070,7 +6048,7 @@ static void window_ride_customer_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
shopItem = ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO ?
|
||||
RCT2_GLOBAL(0x0097D7CB + (ride->type * 4), uint8) :
|
||||
get_ride_entry_by_ride(ride)->shop_item_secondary;
|
||||
if (shopItem != 0xFF) {
|
||||
if (shopItem != SHOP_ITEM_NONE) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = ShopItemStringIds[shopItem].plural;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = ride->no_secondary_items_sold;
|
||||
gfx_draw_string_left(dpi, STR_ITEMS_SOLD, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, x, y);
|
||||
|
||||
@@ -701,11 +701,11 @@ void game_command_set_park_open(int* eax, int* ebx, int* ecx, int* edx, int* esi
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
RCT2_GLOBAL(0x01358838, uint32) = *edi;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SAME_PRICE_THROUGHOUT, uint32) = *edi;
|
||||
window_invalidate_by_class(WC_RIDE);
|
||||
break;
|
||||
case 3:
|
||||
RCT2_GLOBAL(0x0135934C, uint32) = *edi;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SAME_PRICE_THROUGHOUT_EXTENDED, uint32) = *edi;
|
||||
window_invalidate_by_class(WC_RIDE);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user