From 9db3cde73af598852da13b748eef31a8207cfcf2 Mon Sep 17 00:00:00 2001 From: frosch Date: Mon, 31 May 2010 20:22:57 +0000 Subject: (svn r19914) -Codechange: Wrap a helper class around temporary assignments of _current_company to ensure proper restoration. --- src/water_cmd.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/water_cmd.cpp') 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 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 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(); } /** -- cgit v1.2.3-70-g09d2