diff --git a/src/command.cpp b/src/command.cpp index 51ec446e77..d7c0efb815 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -161,21 +161,6 @@ bool IsCommandAllowedWhilePaused(Commands cmd) return _game_mode == GM_EDITOR || command_type_lookup[_command_proc_table[cmd].type] <= _settings_game.construction.command_pause_level; } -/*! - * This functions returns the money which can be used to execute a command. - * This is either the money of the current company or INT64_MAX if there - * is no such a company "at the moment" like the server itself. - * - * @return The available money of a company or INT64_MAX - */ -Money GetAvailableMoneyForCommand() -{ - CompanyID company = _current_company; - if (!Company::IsValidID(company)) return INT64_MAX; - return Company::Get(company)->money; -} - - /** * Prepare for calling a command proc. * @param top_level Top level of command execution, i.e. command from a command. diff --git a/src/command_func.h b/src/command_func.h index 47ce1ffe24..f0da57c65e 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -42,7 +42,6 @@ void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *cal bool IsValidCommand(Commands cmd); CommandFlags GetCommandFlags(Commands cmd); const char *GetCommandName(Commands cmd); -Money GetAvailableMoneyForCommand(); bool IsCommandAllowedWhilePaused(Commands cmd); template diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 6605ef9878..c44c69e0d1 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -193,6 +193,31 @@ void InvalidateCompanyWindows(const Company *company) SetWindowDirty(WC_FINANCES, cid); } +/** + * Get the amount of money that a company has available, or INT64_MAX + * if there is no such valid company. + * + * @param company Company to check + * @return The available money of the company or INT64_MAX + */ +Money GetAvailableMoney(CompanyID company) +{ + if (!Company::IsValidID(company)) return INT64_MAX; + return Company::Get(company)->money; +} + +/** + * This functions returns the money which can be used to execute a command. + * This is either the money of the current company or INT64_MAX if there + * is no such a company "at the moment" like the server itself. + * + * @return The available money of the current company or INT64_MAX + */ +Money GetAvailableMoneyForCommand() +{ + return GetAvailableMoney(_current_company); +} + /** * Verify whether the company can pay the bill. * @param[in,out] cost Money to pay, is changed to an error if the company does not have enough money. diff --git a/src/company_func.h b/src/company_func.h index 47adc24870..5d2d0df1dd 100644 --- a/src/company_func.h +++ b/src/company_func.h @@ -26,6 +26,8 @@ void CompanyAdminBankrupt(CompanyID company_id); void UpdateLandscapingLimits(); void UpdateCompanyLiveries(Company *c); +Money GetAvailableMoney(CompanyID company); +Money GetAvailableMoneyForCommand(); bool CheckCompanyHasMoney(CommandCost &cost); void SubtractMoneyFromCompany(const CommandCost &cost); void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cost); diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index 066e4a2f55..81764fccf2 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -10,6 +10,7 @@ #include "stdafx.h" #include "landscape.h" #include "command_func.h" +#include "company_func.h" #include "viewport_func.h" #include "company_base.h" #include "town.h" diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index ffaf3e5cad..1d814a65ee 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -12,6 +12,7 @@ #include "road_internal.h" #include "viewport_func.h" #include "command_func.h" +#include "company_func.h" #include "pathfinder/yapf/yapf_cache.h" #include "depot_base.h" #include "newgrf.h" diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index f9e78fc902..60de5745e1 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -15,6 +15,7 @@ #include "viewport_func.h" #include "viewport_kdtree.h" #include "command_func.h" +#include "company_func.h" #include "industry.h" #include "station_base.h" #include "waypoint_base.h"