From 1d17d604496e8d84ebaf23f1f7272c287042da6f Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 29 May 2014 13:42:05 +0300 Subject: [PATCH 1/3] gcc update: - removed support for 4.6 - compilation fixes for 4.7 --- AI/VCAI/VCAI.cpp | 3 +-- Global.h | 11 +++-------- client/NetPacksClient.cpp | 1 - lib/rmg/CRmgTemplateZone.cpp | 4 ++-- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 06e8d5567..b2df6f015 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -1213,7 +1213,6 @@ std::vector VCAI::getPossibleDestinations(HeroPtr h) std::vector possibleDestinations; for(const CGObjectInstance *obj : visitableObjs) { - const int3 pos = obj->visitablePos(); if (isGoodForVisit(obj, h)) { possibleDestinations.push_back(obj); @@ -1305,7 +1304,7 @@ void VCAI::wander(HeroPtr h) if(townsReachable.size()) { boost::sort(townsReachable, compareReinforcements); - dests.emplace_back(townsReachable.back()); + dests.push_back(townsReachable.back()); } else if(townsNotReachable.size()) { diff --git a/Global.h b/Global.h index 601517f1d..3802796ef 100644 --- a/Global.h +++ b/Global.h @@ -24,12 +24,12 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); # define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__) #endif -#if !defined(__clang__) && defined(__GNUC__) && (GCC_VERSION < 460) -# error VCMI requires at least gcc-4.6 for successful compilation or clang-3.1. Please update your compiler +#if !defined(__clang__) && defined(__GNUC__) && (GCC_VERSION < 470) +# error VCMI requires at least gcc-4.7.2 for successful compilation or clang-3.1. Please update your compiler #endif #if defined(__GNUC__) && (GCC_VERSION == 470 || GCC_VERSION == 471) -# error This GCC version has buggy std::array::at version and should not be used. Please update to 4.7.2 or use 4.6.x. +# error This GCC version has buggy std::array::at version and should not be used. Please update to 4.7.2 or later #endif /* ---------------------------------------------------------------------------- */ @@ -42,11 +42,6 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); # define CPP11_USE_INITIALIZERS_LIST #endif -//override keyword - not present in gcc-4.6 -#if !defined(_MSC_VER) && !defined(__clang__) && !(defined(__GNUC__) && (GCC_VERSION >= 470)) -# define override -#endif - /* ---------------------------------------------------------------------------- */ /* Suppress some compiler warnings */ /* ---------------------------------------------------------------------------- */ diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 48a27020c..6c928f893 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -332,7 +332,6 @@ void RemoveObject::applyFirstCl( CClient *cl ) CGI->mh->hideObject(o); - int3 pos = o->visitablePos(); //notify interfaces about removal for(auto i=cl->playerint.begin(); i!=cl->playerint.end(); i++) { diff --git a/lib/rmg/CRmgTemplateZone.cpp b/lib/rmg/CRmgTemplateZone.cpp index 012a291b0..8a1a9db54 100644 --- a/lib/rmg/CRmgTemplateZone.cpp +++ b/lib/rmg/CRmgTemplateZone.cpp @@ -515,8 +515,8 @@ void CRmgTemplateZone::placeObject(CMapGenerator* gen, CGObjectInstance* object, auto points = object->getBlockedPos(); if (object->isVisitable()) - points.emplace(pos + object->getVisitableOffset()); - points.emplace(pos); + points.insert(pos + object->getVisitableOffset()); + points.insert(pos); for(auto const &p : points) { if (tileinfo.find(pos + p) != tileinfo.end()) From 40ab89e179d36a9c2c8f82ce750acb47893fd02f Mon Sep 17 00:00:00 2001 From: beegee1 Date: Thu, 29 May 2014 17:07:21 +0200 Subject: [PATCH 2/3] - copy of campaign heroes can be done later (at the point where it's clear if they will be replaced) --- lib/CGameState.cpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 3e9165e0d..cd94b763d 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -1268,21 +1268,6 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar } } - // Now we need to perform deep copies of all heroes - // The lambda below replaces pointer to a hero with a pointer to its deep copy. - auto replaceWithDeepCopy = [](CGHeroInstance *&hero) - { - // We cache map original hero => copy. - // We may be called multiple times with the same hero and should return a single copy. - static std::map oldToCopy; - if(!oldToCopy[hero]) - oldToCopy[hero] = CMemorySerializer::deepCopy(*hero).release(); - - hero = oldToCopy[hero]; - }; - range::for_each(crossoverHeroes.heroesFromAnyPreviousScenarios, replaceWithDeepCopy); - range::for_each(crossoverHeroes.heroesFromPreviousScenario, replaceWithDeepCopy); - return crossoverHeroes; } @@ -2808,7 +2793,7 @@ std::vector CGameState::generateCampaignHer { auto hero = *it; crossoverHeroes.removeHeroFromBothLists(hero); - campaignHeroReplacements.push_back(CampaignHeroReplacement(hero, heroPlaceholder->id)); + campaignHeroReplacements.push_back(CampaignHeroReplacement(CMemorySerializer::deepCopy(*hero).release(), heroPlaceholder->id)); } } } @@ -2843,7 +2828,8 @@ std::vector CGameState::generateCampaignHer auto heroPlaceholder = heroPlaceholders[i]; if(crossoverHeroes.heroesFromPreviousScenario.size() > i) { - campaignHeroReplacements.push_back(CampaignHeroReplacement(crossoverHeroes.heroesFromPreviousScenario[i], heroPlaceholder->id)); + auto hero = crossoverHeroes.heroesFromPreviousScenario[i]; + campaignHeroReplacements.push_back(CampaignHeroReplacement(CMemorySerializer::deepCopy(*hero).release(), heroPlaceholder->id)); } } From 72b2e1b8febb1565fa19759b832a037f95e9c0f5 Mon Sep 17 00:00:00 2001 From: beegee1 Date: Thu, 29 May 2014 17:34:46 +0200 Subject: [PATCH 3/3] - fixed bug when generating random map and adding player info data --- lib/rmg/CMapGenerator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/rmg/CMapGenerator.cpp b/lib/rmg/CMapGenerator.cpp index 017aad6d9..0ea3c582f 100644 --- a/lib/rmg/CMapGenerator.cpp +++ b/lib/rmg/CMapGenerator.cpp @@ -133,7 +133,8 @@ void CMapGenerator::addPlayerInfo() { player.canHumanPlay = true; } - auto itTeam = std::next(teamNumbers[j].begin(), rand.nextInt (teamNumbers[j].size())); + + auto itTeam = RandomGeneratorUtil::nextItem(teamNumbers[j], rand); player.team = TeamID(*itTeam); teamNumbers[j].erase(itTeam); map->players[pSettings.getColor().getNum()] = player; @@ -215,4 +216,4 @@ void CMapGenerator::addHeaderInfo() std::map CMapGenerator::getZones() const { return zones; -} \ No newline at end of file +}