diff --git a/src/game.c b/src/game.c index cc3a4cf660..649bd29e74 100644 --- a/src/game.c +++ b/src/game.c @@ -1078,7 +1078,7 @@ void game_load_or_quit_no_save_prompt() } } -GAME_COMMAND_POINTER* new_game_command_table[67] = { +GAME_COMMAND_POINTER* new_game_command_table[68] = { game_command_set_ride_appearance, game_command_set_land_height, game_pause_toggle, @@ -1145,5 +1145,6 @@ GAME_COMMAND_POINTER* new_game_command_table[67] = { game_command_set_player_group, game_command_modify_groups, game_command_kick_player, - game_command_cheat + game_command_cheat, + game_command_reset_sprites, }; diff --git a/src/game.h b/src/game.h index e186f119dd..23ca1b3981 100644 --- a/src/game.h +++ b/src/game.h @@ -88,7 +88,8 @@ enum GAME_COMMAND { GAME_COMMAND_SET_PLAYER_GROUP, GAME_COMMAND_MODIFY_GROUPS, GAME_COMMAND_KICK_PLAYER, - GAME_COMMAND_CHEAT + GAME_COMMAND_CHEAT, + GAME_COMMAND_RESET_SPRITES, }; enum { @@ -128,7 +129,7 @@ extern rct_string_id gGameCommandErrorText; extern uint8 gErrorType; extern uint16 gErrorStringId; -extern GAME_COMMAND_POINTER* new_game_command_table[67]; +extern GAME_COMMAND_POINTER* new_game_command_table[68]; #define gCurrentTicks RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) diff --git a/src/network/network.cpp b/src/network/network.cpp index 9966c8a95e..4016479ff9 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -1477,6 +1477,9 @@ void Network::Server_Client_Joined(const char* name, const std::string &keyhash, format_string(text, STR_MULTIPLAYER_PLAYER_HAS_JOINED_THE_GAME, &player_name); chat_history_add(text); Server_Send_MAP(&connection); + // This is needed to synchronise calls to reset sprite order across clients, + // otherwise connected clients will fall out of sync in simulation. + game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, 0, GAME_COMMAND_RESET_SPRITES, 0, 0); gNetwork.Server_Send_EVENT_PLAYER_JOINED(player_name); Server_Send_GROUPLIST(connection); Server_Send_PLAYERLIST(); diff --git a/src/network/network.h b/src/network/network.h index a436a13129..1d1af8f3a3 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -54,7 +54,7 @@ extern "C" { // This define specifies which version of network stream current build uses. // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "9" +#define NETWORK_STREAM_VERSION "10" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION // Fixes issues on OS X diff --git a/src/rct2/S6Exporter.cpp b/src/rct2/S6Exporter.cpp index 938e1db644..c06a2d4e18 100644 --- a/src/rct2/S6Exporter.cpp +++ b/src/rct2/S6Exporter.cpp @@ -480,7 +480,7 @@ extern "C" } map_reorganise_elements(); - reset_0x69EBE4(); + game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, 0, GAME_COMMAND_RESET_SPRITES, 0, 0); sprite_clear_all_unused(); viewport_set_saved_view(); diff --git a/src/rct2/S6Importer.cpp b/src/rct2/S6Importer.cpp index 406c087a00..25c21d3a25 100644 --- a/src/rct2/S6Importer.cpp +++ b/src/rct2/S6Importer.cpp @@ -378,7 +378,7 @@ void S6Importer::Import() } reset_loaded_objects(); map_update_tile_pointers(); - reset_0x69EBE4(); + game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, 0, GAME_COMMAND_RESET_SPRITES, 0, 0); game_convert_strings_to_utf8(); if (FixIssues) { diff --git a/src/world/sprite.c b/src/world/sprite.c index 3f2c4a4643..e6002f2141 100644 --- a/src/world/sprite.c +++ b/src/world/sprite.c @@ -17,6 +17,7 @@ #include "../addresses.h" #include "../audio/audio.h" #include "../cheats.h" +#include "../game.h" #include "../interface/viewport.h" #include "../localisation/date.h" #include "../localisation/localisation.h" @@ -121,7 +122,7 @@ void reset_sprite_list() gSpriteListCount[SPRITE_LIST_NULL] = MAX_SPRITES; - reset_0x69EBE4(); + game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, 0, GAME_COMMAND_RESET_SPRITES, 0, 0); } /** @@ -154,6 +155,14 @@ void reset_0x69EBE4() } } +void game_command_reset_sprites(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) +{ + if (*ebx & GAME_COMMAND_FLAG_APPLY) { + reset_0x69EBE4(); + } + *ebx = 0; +} + /** * Clears all the unused sprite memory to zero. Probably so that it can be compressed better when saving. * rct2: 0x0069EBA4 diff --git a/src/world/sprite.h b/src/world/sprite.h index 3e5543ca6b..56612e4027 100644 --- a/src/world/sprite.h +++ b/src/world/sprite.h @@ -376,6 +376,7 @@ extern uint16 *gSpriteListCount; rct_sprite *create_sprite(uint8 bl); void reset_sprite_list(); +void game_command_reset_sprites(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); void reset_0x69EBE4(); void sprite_clear_all_unused(); void move_sprite_to_list(rct_sprite *sprite, uint8 cl);