(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.

This commit is contained in:
rubidium
2008-12-28 14:37:19 +00:00
parent 53679122af
commit 87e5a8b52b
67 changed files with 373 additions and 430 deletions

View File

@@ -375,13 +375,13 @@ void CheckMinActiveClients()
if (_min_active_clients_paused) return;
_min_active_clients_paused = true;
DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
DoCommandP(0, 1, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game paused (not enough players)", CLIENT_ID_SERVER);
} else {
if (!_min_active_clients_paused) return;
_min_active_clients_paused = false;
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
DoCommandP(0, 0, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (enough players)", CLIENT_ID_SERVER);
}
}
@@ -470,7 +470,7 @@ void NetworkCloseClient(NetworkClientSocket *cs)
/* When the client was PRE_ACTIVE, the server was in pause mode, so unpause */
if (cs->status == STATUS_PRE_ACTIVE && _settings_client.network.pause_on_join) {
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
DoCommandP(0, 0, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused", CLIENT_ID_SERVER);
}
@@ -1057,8 +1057,7 @@ void NetworkGameLoop()
while (f != NULL && !feof(f)) {
if (cp != NULL && _date == next_date && _date_fract == next_date_fract) {
_current_company = cp->company;
_cmd_text = cp->text;
DoCommandP(cp->tile, cp->p1, cp->p2, NULL, cp->cmd);
DoCommandP(cp->tile, cp->p1, cp->p2, cp->cmd, NULL, cp->text);
free(cp);
cp = NULL;
}

View File

@@ -620,7 +620,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
* the server will give us a client-id and let us in */
_network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
ShowJoinStatusWindow();
NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL);
NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL, NULL);
}
} else {
// take control over an existing company

View File

@@ -32,7 +32,7 @@ void NetworkAddCommandQueue(NetworkClientSocket *cs, CommandPacket *cp)
}
// Prepare a DoCommand to be send over the network
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback)
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text)
{
CommandPacket c;
@@ -53,7 +53,7 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
c.callback = 0; // _callback_table[0] == NULL
}
strecpy(c.text, (_cmd_text != NULL) ? _cmd_text : "", lastof(c.text));
strecpy(c.text, (text != NULL) ? text : "", lastof(c.text));
if (_network_server) {
/* If we are the server, we queue the command in our 'special' queue.
@@ -96,7 +96,6 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
void NetworkExecuteCommand(CommandPacket *cp)
{
_current_company = cp->company;
_cmd_text = cp->text;
/* cp->callback is unsigned. so we don't need to do lower bounds checking. */
if (cp->callback > _callback_table_count) {
DEBUG(net, 0, "Received out-of-bounds callback (%d)", cp->callback);
@@ -105,7 +104,7 @@ void NetworkExecuteCommand(CommandPacket *cp)
DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)cp->company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text);
DoCommandP(cp->tile, cp->p1, cp->p2, _callback_table[cp->callback], cp->cmd | CMD_NETWORK_COMMAND, cp->my_cmd);
DoCommandP(cp->tile, cp->p1, cp->p2, cp->cmd | CMD_NETWORK_COMMAND, _callback_table[cp->callback], cp->text, cp->my_cmd);
}
#endif /* ENABLE_NETWORK */

View File

@@ -804,7 +804,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK)
if (_settings_client.network.pause_on_join) {
/* Now pause the game till the client is in sync */
DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
DoCommandP(0, 1, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game paused (incoming client)", CLIENT_ID_SERVER);
}
@@ -1030,7 +1030,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ACK)
cs->status = STATUS_ACTIVE;
if (_settings_client.network.pause_on_join) {
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
DoCommandP(0, 0, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (client connected)", CLIENT_ID_SERVER);
}
@@ -1392,7 +1392,7 @@ static void NetworkAutoCleanCompanies()
/* Is the company empty for autoclean_unprotected-months, and is there no protection? */
if (_settings_client.network.autoclean_unprotected != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_unprotected && StrEmpty(_network_company_states[c->index].password)) {
/* Shut the company down */
DoCommandP(0, 2, c->index, NULL, CMD_COMPANY_CTRL);
DoCommandP(0, 2, c->index, CMD_COMPANY_CTRL);
IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d", c->index + 1);
}
/* Is the company empty for autoclean_protected-months, and there is a protection? */