Changeset - r27269:671153a97afa
[Not reviewed]
master
0 3 0
Rubidium - 13 months ago 2023-05-05 09:37:17
rubidium@openttd.org
Codechange: pass (uint) money as Money for CmdGiveMoney
3 files changed with 4 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -1184,13 +1184,13 @@ uint32 CompanyInfrastructure::GetTramTot
 
 * given the fact that you have more money than loan).
 
 * @param flags operation to perform
 
 * @param money the amount of money to transfer; max 20.000.000
 
 * @param dest_company the company to transfer the money to
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdGiveMoney(DoCommandFlag flags, uint32 money, CompanyID dest_company)
 
CommandCost CmdGiveMoney(DoCommandFlag flags, Money money, CompanyID dest_company)
 
{
 
	if (!_settings_game.economy.give_money) return CMD_ERROR;
 

	
 
	const Company *c = Company::Get(_current_company);
 
	CommandCost amount(EXPENSES_OTHER, std::min<Money>(money, 20000000LL));
 

	
src/company_cmd.h
Show inline comments
 
@@ -15,13 +15,13 @@
 
#include "livery.h"
 

	
 
enum ClientID : uint32;
 
enum Colours : byte;
 

	
 
CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id);
 
CommandCost CmdGiveMoney(DoCommandFlag flags, uint32 money, CompanyID dest_company);
 
CommandCost CmdGiveMoney(DoCommandFlag flags, Money money, CompanyID dest_company);
 
CommandCost CmdRenameCompany(DoCommandFlag flags, const std::string &text);
 
CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text);
 
CommandCost CmdSetCompanyManagerFace(DoCommandFlag flags, CompanyManagerFace cmf);
 
CommandCost CmdSetCompanyColour(DoCommandFlag flags, LiveryScheme scheme, bool primary, Colours colour);
 

	
 
DEF_CMD_TRAIT(CMD_COMPANY_CTRL,             CmdCompanyCtrl,           CMD_SPECTATOR | CMD_CLIENT_ID | CMD_NO_EST, CMDT_SERVER_SETTING)
src/company_gui.cpp
Show inline comments
 
@@ -2643,16 +2643,14 @@ struct CompanyWindow : Window
 
		if (str == nullptr) return;
 

	
 
		switch (this->query_widget) {
 
			default: NOT_REACHED();
 

	
 
			case WID_C_GIVE_MONEY: {
 
				Money money = (Money)(std::strtoull(str, nullptr, 10) / _currency->rate);
 
				uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
 

	
 
				Command<CMD_GIVE_MONEY>::Post(STR_ERROR_CAN_T_GIVE_MONEY, money_c, (CompanyID)this->window_number);
 
				Money money = std::strtoull(str, nullptr, 10) / _currency->rate;
 
				Command<CMD_GIVE_MONEY>::Post(STR_ERROR_CAN_T_GIVE_MONEY, money, (CompanyID)this->window_number);
 
				break;
 
			}
 

	
 
			case WID_C_PRESIDENT_NAME:
 
				Command<CMD_RENAME_PRESIDENT>::Post(STR_ERROR_CAN_T_CHANGE_PRESIDENT, str);
 
				break;
0 comments (0 inline, 0 general)