From 3a26f56000518d0b183c836e27ea41c697367c24 Mon Sep 17 00:00:00 2001 From: zsilencer Date: Sun, 26 Jul 2015 20:15:02 -0600 Subject: [PATCH] fix path placement for network --- src/config.c | 2 +- src/game.c | 2 +- src/game.h | 3 ++- src/interface/keyboard_shortcut.c | 2 +- src/ride/track.c | 8 ++++---- src/world/footpath.c | 23 +++++++++++------------ 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/config.c b/src/config.c index a7aa49aa16..32246efe8f 100644 --- a/src/config.c +++ b/src/config.c @@ -986,7 +986,7 @@ static const uint16 _defaultShortcutKeys[SHORTCUT_COUNT] = { SDL_SCANCODE_EQUALS, // SHORTCUT_INCREASE_GAME_SPEED, CTRL | ALT | SDL_SCANCODE_C, // SHORTCUT_OPEN_CHEAT_WINDOW, SDL_SCANCODE_T, // SHORTCUT_REMOVE_TOP_BOTTOM_TOOLBAR_TOGGLE, - SDL_SCANCODE_C // SHORTCUT_OPEN_CHAT_WINDOW + SDL_SCANCODE_C, // SHORTCUT_OPEN_CHAT_WINDOW SDL_SCANCODE_UP, // SHORTCUT_SCROLL_MAP_UP SDL_SCANCODE_LEFT, // SHORTCUT_SCROLL_MAP_LEFT SDL_SCANCODE_DOWN, // SHORTCUT_SCROLL_MAP_DOWN diff --git a/src/game.c b/src/game.c index e543cfa2d4..6cb4bc931b 100644 --- a/src/game.c +++ b/src/game.c @@ -534,7 +534,7 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int * RCT2_GLOBAL(0x009A8C28, uint8)--; // 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_3)) + 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)) window_error_open(RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16), RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16)); return MONEY32_UNDEFINED; diff --git a/src/game.h b/src/game.h index 8ce6a1ef24..dd0d2d9bc3 100644 --- a/src/game.h +++ b/src/game.h @@ -89,7 +89,8 @@ enum GAME_COMMAND { enum { GAME_COMMAND_FLAG_APPLY = (1 << 0), // If this flag is set, the command is applied, otherwise only the cost is retrieved GAME_COMMAND_FLAG_2 = (1 << 2), - GAME_COMMAND_FLAG_3 = (1 << 3), + GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED = (1 << 3), // Allow while paused + GAME_COMMAND_FLAG_4 = (1 << 4), GAME_COMMAND_FLAG_5 = (1 << 5), GAME_COMMAND_FLAG_GHOST = (1 << 6), GAME_COMMAND_FLAG_NETWORKED = (1 << 31) // Game command is coming from network diff --git a/src/interface/keyboard_shortcut.c b/src/interface/keyboard_shortcut.c index ee10a02fd5..cd5e50903b 100644 --- a/src/interface/keyboard_shortcut.c +++ b/src/interface/keyboard_shortcut.c @@ -540,7 +540,7 @@ static const shortcut_action shortcut_table[SHORTCUT_COUNT] = { shortcut_increase_game_speed, shortcut_open_cheat_window, shortcut_remove_top_bottom_toolbar_toggle, - shortcut_open_chat_window + shortcut_open_chat_window, NULL, NULL, NULL, diff --git a/src/ride/track.c b/src/ride/track.c index acf615d50a..c3eba159ff 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -1963,7 +1963,7 @@ int sub_6D2189(int* cost, uint8* ride_id){ entry_index = 0xFF; int eax = 0, ebx, ecx = 0, edx, esi, edi = 0, ebp = 0; - ebx = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_3 | GAME_COMMAND_FLAG_5; + ebx = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5; edx = track_design->type | (entry_index << 8); esi = GAME_COMMAND_CREATE_RIDE; @@ -3185,7 +3185,7 @@ void game_command_place_track_design(int* eax, int* ebx, int* ecx, int* edx, int RCT2_GLOBAL(0x009DEA60, sint16) = y + 16; RCT2_GLOBAL(0x009DEA62, sint16) = z; - if (!(flags & GAME_COMMAND_FLAG_3)){ + if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED)){ if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode){ RCT2_GLOBAL(0x00141E9AC, rct_string_id) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; *ebx = MONEY32_UNDEFINED; @@ -3506,7 +3506,7 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in if (!sub_68B044()) { return MONEY32_UNDEFINED; } - if (!(flags & GAME_COMMAND_FLAG_3)) { + if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED)) { if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; @@ -3649,7 +3649,7 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in // push baseZ and clearanceZ int cur_z = baseZ * 8; - if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_3)) { + if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED)) { footpath_remove_litter(x, y, z); // push bl bh?? if (rideTypeFlags & RIDE_TYPE_FLAG_18) { diff --git a/src/world/footpath.c b/src/world/footpath.c index 0fd76eeddb..1bfd7e83d0 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -34,10 +34,6 @@ void footpath_interrupt_peeps(int x, int y, int z); void sub_6A7642(int x, int y, rct_map_element *mapElement); void sub_6A76E9(int rideIndex); -enum { - FOOTPATH_CONSTRUCTION_FLAG_ALLOW_DURING_PAUSED = 1 << 3 -}; - const rct_xy16 word_981D6C[4] = { { -1, 0 }, { 0, 1 }, @@ -148,7 +144,7 @@ static money32 footpath_element_insert(int type, int x, int y, int z, int slope, if (!sub_68B044()) return MONEY32_UNDEFINED; - if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & (FOOTPATH_CONSTRUCTION_FLAG_ALLOW_DURING_PAUSED | (1 << 6)))) + if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & (GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST))) footpath_remove_litter(x, y, RCT2_GLOBAL(0x009DEA62, uint16)); // loc_6A649D: @@ -320,7 +316,7 @@ static money32 footpath_place_real(int type, int x, int y, int z, int slope, int RCT2_GLOBAL(0x009DEA60, uint16) = y + 16; RCT2_GLOBAL(0x009DEA62, uint16) = z * 8; - if (!(flags & FOOTPATH_CONSTRUCTION_FLAG_ALLOW_DURING_PAUSED) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) { + if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } @@ -355,10 +351,13 @@ static money32 footpath_place_real(int type, int x, int y, int z, int slope, int return MONEY32_UNDEFINED; } + footpath_provisional_remove(); mapElement = map_get_footpath_element_slope((x / 32), (y / 32), z, slope); - return mapElement == NULL ? - footpath_element_insert(type, x, y, z, slope, flags) : - footpath_element_update(x, y, mapElement, type, flags); + if (mapElement == NULL) { + return footpath_element_insert(type, x, y, z, slope, flags); + } else { + return footpath_element_update(x, y, mapElement, type, flags); + } } /* rct2: 0x006BA23E */ @@ -381,7 +380,7 @@ money32 footpath_remove_real(int x, int y, int z, int flags) RCT2_GLOBAL(0x009DEA60, uint16) = y + 16; RCT2_GLOBAL(0x009DEA62, uint16) = z * 8; - if (!(flags & FOOTPATH_CONSTRUCTION_FLAG_ALLOW_DURING_PAUSED) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) { + if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } @@ -453,7 +452,7 @@ money32 footpath_provisional_set(int type, int x, int y, int z, int slope) footpath_provisional_remove(); - cost = footpath_place(type, x, y, z, slope, (1 << 6) | (1 << 5) | (1 << 4) | FOOTPATH_CONSTRUCTION_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_APPLY); + cost = footpath_place(type, x, y, z, slope, GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_4 | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_APPLY); if (cost != MONEY32_UNDEFINED) { RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_Y, uint16) = y; @@ -479,7 +478,7 @@ void footpath_provisional_remove() RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_Z, uint16), - (1 << 0) | FOOTPATH_CONSTRUCTION_FLAG_ALLOW_DURING_PAUSED | (1 << 5) + GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 ); } }