summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-05-31 20:22:57 +0000
committerfrosch <frosch@openttd.org>2010-05-31 20:22:57 +0000
commit9db3cde73af598852da13b748eef31a8207cfcf2 (patch)
tree996d3e9c49ce7c3611a70ed4fa6f03774b4cafe9 /src/roadveh_cmd.cpp
parent1d05fbebbef72722d400ab4f7693dde11205a7f4 (diff)
downloadopenttd-9db3cde73af598852da13b748eef31a8207cfcf2.tar.xz
(svn r19914) -Codechange: Wrap a helper class around temporary assignments of _current_company to ensure proper restoration.
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index f207efaf7..67fa291ef 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -41,6 +41,7 @@
#include "engine_base.h"
#include "company_base.h"
#include "engine_func.h"
+#include "core/backup_type.hpp"
#include "table/strings.h"
#include "table/sprites.h"
@@ -1159,12 +1160,11 @@ static Trackdir FollowPreviousRoadVehicle(const RoadVehicle *v, const RoadVehicl
static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadBits r)
{
/* The 'current' company is not necessarily the owner of the vehicle. */
- CompanyID original_company = _current_company;
- _current_company = c;
+ Backup<CompanyByte> cur_company(_current_company, c);
CommandCost ret = DoCommand(t, ROADTYPE_TRAM << 4 | r, 0, DC_NONE, CMD_BUILD_ROAD);
- _current_company = original_company;
+ cur_company.Restore();
return ret.Succeeded();
}