diff --git a/src/game.c b/src/game.c index 762d3ed4de..81afd664ea 100644 --- a/src/game.c +++ b/src/game.c @@ -1142,5 +1142,4 @@ GAME_COMMAND_POINTER* new_game_command_table[68] = { game_command_modify_groups, game_command_kick_player, game_command_cheat, - game_command_reset_sprites, }; diff --git a/src/game.h b/src/game.h index 3e88027825..a0d9c0c155 100644 --- a/src/game.h +++ b/src/game.h @@ -89,7 +89,6 @@ enum GAME_COMMAND { GAME_COMMAND_MODIFY_GROUPS, GAME_COMMAND_KICK_PLAYER, GAME_COMMAND_CHEAT, - GAME_COMMAND_RESET_SPRITES, }; enum { diff --git a/src/network/network.cpp b/src/network/network.cpp index 7b4ecf5cc3..55f4f900ad 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -1520,9 +1520,6 @@ 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/peep/peep.c b/src/peep/peep.c index f2f85dd6dd..c18494d462 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -6295,7 +6295,7 @@ rct_peep *peep_generate(int x, int y, int z) move_sprite_to_list((rct_sprite*)peep, SPRITE_LIST_PEEP * 2); - peep->sprite_identifier = 1; + peep->sprite_identifier = SPRITE_IDENTIFIER_PEEP; peep->sprite_type = PEEP_SPRITE_TYPE_NORMAL; peep->outside_of_park = 1; peep->state = PEEP_STATE_FALLING; diff --git a/src/rct2/S6Exporter.cpp b/src/rct2/S6Exporter.cpp index adc4bc1c77..cb4cbf8c0f 100644 --- a/src/rct2/S6Exporter.cpp +++ b/src/rct2/S6Exporter.cpp @@ -483,7 +483,6 @@ extern "C" } map_reorganise_elements(); - game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, 0, GAME_COMMAND_RESET_SPRITES, 0, 0); sprite_clear_all_unused(); viewport_set_saved_view(); @@ -544,6 +543,7 @@ extern "C" } // Write other data not in normal save files + SDL_RWwrite(rw, gSpriteSpatialIndex, 0x10001 * sizeof(uint16), 1); SDL_WriteLE32(rw, gGamePaused); SDL_WriteLE32(rw, _guestGenerationProbability); SDL_WriteLE32(rw, _suggestedGuestMaximum); diff --git a/src/rct2/S6Importer.cpp b/src/rct2/S6Importer.cpp index 6a4c2af15f..1792e73b29 100644 --- a/src/rct2/S6Importer.cpp +++ b/src/rct2/S6Importer.cpp @@ -367,10 +367,9 @@ void S6Importer::Import() } map_update_tile_pointers(); reset_all_sprite_quadrant_placements(); - reset_sprite_spatial_index(); - if (network_get_mode() == NETWORK_MODE_CLIENT) + if (network_get_mode() != NETWORK_MODE_CLIENT) { - game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, 0, GAME_COMMAND_RESET_SPRITES, 0, 0); + reset_sprite_spatial_index(); } game_convert_strings_to_utf8(); if (FixIssues) @@ -491,6 +490,7 @@ extern "C" SDL_RWread(rw, &checksum, sizeof(uint32), 1); // Read other data not in normal save files + SDL_RWread(rw, gSpriteSpatialIndex, 0x10001 * sizeof(uint16), 1); gGamePaused = SDL_ReadLE32(rw); _guestGenerationProbability = SDL_ReadLE32(rw); _suggestedGuestMaximum = SDL_ReadLE32(rw); diff --git a/src/title.c b/src/title.c index ad44ba53ad..67488463b9 100644 --- a/src/title.c +++ b/src/title.c @@ -106,6 +106,9 @@ void title_load() gScreenFlags = SCREEN_FLAGS_TITLE_DEMO; +#ifndef DISABLE_NETWORK + network_close(); +#endif reset_park_entrances(); user_string_clear_all(); reset_sprite_list(); @@ -131,9 +134,6 @@ void title_load() title_init_showcase(); gfx_invalidate_screen(); gScreenAge = 0; -#ifndef DISABLE_NETWORK - network_close(); -#endif if (gOpenRCT2ShowChangelog) { gOpenRCT2ShowChangelog = false; diff --git a/src/world/balloon.c b/src/world/balloon.c index 0811156240..f4c0cdc8a8 100644 --- a/src/world/balloon.c +++ b/src/world/balloon.c @@ -15,6 +15,7 @@ #pragma endregion #include "../audio/audio.h" +#include "../network/network.h" #include "../scenario.h" #include "../util/util.h" #include "sprite.h" @@ -82,6 +83,9 @@ void balloon_update(rct_balloon *balloon) */ void balloon_press(rct_balloon *balloon) { + if (network_get_mode() != NETWORK_MODE_NONE) { + return; + } if (balloon->popped == 1) return; diff --git a/src/world/climate.c b/src/world/climate.c index 985b07f617..e112570c0c 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -93,7 +93,7 @@ void climate_reset(int climate) _rainVolume = 1; } - climate_determine_future_weather(util_rand()); + climate_determine_future_weather(scenario_rand()); } static sint8 step_weather_level(sint8 cur_weather_level, sint8 next_weather_level) { diff --git a/src/world/particle.c b/src/world/particle.c index 599b03ca10..5866f871c4 100644 --- a/src/world/particle.c +++ b/src/world/particle.c @@ -16,6 +16,7 @@ #include "../audio/audio.h" #include "../util/util.h" +#include "../scenario.h" #include "sprite.h" /** @@ -35,12 +36,12 @@ void crashed_vehicle_particle_create(rct_vehicle_colour colours, int x, int y, i sprite_move(x, y, z, (rct_sprite*)sprite); sprite->misc_identifier = SPRITE_MISC_CRASHED_VEHICLE_PARTICLE; - sprite->frame = (util_rand() & 0xFF) * 12; - sprite->var_24 = (util_rand() & 0x7F) + 140; - sprite->var_2E = ((util_rand() & 0xFF) * 5) >> 8; - sprite->acceleration_x = ((sint16)(util_rand() & 0xFFFF)) * 4; - sprite->acceleration_y = ((sint16)(util_rand() & 0xFFFF)) * 4; - sprite->acceleration_z = (util_rand() & 0xFFFF) * 4 + 0x10000; + sprite->frame = (scenario_rand() & 0xFF) * 12; + sprite->var_24 = (scenario_rand() & 0x7F) + 140; + sprite->var_2E = ((scenario_rand() & 0xFF) * 5) >> 8; + sprite->acceleration_x = ((sint16)(scenario_rand() & 0xFFFF)) * 4; + sprite->acceleration_y = ((sint16)(scenario_rand() & 0xFFFF)) * 4; + sprite->acceleration_z = (scenario_rand() & 0xFFFF) * 4 + 0x10000; sprite->velocity_x = 0; sprite->velocity_y = 0; sprite->velocity_z = 0; diff --git a/src/world/sprite.c b/src/world/sprite.c index 6b282945c5..446df6dd2e 100644 --- a/src/world/sprite.c +++ b/src/world/sprite.c @@ -128,8 +128,6 @@ void reset_sprite_list() } gSpriteListCount[SPRITE_LIST_NULL] = MAX_SPRITES; - - game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, 0, GAME_COMMAND_RESET_SPRITES, 0, 0); } /** @@ -159,15 +157,6 @@ void reset_sprite_spatial_index() } } -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_all_sprite_quadrant_placements(); - reset_sprite_spatial_index(); - } - *ebx = 0; -} - #ifndef DISABLE_NETWORK static unsigned char _spriteChecksum[EVP_MAX_MD_SIZE + 1]; @@ -181,9 +170,11 @@ const char * sprite_checksum() for (size_t i = 0; i < MAX_SPRITES; i++) { rct_sprite *sprite = get_sprite(i); - if (sprite->unknown.sprite_identifier != SPRITE_IDENTIFIER_NULL) + if (sprite->unknown.sprite_identifier != SPRITE_IDENTIFIER_NULL && sprite->unknown.sprite_identifier != SPRITE_IDENTIFIER_MISC) { - if (EVP_DigestUpdate(gHashCTX, sprite, sizeof(rct_sprite)) <= 0) + rct_sprite copy = *sprite; + copy.unknown.sprite_left = copy.unknown.sprite_right = copy.unknown.sprite_top = copy.unknown.sprite_bottom = 0; + if (EVP_DigestUpdate(gHashCTX, ©, sizeof(rct_sprite)) <= 0) { openrct2_assert(false, "Failed to update digest"); } diff --git a/src/world/sprite.h b/src/world/sprite.h index b956ad710c..61a0b5ccf3 100644 --- a/src/world/sprite.h +++ b/src/world/sprite.h @@ -395,7 +395,6 @@ extern uint16 *gSpriteSpatialIndex; 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_sprite_spatial_index(); void sprite_clear_all_unused(); void move_sprite_to_list(rct_sprite *sprite, uint8 cl);