mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
5 Commits
fcaf7c37af
...
c01adb446f
Author | SHA1 | Date |
---|---|---|
Peter Nelson | c01adb446f | |
Rubidium | cef9417c9f | |
Rubidium | a313676189 | |
Rubidium | ed888c617b | |
Koen Bussemaker | 59ac27f385 |
|
@ -151,7 +151,7 @@ bool IsCommandAllowedWhilePaused(Commands cmd)
|
|||
CMDPL_NO_CONSTRUCTION, ///< CMDT_VEHICLE_MANAGEMENT
|
||||
CMDPL_NO_CONSTRUCTION, ///< CMDT_ROUTE_MANAGEMENT
|
||||
CMDPL_NO_CONSTRUCTION, ///< CMDT_OTHER_MANAGEMENT
|
||||
CMDPL_NO_CONSTRUCTION, ///< CMDT_COMPANY_SETTING
|
||||
CMDPL_NO_ACTIONS, ///< CMDT_COMPANY_SETTING
|
||||
CMDPL_NO_ACTIONS, ///< CMDT_SERVER_SETTING
|
||||
CMDPL_NO_ACTIONS, ///< CMDT_CHEAT
|
||||
};
|
||||
|
|
|
@ -898,8 +898,12 @@ CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID
|
|||
assert(_local_company == COMPANY_SPECTATOR);
|
||||
SetLocalCompany(c->index);
|
||||
|
||||
/* In network games, we need to try setting the company manager face here to sync it to all clients.
|
||||
* If a favorite company manager face is selected, choose it. Otherwise, use a random face. */
|
||||
/*
|
||||
* If a favorite company manager face is selected, choose it. Otherwise, use a random face.
|
||||
* Because this needs to be synchronised over the network, only the client knows
|
||||
* its configuration and we are currently in the execution of a command, we have
|
||||
* to circumvent the normal ::Post logic for commands and just send the command.
|
||||
*/
|
||||
if (_company_manager_face != 0) Command<CMD_SET_COMPANY_MANAGER_FACE>::SendNet(STR_NULL, c->index, _company_manager_face);
|
||||
|
||||
/* Now that we have a new company, broadcast our company settings to
|
||||
|
|
|
@ -28,9 +28,9 @@ CommandCost CmdSetCompanyColour(DoCommandFlag flags, LiveryScheme scheme, bool p
|
|||
DEF_CMD_TRAIT(CMD_COMPANY_CTRL, CmdCompanyCtrl, CMD_SPECTATOR | CMD_CLIENT_ID | CMD_NO_EST, CMDT_SERVER_SETTING)
|
||||
DEF_CMD_TRAIT(CMD_COMPANY_ADD_ALLOW_LIST, CmdCompanyAddAllowList, CMD_NO_EST, CMDT_SERVER_SETTING)
|
||||
DEF_CMD_TRAIT(CMD_GIVE_MONEY, CmdGiveMoney, 0, CMDT_MONEY_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_RENAME_COMPANY, CmdRenameCompany, 0, CMDT_OTHER_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_RENAME_PRESIDENT, CmdRenamePresident, 0, CMDT_OTHER_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_SET_COMPANY_MANAGER_FACE, CmdSetCompanyManagerFace, 0, CMDT_OTHER_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_SET_COMPANY_COLOUR, CmdSetCompanyColour, 0, CMDT_OTHER_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_RENAME_COMPANY, CmdRenameCompany, 0, CMDT_COMPANY_SETTING)
|
||||
DEF_CMD_TRAIT(CMD_RENAME_PRESIDENT, CmdRenamePresident, 0, CMDT_COMPANY_SETTING)
|
||||
DEF_CMD_TRAIT(CMD_SET_COMPANY_MANAGER_FACE, CmdSetCompanyManagerFace, 0, CMDT_COMPANY_SETTING)
|
||||
DEF_CMD_TRAIT(CMD_SET_COMPANY_COLOUR, CmdSetCompanyColour, 0, CMDT_COMPANY_SETTING)
|
||||
|
||||
#endif /* COMPANY_CMD_H */
|
||||
|
|
|
@ -886,7 +886,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
|
|||
Debug(net, 9, "Client::join_status = REGISTERING");
|
||||
_network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
|
||||
ShowJoinStatusWindow();
|
||||
Command<CMD_COMPANY_CTRL>::SendNet(STR_NULL, _local_company, CCA_NEW, INVALID_COMPANY, CRR_NONE, INVALID_CLIENT_ID);
|
||||
Command<CMD_COMPANY_CTRL>::Post(CCA_NEW, INVALID_COMPANY, CRR_NONE, _network_own_client_id);
|
||||
}
|
||||
} else {
|
||||
/* take control over an existing company */
|
||||
|
|
|
@ -1460,11 +1460,7 @@ private:
|
|||
*/
|
||||
static void OnClickCompanyNew([[maybe_unused]] NetworkClientListWindow *w, [[maybe_unused]] Point pt, CompanyID)
|
||||
{
|
||||
if (_network_server) {
|
||||
Command<CMD_COMPANY_CTRL>::Post(CCA_NEW, INVALID_COMPANY, CRR_NONE, _network_own_client_id);
|
||||
} else {
|
||||
Command<CMD_COMPANY_CTRL>::SendNet(STR_NULL, _local_company, CCA_NEW, INVALID_COMPANY, CRR_NONE, INVALID_CLIENT_ID);
|
||||
}
|
||||
Command<CMD_COMPANY_CTRL>::Post(CCA_NEW, INVALID_COMPANY, CRR_NONE, _network_own_client_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2157,6 +2157,13 @@ void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci)
|
|||
/* ci is nullptr when replaying, or for AIs. In neither case there is a client. */
|
||||
ci->client_playas = c->index;
|
||||
NetworkUpdateClientInfo(ci->client_id);
|
||||
|
||||
/*
|
||||
* This function is called from a command, but is only called for the server.
|
||||
* The client information is managed out-of-band from the commands, so to not have a
|
||||
* different state/president/company name in the different clients, we need to
|
||||
* circumvent the normal ::Post logic and go directly to sending the command.
|
||||
*/
|
||||
Command<CMD_COMPANY_ADD_ALLOW_LIST>::SendNet(STR_NULL, c->index, ci->public_key);
|
||||
Command<CMD_RENAME_PRESIDENT>::SendNet(STR_NULL, c->index, ci->client_name);
|
||||
|
||||
|
|
|
@ -405,6 +405,7 @@ void AllocateWaterRegions()
|
|||
_water_regions.clear();
|
||||
_water_regions.reserve(number_of_regions);
|
||||
|
||||
_is_water_region_valid.clear();
|
||||
_is_water_region_valid.resize(number_of_regions, false);
|
||||
|
||||
Debug(map, 2, "Allocating {} x {} water regions", GetWaterRegionMapSizeX(), GetWaterRegionMapSizeY());
|
||||
|
|
|
@ -1790,6 +1790,11 @@ void SyncCompanySettings()
|
|||
const SettingDesc *sd = GetSettingDesc(desc);
|
||||
uint32_t old_value = (uint32_t)sd->AsIntSetting()->Read(old_object);
|
||||
uint32_t new_value = (uint32_t)sd->AsIntSetting()->Read(new_object);
|
||||
/*
|
||||
* This is called from a command, and since it contains local configuration information
|
||||
* that the rest of the clients do not know about, we need to circumvent the normal ::Post
|
||||
* local command validation and immediately send the command to the server.
|
||||
*/
|
||||
if (old_value != new_value) Command<CMD_CHANGE_COMPANY_SETTING>::SendNet(STR_NULL, _local_company, sd->GetName(), new_value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue