From e666b2740c2c641fca8192679474695ae662e090 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sun, 11 Mar 2018 18:56:33 +0300 Subject: [PATCH] Do not use CCreature in CSimpleArmy --- CCallback.cpp | 6 ------ CCallback.h | 3 --- lib/CCreatureSet.cpp | 7 ++----- lib/CCreatureSet.h | 2 +- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/CCallback.cpp b/CCallback.cpp index 8473a8806..8e25354a8 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -126,12 +126,6 @@ bool CCallback::dismissHero(const CGHeroInstance *hero) return true; } -// int CCallback::getMySerial() const -// { -// boost::shared_lock lock(*gs->mx); -// return gs->players[player].serial; -// } - bool CCallback::swapArtifacts(const ArtifactLocation &l1, const ArtifactLocation &l2) { ExchangeArtifacts ea; diff --git a/CCallback.h b/CCallback.h index a67859705..6c72ddeb6 100644 --- a/CCallback.h +++ b/CCallback.h @@ -126,10 +126,7 @@ public: int mergeStacks(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2) override; //first goes to the second int splitStack(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2, int val) override; bool dismissHero(const CGHeroInstance * hero) override; - //bool swapArtifacts(const CGHeroInstance * hero1, ui16 pos1, const CGHeroInstance * hero2, ui16 pos2); bool swapArtifacts(const ArtifactLocation &l1, const ArtifactLocation &l2) override; - //bool moveArtifact(const CGHeroInstance * hero, ui16 src, const CStackInstance * stack, ui16 dest); // TODO: unify classes - //bool moveArtifact(const CStackInstance * stack, ui16 src , const CGHeroInstance * hero, ui16 dest); // TODO: unify classes bool assembleArtifacts(const CGHeroInstance * hero, ArtifactPosition artifactSlot, bool assemble, ArtifactID assembleTo) override; bool buildBuilding(const CGTownInstance *town, BuildingID buildingID) override; void recruitCreatures(const CGDwelling * obj, const CArmedInstance * dst, CreatureID ID, ui32 amount, si32 level=-1) override; diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index 2fd029ae0..ab79edc04 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -399,10 +399,7 @@ void CCreatureSet::setToArmy(CSimpleArmy &src) { auto i = src.army.begin(); - assert(i->second.type); - assert(i->second.count); - - putStack(i->first, new CStackInstance(i->second.type, i->second.count)); + putStack(i->first, new CStackInstance(i->second.first, i->second.second)); src.army.erase(i); } } @@ -919,6 +916,6 @@ CSimpleArmy::operator bool() const bool CSimpleArmy::setCreature(SlotID slot, CreatureID cre, TQuantity count) { assert(!vstd::contains(army, slot)); - army[slot] = CStackBasicDescriptor(cre, count); + army[slot] = std::make_pair(cre, count); return true; } diff --git a/lib/CCreatureSet.h b/lib/CCreatureSet.h index 9a814b122..065e6241d 100644 --- a/lib/CCreatureSet.h +++ b/lib/CCreatureSet.h @@ -135,7 +135,7 @@ public: }; typedef std::map TSlots; -typedef std::map TSimpleSlots; +typedef std::map> TSimpleSlots; class IArmyDescriptor {