From cfc39813426fbfd26bc35c743711434ae0a894e5 Mon Sep 17 00:00:00 2001 From: Wanne Date: Fri, 4 Nov 2011 11:18:22 +0000 Subject: [PATCH] - Fixed exclusive VS 2010 compilation error that was introduced in revision 4665 when making improvement to the tactical save code (thx to BirdFlu) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4779 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TileEngine/SaveLoadMap.cpp | 51 ++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/TileEngine/SaveLoadMap.cpp b/TileEngine/SaveLoadMap.cpp index 987a8e22..a2e774a9 100644 --- a/TileEngine/SaveLoadMap.cpp +++ b/TileEngine/SaveLoadMap.cpp @@ -46,29 +46,32 @@ BOOLEAN ModifyWindowStatus( INT32 uiMapIndex ); struct ModifiedMapFile { - UINT32 uiType; - INT16 sMapX; - INT16 sMapY; - INT8 bMapZ; + struct Key + { + UINT32 uiType; + INT16 sMapX; + INT16 sMapY; + INT8 bMapZ; + } key; CHAR8 szMapName[128]; HWFILE hFileHandle; ModifiedMapFile(UINT32 uiType, INT16 sMapX, INT16 sMapY, INT8 bMapZ) { - this->uiType = uiType; - this->sMapX = sMapX; - this->sMapY = sMapY; - this->bMapZ = bMapZ; + this->key.uiType = uiType; + this->key.sMapX = sMapX; + this->key.sMapY = sMapY; + this->key.bMapZ = bMapZ; this->szMapName[0] = 0; - this->hFileHandle = NULL; + this->hFileHandle = NULL; } ModifiedMapFile(UINT32 uiType, STR pMapName, INT16 sMapX, INT16 sMapY, INT8 bMapZ) { - this->uiType = uiType; - this->sMapX = sMapX; - this->sMapY = sMapY; - this->bMapZ = bMapZ; + this->key.uiType = uiType; + this->key.sMapX = sMapX; + this->key.sMapY = sMapY; + this->key.bMapZ = bMapZ; strncpy(this->szMapName, pMapName, _countof(this->szMapName)); this->szMapName[_countof(this->szMapName) - 1] = 0; this->hFileHandle = NULL; @@ -141,7 +144,7 @@ struct ModifiedMapFile struct ltMMF { - bool compare(const ModifiedMapFile& s1, const ModifiedMapFile& s2) const + bool compare(const ModifiedMapFile::Key& s1, const ModifiedMapFile::Key& s2) const { int diff = s1.uiType - s2.uiType; if (diff == 0) @@ -158,13 +161,13 @@ struct ltMMF } return diff < 0; } - bool operator()(const ModifiedMapFile& s1, const ModifiedMapFile& s2) const { return compare(s1, s2); } - bool operator()(const ModifiedMapFile* s1, const ModifiedMapFile* s2) const { return compare(*s1, *s2); } - bool operator()(const ModifiedMapFile& s1, const ModifiedMapFile* s2) const { return compare(s1, *s2); } - bool operator()(const ModifiedMapFile* s1, const ModifiedMapFile& s2) const { return compare(*s1, s2); } + bool operator()(const ModifiedMapFile::Key& s1, const ModifiedMapFile::Key& s2) const { return compare(s1, s2); } + bool operator()(const ModifiedMapFile::Key* s1, const ModifiedMapFile::Key* s2) const { return compare(*s1, *s2); } + bool operator()(const ModifiedMapFile::Key& s1, const ModifiedMapFile::Key* s2) const { return compare(s1, *s2); } + bool operator()(const ModifiedMapFile::Key* s1, const ModifiedMapFile::Key& s2) const { return compare(*s1, s2); } }; -typedef std::set ModifiedMapFileSet; +typedef std::map ModifiedMapFileSet; ModifiedMapFileSet g_mapFileSet; BOOLEAN g_useSaveCache; @@ -194,13 +197,13 @@ bool TryGetModifiedMapFile( UINT32 uiType, INT16 sMapX, INT16 sMapY, INT8 bMapZ, return false; ModifiedMapFile key(uiType, sMapX, sMapY, bMapZ); - ModifiedMapFileSet::iterator itr = g_mapFileSet.find(key); + ModifiedMapFileSet::iterator itr = g_mapFileSet.find(key.key); if (itr == g_mapFileSet.end()) { *ppMMF = NULL; return false; } - *ppMMF = &(*itr); + *ppMMF = &(itr->second); return true; } @@ -211,10 +214,10 @@ ModifiedMapFile& GetOrCreateModifiedMapFile(UINT32 uiType, INT16 sMapX, INT16 sM return *pResult; ModifiedMapFile key(uiType, sMapX, sMapY, bMapZ); - ModifiedMapFileSet::iterator itr = g_mapFileSet.insert(g_mapFileSet.end(), key); - pResult = &(*itr); + ModifiedMapFileSet::iterator itr = g_mapFileSet.insert(g_mapFileSet.end(), std::make_pair(key.key, key)); + pResult = &(itr->second); - GetMapTempFileName( pResult->uiType, pResult->szMapName, pResult->sMapX, pResult->sMapY, pResult->bMapZ ); + GetMapTempFileName( pResult->key.uiType, pResult->szMapName, pResult->key.sMapX, pResult->key.sMapY, pResult->key.bMapZ ); return *pResult; }