mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
fix scenery placement issue over network
This commit is contained in:
12
src/game.c
12
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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<NetworkPacket> 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<NetworkPacket> 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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user