(svn r19914) -Codechange: Wrap a helper class around temporary assignments of _current_company to ensure proper restoration.

This commit is contained in:
frosch
2010-05-31 20:22:57 +00:00
parent 1d05fbebbe
commit 9db3cde73a
19 changed files with 256 additions and 117 deletions

View File

@@ -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