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

integrate gGameCommandNestLevel

This commit is contained in:
Ted John
2016-05-17 21:47:14 +01:00
parent 4847cfe84f
commit e73aeb9a42
7 changed files with 34 additions and 32 deletions

View File

@@ -63,6 +63,7 @@ uint8 gGamePaused = 0;
int gGameSpeed = 1;
float gDayNightCycle = 0;
bool gInUpdateCode = false;
int gGameCommandNestLevel;
extern void game_command_callback_place_banner(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
@@ -314,7 +315,7 @@ void game_update()
news_item_update_current();
window_dispatch_update_all();
RCT2_GLOBAL(0x009A8C28, uint8) = 0;
gGameCommandNestLevel = 0;
gInputFlags &= ~INPUT_FLAG_VIEWPORT_SCROLLING;
@@ -459,7 +460,7 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
gGameCommandErrorText = 0xFFFF;
// Increment nest count
RCT2_GLOBAL(0x009A8C28, uint8)++;
gGameCommandNestLevel++;
// Remove ghost scenery so it doesn't interfere with incoming network command
if ((flags & GAME_COMMAND_FLAG_NETWORKED) && !(flags & GAME_COMMAND_FLAG_GHOST) &&
@@ -484,7 +485,7 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
if (cost != MONEY32_UNDEFINED) {
// Check funds
insufficientFunds = 0;
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & GAME_COMMAND_FLAG_2) && !(flags & GAME_COMMAND_FLAG_5) && cost != 0)
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_2) && !(flags & GAME_COMMAND_FLAG_5) && cost != 0)
insufficientFunds = game_check_affordability(cost);
if (insufficientFunds != MONEY32_UNDEFINED) {
@@ -496,17 +497,17 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
if (!(flags & GAME_COMMAND_FLAG_APPLY)) {
// Decrement nest count
RCT2_GLOBAL(0x009A8C28, uint8)--;
gGameCommandNestLevel--;
return cost;
}
if (network_get_mode() != NETWORK_MODE_NONE && !(flags & GAME_COMMAND_FLAG_NETWORKED) && !(flags & GAME_COMMAND_FLAG_GHOST) && !(flags & GAME_COMMAND_FLAG_5) && RCT2_GLOBAL(0x009A8C28, uint8) == 1 /* Send only top-level commands */) {
if (network_get_mode() != NETWORK_MODE_NONE && !(flags & GAME_COMMAND_FLAG_NETWORKED) && !(flags & GAME_COMMAND_FLAG_GHOST) && !(flags & GAME_COMMAND_FLAG_5) && gGameCommandNestLevel == 1 /* Send only top-level commands */) {
if (command != GAME_COMMAND_LOAD_OR_QUIT) { // Disable these commands over the network
network_send_gamecmd(*eax, *ebx, *ecx, *edx, *esi, *edi, *ebp, game_command_callback_get_index(game_command_callback));
if (network_get_mode() == NETWORK_MODE_CLIENT) { // Client sent the command to the server, do not run it locally, just return. It will run when server sends it
game_command_callback = 0;
// Decrement nest count
RCT2_GLOBAL(0x009A8C28, uint8)--;
gGameCommandNestLevel--;
return cost;
}
}
@@ -516,7 +517,7 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
new_game_command_table[command](eax, ebx, ecx, edx, esi, edi, ebp);
// Do the callback (required for multiplayer to work correctly), but only for top level commands
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
if (gGameCommandNestLevel == 1) {
if (game_command_callback && !(flags & GAME_COMMAND_FLAG_GHOST)) {
game_command_callback(*eax, *ebx, *ecx, *edx, *esi, *edi, *ebp);
game_command_callback = 0;
@@ -531,8 +532,8 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
cost = *edx;
// Decrement nest count
RCT2_GLOBAL(0x009A8C28, uint8)--;
if (RCT2_GLOBAL(0x009A8C28, uint8) != 0)
gGameCommandNestLevel--;
if (gGameCommandNestLevel != 0)
return cost;
//
@@ -558,13 +559,13 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
// Error occured
// Decrement nest count
RCT2_GLOBAL(0x009A8C28, uint8)--;
gGameCommandNestLevel--;
// Clear the game command callback to prevent the next command triggering it
game_command_callback = 0;
// Show error window
if (RCT2_GLOBAL(0x009A8C28, uint8) == 0 && (flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x0141F568, uint8) == RCT2_GLOBAL(0x013CA740, uint8) && !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && !(flags & GAME_COMMAND_FLAG_NETWORKED))
if (gGameCommandNestLevel == 0 && (flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x0141F568, uint8) == RCT2_GLOBAL(0x013CA740, uint8) && !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && !(flags & GAME_COMMAND_FLAG_NETWORKED))
window_error_open(gGameCommandErrorTitle, gGameCommandErrorText);
return MONEY32_UNDEFINED;

View File

@@ -136,6 +136,7 @@ extern uint8 gGamePaused;
extern int gGameSpeed;
extern float gDayNightCycle;
extern bool gInUpdateCode;
extern int gGameCommandNestLevel;
void game_increase_game_speed();
void game_reduce_game_speed();

View File

@@ -6414,7 +6414,7 @@ void game_command_set_ride_appearance(int *eax, int *ebx, int *ecx, int *edx, in
return;
}
if (apply && RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
if (apply && gGameCommandNestLevel == 1) {
if (ride->overall_view != (uint16)-1) {
rct_xyz16 coord;
coord.x = (ride->overall_view & 0xFF) * 32 + 16;

View File

@@ -1063,7 +1063,7 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in
map_invalidate_tile_full(x, y);
}
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
if (gGameCommandNestLevel == 1) {
rct_xyz16 coord;
coord.x = originX + 16;
coord.y = originY + 16;
@@ -1365,7 +1365,7 @@ money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 originY,
else
price *= -10;
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
if (gGameCommandNestLevel == 1) {
rct_xyz16 coord;
coord.x = originX + 16;
coord.y = originY + 16;

View File

@@ -1598,7 +1598,7 @@ money32 place_maze_design(uint8 flags, uint8 rideIndex, uint16 mazeEntry, sint16
cost += price;
if (flags & GAME_COMMAND_FLAG_APPLY) {
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 8;
coord.y = y + 8;

View File

@@ -355,7 +355,7 @@ static money32 footpath_place_real(int type, int x, int y, int z, int slope, int
// Force ride construction to recheck area
_currentTrackSelectionFlags |= 8;
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;
@@ -410,7 +410,7 @@ money32 footpath_remove_real(int x, int y, int z, int flags)
mapElement = map_get_footpath_element(x / 32, y / 32, z);
if (mapElement != NULL && (flags & GAME_COMMAND_FLAG_APPLY)) {
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;
@@ -512,7 +512,7 @@ static money32 footpath_place_from_track(int type, int x, int y, int z, int slop
gFootpathPrice += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / 2) * MONEY(5, 00);
if (flags & GAME_COMMAND_FLAG_APPLY) {
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;

View File

@@ -796,7 +796,7 @@ void game_command_remove_scenery(int* eax, int* ebx, int* ecx, int* edx, int* es
// Remove element
if (flags & GAME_COMMAND_FLAG_APPLY) {
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;
@@ -945,7 +945,7 @@ void game_command_remove_large_scenery(int* eax, int* ebx, int* ecx, int* edx, i
}
}
if (flags & GAME_COMMAND_FLAG_APPLY && RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
if (flags & GAME_COMMAND_FLAG_APPLY && gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;
@@ -1001,7 +1001,7 @@ void game_command_remove_banner(int* eax, int* ebx, int* ecx, int* edx, int* esi
rct_scenery_entry *scenery_entry = get_banner_entry(banner->type);
if (flags & GAME_COMMAND_FLAG_APPLY) {
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;
@@ -1420,7 +1420,7 @@ money32 map_clear_scenery(int x0, int y0, int x1, int y1, int clear, int flags)
}
}
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && flags & GAME_COMMAND_FLAG_APPLY) {
if (gGameCommandNestLevel == 1 && flags & GAME_COMMAND_FLAG_APPLY) {
rct_xyz16 coord;
coord.x = ((x0 + x1) / 2) + 16;
coord.y = ((y0 + y1) / 2) + 16;
@@ -1557,7 +1557,7 @@ money32 map_change_surface_style(int x0, int y0, int x1, int y1, uint8 surfaceSt
}
}
if (flags & GAME_COMMAND_FLAG_APPLY && RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
if (flags & GAME_COMMAND_FLAG_APPLY && gGameCommandNestLevel == 1) {
rct_xyz16 coord;
coord.x = ((x0 + x1) / 2) + 16;
coord.y = ((y0 + y1) / 2) + 16;
@@ -1787,7 +1787,7 @@ static money32 map_set_land_height(int flags, int x, int y, int height, int styl
if(flags & GAME_COMMAND_FLAG_APPLY)
{
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
if (gGameCommandNestLevel == 1) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;
@@ -1879,7 +1879,7 @@ money32 raise_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b
return MONEY32_UNDEFINED;
}
if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
if ((flags & GAME_COMMAND_FLAG_APPLY) && gGameCommandNestLevel == 1) {
audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z);
}
@@ -1935,7 +1935,7 @@ money32 lower_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b
{
money32 cost = 0;
if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
if ((flags & GAME_COMMAND_FLAG_APPLY) && gGameCommandNestLevel == 1) {
audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z);
}
@@ -2313,7 +2313,7 @@ money32 smooth_land(int flags, int centreX, int centreY, int mapLeft, int mapTop
int mapTopBottom = mapTop | (mapBottom << 16);
// Play sound (only once)
if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
if ((flags & GAME_COMMAND_FLAG_APPLY) && gGameCommandNestLevel == 1) {
audio_play_sound_at_location(SOUND_PLACE_ITEM, centreX, centreY, centreZ);
}
@@ -2697,7 +2697,7 @@ void game_command_remove_fence(int* eax, int* ebx, int* ecx, int* edx, int* esi,
return;
}
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;
@@ -2798,7 +2798,7 @@ void game_command_place_banner(int* eax, int* ebx, int* ecx, int* edx, int* esi,
}
*edi = banner_index;
if(*ebx & GAME_COMMAND_FLAG_APPLY){
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;
@@ -3037,7 +3037,7 @@ void game_command_place_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi
if(gCheatsDisableClearanceChecks || map_can_construct_with_clear_at(x, y, zLow, zHigh, &map_place_scenery_clear_func, bl, flags, RCT2_ADDRESS(0x00F64F26, money32))){
gSceneryGroundFlags = gMapGroundFlags & (ELEMENT_IS_1 | ELEMENT_IS_UNDERGROUND);
if(flags & GAME_COMMAND_FLAG_APPLY){
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;
@@ -3474,7 +3474,7 @@ void game_command_place_fence(int* eax, int* ebx, int* ecx, int* edx, int* esi,
}
if (flags & GAME_COMMAND_FLAG_APPLY){
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = position.x + 16;
coord.y = position.y + 16;
@@ -3723,7 +3723,7 @@ void game_command_place_large_scenery(int* eax, int* ebx, int* ecx, int* edx, in
map_remove_walls_at(curTile.x, curTile.y, zLow * 8, zHigh * 8);
}
}
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
if (gGameCommandNestLevel == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) {
rct_xyz16 coord;
coord.x = x + 16;
coord.y = y + 16;