diff options
author | frosch <frosch@openttd.org> | 2010-05-31 20:22:57 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-05-31 20:22:57 +0000 |
commit | 9db3cde73af598852da13b748eef31a8207cfcf2 (patch) | |
tree | 996d3e9c49ce7c3611a70ed4fa6f03774b4cafe9 /src/misc_cmd.cpp | |
parent | 1d05fbebbef72722d400ab4f7693dde11205a7f4 (diff) | |
download | openttd-9db3cde73af598852da13b748eef31a8207cfcf2.tar.xz |
(svn r19914) -Codechange: Wrap a helper class around temporary assignments of _current_company to ensure proper restoration.
Diffstat (limited to 'src/misc_cmd.cpp')
-rw-r--r-- | src/misc_cmd.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp index fe9bc9fde..181b8c190 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -21,6 +21,7 @@ #include "company_func.h" #include "company_gui.h" #include "company_base.h" +#include "core/backup_type.hpp" #include "table/strings.h" @@ -228,10 +229,9 @@ CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if (flags & DC_EXEC) { /* Add money to company */ - CompanyID old_company = _current_company; - _current_company = (CompanyID)p2; + Backup<CompanyByte> cur_company(_current_company, (CompanyID)p2); SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -amount.GetCost())); - _current_company = old_company; + cur_company.Restore(); } /* Subtract money from local-company */ |