Changeset - r14223:fd89464d3da0
[Not reviewed]
master
0 8 0
rubidium - 14 years ago 2010-01-11 20:32:32
rubidium@openttd.org
(svn r18784) -Codechange: make NetworkSend_Command accept a company instead of using _local_company to pass that information, with the whole mess when you don't want the company to be _local_company.
8 files changed with 11 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_object.cpp
Show inline comments
 
@@ -230,12 +230,7 @@ bool AIObject::DoCommand(TileIndex tile,
 
#ifdef ENABLE_NETWORK
 
	/* Send the command */
 
	if (_networking) {
 
		/* NetworkSend_Command needs _local_company to be set correctly, so
 
		 * adjust it, and put it back right after the function */
 
		CompanyID old_company = _local_company;
 
		_local_company = _current_company;
 
		::NetworkSend_Command(tile, p1, p2, cmd, CcAI, text);
 
		_local_company = old_company;
 
		::NetworkSend_Command(tile, p1, p2, cmd, CcAI, text, _current_company);
 
		SetLastCost(res.GetCost());
 

	
 
		/* Suspend the AI till the command is really executed */
src/command.cpp
Show inline comments
 
@@ -589,7 +589,7 @@ bool DoCommandP(TileIndex tile, uint32 p
 
	 * send it to the command-queue and abort execution
 
	 */
 
	if (_networking && !(cmd & CMD_NETWORK_COMMAND)) {
 
		NetworkSend_Command(tile, p1, p2, cmd & ~CMD_FLAGS_MASK, callback, text);
 
		NetworkSend_Command(tile, p1, p2, cmd & ~CMD_FLAGS_MASK, callback, text, _current_company);
 
		_docommand_recursive = 0;
 
		ClearStorageChanges(false);
 
		return true;
src/command_func.h
Show inline comments
 
@@ -13,6 +13,7 @@
 
#define COMMAND_FUNC_H
 

	
 
#include "command_type.h"
 
#include "company_type.h"
 

	
 
/**
 
 * Checks if a command failes.
 
@@ -70,11 +71,10 @@ bool DoCommandP(TileIndex tile, uint32 p
 
bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/**
 
 * Send a command over the network
 
 */
 
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text);
 
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company);
 
#endif /* ENABLE_NETWORK */
 

	
 
extern Money _additional_cash_required;
src/company_cmd.cpp
Show inline comments
 
@@ -790,7 +790,6 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
				NetworkUpdateClientInfo(ci->client_id);
 

	
 
				if (Company::IsValidID(ci->client_playas)) {
 
					CompanyID company_backup = _local_company;
 
					_network_company_states[c->index].months_empty = 0;
 
					_network_company_states[c->index].password[0] = '\0';
 
					NetworkServerUpdateCompanyPassworded(ci->client_playas, false);
 
@@ -806,9 +805,7 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
					 * TODO: Perhaps this could be improved by when the client is ready
 
					 * with joining to let it send itself the command, and not the server?
 
					 * For example in network_client.c:534? */
 
					_local_company = ci->client_playas;
 
					NetworkSend_Command(0, 0, 0, CMD_RENAME_PRESIDENT, NULL, ci->client_name);
 
					_local_company = company_backup;
 
					NetworkSend_Command(0, 0, 0, CMD_RENAME_PRESIDENT, NULL, ci->client_name, ci->client_playas);
 
				}
 

	
 
				/* Announce new company on network, if the client was a SPECTATOR before */
src/network/network_client.cpp
Show inline comments
 
@@ -643,7 +643,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
				 * 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, NULL);
 
				NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL, NULL, _local_company);
 
			}
 
		} else {
 
			/* take control over an existing company */
src/network/network_command.cpp
Show inline comments
 
@@ -78,13 +78,14 @@ void NetworkAddCommandQueue(CommandPacke
 
 * @param cmd The command to execute (a CMD_* value)
 
 * @param callback A callback function to call after the command is finished
 
 * @param text The text to pass
 
 * @param company The company that wants to send the command
 
 */
 
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text)
 
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company)
 
{
 
	assert((cmd & CMD_FLAGS_MASK) == 0);
 

	
 
	CommandPacket c;
 
	c.company  = _local_company;
 
	c.company  = company;
 
	c.next     = NULL;
 
	c.tile     = tile;
 
	c.p1       = p1;
src/settings.cpp
Show inline comments
 
@@ -1579,7 +1579,7 @@ void SyncCompanySettings()
 
		const void *new_var = GetVariableAddress(&_settings_client.company, &sd->save);
 
		uint32 old_value = (uint32)ReadValue(old_var, sd->save.conv);
 
		uint32 new_value = (uint32)ReadValue(new_var, sd->save.conv);
 
		if (old_value != new_value) NetworkSend_Command(0, i, new_value, CMD_CHANGE_COMPANY_SETTING, NULL, NULL);
 
		if (old_value != new_value) NetworkSend_Command(0, i, new_value, CMD_CHANGE_COMPANY_SETTING, NULL, NULL, _local_company);
 
	}
 
}
 
#endif /* ENABLE_NETWORK */
src/toolbar_gui.cpp
Show inline comments
 
@@ -486,7 +486,7 @@ static void MenuClickCompany(int index)
 
				if (_network_server) {
 
					DoCommandP(0, 0, _network_own_client_id, CMD_COMPANY_CTRL);
 
				} else {
 
					NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL, NULL);
 
					NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL, NULL, _local_company);
 
				}
 
				return;
 

	
0 comments (0 inline, 0 general)