src/command.cpp
changeset 7222 d46753675bf7
parent 7066 e5d16aa8d6ca
child 7266 b16e67e992b4
equal deleted inserted replaced
7221:e4e12bbbba63 7222:d46753675bf7
   427 	return GetPlayer(pid)->player_money;
   427 	return GetPlayer(pid)->player_money;
   428 }
   428 }
   429 
   429 
   430 /* toplevel network safe docommand function for the current player. must not be called recursively.
   430 /* toplevel network safe docommand function for the current player. must not be called recursively.
   431  * the callback is called when the command succeeded or failed. */
   431  * the callback is called when the command succeeded or failed. */
   432 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd)
   432 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd)
   433 {
   433 {
   434 	CommandCost res, res2;
   434 	CommandCost res, res2;
   435 	CommandProc *proc;
   435 	CommandProc *proc;
   436 	uint32 flags;
   436 	uint32 flags;
   437 	bool notest;
   437 	bool notest;
   453 	_additional_cash_required = 0;
   453 	_additional_cash_required = 0;
   454 
   454 
   455 	/** Spectator has no rights except for the (dedicated) server which
   455 	/** Spectator has no rights except for the (dedicated) server which
   456 	 * is/can be a spectator but as the server it can do anything */
   456 	 * is/can be a spectator but as the server it can do anything */
   457 	if (_current_player == PLAYER_SPECTATOR && !_network_server) {
   457 	if (_current_player == PLAYER_SPECTATOR && !_network_server) {
   458 		ShowErrorMessage(_error_message, error_part1, x, y);
   458 		if (my_cmd) ShowErrorMessage(_error_message, error_part1, x, y);
   459 		_cmd_text = NULL;
   459 		_cmd_text = NULL;
   460 		return false;
   460 		return false;
   461 	}
   461 	}
   462 
   462 
   463 	flags = 0;
   463 	flags = 0;
   570 
   570 
   571 	if (IsLocalPlayer() && _game_mode != GM_EDITOR) {
   571 	if (IsLocalPlayer() && _game_mode != GM_EDITOR) {
   572 		if (res2.GetCost() != 0) ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2.GetCost());
   572 		if (res2.GetCost() != 0) ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2.GetCost());
   573 		if (_additional_cash_required != 0) {
   573 		if (_additional_cash_required != 0) {
   574 			SetDParam(0, _additional_cash_required);
   574 			SetDParam(0, _additional_cash_required);
   575 			ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, error_part1, x, y);
   575 			if (my_cmd) ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, error_part1, x, y);
   576 			if (res2.GetCost() == 0) goto callb_err;
   576 			if (res2.GetCost() == 0) goto callb_err;
   577 		}
   577 		}
   578 	}
   578 	}
   579 
   579 
   580 	_docommand_recursive = 0;
   580 	_docommand_recursive = 0;
   583 	_cmd_text = NULL;
   583 	_cmd_text = NULL;
   584 	return true;
   584 	return true;
   585 
   585 
   586 show_error:
   586 show_error:
   587 	/* show error message if the command fails? */
   587 	/* show error message if the command fails? */
   588 	if (IsLocalPlayer() && error_part1 != 0) {
   588 	if (IsLocalPlayer() && error_part1 != 0 && my_cmd) {
   589 		ShowErrorMessage(_error_message, error_part1, x, y);
   589 		ShowErrorMessage(_error_message, error_part1, x, y);
   590 	}
   590 	}
   591 
   591 
   592 callb_err:
   592 callb_err:
   593 	_docommand_recursive = 0;
   593 	_docommand_recursive = 0;