diff --git a/src/game.c b/src/game.c index 8bfadc4d32..4fb5541386 100644 --- a/src/game.c +++ b/src/game.c @@ -418,6 +418,16 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int * // Increment nest count RCT2_GLOBAL(0x009A8C28, uint8)++; + // Remove ghost scenery so it doesn't interfere with incoming network command + if ((flags & GAME_COMMAND_FLAG_NETWORKED) && !(flags & 0x40) && + (command == GAME_COMMAND_PLACE_FENCE || + command == GAME_COMMAND_PLACE_SCENERY || + command == GAME_COMMAND_PLACE_LARGE_SCENERY || + command == GAME_COMMAND_PLACE_BANNER || + command == GAME_COMMAND_PLACE_PATH)) { + scenery_remove_ghost_tool_placement(); + } + *ebx &= ~GAME_COMMAND_FLAG_APPLY; // Primary command @@ -447,7 +457,7 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int * return cost; } - if (network_get_mode() != NETWORK_MODE_NONE && !(flags & (1 << 31)) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { + if (network_get_mode() != NETWORK_MODE_NONE && !(flags & GAME_COMMAND_FLAG_NETWORKED) && !(flags & 0x40) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { network_send_gamecmd(*eax, *ebx, *ecx, *edx, *esi, *edi, *ebp); if (network_get_mode() == NETWORK_MODE_CLIENT) { // Decrement nest count diff --git a/src/game.h b/src/game.h index ae0ebf5880..5900a57c40 100644 --- a/src/game.h +++ b/src/game.h @@ -89,6 +89,9 @@ enum GAME_COMMAND { // If this flag is set, the command is applied, otherwise only the cost is retrieved #define GAME_COMMAND_FLAG_APPLY (1 << 0) +// Game command is coming from network +#define GAME_COMMAND_FLAG_NETWORKED (1 << 31) + typedef void (GAME_COMMAND_POINTER)(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); extern int gGameSpeed; diff --git a/src/network/network.cpp b/src/network/network.cpp index c1c17a36e2..54f3fa7015 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -494,14 +494,14 @@ void Network::Server_Send_CHAT(const char* text) void Network::Client_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp) { std::unique_ptr packet = NetworkPacket::AllocatePacket(); - *packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) << eax << (ebx | (1 << 31)) << ecx << edx << esi << edi << ebp; + *packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED) << ecx << edx << esi << edi << ebp; server_connection.QueuePacket(std::move(packet)); } void Network::Server_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp) { std::unique_ptr packet = NetworkPacket::AllocatePacket(); - *packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) << eax << (ebx | (1 << 31)) << ecx << edx << esi << edi << ebp; + *packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED) << ecx << edx << esi << edi << ebp; for (auto it = client_connection_list.begin(); it != client_connection_list.end(); it++) { (*it)->QueuePacket(NetworkPacket::DuplicatePacket(*packet)); }