File diff r8186:a9e8ad715d2a → r8187:e86eb57c9d06
src/command.cpp
Show inline comments
 
@@ -14,13 +14,12 @@
 
#include "variables.h"
 
#include "genworld.h"
 
#include "newgrf_storage.h"
 
#include "strings_func.h"
 
#include "gfx_func.h"
 
#include "functions.h"
 
#include "town.h"
 

	
 
const char *_cmd_text = NULL;
 

	
 
/**
 
 * Helper macro to define the header of all command handler macros.
 
 *
 
@@ -386,13 +385,13 @@ bool IsValidCommand(uint cmd)
 
 */
 
byte GetCommandFlags(uint cmd)
 
{
 
	return _command_proc_table[cmd & 0xFF].flags;
 
}
 

	
 
static int _docommand_recursive = 0;
 
static int _docommand_recursive;
 

	
 
/*!
 
 * This function executes a given command with the parameters from the #CommandProc parameter list.
 
 * Depending on the flags parameter it execute or test a command.
 
 *
 
 * @param tile The tile to apply the command on (for the #CommandProc)
 
@@ -418,15 +417,13 @@ CommandCost DoCommand(TileIndex tile, ui
 
	if (_docommand_recursive == 0) _error_message = INVALID_STRING_ID;
 

	
 
	_docommand_recursive++;
 

	
 
	/* only execute the test call if it's toplevel, or we're not execing. */
 
	if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) {
 
		SetTownRatingTestMode(true);
 
		res = proc(tile, flags & ~DC_EXEC, p1, p2);
 
		SetTownRatingTestMode(false);
 
		if (CmdFailed(res)) {
 
			res.SetGlobalErrorMessage();
 
			goto error;
 
		}
 

	
 
		if (_docommand_recursive == 1 &&
 
@@ -554,13 +551,13 @@ bool DoCommandP(TileIndex tile, uint32 p
 
	notest =
 
		(cmd & 0xFF) == CMD_CLEAR_AREA ||
 
		(cmd & 0xFF) == CMD_LEVEL_LAND ||
 
		(cmd & 0xFF) == CMD_REMOVE_ROAD ||
 
		(cmd & 0xFF) == CMD_REMOVE_LONG_ROAD ||
 
		(cmd & 0xFF) == CMD_CLONE_VEHICLE;
 
	notest = false;
 

	
 
	_docommand_recursive = 1;
 

	
 
	/* cost estimation only? */
 
	if (!IsGeneratingWorld() &&
 
			_shift_pressed &&
 
			IsLocalPlayer() &&
 
@@ -581,15 +578,13 @@ bool DoCommandP(TileIndex tile, uint32 p
 
		return false;
 
	}
 

	
 

	
 
	if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
 
		/* first test if the command can be executed. */
 
		SetTownRatingTestMode(true);
 
		res = proc(tile, flags, p1, p2);
 
		SetTownRatingTestMode(false);
 
		if (CmdFailed(res)) {
 
			res.SetGlobalErrorMessage();
 
			goto show_error;
 
		}
 
		/* no money? Only check if notest is off */
 
		if (!notest && res.GetCost() != 0 && !CheckPlayerHasMoney(res)) goto show_error;