summaryrefslogtreecommitdiff
path: root/src/saveload
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/saveload
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/saveload')
-rw-r--r--src/saveload/afterload.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 9a128e404..59c743012 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -52,6 +52,7 @@
#include "../engine_base.h"
#include "../engine_func.h"
#include "../rail_gui.h"
+#include "../core/backup_type.hpp"
#include "table/strings.h"
@@ -1570,8 +1571,9 @@ bool AfterLoadGame()
if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
Owner o = GetTileOwner(t);
if (o < MAX_COMPANIES && !Company::IsValidID(o)) {
- _current_company = o;
+ Backup<CompanyByte> cur_company(_current_company, o);
ChangeTileOwner(t, o, INVALID_OWNER);
+ cur_company.Restore();
}
if (IsBuoyTile(t)) {
/* reset buoy owner to OWNER_NONE in the station struct