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/water_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/water_cmd.cpp')
-rw-r--r-- | src/water_cmd.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 4f05633aa..6912d07ec 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -34,6 +34,7 @@ #include "station_base.h" #include "ai/ai.hpp" #include "core/random_func.hpp" +#include "core/backup_type.hpp" #include "table/sprites.h" #include "table/strings.h" @@ -881,7 +882,7 @@ void DoFloodTile(TileIndex target) bool flooded = false; // Will be set to true if something is changed. - _current_company = OWNER_WATER; + Backup<CompanyByte> cur_company(_current_company, OWNER_WATER); Slope tileh = GetTileSlope(target, NULL); if (tileh != SLOPE_FLAT) { @@ -933,7 +934,7 @@ void DoFloodTile(TileIndex target) UpdateSignalsInBuffer(); } - _current_company = OWNER_NONE; + cur_company.Restore(); } /** @@ -941,7 +942,7 @@ void DoFloodTile(TileIndex target) */ static void DoDryUp(TileIndex tile) { - _current_company = OWNER_WATER; + Backup<CompanyByte> cur_company(_current_company, OWNER_WATER); switch (GetTileType(tile)) { case MP_RAILWAY: @@ -977,7 +978,7 @@ static void DoDryUp(TileIndex tile) default: NOT_REACHED(); } - _current_company = OWNER_NONE; + cur_company.Restore(); } /** |