summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-12-28 14:37:19 +0000
committerrubidium <rubidium@openttd.org>2008-12-28 14:37:19 +0000
commit87e5a8b52bf2f200467d65c1e17fd79548d31129 (patch)
tree36bbbb5d389d41119ee184607bc012666dda7812 /src/network
parent53679122af1e0a68bbe4e9c1f73526dd7e118df6 (diff)
downloadopenttd-87e5a8b52bf2f200467d65c1e17fd79548d31129.tar.xz
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network.cpp9
-rw-r--r--src/network/network_client.cpp2
-rw-r--r--src/network/network_data.cpp7
-rw-r--r--src/network/network_server.cpp6
4 files changed, 11 insertions, 13 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index fefd5cfe3..7f54ef42e 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -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;
}
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 5abb151fd..da0c1f421 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -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
diff --git a/src/network/network_data.cpp b/src/network/network_data.cpp
index 7570ed527..42358f284 100644
--- a/src/network/network_data.cpp
+++ b/src/network/network_data.cpp
@@ -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 */
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index dcf9f3cb1..3226da0bf 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -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? */