src/command.cpp
changeset 8726 5ae45b46506b
parent 8695 d8114f67f675
child 8728 26930bbf9bee
equal deleted inserted replaced
8725:b769d0a63f06 8726:5ae45b46506b
   439 			return res;
   439 			return res;
   440 		}
   440 		}
   441 	}
   441 	}
   442 
   442 
   443 	/* Execute the command here. All cost-relevant functions set the expenses type
   443 	/* Execute the command here. All cost-relevant functions set the expenses type
   444 	 * themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */
   444 	 * themselves to the cost object at some point */
   445 	res = proc(tile, flags, p1, p2);
   445 	res = proc(tile, flags, p1, p2);
   446 	if (CmdFailed(res)) {
   446 	if (CmdFailed(res)) {
   447 		res.SetGlobalErrorMessage();
   447 		res.SetGlobalErrorMessage();
   448 error:
   448 error:
   449 		_docommand_recursive--;
   449 		_docommand_recursive--;
   620 		GetPlayer(_current_player)->last_build_coordinate = tile;
   620 		GetPlayer(_current_player)->last_build_coordinate = tile;
   621 	}
   621 	}
   622 
   622 
   623 	/* Actually try and execute the command. If no cost-type is given
   623 	/* Actually try and execute the command. If no cost-type is given
   624 	 * use the construction one */
   624 	 * use the construction one */
   625 	_yearly_expenses_type = EXPENSES_CONSTRUCTION;
       
   626 	res2 = proc(tile, flags | DC_EXEC, p1, p2);
   625 	res2 = proc(tile, flags | DC_EXEC, p1, p2);
   627 
   626 
   628 	/* If notest is on, it means the result of the test can be different than
   627 	/* If notest is on, it means the result of the test can be different than
   629 	 *  the real command.. so ignore the test */
   628 	 *  the real command.. so ignore the test */
   630 	if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
   629 	if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
   695 Money CommandCost::GetCost() const
   694 Money CommandCost::GetCost() const
   696 {
   695 {
   697 	return this->cost;
   696 	return this->cost;
   698 }
   697 }
   699 
   698 
       
   699 ExpensesType CommandCost::GetExpensesType() const
       
   700 {
       
   701 	return this->expense_type;
       
   702 }
       
   703 
   700 void CommandCost::SetGlobalErrorMessage() const
   704 void CommandCost::SetGlobalErrorMessage() const
   701 {
   705 {
   702 	extern StringID _error_message;
   706 	extern StringID _error_message;
   703 	if (this->message != INVALID_STRING_ID) _error_message = this->message;
   707 	if (this->message != INVALID_STRING_ID) _error_message = this->message;
   704 }
   708 }