File diff r25561:3defb050f30b → r25562:30716ba6a396
src/command.cpp
Show inline comments
 
@@ -462,13 +462,13 @@ CommandCost DoCommand(const CommandConta
 
 * @param flags Flags for the command and how to execute the command
 
 * @param cmd The command-id to execute (a value of the CMD_* enums)
 
 * @param text The text to pass
 
 * @see CommandProc
 
 * @return the cost
 
 */
 
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text)
 
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const std::string &text)
 
{
 
	CommandCost res;
 

	
 
	/* Do not even think about executing out-of-bounds tile-commands */
 
	if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (flags & DC_ALL_TILES) == 0))) return CMD_ERROR;
 

	
 
@@ -555,13 +555,13 @@ bool DoCommandP(const CommandContainer *
 
 * @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 my_cmd indicator if the command is from a company or server (to display error messages for a user)
 
 * @return \c true if the command succeeded, else \c false.
 
 */
 
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd)
 
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd)
 
{
 
	/* Cost estimation is generally only done when the
 
	 * local user presses shift while doing something.
 
	 * However, in case of incoming network commands,
 
	 * map generation or the pause button we do want
 
	 * to execute. */
 
@@ -628,13 +628,13 @@ bool DoCommandP(TileIndex tile, uint32 p
 
 * @param callback A callback function to call after the command is finished
 
 * @param text The text to pass
 
 * @param my_cmd indicator if the command is from a company or server (to display error messages for a user)
 
 * @param estimate_only whether to give only the estimate or also execute the command
 
 * @return the command cost of this function.
 
 */
 
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only)
 
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd, bool estimate_only)
 
{
 
	/* Prevent recursion; it gives a mess over the network */
 
	assert(_docommand_recursive == 0);
 
	_docommand_recursive = 1;
 

	
 
	/* Reset the state. */
 
@@ -693,13 +693,13 @@ CommandCost DoCommandPInternal(TileIndex
 
	 * we bail out here. */
 
	if (res.Failed() || estimate_only ||
 
			(!test_and_exec_can_differ && !CheckCompanyHasMoney(res))) {
 
		if (!_networking || _generating_world || (cmd & CMD_NETWORK_COMMAND) != 0) {
 
			/* Log the failed command as well. Just to be able to be find
 
			 * causes of desyncs due to bad command test implementations. */
 
			DEBUG(desync, 1, "cmdf: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
 
			DEBUG(desync, 1, "cmdf: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text.c_str(), GetCommandName(cmd));
 
		}
 
		cur_company.Restore();
 
		return_dcpi(res);
 
	}
 

	
 
	/*
 
@@ -713,13 +713,13 @@ CommandCost DoCommandPInternal(TileIndex
 
		/* Don't return anything special here; no error, no costs.
 
		 * This way it's not handled by DoCommand and only the
 
		 * actual execution of the command causes messages. Also
 
		 * reset the storages as we've not executed the command. */
 
		return_dcpi(CommandCost());
 
	}
 
	DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
 
	DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text.c_str(), GetCommandName(cmd));
 

	
 
	/* Actually try and execute the command. If no cost-type is given
 
	 * use the construction one */
 
	_cleared_object_areas.clear();
 
	BasePersistentStorageArray::SwitchMode(PSM_ENTER_COMMAND);
 
	CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text);