mirror of https://github.com/OpenRCT2/OpenRCT2.git
fix game_command_create_ride for network
This commit is contained in:
parent
3b4a4fcdac
commit
584b34e6d5
41
src/game.c
41
src/game.c
|
@ -61,6 +61,30 @@
|
|||
int gGameSpeed = 1;
|
||||
float gDayNightCycle = 0;
|
||||
|
||||
GAME_COMMAND_CALLBACK_POINTER* game_command_callback = 0;
|
||||
GAME_COMMAND_CALLBACK_POINTER* game_command_callback_table[] = {
|
||||
0,
|
||||
game_command_callback_ride_construct_new,
|
||||
};
|
||||
|
||||
int game_command_callback_get_index(GAME_COMMAND_CALLBACK_POINTER* callback)
|
||||
{
|
||||
for (int i = 0; i < countof(game_command_callback_table); i++ ) {
|
||||
if (game_command_callback_table[i] == callback) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
GAME_COMMAND_CALLBACK_POINTER* game_command_callback_get_callback(int index)
|
||||
{
|
||||
if (index < countof(game_command_callback_table)) {
|
||||
return game_command_callback_table[index];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void game_increase_game_speed()
|
||||
{
|
||||
gGameSpeed = min(gConfigGeneral.debugging_tools ? 5 : 4, gGameSpeed + 1);
|
||||
|
@ -419,7 +443,7 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
|
|||
RCT2_GLOBAL(0x009A8C28, uint8)++;
|
||||
|
||||
// Remove ghost scenery so it doesn't interfere with incoming network command
|
||||
if ((flags & GAME_COMMAND_FLAG_NETWORKED) && !(flags & 0x40) &&
|
||||
if ((flags & GAME_COMMAND_FLAG_NETWORKED) && !(flags & GAME_COMMAND_FLAG_GHOST) &&
|
||||
(command == GAME_COMMAND_PLACE_FENCE ||
|
||||
command == GAME_COMMAND_PLACE_SCENERY ||
|
||||
command == GAME_COMMAND_PLACE_LARGE_SCENERY ||
|
||||
|
@ -441,7 +465,7 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
|
|||
if (cost != MONEY32_UNDEFINED) {
|
||||
// Check funds
|
||||
insufficientFunds = 0;
|
||||
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & 4) && !(flags & 0x20) && cost != 0)
|
||||
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & GAME_COMMAND_FLAG_2) && !(flags & GAME_COMMAND_FLAG_5) && cost != 0)
|
||||
insufficientFunds = game_check_affordability(cost);
|
||||
|
||||
if (insufficientFunds != MONEY32_UNDEFINED) {
|
||||
|
@ -457,9 +481,10 @@ 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 & 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_NONE && !(flags & GAME_COMMAND_FLAG_NETWORKED) && !(flags & GAME_COMMAND_FLAG_GHOST) && !(flags & GAME_COMMAND_FLAG_5) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
|
||||
network_send_gamecmd(*eax, *ebx, *ecx, *edx, *esi, *edi, *ebp, game_command_callback_get_index(game_command_callback));
|
||||
if (network_get_mode() == NETWORK_MODE_CLIENT) {
|
||||
game_command_callback = 0;
|
||||
// Decrement nest count
|
||||
RCT2_GLOBAL(0x009A8C28, uint8)--;
|
||||
return cost;
|
||||
|
@ -472,6 +497,12 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
|
|||
} else {
|
||||
RCT2_CALLFUNC_X(game_do_command_table[command], eax, ebx, ecx, edx, esi, edi, ebp);
|
||||
}
|
||||
|
||||
if (game_command_callback) {
|
||||
game_command_callback(*eax, *ebx, *ecx, *edx, *esi, *edi, *ebp);
|
||||
game_command_callback = 0;
|
||||
}
|
||||
|
||||
*edx = *ebx;
|
||||
|
||||
if (*edx != MONEY32_UNDEFINED && *edx < cost)
|
||||
|
@ -503,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 & 1) && RCT2_GLOBAL(0x0141F568, uint8) == RCT2_GLOBAL(0x013CA740, uint8) && !(flags & 8))
|
||||
if (RCT2_GLOBAL(0x009A8C28, uint8) == 0 && (flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x0141F568, uint8) == RCT2_GLOBAL(0x013CA740, uint8) && !(flags & GAME_COMMAND_FLAG_3))
|
||||
window_error_open(RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16), RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16));
|
||||
|
||||
return MONEY32_UNDEFINED;
|
||||
|
|
20
src/game.h
20
src/game.h
|
@ -86,14 +86,26 @@ enum GAME_COMMAND {
|
|||
GAME_COMMAND_CLEAR_SCENERY
|
||||
};
|
||||
|
||||
// If this flag is set, the command is applied, otherwise only the cost is retrieved
|
||||
#define GAME_COMMAND_FLAG_APPLY (1 << 0)
|
||||
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_5 = (1 << 5),
|
||||
GAME_COMMAND_FLAG_GHOST = (1 << 6),
|
||||
GAME_COMMAND_FLAG_NETWORKED = (1 << 31) // Game command is coming from network
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
typedef void (GAME_COMMAND_CALLBACK_POINTER)(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
|
||||
|
||||
extern GAME_COMMAND_CALLBACK_POINTER* game_command_callback;
|
||||
int game_command_callback_get_index(GAME_COMMAND_CALLBACK_POINTER* callback);
|
||||
GAME_COMMAND_CALLBACK_POINTER* game_command_callback_get_callback(int index);
|
||||
|
||||
extern int gGameSpeed;
|
||||
extern float gDayNightCycle;
|
||||
|
||||
|
|
|
@ -358,6 +358,7 @@ bool Network::BeginServer(unsigned short port)
|
|||
|
||||
NetworkPlayer* player = AddPlayer("Server Player");
|
||||
player->flags |= NETWORK_PLAYER_FLAG_ISSERVER;
|
||||
player_id = player->id;
|
||||
|
||||
printf("Ready for clients...\n");
|
||||
|
||||
|
@ -386,6 +387,11 @@ uint32 Network::GetServerTick()
|
|||
return server_tick;
|
||||
}
|
||||
|
||||
uint8 Network::GetPlayerID()
|
||||
{
|
||||
return player_id;
|
||||
}
|
||||
|
||||
void Network::Update()
|
||||
{
|
||||
if (GetMode() == NETWORK_MODE_NONE)
|
||||
|
@ -446,12 +452,13 @@ NetworkPlayer* Network::GetPlayerByID(int id) {
|
|||
const char* Network::FormatChat(NetworkPlayer* fromplayer, const char* text)
|
||||
{
|
||||
static char formatted[1024];
|
||||
formatted[0] = (char)FORMAT_OUTLINE;
|
||||
formatted[1] = (char)FORMAT_BABYBLUE;
|
||||
formatted[0] = 0;
|
||||
if (fromplayer) {
|
||||
formatted[0] = (char)FORMAT_OUTLINE;
|
||||
formatted[1] = (char)FORMAT_BABYBLUE;
|
||||
strcpy(&formatted[2], (const char*)fromplayer->name);
|
||||
strcat(formatted, ": ");
|
||||
}
|
||||
strcat(formatted, ": ");
|
||||
strcat(formatted, text);
|
||||
return formatted;
|
||||
}
|
||||
|
@ -508,17 +515,17 @@ void Network::Server_Send_CHAT(const char* text)
|
|||
SendPacketToClients(*packet);
|
||||
}
|
||||
|
||||
void Network::Client_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp)
|
||||
void Network::Client_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 callback)
|
||||
{
|
||||
std::unique_ptr<NetworkPacket> packet = std::move(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED) << 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 << callback;
|
||||
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)
|
||||
void Network::Server_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 playerid, uint8 callback)
|
||||
{
|
||||
std::unique_ptr<NetworkPacket> packet = std::move(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED) << 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 << playerid << callback;
|
||||
SendPacketToClients(*packet);
|
||||
}
|
||||
|
||||
|
@ -627,7 +634,10 @@ void Network::ProcessGameCommandQueue()
|
|||
while (game_command_queue.begin() != game_command_queue.end() && game_command_queue.begin()->tick == RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32)) {
|
||||
// run all the game commands at the current tick
|
||||
const GameCommand& gc = (*game_command_queue.begin());
|
||||
game_do_command(gc.eax, gc.ebx, gc.ecx, gc.edx, gc.esi, gc.edi, gc.ebp);
|
||||
if (GetPlayerID() == gc.playerid) {
|
||||
game_command_callback = game_command_callback_get_callback(gc.callback);
|
||||
}
|
||||
game_do_command_p(gc.esi, (int*)&gc.eax, (int*)&gc.ebx, (int*)&gc.ecx, (int*)&gc.edx, (int*)&gc.esi, (int*)&gc.edi, (int*)&gc.ebp);
|
||||
game_command_queue.erase(game_command_queue.begin());
|
||||
}
|
||||
}
|
||||
|
@ -692,7 +702,7 @@ void Network::PrintError()
|
|||
|
||||
int Network::Client_Handle_AUTH(NetworkConnection& connection, NetworkPacket& packet)
|
||||
{
|
||||
packet >> (uint32&)connection.authstatus;
|
||||
packet >> (uint32&)connection.authstatus >> (uint8&)player_id;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -702,6 +712,7 @@ int Network::Server_Handle_AUTH(NetworkConnection& connection, NetworkPacket& pa
|
|||
const char* gameversion = packet.ReadString();
|
||||
const char* name = packet.ReadString();
|
||||
const char* password = packet.ReadString();
|
||||
uint8 playerid = 0;
|
||||
if (!gameversion || strcmp(gameversion, OPENRCT2_VERSION) != 0) {
|
||||
connection.authstatus = NETWORK_AUTH_BADVERSION;
|
||||
} else
|
||||
|
@ -714,15 +725,18 @@ int Network::Server_Handle_AUTH(NetworkConnection& connection, NetworkPacket& pa
|
|||
connection.authstatus = NETWORK_AUTH_OK;
|
||||
NetworkPlayer* player = AddPlayer(name);
|
||||
connection.player = player;
|
||||
char text[256];
|
||||
text[0] = (char)FORMAT_OUTLINE;
|
||||
text[1] = (char)FORMAT_GREEN;
|
||||
sprintf(&text[2], "%s has joined the game", player->name);
|
||||
chat_history_add(text);
|
||||
gNetwork.Server_Send_CHAT(text);
|
||||
if (player) {
|
||||
playerid = player->id;
|
||||
char text[256];
|
||||
text[0] = (char)FORMAT_OUTLINE;
|
||||
text[1] = (char)FORMAT_GREEN;
|
||||
sprintf(&text[2], "%s has joined the game", player->name);
|
||||
chat_history_add(text);
|
||||
gNetwork.Server_Send_CHAT(text);
|
||||
}
|
||||
}
|
||||
std::unique_ptr<NetworkPacket> responsepacket = std::move(NetworkPacket::Allocate());
|
||||
*responsepacket << (uint32)NETWORK_COMMAND_AUTH << (uint32)connection.authstatus;
|
||||
*responsepacket << (uint32)NETWORK_COMMAND_AUTH << (uint32)connection.authstatus << (uint8)playerid;
|
||||
connection.QueuePacket(std::move(responsepacket));
|
||||
}
|
||||
return 1;
|
||||
|
@ -786,8 +800,10 @@ int Network::Client_Handle_GAMECMD(NetworkConnection& connection, NetworkPacket&
|
|||
{
|
||||
uint32 tick;
|
||||
uint32 args[7];
|
||||
packet >> tick >> args[0] >> args[1] >> args[2] >> args[3] >> args[4] >> args[5] >> args[6];
|
||||
GameCommand gc = GameCommand(tick, args);
|
||||
uint8 playerid;
|
||||
uint8 callback;
|
||||
packet >> tick >> args[0] >> args[1] >> args[2] >> args[3] >> args[4] >> args[5] >> args[6] >> playerid >> callback;
|
||||
GameCommand gc = GameCommand(tick, args, playerid, callback);
|
||||
game_command_queue.insert(gc);
|
||||
return 1;
|
||||
}
|
||||
|
@ -796,8 +812,13 @@ int Network::Server_Handle_GAMECMD(NetworkConnection& connection, NetworkPacket&
|
|||
{
|
||||
uint32 tick;
|
||||
uint32 args[7];
|
||||
packet >> tick >> args[0] >> args[1] >> args[2] >> args[3] >> args[4] >> args[5] >> args[6];
|
||||
Server_Send_GAMECMD(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
||||
uint8 playerid;
|
||||
uint8 callback;
|
||||
if (connection.player) {
|
||||
playerid = connection.player->id;
|
||||
}
|
||||
packet >> tick >> args[0] >> args[1] >> args[2] >> args[3] >> args[4] >> args[5] >> args[6] >> callback;
|
||||
Server_Send_GAMECMD(args[0], args[1], args[2], args[3], args[4], args[5], args[6], playerid, callback);
|
||||
game_do_command(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
||||
return 1;
|
||||
}
|
||||
|
@ -900,6 +921,11 @@ uint32 network_get_server_tick()
|
|||
return gNetwork.GetServerTick();
|
||||
}
|
||||
|
||||
uint8 network_get_player_id()
|
||||
{
|
||||
return gNetwork.GetPlayerID();
|
||||
}
|
||||
|
||||
int network_get_num_players()
|
||||
{
|
||||
return gNetwork.player_list.size();
|
||||
|
@ -931,20 +957,20 @@ void network_send_chat(const char* text)
|
|||
gNetwork.Client_Send_CHAT(text);
|
||||
} else
|
||||
if (gNetwork.GetMode() == NETWORK_MODE_SERVER) {
|
||||
NetworkPlayer* player = gNetwork.GetPlayerByID(0);
|
||||
NetworkPlayer* player = gNetwork.GetPlayerByID(gNetwork.GetPlayerID());
|
||||
const char* formatted = gNetwork.FormatChat(player, text);
|
||||
chat_history_add(formatted);
|
||||
gNetwork.Server_Send_CHAT(formatted);
|
||||
}
|
||||
}
|
||||
|
||||
void network_send_gamecmd(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp)
|
||||
void network_send_gamecmd(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 callback)
|
||||
{
|
||||
if (gNetwork.GetMode() == NETWORK_MODE_CLIENT) {
|
||||
gNetwork.Client_Send_GAMECMD(eax, ebx, ecx, edx, esi, edi, ebp);
|
||||
gNetwork.Client_Send_GAMECMD(eax, ebx, ecx, edx, esi, edi, ebp, callback);
|
||||
} else
|
||||
if (gNetwork.GetMode() == NETWORK_MODE_SERVER) {
|
||||
gNetwork.Server_Send_GAMECMD(eax, ebx, ecx, edx, esi, edi, ebp);
|
||||
gNetwork.Server_Send_GAMECMD(eax, ebx, ecx, edx, esi, edi, ebp, gNetwork.GetPlayerID(), callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ public:
|
|||
int GetMode();
|
||||
int GetAuthStatus();
|
||||
uint32 GetServerTick();
|
||||
uint8 GetPlayerID();
|
||||
void Update();
|
||||
NetworkPlayer* GetPlayerByID(int id);
|
||||
const char* FormatChat(NetworkPlayer* fromplayer, const char* text);
|
||||
|
@ -139,8 +140,8 @@ public:
|
|||
void Server_Send_MAP();
|
||||
void Client_Send_CHAT(const char* text);
|
||||
void Server_Send_CHAT(const char* text);
|
||||
void Client_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp);
|
||||
void Server_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp);
|
||||
void Client_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 callback);
|
||||
void Server_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 playerid, uint8 callback);
|
||||
void Server_Send_TICK();
|
||||
void Server_Send_PLAYERLIST();
|
||||
void Client_Send_PING();
|
||||
|
@ -160,9 +161,11 @@ private:
|
|||
|
||||
struct GameCommand
|
||||
{
|
||||
GameCommand(uint32 t, uint32* args) { tick = t, eax = args[0], ebx = args[1], ecx = args[2], edx = args[3], esi = args[4], edi = args[5], ebp = args[6]; };
|
||||
GameCommand(uint32 t, uint32* args, uint8 p, uint8 cb) { tick = t, eax = args[0], ebx = args[1], ecx = args[2], edx = args[3], esi = args[4], edi = args[5], ebp = args[6]; playerid = p; callback = cb; };
|
||||
uint32 tick;
|
||||
uint32 eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
uint8 playerid;
|
||||
uint8 callback;
|
||||
bool operator<(const GameCommand& comp) const {
|
||||
return tick < comp.tick;
|
||||
}
|
||||
|
@ -176,6 +179,7 @@ private:
|
|||
uint32 last_tick_sent_time;
|
||||
uint32 last_ping_sent_time;
|
||||
uint32 server_tick;
|
||||
uint8 player_id;
|
||||
std::list<std::unique_ptr<NetworkConnection>> client_connection_list;
|
||||
std::multiset<GameCommand> game_command_queue;
|
||||
std::vector<uint8> chunk_buffer;
|
||||
|
@ -210,6 +214,7 @@ void network_update();
|
|||
int network_get_mode();
|
||||
int network_get_authstatus();
|
||||
uint32 network_get_server_tick();
|
||||
uint8 network_get_player_id();
|
||||
int network_get_num_players();
|
||||
const char* network_get_player_name(unsigned int index);
|
||||
uint32 network_get_player_flags(unsigned int index);
|
||||
|
@ -217,7 +222,7 @@ int network_get_player_ping(unsigned int index);
|
|||
|
||||
void network_send_map();
|
||||
void network_send_chat(const char* text);
|
||||
void network_send_gamecmd(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp);
|
||||
void network_send_gamecmd(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 callback);
|
||||
|
||||
void network_print_error();
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "../management/finance.h"
|
||||
#include "../management/marketing.h"
|
||||
#include "../management/news_item.h"
|
||||
#include "../network/network.h"
|
||||
#include "../peep/peep.h"
|
||||
#include "../peep/staff.h"
|
||||
#include "../rct1.h"
|
||||
|
@ -812,7 +813,7 @@ int ride_create_ride(ride_list_item listItem)
|
|||
edx = *((uint16*)&listItem);
|
||||
eax = 0;
|
||||
ecx = 0;
|
||||
ebx = 1;
|
||||
ebx = GAME_COMMAND_FLAG_APPLY;
|
||||
edi = 0;
|
||||
esi = 0;
|
||||
|
||||
|
@ -831,9 +832,12 @@ void ride_construct_new(ride_list_item listItem)
|
|||
{
|
||||
int rideIndex;
|
||||
|
||||
game_command_callback = game_command_callback_ride_construct_new;
|
||||
rideIndex = ride_create_ride(listItem);
|
||||
if (rideIndex != -1)
|
||||
ride_construct(rideIndex);
|
||||
|
||||
// moved to game_command_callback_ride_construct_new:
|
||||
/*if (rideIndex != -1)
|
||||
ride_construct(rideIndex);*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5072,6 +5076,13 @@ void game_command_create_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi,
|
|||
*ebx = ride_create(*edx & 0xFF, (*edx >> 8) & 0xFF, *ebx & 0xFF, edi);
|
||||
}
|
||||
|
||||
void game_command_callback_ride_construct_new(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp)
|
||||
{
|
||||
int rideIndex = edi;
|
||||
if (rideIndex != -1)
|
||||
ride_construct(rideIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B49D9
|
||||
|
|
|
@ -960,6 +960,7 @@ void game_command_set_ride_name(int *eax, int *ebx, int *ecx, int *edx, int *esi
|
|||
void game_command_set_ride_setting(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
int ride_get_refund_price(int ride_id);
|
||||
void game_command_create_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
void game_command_callback_ride_construct_new(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
|
||||
void game_command_demolish_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
void game_command_set_ride_appearance(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
void game_command_set_ride_price(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
|
|
|
@ -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 = 41;
|
||||
ebx = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_3 | 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 & (1 << 3))){
|
||||
if (!(flags & GAME_COMMAND_FLAG_3)){
|
||||
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;
|
||||
|
@ -3232,7 +3232,7 @@ void game_command_place_track_design(int* eax, int* ebx, int* ecx, int* edx, int
|
|||
}
|
||||
else{
|
||||
uint8 bl = 0;
|
||||
if (flags & (1 << 6)){
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST){
|
||||
bl = 4;
|
||||
}
|
||||
else{
|
||||
|
@ -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 & (1 << 3))) {
|
||||
if (!(flags & GAME_COMMAND_FLAG_3)) {
|
||||
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;
|
||||
|
@ -3638,7 +3638,7 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in
|
|||
|
||||
RCT2_GLOBAL(0x00F44060, void*) = &clearance_struct;
|
||||
|
||||
if (!gCheatsDisableClearanceChecks) {
|
||||
if (!gCheatsDisableClearanceChecks || flags & GAME_COMMAND_FLAG_GHOST){
|
||||
if (!map_can_construct_with_clear_at(x, y, baseZ, clearanceZ, (void*)0x006C5A5F, bl))
|
||||
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 & (1 << 3))) {
|
||||
if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_3)) {
|
||||
footpath_remove_litter(x, y, z);
|
||||
// push bl bh??
|
||||
if (rideTypeFlags & RIDE_TYPE_FLAG_18) {
|
||||
|
@ -3755,7 +3755,7 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in
|
|||
if (entranceDirections & 0x20) {
|
||||
entranceDirections &= 0x0F;
|
||||
if (entranceDirections != 0) {
|
||||
if (!(flags & GAME_COMMAND_FLAG_APPLY) && !(flags & 0x40)) {
|
||||
if (!(flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_GHOST)) {
|
||||
uint8 _bl = entranceDirections;
|
||||
for (int dl = bitscanforward(_bl); dl != -1; dl = bitscanforward(_bl)){
|
||||
_bl &= ~(1 << dl);
|
||||
|
@ -3836,7 +3836,7 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in
|
|||
|
||||
entranceDirections = 0;
|
||||
if (ride->overall_view != 0xFFFF){
|
||||
if (!(flags & (1 << 5))){
|
||||
if (!(flags & GAME_COMMAND_FLAG_5)){
|
||||
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) {
|
||||
entranceDirections = RCT2_ADDRESS(0x0099CA64, uint8)[type * 16];
|
||||
}
|
||||
|
@ -3863,7 +3863,7 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in
|
|||
mapElement->properties.track.ride_index = rideIndex;
|
||||
mapElement->properties.track.type = type;
|
||||
mapElement->properties.track.colour = 0;
|
||||
if (flags & (1 << 6)){
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST){
|
||||
mapElement->flags |= MAP_ELEMENT_FLAG_GHOST;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "../interface/widget.h"
|
||||
#include "../interface/window.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../network/network.h"
|
||||
#include "../ride/track.h"
|
||||
#include "dropdown.h"
|
||||
|
||||
|
@ -579,7 +580,7 @@ static void window_ride_construction_close(rct_window *w)
|
|||
hide_gridlines();
|
||||
|
||||
uint8 rideIndex = _currentRideIndex;
|
||||
if (sub_6CAF80(rideIndex, &mapElement)) {
|
||||
if (sub_6CAF80(rideIndex, &mapElement) || network_get_mode() == NETWORK_MODE_CLIENT) {
|
||||
window_ride_main_open(rideIndex);
|
||||
} else {
|
||||
int eax = RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8);
|
||||
|
|
Loading…
Reference in New Issue