Changeset - r23280:382c4bba9365
[Not reviewed]
master
0 3 0
Peter Nelson - 5 years ago 2019-02-04 17:19:21
peter1138@openttd.org
Fix #7151: Hang when concurrently starting AIs in multiplayer, or with shift pressed.
3 files changed with 8 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/command.cpp
Show inline comments
 
@@ -283,7 +283,7 @@ static const Command _command_proc_table
 

	
 
	DEF_CMD(CmdTurnRoadVeh,                                    0, CMDT_VEHICLE_MANAGEMENT    ), // CMD_TURN_ROADVEH
 

	
 
	DEF_CMD(CmdPause,                                 CMD_SERVER, CMDT_SERVER_SETTING        ), // CMD_PAUSE
 
	DEF_CMD(CmdPause,                    CMD_SERVER | CMD_NO_EST, CMDT_SERVER_SETTING        ), // CMD_PAUSE
 

	
 
	DEF_CMD(CmdBuyShareInCompany,                              0, CMDT_MONEY_MANAGEMENT      ), // CMD_BUY_SHARE_IN_COMPANY
 
	DEF_CMD(CmdSellShareInCompany,                             0, CMDT_MONEY_MANAGEMENT      ), // CMD_SELL_SHARE_IN_COMPANY
 
@@ -307,7 +307,7 @@ static const Command _command_proc_table
 
	DEF_CMD(CmdChangeBankBalance,                      CMD_DEITY, CMDT_MONEY_MANAGEMENT      ), // CMD_CHANGE_BANK_BALANCE
 
	DEF_CMD(CmdBuildCanal,                              CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_CANAL
 
	DEF_CMD(CmdCreateSubsidy,                          CMD_DEITY, CMDT_OTHER_MANAGEMENT      ), // CMD_CREATE_SUBSIDY
 
	DEF_CMD(CmdCompanyCtrl,        CMD_SPECTATOR | CMD_CLIENT_ID, CMDT_SERVER_SETTING        ), // CMD_COMPANY_CTRL
 
	DEF_CMD(CmdCompanyCtrl, CMD_SPECTATOR | CMD_CLIENT_ID | CMD_NO_EST, CMDT_SERVER_SETTING  ), // CMD_COMPANY_CTRL
 
	DEF_CMD(CmdCustomNewsItem,          CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT      ), // CMD_CUSTOM_NEWS_ITEM
 
	DEF_CMD(CmdCreateGoal,              CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT      ), // CMD_CREATE_GOAL
 
	DEF_CMD(CmdRemoveGoal,                             CMD_DEITY, CMDT_OTHER_MANAGEMENT      ), // CMD_REMOVE_GOAL
 
@@ -558,7 +558,7 @@ bool DoCommandP(TileIndex tile, uint32 p
 
	bool estimate_only = _shift_pressed && IsLocalCompany() &&
 
			!_generating_world &&
 
			!(cmd & CMD_NETWORK_COMMAND) &&
 
			(cmd & CMD_ID_MASK) != CMD_PAUSE;
 
			!(GetCommandFlags(cmd) & CMD_NO_EST);
 

	
 
	/* We're only sending the command, so don't do
 
	 * fancy things for 'success'. */
src/command_type.h
Show inline comments
 
@@ -395,6 +395,7 @@ enum CommandFlags {
 
	CMD_CLIENT_ID = 0x080, ///< set p2 with the ClientID of the sending client.
 
	CMD_DEITY     = 0x100, ///< the command may be executed by COMPANY_DEITY
 
	CMD_STR_CTRL  = 0x200, ///< the command's string may contain control strings
 
	CMD_NO_EST    = 0x400, ///< the command is never estimated.
 
};
 
DECLARE_ENUM_AS_BIT_SET(CommandFlags)
 

	
src/company_cmd.cpp
Show inline comments
 
@@ -724,6 +724,10 @@ void OnTick_Companies()
 
		/* Allow multiple AIs to possibly start in the same tick. */
 
		do {
 
			if (!MaybeStartNewCompany()) break;
 

	
 
			/* In networking mode, we can only send a command to start but it
 
			 * didn't execute yet, so we cannot loop. */
 
			if (_networking) break;
 
		} while (AI::GetStartNextTime() == 0);
 
	}
 

	
0 comments (0 inline, 0 general)