From 6737c270c9fa062bf40d006da93f9511ca7561ea Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 19 Jun 2013 21:26:27 +0000 Subject: [PATCH] gcc 4.5 compatibility fixes. Mostly due to lack of fully finctional nullptr class --- Global.h | 2 +- client/CMT.cpp | 2 +- lib/CArtHandler.cpp | 2 +- lib/mapping/CMapEditManager.cpp | 6 +++--- lib/mapping/CMapEditManager.h | 3 ++- lib/mapping/MapFormatH3M.cpp | 2 +- server/CGameHandler.cpp | 4 ++-- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Global.h b/Global.h index d43206d38..196c00b42 100644 --- a/Global.h +++ b/Global.h @@ -575,7 +575,7 @@ namespace vstd if(c.size()) return c.back(); else - return nullptr; + return typename Container::value_type(); } template diff --git a/client/CMT.cpp b/client/CMT.cpp index cd86ab891..0431e9b9f 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -670,7 +670,7 @@ void processCommand(const std::string &message) for (size_t i=0; iourImages.size(); i++) { - std::string filename = outPath + outName + '/' + boost::lexical_cast(i); + std::string filename = outPath + outName + '/' + boost::lexical_cast(i) + ".bmp"; SDL_SaveBMP(cde->ourImages[i].bitmap, filename.c_str()); } } diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index 629d52819..828c0abe3 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -750,7 +750,7 @@ void CArtifactInstance::removeFrom(ArtifactLocation al) bool CArtifactInstance::canBeDisassembled() const { - return artType->constituents != nullptr; + return bool(artType->constituents); } std::vector CArtifactInstance::assemblyPossibilities(const CArtifactSet *h) const diff --git a/lib/mapping/CMapEditManager.cpp b/lib/mapping/CMapEditManager.cpp index d20372d16..9a8b60b7f 100644 --- a/lib/mapping/CMapEditManager.cpp +++ b/lib/mapping/CMapEditManager.cpp @@ -327,9 +327,9 @@ CTerrainViewPatternConfig::CTerrainViewPatternConfig() // Read pattern data const JsonVector & data = ptrnNode["data"].Vector(); assert(data.size() == 9); - for(int i = 0; i < data.size(); ++i) + for(int j = 0; j < data.size(); ++j) { - std::string cell = data[i].String(); + std::string cell = data[j].String(); boost::algorithm::erase_all(cell, " "); std::vector rules; boost::split(rules, cell, boost::is_any_of(",")); @@ -344,7 +344,7 @@ CTerrainViewPatternConfig::CTerrainViewPatternConfig() { rule.points = boost::lexical_cast(ruleParts[1]); } - pattern.data[i].push_back(rule); + pattern.data[j].push_back(rule); } } diff --git a/lib/mapping/CMapEditManager.h b/lib/mapping/CMapEditManager.h index 686a469b6..d89f5c65f 100644 --- a/lib/mapping/CMapEditManager.h +++ b/lib/mapping/CMapEditManager.h @@ -137,7 +137,8 @@ public: void addOperation(unique_ptr && operation); /// Client code does not need to call this method. private: - typedef std::list > TStack; + // FIXME: switch back to unique_ptr once gcc 4.5 is abandoned + typedef std::list > TStack; void doOperation(TStack & fromStack, TStack & toStack, bool doUndo); const CMapOperation * peek(const TStack & stack) const; diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index a63a81f30..f82daa795 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/lib/mapping/MapFormatH3M.cpp @@ -685,7 +685,7 @@ CArtifactInstance * CMapLoaderH3M::createArtifact(int aid, int spellID /*= -1*/) map->addNewArtifactInstance(a); //TODO make it nicer - if(a->artType && a->artType->constituents != nullptr) + if(a->artType && (!!a->artType->constituents)) { CCombinedArtifactInstance * comb = dynamic_cast(a); BOOST_FOREACH(CCombinedArtifactInstance::ConstituentInfo & ci, comb->constituentsInfo) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index e46f5412b..712bfbc22 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -432,7 +432,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer if(bq->bi == gs->curB) return bq; } - return nullptr; + return shared_ptr(); }; auto battleQuery = findBattleQuery(); @@ -1710,7 +1710,7 @@ bool CGameHandler::moveHero( ObjectInstanceID hid, int3 dst, ui8 teleporting, Pl tmh.result = result; sendAndApply(&tmh); - if(lookForGuards == CHECK_FOR_GUARDS && isInTheMap(guardPos)) + if(lookForGuards == CHECK_FOR_GUARDS && this->isInTheMap(guardPos)) { tmh.attackedFrom = guardPos;