1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

* refactoring, including a generic solution for IDs

This commit is contained in:
mateuszb 2013-02-10 23:24:57 +00:00
parent 2f39db2375
commit 86dc9386d6
57 changed files with 849 additions and 662 deletions

View File

@ -1126,7 +1126,7 @@ void VCAI::performObjectInteraction(const CGObjectInstance * obj, HeroPtr h)
{
townVisitsThisWeek[h].push_back(h->visitedTown);
if (!h->hasSpellbook() && cb->getResourceAmount(Res::GOLD) >= GameConstants::SPELLBOOK_GOLD_COST + saving[Res::GOLD] &&
h->visitedTown->hasBuilt (EBuilding::MAGES_GUILD_1))
h->visitedTown->hasBuilt (BuildingID::MAGES_GUILD_1))
cb->buyArtifact(h.get(), ArtifactID::SPELLBOOK);
}
break;
@ -1243,7 +1243,7 @@ void VCAI::recruitCreatures(const CGDwelling * d)
continue;
int count = d->creatures[i].first;
CreatureID::CreatureID creID = d->creatures[i].second.back();
CreatureID creID = d->creatures[i].second.back();
// const CCreature *c = VLC->creh->creatures[creID];
// if(containsSavedRes(c->cost))
// continue;
@ -1348,20 +1348,22 @@ bool VCAI::tryBuildNextStructure(const CGTownInstance * t, std::vector<int> buil
void VCAI::buildStructure(const CGTownInstance * t)
{
using namespace EBuilding;
//TODO make *real* town development system
//TODO: faction-specific development: use special buildings, build dwellings in better order, etc
//TODO: build resource silo, defences when needed
//Possible - allow "locking" on specific building (build prerequisites and then building itself)
//Set of buildings for different goals. Does not include any prerequisites.
const int essential[] = {TAVERN, TOWN_HALL};
const int goldSource[] = {TOWN_HALL, CITY_HALL, CAPITOL};
const int essential[] = {BuildingID::TAVERN, BuildingID::TOWN_HALL};
const int goldSource[] = {BuildingID::TOWN_HALL, BuildingID::CITY_HALL, BuildingID::CAPITOL};
const int unitsSource[] = { 30, 31, 32, 33, 34, 35, 36};
const int unitsUpgrade[] = { 37, 38, 39, 40, 41, 42, 43};
const int unitGrowth[] = { FORT, CITADEL, CASTLE, HORDE_1, HORDE_1_UPGR, HORDE_2, HORDE_2_UPGR};
const int spells[] = {MAGES_GUILD_1, MAGES_GUILD_2, MAGES_GUILD_3, MAGES_GUILD_4, MAGES_GUILD_5};
const int extra[] = {RESOURCE_SILO, SPECIAL_1, SPECIAL_2, SPECIAL_3, SPECIAL_4, SHIPYARD}; // all remaining buildings
const int unitGrowth[] = { BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::HORDE_1,
BuildingID::HORDE_1_UPGR, BuildingID::HORDE_2, BuildingID::HORDE_2_UPGR};
const int spells[] = {BuildingID::MAGES_GUILD_1, BuildingID::MAGES_GUILD_2, BuildingID::MAGES_GUILD_3,
BuildingID::MAGES_GUILD_4, BuildingID::MAGES_GUILD_5};
const int extra[] = {BuildingID::RESOURCE_SILO, BuildingID::SPECIAL_1, BuildingID::SPECIAL_2, BuildingID::SPECIAL_3,
BuildingID::SPECIAL_4, BuildingID::SHIPYARD}; // all remaining buildings
TResources currentRes = cb->getResourceAmount();
TResources income = estimateIncome();
@ -2014,7 +2016,7 @@ void VCAI::tryRealize(CGoal g)
const CGTownInstance * VCAI::findTownWithTavern() const
{
BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
if(t->hasBuilt(EBuilding::TAVERN) && !t->visitingHero)
if(t->hasBuilt(BuildingID::TAVERN) && !t->visitingHero)
return t;
return NULL;
@ -2445,7 +2447,7 @@ TResources VCAI::estimateIncome() const
ret[Res::GOLD] += t->dailyIncome();
//TODO duplikuje newturn
if(t->hasBuilt(EBuilding::RESOURCE_SILO)) //there is resource silo
if(t->hasBuilt(BuildingID::RESOURCE_SILO)) //there is resource silo
{
if(t->town->primaryRes == 127) //we'll give wood and ore
{
@ -2779,10 +2781,10 @@ TSubgoal CGoal::whatToDoToAchieve()
if(auto h = ai->getHeroWithGrail())
{
//hero is in a town that can host Grail
if(h->visitedTown && !vstd::contains(h->visitedTown->forbiddenBuildings, EBuilding::GRAIL))
if(h->visitedTown && !vstd::contains(h->visitedTown->forbiddenBuildings, BuildingID::GRAIL))
{
const CGTownInstance *t = h->visitedTown;
return CGoal(BUILD_STRUCTURE).setbid(EBuilding::GRAIL).settown(t);
return CGoal(BUILD_STRUCTURE).setbid(BuildingID::GRAIL).settown(t);
}
else
{
@ -2790,7 +2792,7 @@ TSubgoal CGoal::whatToDoToAchieve()
towns.erase(boost::remove_if(towns,
[](const CGTownInstance *t) -> bool
{
return vstd::contains(t->forbiddenBuildings, EBuilding::GRAIL);
return vstd::contains(t->forbiddenBuildings, BuildingID::GRAIL);
}),
towns.end());
boost::sort(towns, isCloser);
@ -2951,7 +2953,7 @@ TSubgoal CGoal::whatToDoToAchieve()
{
if (vstd::contains(ai->alreadyVisited, obj))
return true;
switch (obj->ID)
switch (obj->ID.num)
{
case Obj::REDWOOD_OBSERVATORY:
case Obj::PILLAR_OF_FIRE:
@ -2997,7 +2999,7 @@ TSubgoal CGoal::whatToDoToAchieve()
{
erase_if (objs, [&](const CGObjectInstance *obj) -> bool
{
switch (obj->ID)
switch (obj->ID.num)
{
case Obj::CARTOGRAPHER:
case Obj::SUBTERRANEAN_GATE:
@ -3061,7 +3063,7 @@ TSubgoal CGoal::whatToDoToAchieve()
{
const CGTownInstance *t = ai->findTownWithTavern();
if(!t)
return CGoal(BUILD_STRUCTURE).setbid(EBuilding::TAVERN);
return CGoal(BUILD_STRUCTURE).setbid(BuildingID::TAVERN);
if(cb->getResourceAmount(Res::GOLD) < HERO_GOLD_COST)
return CGoal(COLLECT_RES).setresID(Res::GOLD).setvalue(HERO_GOLD_COST);
@ -3162,8 +3164,8 @@ TSubgoal CGoal::whatToDoToAchieve()
{
BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
{
if(cb->canBuildStructure(t, EBuilding::MARKETPLACE) == EBuildingState::ALLOWED)
return CGoal(BUILD_STRUCTURE).settown(t).setbid(EBuilding::MARKETPLACE);
if(cb->canBuildStructure(t, BuildingID::MARKETPLACE) == EBuildingState::ALLOWED)
return CGoal(BUILD_STRUCTURE).settown(t).setbid(BuildingID::MARKETPLACE);
}
}
else
@ -3202,7 +3204,7 @@ TSubgoal CGoal::whatToDoToAchieve()
auto creatures = t->town->creatures[creature->level];
int upgradeNumber = std::find(creatures.begin(), creatures.end(), creature->idNumber) - creatures.begin();
int bid = EBuilding::DWELL_FIRST + creature->level + upgradeNumber * GameConstants::CREATURES_PER_TOWN;
int bid = BuildingID::DWELL_FIRST + creature->level + upgradeNumber * GameConstants::CREATURES_PER_TOWN;
if (t->hasBuilt(bid)) //this assumes only creatures with dwellings are assigned to faction
{
dwellings.push_back(t);
@ -3758,7 +3760,7 @@ int3 SectorMap::firstTileToGet(HeroPtr h, crint3 dst)
std::vector<const IShipyard *> shipyards;
BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
{
if(t->hasBuilt(EBuilding::SHIPYARD))
if(t->hasBuilt(BuildingID::SHIPYARD))
shipyards.push_back(t);
}

View File

@ -69,7 +69,7 @@ int CCallback::selectionMade(int selection, int queryID)
return sendRequest(&pack);
}
void CCallback::recruitCreatures(const CGObjectInstance *obj, CreatureID::CreatureID ID, ui32 amount, si32 level/*=-1*/)
void CCallback::recruitCreatures(const CGObjectInstance *obj, CreatureID ID, ui32 amount, si32 level/*=-1*/)
{
if(player!=obj->tempOwner && obj->ID != Obj::WAR_MACHINE_FACTORY)
return;
@ -88,7 +88,7 @@ bool CCallback::dismissCreature(const CArmedInstance *obj, int stackPos)
return true;
}
bool CCallback::upgradeCreature(const CArmedInstance *obj, int stackPos, CreatureID::CreatureID newID)
bool CCallback::upgradeCreature(const CArmedInstance *obj, int stackPos, CreatureID newID)
{
UpgradeCreature pack(stackPos,obj->id,newID);
sendRequest(&pack);
@ -205,7 +205,7 @@ void CCallback::swapGarrisonHero( const CGTownInstance *town )
sendRequest(&pack);
}
void CCallback::buyArtifact(const CGHeroInstance *hero, ArtifactID::ArtifactID aid)
void CCallback::buyArtifact(const CGHeroInstance *hero, ArtifactID aid)
{
if(hero->tempOwner != player) return;
@ -329,7 +329,7 @@ void CCallback::dig( const CGObjectInstance *hero )
sendRequest(&dwh);
}
void CCallback::castSpell(const CGHeroInstance *hero, int spellID, const int3 &pos)
void CCallback::castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos)
{
CastAdvSpell cas;
cas.hid = hero->id;

View File

@ -45,13 +45,13 @@ public:
virtual bool moveHero(const CGHeroInstance *h, int3 dst) =0; //dst must be free, neighbouring tile (this function can move hero only by one tile)
virtual bool dismissHero(const CGHeroInstance * hero)=0; //dismisses given hero; true - successfuly, false - not successfuly
virtual void dig(const CGObjectInstance *hero)=0;
virtual void castSpell(const CGHeroInstance *hero, int spellID, const int3 &pos = int3(-1, -1, -1))=0; //cast adventure map spell
virtual void castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos = int3(-1, -1, -1))=0; //cast adventure map spell
//town
virtual void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero)=0;
virtual bool buildBuilding(const CGTownInstance *town, si32 buildingID)=0;
virtual void recruitCreatures(const CGObjectInstance *obj, CreatureID::CreatureID ID, ui32 amount, si32 level=-1)=0;
virtual bool upgradeCreature(const CArmedInstance *obj, int stackPos, CreatureID::CreatureID newID=CreatureID::NONE)=0; //if newID==-1 then best possible upgrade will be made
virtual void recruitCreatures(const CGObjectInstance *obj, CreatureID ID, ui32 amount, si32 level=-1)=0;
virtual bool upgradeCreature(const CArmedInstance *obj, int stackPos, CreatureID newID=CreatureID::NONE)=0; //if newID==-1 then best possible upgrade will be made
virtual void swapGarrisonHero(const CGTownInstance *town)=0;
virtual void trade(const CGObjectInstance *market, EMarketMode::EMarketMode mode, int id1, int id2, int val1, const CGHeroInstance *hero = NULL)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce
@ -66,7 +66,7 @@ public:
virtual bool assembleArtifacts(const CGHeroInstance * hero, ArtifactPosition::ArtifactPosition artifactSlot, bool assemble, ui32 assembleTo)=0;
virtual bool dismissCreature(const CArmedInstance *obj, int stackPos)=0;
virtual void endTurn()=0;
virtual void buyArtifact(const CGHeroInstance *hero, ArtifactID::ArtifactID aid)=0; //used to buy artifacts in towns (including spell book in the guild and war machines in blacksmith)
virtual void buyArtifact(const CGHeroInstance *hero, ArtifactID aid)=0; //used to buy artifacts in towns (including spell book in the guild and war machines in blacksmith)
virtual void setFormation(const CGHeroInstance * hero, bool tight)=0;
virtual void setSelection(const CArmedInstance * obj)=0;
@ -128,12 +128,12 @@ public:
//bool moveArtifact(const CStackInstance * stack, ui16 src , const CGHeroInstance * hero, ui16 dest); // TODO: unify classes
bool assembleArtifacts(const CGHeroInstance * hero, ArtifactPosition::ArtifactPosition artifactSlot, bool assemble, ui32 assembleTo);
bool buildBuilding(const CGTownInstance *town, si32 buildingID);
void recruitCreatures(const CGObjectInstance *obj, CreatureID::CreatureID ID, ui32 amount, si32 level=-1);
void recruitCreatures(const CGObjectInstance *obj, CreatureID ID, ui32 amount, si32 level=-1);
bool dismissCreature(const CArmedInstance *obj, int stackPos);
bool upgradeCreature(const CArmedInstance *obj, int stackPos, CreatureID::CreatureID newID=CreatureID::NONE) OVERRIDE;
bool upgradeCreature(const CArmedInstance *obj, int stackPos, CreatureID newID=CreatureID::NONE) OVERRIDE;
void endTurn();
void swapGarrisonHero(const CGTownInstance *town);
void buyArtifact(const CGHeroInstance *hero, ArtifactID::ArtifactID aid) OVERRIDE;
void buyArtifact(const CGHeroInstance *hero, ArtifactID aid) OVERRIDE;
void trade(const CGObjectInstance *market, EMarketMode::EMarketMode mode, int id1, int id2, int val1, const CGHeroInstance *hero = NULL);
void setFormation(const CGHeroInstance * hero, bool tight);
void setSelection(const CArmedInstance * obj);
@ -142,7 +142,7 @@ public:
void sendMessage(const std::string &mess);
void buildBoat(const IShipyard *obj);
void dig(const CGObjectInstance *hero);
void castSpell(const CGHeroInstance *hero, int spellID, const int3 &pos = int3(-1, -1, -1));
void castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos = int3(-1, -1, -1));
//friends
friend class CClient;

View File

@ -1615,12 +1615,12 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
switch(sc->id)
{
case Spells::MAGIC_ARROW:
case SpellID::MAGIC_ARROW:
{
//initialization of anims
anims.push_back("C20SPX0.DEF"); anims.push_back("C20SPX1.DEF"); anims.push_back("C20SPX2.DEF"); anims.push_back("C20SPX3.DEF"); anims.push_back("C20SPX4.DEF");
}
case Spells::ICE_BOLT:
case SpellID::ICE_BOLT:
{
if(anims.size() == 0) //initialization of anims
{
@ -1669,33 +1669,33 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
break; //for 15 and 16 cases
}
case Spells::LIGHTNING_BOLT:
case Spells::TITANS_LIGHTNING_BOLT:
case Spells::THUNDERBOLT:
case Spells::CHAIN_LIGHTNING: //TODO: zigzag effect
case SpellID::LIGHTNING_BOLT:
case SpellID::TITANS_LIGHTNING_BOLT:
case SpellID::THUNDERBOLT:
case SpellID::CHAIN_LIGHTNING: //TODO: zigzag effect
for (auto it = sc->affectedCres.begin(); it != sc->affectedCres.end(); ++it) //in case we have multiple targets
{
displayEffect(1, curInt->cb->battleGetStackByID(*it, false)->position);
displayEffect(spell.mainEffectAnim, curInt->cb->battleGetStackByID(*it, false)->position);
}
break;
case Spells::DISPEL:
case Spells::CURE:
case Spells::RESURRECTION:
case Spells::ANIMATE_DEAD:
case Spells::DISPEL_HELPFUL_SPELLS:
case Spells::SACRIFICE: //TODO: animation upon killed stack
case SpellID::DISPEL:
case SpellID::CURE:
case SpellID::RESURRECTION:
case SpellID::ANIMATE_DEAD:
case SpellID::DISPEL_HELPFUL_SPELLS:
case SpellID::SACRIFICE: //TODO: animation upon killed stack
for(std::set<ui32>::const_iterator it = sc->affectedCres.begin(); it != sc->affectedCres.end(); ++it)
{
displayEffect(spell.mainEffectAnim, curInt->cb->battleGetStackByID(*it, false)->position);
}
break;
case Spells::SUMMON_FIRE_ELEMENTAL:
case Spells::SUMMON_EARTH_ELEMENTAL:
case Spells::SUMMON_WATER_ELEMENTAL:
case Spells::SUMMON_AIR_ELEMENTAL:
case Spells::CLONE:
case Spells::REMOVE_OBSTACLE:
case SpellID::SUMMON_FIRE_ELEMENTAL:
case SpellID::SUMMON_EARTH_ELEMENTAL:
case SpellID::SUMMON_WATER_ELEMENTAL:
case SpellID::SUMMON_AIR_ELEMENTAL:
case SpellID::CLONE:
case SpellID::REMOVE_OBSTACLE:
addNewAnim(new CDummyAnimation(this, 2)); //interface won't return until animation is played. TODO: make it smarter?
break;
} //switch(sc->id)
@ -1724,32 +1724,32 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
{
switch(sc->id)
{
case Spells::STONE_GAZE:
case SpellID::STONE_GAZE:
customSpell = true;
plural = true;
textID = 558;
break;
case Spells::POISON:
case SpellID::POISON:
customSpell = true;
plural = true;
textID = 561;
break;
case Spells::BIND:
case SpellID::BIND:
customSpell = true;
text = CGI->generaltexth->allTexts[560];
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin(), false)->getCreature()->namePl );
break; //Roots and vines bind the %s to the ground!
case Spells::DISEASE:
case SpellID::DISEASE:
customSpell = true;
plural = true;
textID = 553;
break;
case Spells::PARALYZE:
case SpellID::PARALYZE:
customSpell = true;
plural = true;
textID = 563;
break;
case Spells::AGE:
case SpellID::AGE:
{
customSpell = true;
if (curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->count > 1)
@ -1768,7 +1768,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(bl->totalValue()/2));
}
break;
case Spells::THUNDERBOLT:
case SpellID::THUNDERBOLT:
text = CGI->generaltexth->allTexts[367];
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->type->namePl);
console->addText(text);
@ -1778,12 +1778,12 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
customSpell = true;
text = ""; //yeah, it's a terrible mess
break;
case Spells::DISPEL_HELPFUL_SPELLS:
case SpellID::DISPEL_HELPFUL_SPELLS:
text = CGI->generaltexth->allTexts[555];
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->type->namePl);
customSpell = true;
break;
case Spells::DEATH_STARE:
case SpellID::DEATH_STARE:
customSpell = true;
if (sc->dmgToDisplay)
{
@ -1942,7 +1942,7 @@ void CBattleInterface::castThisSpell(int spellID)
spellSelMode = ANY_LOCATION;
}
if(spellID == Spells::FIRE_WALL || spellID == Spells::FORCE_FIELD)
if(spellID == SpellID::FIRE_WALL || spellID == SpellID::FORCE_FIELD)
{
spellSelMode = FREE_LOCATION;
}
@ -2126,7 +2126,7 @@ void CBattleInterface::getPossibleActionsForStack(const CStack * stack)
{
switch (spellBonus->subtype)
{
case Spells::REMOVE_OBSTACLE:
case SpellID::REMOVE_OBSTACLE:
possibleActions.push_back (OBSTACLE);
break;
default:
@ -2897,7 +2897,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
{
ui8 skill = 0;
if (creatureCasting)
skill = sactive->valOfBonuses(Selector::typeSubtype(Bonus::SPELLCASTER, Spells::TELEPORT));
skill = sactive->valOfBonuses(Selector::typeSubtype(Bonus::SPELLCASTER, SpellID::TELEPORT));
else
skill = getActiveHero()->getSpellSchoolLevel (CGI->spellh->spells[spellToCast->additionalInfo]);
//TODO: explicitely save power, skill
@ -3060,8 +3060,8 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[27]) % sp->name % shere->getName()); //Cast %s on %s
switch (sp->id)
{
case Spells::SACRIFICE:
case Spells::TELEPORT:
case SpellID::SACRIFICE:
case SpellID::TELEPORT:
selectedStack = shere; //remember firts target
secondaryTarget = true;
break;
@ -3177,13 +3177,13 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
if (secondaryTarget) //select that target now
{
possibleActions.clear();
switch (sp->id)
switch (sp->id.toEnum())
{
case Spells::TELEPORT: //don't cast spell yet, only select target
case SpellID::TELEPORT: //don't cast spell yet, only select target
possibleActions.push_back (TELEPORT);
spellToCast->selectedStack = selectedStack->ID;
break;
case Spells::SACRIFICE:
case SpellID::SACRIFICE:
possibleActions.push_back (SACRIFICE);
break;
}
@ -3204,9 +3204,9 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
else
{
assert (sp);
switch (sp->id)
switch (sp->id.toEnum())
{
case Spells::SACRIFICE:
case SpellID::SACRIFICE:
spellToCast->destinationTile = selectedStack->position; //cast on first creature that will be resurrected
break;
default:

View File

@ -799,7 +799,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
{
//find first town with tavern
auto itr = range::find_if(LOCPLINT->towns, boost::bind(&CGTownInstance::hasBuilt, _1, EBuilding::TAVERN));
auto itr = range::find_if(LOCPLINT->towns, boost::bind(&CGTownInstance::hasBuilt, _1, BuildingID::TAVERN));
if(itr != LOCPLINT->towns.end())
LOCPLINT->showThievesGuildWindow(*itr);
else
@ -877,7 +877,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
const CGTownInstance *townWithMarket = NULL;
BOOST_FOREACH(const CGTownInstance *t, LOCPLINT->cb->getTownsInfo())
{
if(t->hasBuilt(EBuilding::MARKETPLACE))
if(t->hasBuilt(BuildingID::MARKETPLACE))
{
townWithMarket = t;
break;
@ -1140,11 +1140,11 @@ void CAdvMapInt::tileLClicked(const int3 &mapPos)
switch(spellBeingCasted->id)
{
case Spells::SCUTTLE_BOAT: //Scuttle Boat
case SpellID::SCUTTLE_BOAT: //Scuttle Boat
if(topBlocking && topBlocking->ID == Obj::BOAT)
leaveCastingMode(true, mapPos);
break;
case Spells::DIMENSION_DOOR:
case SpellID::DIMENSION_DOOR:
if(!tile || tile->isClear(heroTile))
leaveCastingMode(true, mapPos);
break;
@ -1244,13 +1244,13 @@ void CAdvMapInt::tileHovered(const int3 &mapPos)
{
switch(spellBeingCasted->id)
{
case Spells::SCUTTLE_BOAT:
case SpellID::SCUTTLE_BOAT:
if(objAtTile && objAtTile->ID == Obj::BOAT)
CCS->curh->changeGraphic(ECursor::ADVENTURE, 42);
else
CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
return;
case Spells::DIMENSION_DOOR:
case SpellID::DIMENSION_DOOR:
{
const TerrainTile *t = LOCPLINT->cb->getTile(mapPos, false);
int3 hpos = selection->getSightCenter();
@ -1436,8 +1436,7 @@ void CAdvMapInt::tileRClicked(const int3 &mapPos)
void CAdvMapInt::enterCastingMode(const CSpell * sp)
{
using namespace Spells;
assert(sp->id == SCUTTLE_BOAT || sp->id == DIMENSION_DOOR);
assert(sp->id == SpellID::SCUTTLE_BOAT || sp->id == SpellID::DIMENSION_DOOR);
spellBeingCasted = sp;
deactivate();
@ -1448,7 +1447,7 @@ void CAdvMapInt::enterCastingMode(const CSpell * sp)
void CAdvMapInt::leaveCastingMode(bool cast /*= false*/, int3 dest /*= int3(-1, -1, -1)*/)
{
assert(spellBeingCasted);
int id = spellBeingCasted->id;
SpellID id = spellBeingCasted->id;
spellBeingCasted = NULL;
terrain.deactivate();
activate();

View File

@ -107,14 +107,14 @@ void CBuildingRect::clickRight(tribool down, bool previousState)
{
int bid = str->building->bid;
const CBuilding *bld = town->town->buildings[bid];
if (bid < EBuilding::DWELL_FIRST)
if (bid < BuildingID::DWELL_FIRST)
{
CRClickPopup::createAndPush(CInfoWindow::genText(bld->Name(), bld->Description()),
new CComponent(CComponent::building, bld->tid, bld->bid));
}
else
{
int level = ( bid - EBuilding::DWELL_FIRST ) % GameConstants::CREATURES_PER_TOWN;
int level = ( bid - BuildingID::DWELL_FIRST ) % GameConstants::CREATURES_PER_TOWN;
GH.pushInt(new CDwellingInfoBox(parent->pos.x+parent->pos.w/2, parent->pos.y+parent->pos.h/2, town, level));
}
}
@ -471,13 +471,13 @@ void CCastleBuildings::recreate()
auto buildingsCopy = town->builtBuildings;// a bit modified copy of built buildings
if(vstd::contains(town->builtBuildings, EBuilding::SHIPYARD))
if(vstd::contains(town->builtBuildings, BuildingID::SHIPYARD))
{
std::vector <const CGObjectInstance *> vobjs = LOCPLINT->cb->getVisitableObjs(town->bestLocation());
//there is visitable obj at shipyard output tile and it's a boat or hero (on boat)
if(!vobjs.empty() && (vobjs.front()->ID == Obj::BOAT || vobjs.front()->ID == Obj::HERO))
{
buildingsCopy.insert(EBuilding::SHIP);
buildingsCopy.insert(BuildingID::SHIP);
}
}
@ -573,52 +573,52 @@ void CCastleBuildings::buildingClicked(int building)
tlog5<<"You've clicked on "<<building<<std::endl;
const CBuilding *b = town->town->buildings.find(building)->second;
if(building >= EBuilding::DWELL_FIRST)
if(building >= BuildingID::DWELL_FIRST)
{
enterDwelling((building-EBuilding::DWELL_FIRST)%GameConstants::CREATURES_PER_TOWN);
enterDwelling((building-BuildingID::DWELL_FIRST)%GameConstants::CREATURES_PER_TOWN);
}
else
{
switch(building)
{
case EBuilding::MAGES_GUILD_1:
case EBuilding::MAGES_GUILD_2:
case EBuilding::MAGES_GUILD_3:
case EBuilding::MAGES_GUILD_4:
case EBuilding::MAGES_GUILD_5:
case BuildingID::MAGES_GUILD_1:
case BuildingID::MAGES_GUILD_2:
case BuildingID::MAGES_GUILD_3:
case BuildingID::MAGES_GUILD_4:
case BuildingID::MAGES_GUILD_5:
enterMagesGuild();
break;
case EBuilding::TAVERN:
case BuildingID::TAVERN:
LOCPLINT->showTavernWindow(town);
break;
case EBuilding::SHIPYARD:
case BuildingID::SHIPYARD:
LOCPLINT->showShipyardDialog(town);
break;
case EBuilding::FORT:
case EBuilding::CITADEL:
case EBuilding::CASTLE:
case BuildingID::FORT:
case BuildingID::CITADEL:
case BuildingID::CASTLE:
GH.pushInt(new CFortScreen(town));
break;
case EBuilding::VILLAGE_HALL:
case EBuilding::CITY_HALL:
case EBuilding::TOWN_HALL:
case EBuilding::CAPITOL:
case BuildingID::VILLAGE_HALL:
case BuildingID::CITY_HALL:
case BuildingID::TOWN_HALL:
case BuildingID::CAPITOL:
enterTownHall();
break;
case EBuilding::MARKETPLACE:
case BuildingID::MARKETPLACE:
GH.pushInt(new CMarketplaceWindow(town, town->visitingHero));
break;
case EBuilding::BLACKSMITH:
case BuildingID::BLACKSMITH:
enterBlacksmith(town->town->warMachine);
break;
case EBuilding::SPECIAL_1:
case BuildingID::SPECIAL_1:
switch(town->subID)
{
case ETownType::RAMPART://Mystic Pond
@ -640,11 +640,11 @@ void CCastleBuildings::buildingClicked(int building)
}
break;
case EBuilding::SHIP:
case BuildingID::SHIP:
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[51]); //Cannot build another boat
break;
case EBuilding::SPECIAL_2:
case BuildingID::SPECIAL_2:
switch(town->subID)
{
case ETownType::RAMPART: //Fountain of Fortune
@ -671,7 +671,7 @@ void CCastleBuildings::buildingClicked(int building)
}
break;
case EBuilding::SPECIAL_3:
case BuildingID::SPECIAL_3:
switch(town->subID)
{
case ETownType::CASTLE: //Brotherhood of sword
@ -710,7 +710,7 @@ void CCastleBuildings::buildingClicked(int building)
}
}
void CCastleBuildings::enterBlacksmith(ArtifactID::ArtifactID artifactID)
void CCastleBuildings::enterBlacksmith(ArtifactID artifactID)
{
const CGHeroInstance *hero = town->visitingHero;
if(!hero)
@ -744,12 +744,12 @@ void CCastleBuildings::enterCastleGate()
{
const CGTownInstance *t = Towns[i];
if (t->id != this->town->id && t->visitingHero == NULL && //another town, empty and this is
t->hasBuilt(EBuilding::CASTLE_GATE, ETownType::INFERNO))
t->hasBuilt(BuildingID::CASTLE_GATE, ETownType::INFERNO))
{
availableTowns.push_back(t->id);//add to the list
}
}
CPicture *titlePic = new CPicture (LOCPLINT->castleInt->bicons->ourImages[EBuilding::CASTLE_GATE].bitmap, 0,0, false);//will be deleted by selection window
CPicture *titlePic = new CPicture (LOCPLINT->castleInt->bicons->ourImages[BuildingID::CASTLE_GATE].bitmap, 0,0, false);//will be deleted by selection window
GH.pushInt (new CObjectListWindow(availableTowns, titlePic, CGI->generaltexth->jktexts[40],
CGI->generaltexth->jktexts[41], boost::bind (&CCastleInterface::castleTeleport, LOCPLINT->castleInt, _1)));
}
@ -766,8 +766,8 @@ void CCastleBuildings::enterFountain(int building)
std::string descr = town->town->buildings.find(building)->second->Description();
if ( building == EBuilding::FOUNTAIN_OF_FORTUNE)
descr += "\n\n"+town->town->buildings.find(EBuilding::MYSTIC_POND)->second->Description();
if ( building == BuildingID::FOUNTAIN_OF_FORTUNE)
descr += "\n\n"+town->town->buildings.find(BuildingID::MYSTIC_POND)->second->Description();
if (town->bonusValue.first == 0)//fountain was builded this week
descr += "\n\n"+ CGI->generaltexth->allTexts[677];
@ -810,12 +810,12 @@ void CCastleBuildings::enterMagesGuild()
void CCastleBuildings::enterTownHall()
{
if(town->visitingHero && town->visitingHero->hasArt(2) &&
!vstd::contains(town->builtBuildings, EBuilding::GRAIL)) //hero has grail, but town does not have it
!vstd::contains(town->builtBuildings, BuildingID::GRAIL)) //hero has grail, but town does not have it
{
if(!vstd::contains(town->forbiddenBuildings, EBuilding::GRAIL))
if(!vstd::contains(town->forbiddenBuildings, BuildingID::GRAIL))
{
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[597], //Do you wish this to be the permanent home of the Grail?
boost::bind(&CCallback::buildBuilding, LOCPLINT->cb, town, EBuilding::GRAIL),
boost::bind(&CCallback::buildBuilding, LOCPLINT->cb, town, BuildingID::GRAIL),
boost::bind(&CCastleBuildings::openTownHall, this), true);
}
else
@ -1175,7 +1175,7 @@ void CCastleInterface::keyPressed( const SDL_KeyboardEvent & key )
heroes->swapArmies();
break;
case SDLK_t:
if(town->hasBuilt(EBuilding::TAVERN))
if(town->hasBuilt(BuildingID::TAVERN))
LOCPLINT->showTavernWindow(town);
break;
default:
@ -1285,7 +1285,7 @@ CHallInterface::CHallInterface(const CGTownInstance *Town):
Rect barRect(5, 556, 740, 18);
statusBar = new CGStatusBar(new CPicture(*background, barRect, 5, 556, false));
title = new CLabel(399, 12, FONT_MEDIUM, CENTER, Colors::WHITE, town->town->buildings[town->hallLevel()+EBuilding::VILLAGE_HALL]->Name());
title = new CLabel(399, 12, FONT_MEDIUM, CENTER, Colors::WHITE, town->town->buildings[town->hallLevel()+BuildingID::VILLAGE_HALL]->Name());
exit = new CAdventureMapButton(CGI->generaltexth->hcommands[8], "",
boost::bind(&CHallInterface::close,this), 748, 556, "TPMAGE1.DEF", SDLK_RETURN);
exit->assignedKeys.insert(SDLK_ESCAPE);
@ -1435,10 +1435,10 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
int buildingID;
if (fortSize == GameConstants::CREATURES_PER_TOWN)
{
if (vstd::contains(town->builtBuildings, EBuilding::DWELL_UP_FIRST+i))
buildingID = EBuilding::DWELL_UP_FIRST+i;
if (vstd::contains(town->builtBuildings, BuildingID::DWELL_UP_FIRST+i))
buildingID = BuildingID::DWELL_UP_FIRST+i;
else
buildingID = EBuilding::DWELL_FIRST+i;
buildingID = BuildingID::DWELL_FIRST+i;
}
else
buildingID = 22;
@ -1653,7 +1653,7 @@ void CMageGuildScreen::Scroll::hover(bool on)
}
CBlacksmithDialog::CBlacksmithDialog(bool possible, int creMachineID, ArtifactID::ArtifactID aid, int hid):
CBlacksmithDialog::CBlacksmithDialog(bool possible, int creMachineID, ArtifactID aid, int hid):
CWindowObject(PLAYER_COLORED, "TPSMITH")
{
OBJ_CONSTRUCTION_CAPTURING_ALL;

View File

@ -123,7 +123,7 @@ class CCastleBuildings : public CIntObject
const CGHeroInstance* getHero();//Select hero for buildings usage
void enterBlacksmith(ArtifactID::ArtifactID artifactID);//support for blacksmith + ballista yard
void enterBlacksmith(ArtifactID artifactID);//support for blacksmith + ballista yard
void enterBuilding(int building);//for buildings with simple description + pic left-click messages
void enterCastleGate();
void enterFountain(int building);//Rampart's fountains
@ -369,5 +369,5 @@ class CBlacksmithDialog : public CWindowObject
CGStatusBar *statusBar;
public:
CBlacksmithDialog(bool possible, int creMachineID, ArtifactID::ArtifactID aid, int hid);
CBlacksmithDialog(bool possible, int creMachineID, ArtifactID aid, int hid);
};

View File

@ -66,7 +66,7 @@ CCreatureWindow::CCreatureWindow (const CStackInstance &stack, CreWinType Type):
init(&stack, &stack, dynamic_cast<const CGHeroInstance*>(stack.armyObj));
}
CCreatureWindow::CCreatureWindow(CreatureID::CreatureID Cid, CreWinType Type, int creatureCount):
CCreatureWindow::CCreatureWindow(CreatureID Cid, CreWinType Type, int creatureCount):
CWindowObject(PLAYER_COLORED | (Type == OTHER ? RCLICK_POPUP : 0 ) ),
type(Type)
{
@ -903,7 +903,7 @@ CIntObject * createCreWindow(
}
}
CIntObject * createCreWindow(CreatureID::CreatureID Cid, CCreatureWindow::CreWinType Type, int creatureCount)
CIntObject * createCreWindow(CreatureID Cid, CCreatureWindow::CreWinType Type, int creatureCount)
{
if(settings["general"]["classicCreatureWindow"].Bool())
return new CCreInfoWindow(Cid, Type, creatureCount);

View File

@ -91,7 +91,7 @@ public:
CCreatureWindow(const CStackInstance &st, CreWinType Type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //full garrison window
CCreatureWindow(const CCommanderInstance * commander, const CStack * stack = NULL); //commander window
CCreatureWindow(std::vector<ui32> &skills, const CCommanderInstance * commander, boost::function<void(ui32)> callback);
CCreatureWindow(CreatureID::CreatureID Cid, CreWinType Type, int creatureCount); //c-tor
CCreatureWindow(CreatureID Cid, CreWinType Type, int creatureCount); //c-tor
void init(const CStackInstance *stack, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner);
void showAll(SDL_Surface * to);
@ -159,5 +159,5 @@ public:
};
CIntObject *createCreWindow(const CStack *s, bool lclick = false);
CIntObject *createCreWindow(CreatureID::CreatureID Cid, CCreatureWindow::CreWinType Type, int creatureCount);
CIntObject *createCreWindow(CreatureID Cid, CCreatureWindow::CreWinType Type, int creatureCount);
CIntObject *createCreWindow(const CStackInstance *s, CCreatureWindow::CreWinType type, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL);

View File

@ -1498,7 +1498,7 @@ void CPlayerInterface::newObject( const CGObjectInstance * obj )
&& obj->pos-obj->getVisitableOffset() == LOCPLINT->castleInt->town->bestLocation())
{
CCS->soundh->playSound(soundBase::newBuilding);
LOCPLINT->castleInt->addBuilding(EBuilding::SHIP);
LOCPLINT->castleInt->addBuilding(BuildingID::SHIP);
}
}
@ -2096,7 +2096,7 @@ void CPlayerInterface::showPuzzleMap()
void CPlayerInterface::advmapSpellCast(const CGHeroInstance * caster, int spellID)
{
EVENT_HANDLER_CALLED_BY_CLIENT;
if (spellID == Spells::FLY || spellID == Spells::WATER_WALK)
if (spellID == SpellID::FLY || spellID == SpellID::WATER_WALK)
{
eraseCurrentPathOf(caster, false);
}

View File

@ -82,7 +82,7 @@ CSpellWindow::CSpellWindow(const SDL_Rect &, const CGHeroInstance * _myHero, CPl
for(ui32 v=0; v<CGI->spellh->spells.size(); ++v)
{
if( !CGI->spellh->spells[v]->creatureAbility && myHero->canCastThisSpell(CGI->spellh->spells[v]) )
mySpells.insert(v);
mySpells.insert(SpellID(v));
}
//initializing sizes of spellbook's parts
@ -91,9 +91,9 @@ CSpellWindow::CSpellWindow(const SDL_Rect &, const CGHeroInstance * _myHero, CPl
for(int b=0; b<5; ++b)
sitesPerTabBattle[b] = 0;
for(std::set<ui32>::const_iterator g = mySpells.begin(); g!=mySpells.end(); ++g)
BOOST_FOREACH(auto g, mySpells)
{
const CSpell &s = *CGI->spellh->spells[*g];
const CSpell &s = *CGI->spellh->spells[g];
Uint8 *sitesPerOurTab = s.combatSpell ? sitesPerTabBattle : sitesPerTabAdv;
++sitesPerOurTab[4];
@ -386,8 +386,8 @@ public:
void CSpellWindow::computeSpellsPerArea()
{
std::vector<ui32> spellsCurSite;
for(std::set<ui32>::const_iterator it = mySpells.begin(); it != mySpells.end(); ++it)
std::vector<SpellID> spellsCurSite;
for(auto it = mySpells.cbegin(); it != mySpells.cend(); ++it)
{
if(CGI->spellh->spells[*it]->combatSpell ^ !battleSpellsOnly
&& ((CGI->spellh->spells[*it]->air && selectedTab == 0) ||
@ -405,7 +405,7 @@ void CSpellWindow::computeSpellsPerArea()
{
if(spellsCurSite.size() > 12)
{
spellsCurSite = std::vector<ui32>(spellsCurSite.begin() + currentPage*12, spellsCurSite.end());
spellsCurSite = std::vector<SpellID>(spellsCurSite.begin() + currentPage*12, spellsCurSite.end());
if(spellsCurSite.size() > 12)
{
spellsCurSite.erase(spellsCurSite.begin()+12, spellsCurSite.end());
@ -422,7 +422,7 @@ void CSpellWindow::computeSpellsPerArea()
}
else
{
spellsCurSite = std::vector<ui32>(spellsCurSite.begin() + (currentPage-1)*12 + 10, spellsCurSite.end());
spellsCurSite = std::vector<SpellID>(spellsCurSite.begin() + (currentPage-1)*12 + 10, spellsCurSite.end());
if(spellsCurSite.size() > 12)
{
spellsCurSite.erase(spellsCurSite.begin()+12, spellsCurSite.end());
@ -441,20 +441,20 @@ void CSpellWindow::computeSpellsPerArea()
}
else
{
spellAreas[c]->setSpell(-1);
spellAreas[c]->setSpell(SpellID::NONE);
}
}
}
else
{
spellAreas[0]->setSpell(-1);
spellAreas[1]->setSpell(-1);
spellAreas[0]->setSpell(SpellID::NONE);
spellAreas[1]->setSpell(SpellID::NONE);
for(size_t c=0; c<10; ++c)
{
if(c<spellsCurSite.size())
spellAreas[c+2]->setSpell(spellsCurSite[c]);
else
spellAreas[c+2]->setSpell(-1);
spellAreas[c+2]->setSpell(SpellID::NONE);
}
}
redraw();
@ -587,7 +587,7 @@ Uint8 CSpellWindow::pagesWithinCurrentTab()
void CSpellWindow::teleportTo( int town, const CGHeroInstance * hero )
{
const CGTownInstance * dest = LOCPLINT->cb->getTown(town);
LOCPLINT->cb->castSpell(hero, Spells::TOWN_PORTAL, dest->visitablePos());
LOCPLINT->cb->castSpell(hero, SpellID::TOWN_PORTAL, dest->visitablePos());
}
CSpellWindow::SpellArea::SpellArea(SDL_Rect pos, CSpellWindow * owner)
@ -596,7 +596,8 @@ CSpellWindow::SpellArea::SpellArea(SDL_Rect pos, CSpellWindow * owner)
this->owner = owner;
addUsedEvents(LCLICK | RCLICK | HOVER);
spellCost = mySpell = whichSchool = schoolLevel = -1;
spellCost = whichSchool = schoolLevel = -1;
mySpell = SpellID::NONE;
}
void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
@ -694,14 +695,13 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
}
else if(!sp->combatSpell && !owner->myInt->battleInt) //adventure spell
{
using namespace Spells;
int spell = mySpell;
SpellID spell = mySpell;
const CGHeroInstance *h = owner->myHero;
owner->fexitb();
switch(spell)
{
case SUMMON_BOAT:
case SpellID::SUMMON_BOAT:
{
int3 pos = h->bestLocation();
if(pos.x < 0)
@ -711,18 +711,18 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
}
}
break;
case SCUTTLE_BOAT:
case DIMENSION_DOOR:
case SpellID::SCUTTLE_BOAT:
case SpellID::DIMENSION_DOOR:
adventureInt->enterCastingMode(sp);
return;
case VISIONS:
case VIEW_EARTH:
case DISGUISE:
case VIEW_AIR:
case FLY:
case WATER_WALK:
case SpellID::VISIONS:
case SpellID::VIEW_EARTH:
case SpellID::DISGUISE:
case SpellID::VIEW_AIR:
case SpellID::FLY:
case SpellID::WATER_WALK:
break;
case TOWN_PORTAL:
case SpellID::TOWN_PORTAL:
{
std::vector <int> availableTowns;
std::vector <const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(true);
@ -828,7 +828,7 @@ void CSpellWindow::SpellArea::showAll(SDL_Surface * to)
if(mySpell < 0)
return;
const CSpell * spell = CGI->spellh->spells[mySpell];
const CSpell * spell = mySpell.toSpell();
blitAt(owner->spells->ourImages[mySpell].bitmap, pos.x, pos.y, to);
blitAt(owner->schoolBorders[owner->selectedTab >= 4 ? whichSchool : owner->selectedTab]->ourImages[schoolLevel].bitmap, pos.x, pos.y, to); //printing border (indicates level of magic school)
@ -855,7 +855,7 @@ void CSpellWindow::SpellArea::showAll(SDL_Surface * to)
printAtMiddleLoc(ss.str(), 39, 94, FONT_TINY, secondLineColor, to);
}
void CSpellWindow::SpellArea::setSpell(int spellID)
void CSpellWindow::SpellArea::setSpell(SpellID spellID)
{
mySpell = spellID;
if(mySpell < 0)

View File

@ -45,7 +45,7 @@ private:
class SpellArea : public CIntObject
{
public:
int mySpell;
SpellID mySpell;
int schoolLevel; //range: 0 none, 3 - expert
int whichSchool; //0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
int spellCost;
@ -53,7 +53,7 @@ private:
SpellArea(SDL_Rect pos, CSpellWindow * owner);
void setSpell(int spellID);
void setSpell(SpellID spellID);
void clickLeft(tribool down, bool previousState);
void clickRight(tribool down, bool previousState);
@ -79,7 +79,7 @@ private:
bool battleSpellsOnly; //if true, only battle spells are displayed; if false, only adventure map spells are displayed
Uint8 selectedTab; // 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
Uint8 currentPage; //changes when corners are clicked
std::set<ui32> mySpells; //all spels in this spellbook
std::set<SpellID> mySpells; //all spels in this spellbook
const CGHeroInstance * myHero; //hero whose spells are presented

View File

@ -162,7 +162,7 @@ public:
//////////////////////////////////////////////////////////////////////////
//not working yet, will be implement somewhen later with support for local-sim-based gameplay
void changeSpells(const CGHeroInstance * hero, bool give, const std::set<ui32> &spells) OVERRIDE {};
void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells) OVERRIDE {};
bool removeObject(const CGObjectInstance * obj) OVERRIDE {return false;};
void setBlockVis(int objid, bool bv) OVERRIDE {};
void setOwner(const CGObjectInstance * obj, TPlayerColor owner) OVERRIDE {};
@ -201,7 +201,7 @@ public:
void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, boost::function<void(BattleResult*)> cb = 0, bool creatureBank = false) OVERRIDE {}; //if any of armies is hero, hero will be used
void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, boost::function<void(BattleResult*)> cb = 0, bool creatureBank = false) OVERRIDE {}; //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle
void setAmount(int objid, ui32 val) OVERRIDE {};
bool moveHero(si32 hid, int3 dst, ui8 instant, ui8 asker = 255) OVERRIDE {return false;};
bool moveHero(si32 hid, int3 dst, ui8 instant, TPlayerColor asker = GameConstants::NEUTRAL_PLAYER) OVERRIDE {return false;};
void giveHeroBonus(GiveBonus * bonus) OVERRIDE {};
void setMovePoints(SetMovePoints * smp) OVERRIDE {};
void setManaPoints(int hid, int val) OVERRIDE {};

View File

@ -1467,7 +1467,7 @@ void CRecruitmentWindow::select(CCreatureCard *card)
void CRecruitmentWindow::buy()
{
CreatureID::CreatureID crid = selected->creature->idNumber;
CreatureID crid = selected->creature->idNumber;
TSlot dstslot = dst-> getSlotFor(crid);
if(dstslot < 0 && !vstd::contains(CGI->arth->bigArtifacts,CGI->arth->creatureToMachineID(crid))) //no available slot
@ -1510,7 +1510,7 @@ void CRecruitmentWindow::showAll(SDL_Surface * to)
drawBorder(to, pos.x + 289, pos.y + 312, 66, 34, int3(173,142,66));
}
CRecruitmentWindow::CRecruitmentWindow(const CGDwelling *Dwelling, int Level, const CArmedInstance *Dst, const boost::function<void(CreatureID::CreatureID,int)> &Recruit, int y_offset):
CRecruitmentWindow::CRecruitmentWindow(const CGDwelling *Dwelling, int Level, const CArmedInstance *Dst, const boost::function<void(CreatureID,int)> &Recruit, int y_offset):
CWindowObject(PLAYER_COLORED, "TPRCRT"),
onRecruit(Recruit),
level(Level),
@ -2568,14 +2568,14 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan
switch (mode)
{
break; case EMarketMode::CREATURE_RESOURCE:
title = CGI->townh->towns[ETownType::STRONGHOLD].buildings[EBuilding::FREELANCERS_GUILD]->Name();
title = CGI->townh->towns[ETownType::STRONGHOLD].buildings[BuildingID::FREELANCERS_GUILD]->Name();
break; case EMarketMode::RESOURCE_ARTIFACT:
title = CGI->townh->towns[market->o->subID].buildings[EBuilding::ARTIFACT_MERCHANT]->Name();
title = CGI->townh->towns[market->o->subID].buildings[BuildingID::ARTIFACT_MERCHANT]->Name();
sliderNeeded = false;
break; case EMarketMode::ARTIFACT_RESOURCE:
title = CGI->townh->towns[market->o->subID].buildings[EBuilding::ARTIFACT_MERCHANT]->Name();
title = CGI->townh->towns[market->o->subID].buildings[BuildingID::ARTIFACT_MERCHANT]->Name();
sliderNeeded = false;
break; default:
@ -5467,7 +5467,7 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket
CIntObject * titlePic = nullptr;
if (market->o->ID == Obj::TOWN)
titlePic = new CAnimImage(CGI->townh->towns[ETownType::CONFLUX].clientInfo.buildingsIcons, EBuilding::MAGIC_UNIVERSITY);
titlePic = new CAnimImage(CGI->townh->towns[ETownType::CONFLUX].clientInfo.buildingsIcons, BuildingID::MAGIC_UNIVERSITY);
else
titlePic = new CPicture("UNIVBLDG");

View File

@ -430,7 +430,7 @@ class CRecruitmentWindow : public CWindowObject
void createItems(TResources res);
};
boost::function<void(CreatureID::CreatureID,int)> onRecruit; //void (int ID, int amount) <-- call to recruit creatures
boost::function<void(CreatureID,int)> onRecruit; //void (int ID, int amount) <-- call to recruit creatures
int level;
const CArmedInstance *dst;
@ -454,7 +454,7 @@ class CRecruitmentWindow : public CWindowObject
void showAll(SDL_Surface *to);
public:
const CGDwelling * const dwelling;
CRecruitmentWindow(const CGDwelling *Dwelling, int Level, const CArmedInstance *Dst, const boost::function<void(CreatureID::CreatureID,int)> & Recruit, int y_offset = 0); //creatures - pairs<creature_ID,amount> //c-tor
CRecruitmentWindow(const CGDwelling *Dwelling, int Level, const CArmedInstance *Dst, const boost::function<void(CreatureID,int)> & Recruit, int y_offset = 0); //creatures - pairs<creature_ID,amount> //c-tor
void availableCreaturesChanged();
};

View File

@ -406,11 +406,11 @@ void NewStructures::applyCl( CClient *cl )
CGTownInstance *town = GS(cl)->getTown(tid);
BOOST_FOREACH(si32 id, bid)
{
if(id== EBuilding::CAPITOL) //fort or capitol
if(id== BuildingID::CAPITOL) //fort or capitol
{
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->capitols[town->subID].get());
}
if(id == EBuilding::FORT)
if(id == BuildingID::FORT)
{
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->gobjs[Obj::TOWN][town->subID].get());
}

View File

@ -36,7 +36,7 @@ const CStack * BattleInfo::getNextStack() const
return NULL;
}
int BattleInfo::getAvaliableHex(CreatureID::CreatureID creID, bool attackerOwned, int initialPos) const
int BattleInfo::getAvaliableHex(CreatureID creID, bool attackerOwned, int initialPos) const
{
bool twoHex = VLC->creh->creatures[creID]->isDoubleWide();
//bool flying = VLC->creh->creatures[creID]->isFlying();
@ -131,7 +131,7 @@ int BattleInfo::calculateSpellDuration( const CSpell * spell, const CGHeroInstan
}
switch(spell->id)
{
case Spells::FRENZY:
case SpellID::FRENZY:
return 1;
default: //other spells
return caster->getPrimSkillLevel(PrimarySkill::SPELL_POWER) + caster->valOfBonuses(Bonus::SPELL_DURATION);
@ -166,7 +166,7 @@ ui32 BattleInfo::calculateHealedHP(const CGHeroInstance * caster, const CSpell *
{
bool resurrect = resurrects(spell->id);
int healedHealth;
if (spell->id == Spells::SACRIFICE && sacrificedStack)
if (spell->id == SpellID::SACRIFICE && sacrificedStack)
healedHealth = (caster->getPrimSkillLevel(PrimarySkill::SPELL_POWER) + sacrificedStack->MaxHealth() + spell->powers[caster->getSpellSchoolLevel(spell)]) * sacrificedStack->count;
else
healedHealth = caster->getPrimSkillLevel(PrimarySkill::SPELL_POWER) * spell->power + spell->powers[caster->getSpellSchoolLevel(spell)];
@ -186,7 +186,7 @@ ui32 BattleInfo::calculateHealedHP(const CSpell * spell, int usedSpellPower, int
int healedHealth = usedSpellPower * spell->power + spell->powers[spellSchoolLevel];
return std::min<ui32>(healedHealth, stack->MaxHealth() - stack->firstHPleft + (resurrect ? stack->baseAmount * stack->MaxHealth() : 0));
}
bool BattleInfo::resurrects(TSpell spellid) const
bool BattleInfo::resurrects(SpellID spellid) const
{
return VLC->spellh->spells[spellid]->isRisingSpell();
}
@ -512,7 +512,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType::ETerrainType terr
if(!creatureBank)
{
//Checks if hero has artifact and create appropriate stack
auto handleWarMachine= [&](int side, ArtifactPosition::ArtifactPosition artslot, CreatureID::CreatureID cretype, BattleHex hex)
auto handleWarMachine= [&](int side, ArtifactPosition::ArtifactPosition artslot, CreatureID cretype, BattleHex hex)
{
if(heroes[side] && heroes[side]->getArt(artslot))
stacks.push_back(curB->generateNewStack(CStackBasicDescriptor(cretype, 1), !side, 255, hex));
@ -748,7 +748,7 @@ std::vector<ui32> BattleInfo::calculateResistedStacks(const CSpell * sp, const C
}
if(sp->id == Spells::HYPNOTIZE) //hypnotize
if(sp->id == SpellID::HYPNOTIZE) //hypnotize
{
for(auto it = affectedCreatures.begin(); it != affectedCreatures.end(); ++it)
{
@ -908,7 +908,7 @@ ui32 CStack::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const
speed = ((100 + percentBonus) * speed)/100;
//bind effect check - doesn't influence stack initiative
if (useBind && getEffect (Spells::BIND))
if (useBind && getEffect (SpellID::BIND))
{
return 0;
}

View File

@ -90,7 +90,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
//void getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set<BattleHex> & occupyable, bool flying, const CStack* stackToOmmit = NULL) const; //send pointer to at least 187 allocated bytes
//static bool isAccessible(BattleHex hex, bool * accessibility, bool twoHex, bool attackerOwned, bool flying, bool lastPos); //helper for makeBFS
int getAvaliableHex(CreatureID::CreatureID creID, bool attackerOwned, int initialPos = -1) const; //find place for summon / clone effects
int getAvaliableHex(CreatureID creID, bool attackerOwned, int initialPos = -1) const; //find place for summon / clone effects
//void makeBFS(BattleHex start, bool*accessibility, BattleHex *predecessor, int *dists, bool twoHex, bool attackerOwned, bool flying, bool fillPredecessors) const; //*accessibility must be prepared bool[187] array; last two pointers must point to the at least 187-elements int arrays - there is written result
std::pair< std::vector<BattleHex>, int > getPath(BattleHex start, BattleHex dest, const CStack *stack); //returned value: pair<path, length>; length may be different than number of elements in path since flying vreatures jump between distant hexes
//std::vector<BattleHex> getAccessibility(const CStack * stack, bool addOccupiable, std::vector<BattleHex> * attackable = NULL, bool forPassingBy = false) const; //returns vector of accessible tiles (taking into account the creature range)
@ -113,7 +113,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
ui32 calculateHealedHP(const CGHeroInstance * caster, const CSpell * spell, const CStack * stack, const CStack * sacrificedStack = NULL) const; //Sacrifice
ui32 calculateHealedHP(int healedHealth, const CSpell * spell, const CStack * stack) const; //for Archangel
ui32 calculateHealedHP(const CSpell * spell, int usedSpellPower, int spellSchoolLevel, const CStack * stack) const; //healing spells casted by stacks
bool resurrects(TSpell spellid) const; //TODO: move it to spellHandler?
bool resurrects(SpellID spellid) const; //TODO: move it to spellHandler?
const CGHeroInstance * getHero(TPlayerColor player) const; //returns fighting hero that belongs to given player

View File

@ -271,7 +271,7 @@ CArtHandler::CArtHandler()
//VLC->arth = this;
// War machines are the default big artifacts.
for (ArtifactID::ArtifactID i = ArtifactID::CATAPULT; i <= ArtifactID::FIRST_AID_TENT; vstd::advance(i, 1))
for (ArtifactID i = ArtifactID::CATAPULT; i <= ArtifactID::FIRST_AID_TENT; i.advance(1))
bigArtifacts.insert(i);
}
@ -302,7 +302,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
std::map<ui32,ui8>::iterator itr;
for (ArtifactID::ArtifactID i=static_cast<ArtifactID::ArtifactID>(0); i<GameConstants::ARTIFACTS_QUANTITY; vstd::advance(i, 1))
for (ArtifactID i=ArtifactID(0); i<GameConstants::ARTIFACTS_QUANTITY; i.advance(1))
{
CArtifact *art;
if (vstd::contains (growingArtifacts, i))
@ -371,7 +371,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
BOOST_FOREACH(ui32 constituentID, *artifact->constituents)
{
if (artifacts[constituentID]->constituentOf == NULL)
artifacts[constituentID]->constituentOf = new std::vector<ArtifactID::ArtifactID>();
artifacts[constituentID]->constituentOf = new std::vector<ArtifactID>();
artifacts[constituentID]->constituentOf->push_back(artifact->id);
}
}
@ -385,7 +385,7 @@ void CArtHandler::load(const JsonNode & node)
if (!entry.second.isNull()) // may happens if mod removed creature by setting json entry to null
{
CArtifact * art = loadArtifact(entry.second);
art->id = static_cast<ArtifactID::ArtifactID>(artifacts.size());
art->id = ArtifactID(artifacts.size());
artifacts.push_back(art);
tlog5 << "Added artifact: " << entry.first << "\n";
@ -495,13 +495,13 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
return art;
}
void CArtifact::addConstituent (ArtifactID::ArtifactID component)
void CArtifact::addConstituent (ArtifactID component)
{
assert (constituents);
constituents->push_back (component);
}
ArtifactID::ArtifactID CArtHandler::creatureToMachineID(CreatureID::CreatureID id)
ArtifactID CArtHandler::creatureToMachineID(CreatureID id)
{
int dif = 142;
switch (id)
@ -514,10 +514,10 @@ ArtifactID::ArtifactID CArtHandler::creatureToMachineID(CreatureID::CreatureID i
break;
}
dif = -dif;
return static_cast<ArtifactID::ArtifactID>(id+dif);
return ArtifactID(id+dif);
}
CreatureID::CreatureID CArtHandler::machineIDToCreature(ArtifactID::ArtifactID id)
CreatureID CArtHandler::machineIDToCreature(ArtifactID id)
{
int dif = 142;
@ -530,7 +530,7 @@ CreatureID::CreatureID CArtHandler::machineIDToCreature(ArtifactID::ArtifactID i
dif++;
break;
}
return static_cast<CreatureID::CreatureID>(id + dif);
return CreatureID(id + dif);
}
void CArtHandler::sortArts()
@ -651,17 +651,17 @@ Bonus *createBonus(Bonus::BonusType type, int val, int subtype, shared_ptr<IProp
return added;
}
void CArtHandler::giveArtBonus( ArtifactID::ArtifactID aid, Bonus::BonusType type, int val, int subtype, Bonus::ValueType valType, shared_ptr<ILimiter> limiter, int additionalInfo)
void CArtHandler::giveArtBonus( ArtifactID aid, Bonus::BonusType type, int val, int subtype, Bonus::ValueType valType, shared_ptr<ILimiter> limiter, int additionalInfo)
{
giveArtBonus(aid, createBonus(type, val, subtype, valType, limiter, additionalInfo));
}
void CArtHandler::giveArtBonus(ArtifactID::ArtifactID aid, Bonus::BonusType type, int val, int subtype, shared_ptr<IPropagator> propagator /*= NULL*/, int additionalInfo)
void CArtHandler::giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype, shared_ptr<IPropagator> propagator /*= NULL*/, int additionalInfo)
{
giveArtBonus(aid, createBonus(type, val, subtype, propagator, additionalInfo));
}
void CArtHandler::giveArtBonus(ArtifactID::ArtifactID aid, Bonus *bonus)
void CArtHandler::giveArtBonus(ArtifactID aid, Bonus *bonus)
{
bonus->sid = aid;
if(bonus->subtype == Bonus::MORALE || bonus->type == Bonus::LUCK)
@ -750,13 +750,13 @@ void CArtHandler::readComponents (const JsonNode & node, CArtifact * art)
value = &node["components"];
if (!value->isNull())
{
art->constituents = new std::vector<ArtifactID::ArtifactID>();
art->constituents = new std::vector<ArtifactID>();
BOOST_FOREACH (auto component, value->Vector())
{
VLC->modh->identifiers.requestIdentifier(std::string("artifact.") + component.String(),
[art](si32 id)
{
art->addConstituent(static_cast<ArtifactID::ArtifactID>(id));
art->addConstituent(ArtifactID(id));
}
);
}

View File

@ -57,7 +57,7 @@ public:
void setName (std::string desc);
void setDescription (std::string desc);
void setEventText (std::string desc);
void addConstituent (ArtifactID::ArtifactID component);
void addConstituent (ArtifactID component);
int getArtClassSerial() const; //0 - treasure, 1 - minor, 2 - major, 3 - relic, 4 - spell scroll, 5 - other
std::string nodeName() const OVERRIDE;
@ -67,10 +67,10 @@ public:
ui32 price;
bmap<ArtBearer::ArtBearer, std::vector<ArtifactPosition::ArtifactPosition> > possibleSlots; //Bearer Type => ids of slots where artifact can be placed
std::vector<ArtifactID::ArtifactID> * constituents; // Artifacts IDs a combined artifact consists of, or NULL.
std::vector<ArtifactID::ArtifactID> * constituentOf; // Reverse map of constituents.
std::vector<ArtifactID> * constituents; // Artifacts IDs a combined artifact consists of, or NULL.
std::vector<ArtifactID> * constituentOf; // Reverse map of constituents.
EartClass aClass;
ArtifactID::ArtifactID id;
ArtifactID id;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -189,15 +189,15 @@ public:
class DLL_LINKAGE CArtHandler //handles artifacts
{
void giveArtBonus(ArtifactID::ArtifactID aid, Bonus::BonusType type, int val, int subtype = -1, Bonus::ValueType valType = Bonus::BASE_NUMBER, shared_ptr<ILimiter> limiter = shared_ptr<ILimiter>(), int additionalinfo = 0);
void giveArtBonus(ArtifactID::ArtifactID aid, Bonus::BonusType type, int val, int subtype, shared_ptr<IPropagator> propagator, int additionalinfo = 0);
void giveArtBonus(ArtifactID::ArtifactID aid, Bonus *bonus);
void giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype = -1, Bonus::ValueType valType = Bonus::BASE_NUMBER, shared_ptr<ILimiter> limiter = shared_ptr<ILimiter>(), int additionalinfo = 0);
void giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype, shared_ptr<IPropagator> propagator, int additionalinfo = 0);
void giveArtBonus(ArtifactID aid, Bonus *bonus);
public:
std::vector<CArtifact*> treasures, minors, majors, relics;
std::vector< ConstTransitivePtr<CArtifact> > artifacts;
std::vector<CArtifact *> allowedArtifacts;
std::set<ArtifactID::ArtifactID> bigArtifacts; // Artifacts that cannot be moved to backpack, e.g. war machines.
std::set<ArtifactID::ArtifactID> growingArtifacts;
std::set<ArtifactID> bigArtifacts; // Artifacts that cannot be moved to backpack, e.g. war machines.
std::set<ArtifactID> growingArtifacts;
void loadArtifacts(bool onlyTxt);
/// load all artifacts from json structure
@ -217,10 +217,10 @@ public:
void getAllowedArts(std::vector<ConstTransitivePtr<CArtifact> > &out, std::vector<CArtifact*> *arts, int flag);
void getAllowed(std::vector<ConstTransitivePtr<CArtifact> > &out, int flags);
void erasePickedArt (TArtifactInstanceID id);
bool isBigArtifact (ArtifactID::ArtifactID artID) const {return bigArtifacts.find(artID) != bigArtifacts.end();}
bool isBigArtifact (ArtifactID artID) const {return bigArtifacts.find(artID) != bigArtifacts.end();}
void initAllowedArtifactsList(const std::vector<bool> &allowed); //allowed[art_id] -> 0 if not allowed, 1 if allowed
static ArtifactID::ArtifactID creatureToMachineID(CreatureID::CreatureID id);
static CreatureID::CreatureID machineIDToCreature(ArtifactID::ArtifactID id);
static ArtifactID creatureToMachineID(CreatureID id);
static CreatureID machineIDToCreature(ArtifactID id);
void makeItCreatureArt (CArtifact * a, bool onlyCreature = true);
void makeItCreatureArt (TArtifactInstanceID aid, bool onlyCreature = true);
void makeItCommanderArt (CArtifact * a, bool onlyCommander = true);

View File

@ -353,7 +353,7 @@ bool CBattleInfoEssentials::battleCanFlee(TPlayerColor player) const
if(mySide == BattleSide::DEFENDER && battleGetSiegeLevel())
{
auto town = battleGetDefendedTown();
if(!town->hasBuilt(EBuilding::ESCAPE_TUNNEL, ETownType::STRONGHOLD))
if(!town->hasBuilt(BuildingID::ESCAPE_TUNNEL, ETownType::STRONGHOLD))
return false;
}
@ -814,7 +814,7 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
double multDefenceReduction = (100 - battleBonusValue (info.attackerBonuses, Selector::type(Bonus::ENEMY_DEFENCE_REDUCTION))) / 100.0;
attackDefenceDifference -= info.defenderBonuses->Defense() * multDefenceReduction;
if(const Bonus *slayerEffect = info.attackerBonuses->getEffect(Spells::SLAYER)) //slayer handling //TODO: apply only ONLY_MELEE_FIGHT / DISTANCE_FIGHT?
if(const Bonus *slayerEffect = info.attackerBonuses->getEffect(SpellID::SLAYER)) //slayer handling //TODO: apply only ONLY_MELEE_FIGHT / DISTANCE_FIGHT?
{
std::vector<int> affectedIds;
int spLevel = slayerEffect->val;
@ -837,7 +837,7 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
{
if(defenderType->idNumber == affectedIds[g])
{
attackDefenceDifference += VLC->spellh->spells[Spells::SLAYER]->powers[spLevel];
attackDefenceDifference += VLC->spellh->spells[SpellID::SLAYER]->powers[spLevel];
break;
}
}
@ -871,7 +871,7 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
multBonus *= (std::max(0, 100 - info.defenderBonuses->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ARMORER))) / 100.0;
//handling hate effect
additiveBonus += info.attackerBonuses->valOfBonuses(Bonus::HATE, defenderType->idNumber) / 100.;
additiveBonus += info.attackerBonuses->valOfBonuses(Bonus::HATE, defenderType->idNumber.toEnum()) / 100.;
//luck bonus
if (info.luckyHit)
@ -913,7 +913,7 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
auto isAdvancedAirShield = [](const Bonus *bonus)
{
return bonus->source == Bonus::SPELL_EFFECT
&& bonus->sid == Spells::AIR_SHIELD
&& bonus->sid == SpellID::AIR_SHIELD
&& bonus->val >= SecSkillLevel::ADVANCED;
};
@ -1482,7 +1482,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleIsImmune(const C
switch (spell->id) //TODO: more general logic for new spells?
{
case Spells::CLONE:
case SpellID::CLONE:
if (caster) //TODO: how about stacks casting Clone?
{
if (vstd::contains(subject->state, EBattleStackState::CLONED))
@ -1493,7 +1493,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleIsImmune(const C
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
}
break;
case Spells::DISPEL_HELPFUL_SPELLS:
case SpellID::DISPEL_HELPFUL_SPELLS:
{
TBonusListPtr spellBon = subject->getSpellBonuses();
bool hasPositiveSpell = false;
@ -1593,8 +1593,8 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
return ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED;
//IDs of summon elemental spells (fire, earth, water, air)
int spellIDs[] = { Spells::SUMMON_FIRE_ELEMENTAL, Spells::SUMMON_EARTH_ELEMENTAL,
Spells::SUMMON_WATER_ELEMENTAL, Spells::SUMMON_AIR_ELEMENTAL };
int spellIDs[] = { SpellID::SUMMON_FIRE_ELEMENTAL, SpellID::SUMMON_EARTH_ELEMENTAL,
SpellID::SUMMON_WATER_ELEMENTAL, SpellID::SUMMON_AIR_ELEMENTAL };
//(fire, earth, water, air) elementals
int creIDs[] = {114, 113, 115, 112};
@ -1763,7 +1763,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
{
if(!deadStack && !aliveStack)
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
if(spell->id == Spells::ANIMATE_DEAD && deadStack && !deadStack->hasBonusOfType(Bonus::UNDEAD))
if(spell->id == SpellID::ANIMATE_DEAD && deadStack && !deadStack->hasBonusOfType(Bonus::UNDEAD))
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
if(deadStack && deadStack->owner != player) //you can resurrect only your own stacks //FIXME: it includes alive stacks as well
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
@ -1792,7 +1792,7 @@ ui32 CBattleInfoCallback::calculateSpellBonus(ui32 baseDamage, const CSpell * sp
if(caster)
{
ret *= (100.0 + caster->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SORCERY)) / 100.0;
ret *= (100.0 + caster->valOfBonuses(Bonus::SPELL_DAMAGE) + caster->valOfBonuses(Bonus::SPECIFIC_SPELL_DAMAGE, sp->id)) / 100.0;
ret *= (100.0 + caster->valOfBonuses(Bonus::SPELL_DAMAGE) + caster->valOfBonuses(Bonus::SPECIFIC_SPELL_DAMAGE, sp->id.toEnum())) / 100.0;
if(sp->air)
ret *= (100.0 + caster->valOfBonuses(Bonus::AIR_SPELL_DMG_PREMY)) / 100.0;
@ -1804,7 +1804,7 @@ ui32 CBattleInfoCallback::calculateSpellBonus(ui32 baseDamage, const CSpell * sp
ret *= (100.0 + caster->valOfBonuses(Bonus::EARTH_SPELL_DMG_PREMY)) / 100.0;
if (affectedCreature && affectedCreature->getCreature()->level) //Hero specials like Solmyr, Deemer
ret *= (100. + ((caster->valOfBonuses(Bonus::SPECIAL_SPELL_LEV, sp->id) * caster->level) / affectedCreature->getCreature()->level)) / 100.0;
ret *= (100. + ((caster->valOfBonuses(Bonus::SPECIAL_SPELL_LEV, sp->id.toEnum()) * caster->level) / affectedCreature->getCreature()->level)) / 100.0;
}
return ret;
}
@ -1854,7 +1854,7 @@ ui32 CBattleInfoCallback::calculateSpellDmg( const CSpell * sp, const CGHeroInst
//dmg increasing
if( affectedCreature->hasBonusOfType(Bonus::MORE_DAMAGE_FROM_SPELL, sp->id) )
{
ret *= 100 + affectedCreature->valOfBonuses(Bonus::MORE_DAMAGE_FROM_SPELL, sp->id);
ret *= 100 + affectedCreature->valOfBonuses(Bonus::MORE_DAMAGE_FROM_SPELL, sp->id.toEnum());
ret /= 100;
}
}
@ -1868,15 +1868,15 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
const ui8 attackerSide = playerToSide(attackerOwner) == 1;
const auto attackedHexes = spell->rangeInHexes(destinationTile, skillLevel, attackerSide);
const bool onlyAlive = spell->id != Spells::RESURRECTION && spell->id != Spells::ANIMATE_DEAD; //when casting resurrection or animate dead we should be allow to select dead stack
const bool onlyAlive = spell->id != SpellID::RESURRECTION && spell->id != SpellID::ANIMATE_DEAD; //when casting resurrection or animate dead we should be allow to select dead stack
//fixme: what about other rising spells (Sacrifice) ?
if(spell->id == Spells::DEATH_RIPPLE || spell->id == Spells::DESTROY_UNDEAD || spell->id == Spells::ARMAGEDDON)
if(spell->id == SpellID::DEATH_RIPPLE || spell->id == SpellID::DESTROY_UNDEAD || spell->id == SpellID::ARMAGEDDON)
{
BOOST_FOREACH(const CStack *stack, battleGetAllStacks())
{
if((spell->id == Spells::DEATH_RIPPLE && !stack->getCreature()->isUndead()) //death ripple
|| (spell->id == Spells::DESTROY_UNDEAD && stack->getCreature()->isUndead()) //destroy undead
|| (spell->id == Spells::ARMAGEDDON) //Armageddon
if((spell->id == SpellID::DEATH_RIPPLE && !stack->getCreature()->isUndead()) //death ripple
|| (spell->id == SpellID::DESTROY_UNDEAD && stack->getCreature()->isUndead()) //destroy undead
|| (spell->id == SpellID::ARMAGEDDON) //Armageddon
)
{
if(stack->isValidTarget())
@ -1884,7 +1884,7 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
}
}
}
else if (spell->id == Spells::CHAIN_LIGHTNING)
else if (spell->id == SpellID::CHAIN_LIGHTNING)
{
std::set<BattleHex> possibleHexes;
BOOST_FOREACH (auto stack, battleGetAllStacks())
@ -2007,10 +2007,10 @@ std::set<const CStack*> CBattleInfoCallback:: batteAdjacentCreatures(const CStac
return stacks;
}
TSpell CBattleInfoCallback::getRandomBeneficialSpell(const CStack * subject) const
SpellID CBattleInfoCallback::getRandomBeneficialSpell(const CStack * subject) const
{
RETURN_IF_NOT_BATTLE(-1);
std::vector<TSpell> possibleSpells;
RETURN_IF_NOT_BATTLE(SpellID::NONE);
std::vector<SpellID> possibleSpells;
BOOST_FOREACH(const CSpell *spell, VLC->spellh->spells)
{
@ -2022,8 +2022,8 @@ TSpell CBattleInfoCallback::getRandomBeneficialSpell(const CStack * subject) con
switch (spell->id)
{
case Spells::SHIELD:
case Spells::FIRE_SHIELD: // not if all enemy units are shooters
case SpellID::SHIELD:
case SpellID::FIRE_SHIELD: // not if all enemy units are shooters
{
auto walker = getStackIf([&](const CStack *stack) //look for enemy, non-shooting stack
{
@ -2034,7 +2034,7 @@ TSpell CBattleInfoCallback::getRandomBeneficialSpell(const CStack * subject) con
continue;
}
break;
case Spells::AIR_SHIELD: //only against active shooters
case SpellID::AIR_SHIELD: //only against active shooters
{
auto shooter = getStackIf([&](const CStack *stack) //look for enemy, non-shooting stack
@ -2045,32 +2045,32 @@ TSpell CBattleInfoCallback::getRandomBeneficialSpell(const CStack * subject) con
continue;
}
break;
case Spells::ANTI_MAGIC:
case Spells::MAGIC_MIRROR:
case SpellID::ANTI_MAGIC:
case SpellID::MAGIC_MIRROR:
{
if (!battleHasHero(subject->attackerOwned)) //only if there is enemy hero
continue;
}
break;
case Spells::CURE: //only damaged units - what about affected by curse?
case SpellID::CURE: //only damaged units - what about affected by curse?
{
if (subject->firstHPleft >= subject->MaxHealth())
continue;
}
break;
case Spells::BLOODLUST:
case SpellID::BLOODLUST:
{
if (subject->shots) //if can shoot - only if enemy uits are adjacent
continue;
}
break;
case Spells::PRECISION:
case SpellID::PRECISION:
{
if (!(subject->hasBonusOfType(Bonus::SHOOTER) && subject->shots))
continue;
}
break;
case Spells::SLAYER://only if monsters are present
case SpellID::SLAYER://only if monsters are present
{
auto kingMonster = getStackIf([&](const CStack *stack) //look for enemy, non-shooting stack
{
@ -2082,7 +2082,7 @@ TSpell CBattleInfoCallback::getRandomBeneficialSpell(const CStack * subject) con
continue;
}
break;
case Spells::CLONE: //not allowed
case SpellID::CLONE: //not allowed
continue;
break;
}
@ -2093,16 +2093,16 @@ TSpell CBattleInfoCallback::getRandomBeneficialSpell(const CStack * subject) con
if (possibleSpells.size())
return possibleSpells[rand() % possibleSpells.size()];
else
return -1;
return SpellID::NONE;
}
TSpell CBattleInfoCallback::getRandomCastedSpell(const CStack * caster) const
SpellID CBattleInfoCallback::getRandomCastedSpell(const CStack * caster) const
{
RETURN_IF_NOT_BATTLE(-1);
RETURN_IF_NOT_BATTLE(SpellID::NONE);
TBonusListPtr bl = caster->getBonuses(Selector::type(Bonus::SPELLCASTER));
if (!bl->size())
return -1;
return SpellID::NONE;
int totalWeight = 0;
BOOST_FOREACH(Bonus * b, *bl)
{
@ -2114,11 +2114,11 @@ TSpell CBattleInfoCallback::getRandomCastedSpell(const CStack * caster) const
randomPos -= std::max(b->additionalInfo, 1);
if(randomPos < 0)
{
return b->subtype;
return SpellID(b->subtype);
}
}
return -1;
return SpellID::NONE;
}
int CBattleInfoCallback::battleGetSurrenderCost(TPlayerColor Player) const

View File

@ -260,8 +260,8 @@ public:
std::set<const CStack*> getAffectedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, BattleHex destinationTile); //calculates stack affected by given spell
si32 battleGetRandomStackSpell(const CStack * stack, ERandomSpell mode) const;
TSpell getRandomBeneficialSpell(const CStack * subject) const;
TSpell getRandomCastedSpell(const CStack * caster) const; //called at the beginning of turn for Faerie Dragon
SpellID getRandomBeneficialSpell(const CStack * subject) const;
SpellID getRandomCastedSpell(const CStack * caster) const; //called at the beginning of turn for Faerie Dragon
//checks for creature immunity / anything that prevent casting *at given hex* - doesn't take into acount general problems such as not having spellbook or mana points etc.
ESpellCastProblem::ESpellCastProblem battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, ECastingMode::ECastingMode mode, BattleHex dest) const;

View File

@ -221,7 +221,7 @@ void CCreatureHandler::loadCreatures()
parser.endLine();
CCreature &ncre = *new CCreature;
ncre.idNumber = static_cast<CreatureID::CreatureID>(creatures.size());
ncre.idNumber = CreatureID(creatures.size());
ncre.cost.resize(GameConstants::RESOURCE_QUANTITY);
ncre.level=0;
ncre.iconIndex = ncre.idNumber + 2; // +2 for empty\selection images
@ -544,7 +544,7 @@ void CCreatureHandler::load(const JsonNode & node)
{
CCreature * creature = loadCreature(entry.second);
creature->nameRef = entry.first;
creature->idNumber = static_cast<CreatureID::CreatureID>(creatures.size());
creature->idNumber = CreatureID(creatures.size());
creatures.push_back(creature);
tlog5 << "Added creature: " << entry.first << "\n";
@ -678,7 +678,7 @@ void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & c
{
VLC->modh->identifiers.requestIdentifier(std::string("creature.") + value.String(), [=](si32 identifier)
{
creature->upgrades.insert(static_cast<CreatureID::CreatureID>(identifier));
creature->upgrades.insert(CreatureID(identifier));
});
}
@ -1013,7 +1013,7 @@ CCreatureHandler::~CCreatureHandler()
{
}
CreatureID::CreatureID CCreatureHandler::pickRandomMonster(const boost::function<int()> &randGen, int tier) const
CreatureID CCreatureHandler::pickRandomMonster(const boost::function<int()> &randGen, int tier) const
{
int r = 0;
if(tier == -1) //pick any allowed creature
@ -1026,11 +1026,11 @@ CreatureID::CreatureID CCreatureHandler::pickRandomMonster(const boost::function
else
{
assert(vstd::iswithin(tier, 1, 7));
std::vector<CreatureID::CreatureID> allowed;
std::vector<CreatureID> allowed;
BOOST_FOREACH(const CBonusSystemNode *b, creaturesOfLevel[tier].getChildrenNodes())
{
assert(b->getNodeType() == CBonusSystemNode::CREATURE);
CreatureID::CreatureID creid = static_cast<const CCreature*>(b)->idNumber;
CreatureID creid = static_cast<const CCreature*>(b)->idNumber;
if(!vstd::contains(notUsedMonsters, creid))
allowed.push_back(creid);
}
@ -1043,7 +1043,7 @@ CreatureID::CreatureID CCreatureHandler::pickRandomMonster(const boost::function
return vstd::pickRandomElementOf(allowed, randGen);
}
return static_cast<CreatureID::CreatureID>(r);
return CreatureID(r);
}
void CCreatureHandler::addBonusForTier(int tier, Bonus *b)

View File

@ -28,7 +28,7 @@ public:
std::string namePl, nameSing, nameRef; //name in singular and plural form; and reference name
TResources cost; //cost[res_id] - amount of that resource
std::set<std::string> upgradeNames; //for reference, they are later transformed info ui32 upgrades
std::set<CreatureID::CreatureID> upgrades; // IDs of creatures to which this creature can be upgraded
std::set<CreatureID> upgrades; // IDs of creatures to which this creature can be upgraded
//damage, hp. etc are handled by Bonuses
ui32 fightValue, AIValue, growth, hordeGrowth;
ui32 ammMin, ammMax;
@ -36,7 +36,7 @@ public:
std::string abilityRefs; //references to abilities, in text format
std::string animDefName;
std::string advMapDef; //for new creatures only
CreatureID::CreatureID idNumber;
CreatureID idNumber;
si32 iconIndex; // index of icon in files like twcrport
TFaction faction; //-1 = neutral
ui8 level; // 0 - unknown
@ -132,7 +132,7 @@ private:
void loadCreatureJson(CCreature * creature, const JsonNode & config);
public:
std::set<int> notUsedMonsters;
std::set<CreatureID::CreatureID> doubledCreatures; //they get double week
std::set<CreatureID> doubledCreatures; //they get double week
std::vector<ConstTransitivePtr<CCreature> > creatures; //creature ID -> creature info
//stack exp
@ -169,7 +169,7 @@ public:
~CCreatureHandler();
void deserializationFix();
CreatureID::CreatureID pickRandomMonster(const boost::function<int()> &randGen = 0, int tier = -1) const; //tier <1 - CREATURES_PER_TOWN> or -1 for any
CreatureID pickRandomMonster(const boost::function<int()> &randGen = 0, int tier = -1) const; //tier <1 - CREATURES_PER_TOWN> or -1 for any
void addBonusForTier(int tier, Bonus *b); //tier must be <1-7>
void addBonusForAllCreatures(Bonus *b);

View File

@ -39,7 +39,7 @@ const CCreature* CCreatureSet::getCreature(TSlot slot) const
return NULL;
}
bool CCreatureSet::setCreature(TSlot slot, CreatureID::CreatureID type, TQuantity quantity) /*slots 0 to 6 */
bool CCreatureSet::setCreature(TSlot slot, CreatureID type, TQuantity quantity) /*slots 0 to 6 */
{
if(slot > 6 || slot < 0)
{
@ -60,7 +60,7 @@ bool CCreatureSet::setCreature(TSlot slot, CreatureID::CreatureID type, TQuantit
return true;
}
TSlot CCreatureSet::getSlotFor(CreatureID::CreatureID creature, ui32 slotsAmount/*=7*/) const /*returns -1 if no slot available */
TSlot CCreatureSet::getSlotFor(CreatureID creature, ui32 slotsAmount/*=7*/) const /*returns -1 if no slot available */
{
return getSlotFor(VLC->creh->creatures[creature], slotsAmount);
}
@ -162,7 +162,7 @@ void CCreatureSet::sweep()
}
}
void CCreatureSet::addToSlot(TSlot slot, CreatureID::CreatureID cre, TQuantity count, bool allowMerging/* = true*/)
void CCreatureSet::addToSlot(TSlot slot, CreatureID cre, TQuantity count, bool allowMerging/* = true*/)
{
const CCreature *c = VLC->creh->creatures[cre];
@ -463,7 +463,7 @@ CStackInstance::CStackInstance()
init();
}
CStackInstance::CStackInstance(CreatureID::CreatureID id, TQuantity Count)
CStackInstance::CStackInstance(CreatureID id, TQuantity Count)
: armyObj(_armyObj)
{
init();
@ -545,7 +545,7 @@ void CStackInstance::giveStackExp(TExpType exp)
vstd::amin(experience += exp, maxExp); //can't get more exp than this limit
}
void CStackInstance::setType(CreatureID::CreatureID creID)
void CStackInstance::setType(CreatureID creID)
{
if(creID >= 0 && creID < VLC->creh->creatures.size())
setType(VLC->creh->creatures[creID]);
@ -977,7 +977,7 @@ void CStackInstance::deserializationFix()
artDeserializationFix(this);
}
CreatureID::CreatureID CStackInstance::getCreatureID() const
CreatureID CStackInstance::getCreatureID() const
{
if(type)
return type->idNumber;
@ -1007,7 +1007,7 @@ CCommanderInstance::CCommanderInstance()
name = "Unnamed";
}
CCommanderInstance::CCommanderInstance (CreatureID::CreatureID id)
CCommanderInstance::CCommanderInstance (CreatureID id)
{
init();
setType(id);
@ -1073,7 +1073,7 @@ CStackBasicDescriptor::CStackBasicDescriptor()
count = -1;
}
CStackBasicDescriptor::CStackBasicDescriptor(CreatureID::CreatureID id, TQuantity Count)
CStackBasicDescriptor::CStackBasicDescriptor(CreatureID id, TQuantity Count)
: type (VLC->creh->creatures[id]), count(Count)
{
}
@ -1107,7 +1107,7 @@ CSimpleArmy::operator bool() const
return army.size();
}
bool CSimpleArmy::setCreature(TSlot slot, CreatureID::CreatureID cre, TQuantity count)
bool CSimpleArmy::setCreature(TSlot slot, CreatureID cre, TQuantity count)
{
assert(!vstd::contains(army, slot));
army[slot] = CStackBasicDescriptor(cre, count);

View File

@ -27,7 +27,7 @@ public:
TQuantity count;
CStackBasicDescriptor();
CStackBasicDescriptor(CreatureID::CreatureID id, TQuantity Count);
CStackBasicDescriptor(CreatureID id, TQuantity Count);
CStackBasicDescriptor(const CCreature *c, TQuantity Count);
template <typename Handler> void serialize(Handler &h, const int version)
@ -65,15 +65,15 @@ public:
std::string getQuantityTXT(bool capitalized = true) const;
virtual int getExpRank() const;
si32 magicResistance() const;
CreatureID::CreatureID getCreatureID() const; //-1 if not available
CreatureID getCreatureID() const; //-1 if not available
std::string getName() const; //plural or singular
virtual void init();
CStackInstance();
CStackInstance(CreatureID::CreatureID id, TQuantity count);
CStackInstance(CreatureID id, TQuantity count);
CStackInstance(const CCreature *cre, TQuantity count);
~CStackInstance();
void setType(CreatureID::CreatureID creID);
void setType(CreatureID creID);
void setType(const CCreature *c);
void setArmyObj(const CArmedInstance *ArmyObj);
virtual void giveStackExp(TExpType exp);
@ -97,7 +97,7 @@ public:
//std::vector <CArtifactInstance *> arts;
void init() OVERRIDE;
CCommanderInstance();
CCommanderInstance (CreatureID::CreatureID id);
CCommanderInstance (CreatureID id);
~CCommanderInstance();
void setAlive (bool alive);
void giveStackExp (TExpType exp);
@ -123,7 +123,7 @@ class IArmyDescriptor
{
public:
virtual void clear() = 0;
virtual bool setCreature(TSlot slot, CreatureID::CreatureID cre, TQuantity count) = 0;
virtual bool setCreature(TSlot slot, CreatureID cre, TQuantity count) = 0;
};
//simplified version of CCreatureSet
@ -132,7 +132,7 @@ class DLL_LINKAGE CSimpleArmy : public IArmyDescriptor
public:
TSimpleSlots army;
void clear() OVERRIDE;
bool setCreature(TSlot slot, CreatureID::CreatureID cre, TQuantity count) OVERRIDE;
bool setCreature(TSlot slot, CreatureID cre, TQuantity count) OVERRIDE;
operator bool() const;
template <typename Handler> void serialize(Handler &h, const int version)
@ -157,7 +157,7 @@ public:
const TSlots &Slots() const {return stacks;}
void addToSlot(TSlot slot, CreatureID::CreatureID cre, TQuantity count, bool allowMerging = true); //Adds stack to slot. Slot must be empty or with same type creature
void addToSlot(TSlot slot, CreatureID cre, TQuantity count, bool allowMerging = true); //Adds stack to slot. Slot must be empty or with same type creature
void addToSlot(TSlot slot, CStackInstance *stack, bool allowMerging = true); //Adds stack to slot. Slot must be empty or with same type creature
void clear() OVERRIDE;
void setFormation(bool tight);
@ -175,7 +175,7 @@ public:
void eraseStack(TSlot slot); //slot must be occupied
void joinStack(TSlot slot, CStackInstance * stack); //adds new stack to the existing stack of the same type
void changeStackCount(TSlot slot, TQuantity toAdd); //stack must exist!
bool setCreature (TSlot slot, CreatureID::CreatureID type, TQuantity quantity) OVERRIDE; //replaces creature in stack; slots 0 to 6, if quantity=0 erases stack
bool setCreature (TSlot slot, CreatureID type, TQuantity quantity) OVERRIDE; //replaces creature in stack; slots 0 to 6, if quantity=0 erases stack
void setToArmy(CSimpleArmy &src); //erases all our army and moves stacks from src to us; src MUST NOT be an armed object! WARNING: use it wisely. Or better do not use at all.
const CStackInstance& getStack(TSlot slot) const; //stack must exist
@ -184,7 +184,7 @@ public:
int getStackCount (TSlot slot) const;
TExpType getStackExperience(TSlot slot) const;
TSlot findStack(const CStackInstance *stack) const; //-1 if none
TSlot getSlotFor(CreatureID::CreatureID creature, ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns -1 if no slot available
TSlot getSlotFor(CreatureID creature, ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns -1 if no slot available
TSlot getSlotFor(const CCreature *c, ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns -1 if no slot available
TSlot getFreeSlot(ui32 slotsAmount = GameConstants::ARMY_SIZE) const;
bool mergableStacks(std::pair<TSlot, TSlot> &out, TSlot preferable = -1) const; //looks for two same stacks, returns slot positions;

View File

@ -90,7 +90,7 @@ void CDefObjInfoHandler::load()
for(int yy=0; yy<2; ++yy) //first - on which types of terrain object can be placed;
inp>>dump; //second -in which terrains' menus object in the editor will be available (?)
si32 id; inp >> id; nobj->id = static_cast<Obj::Obj>(id);
si32 id; inp >> id; nobj->id = Obj(id);
inp>>nobj->subid;
inp>>nobj->type;
@ -102,22 +102,21 @@ void CDefObjInfoHandler::load()
}
else
{
using namespace Obj;
static int visitableFromTop[] =
{FLOTSAM,
SEA_CHEST,
SHIPWRECK_SURVIVOR,
BUOY,
OCEAN_BOTTLE,
BOAT,
WHIRLPOOL,
GARRISON,
SCHOLAR,
CAMPFIRE,
BORDERGUARD,
BORDER_GATE,
QUEST_GUARD,
CORPSE};
static const Obj visitableFromTop[] =
{Obj::FLOTSAM,
Obj::SEA_CHEST,
Obj::SHIPWRECK_SURVIVOR,
Obj::BUOY,
Obj::OCEAN_BOTTLE,
Obj::BOAT,
Obj::WHIRLPOOL,
Obj::GARRISON,
Obj::SCHOLAR,
Obj::CAMPFIRE,
Obj::BORDERGUARD,
Obj::BORDER_GATE,
Obj::QUEST_GUARD,
Obj::CORPSE};
for(int i=0; i < ARRAY_COUNT(visitableFromTop); i++)
{
@ -134,7 +133,7 @@ void CDefObjInfoHandler::load()
nobj->fetchInfoFromMSK();
gobjs[nobj->id][nobj->subid] = nobj;
nobj->id.toDefObjInfo()[nobj->subid] = nobj;
}
for (int i = 0; i < 8 ; i++)

View File

@ -23,7 +23,7 @@ public:
ui8 blockMap[6];
ui8 coverageMap[6], shadowCoverage[6]; //to determine which tiles are covered by picture of this object
ui8 visitDir; //directions from which object can be entered, format same as for moveDir in CGHeroInstance(but 0 - 7)
Obj::Obj id;
Obj id;
si32 subid; //of object described by this defInfo
si32 terrainAllowed, //on which terrain it is possible to place object
terrainMenu; //in which menus in map editor object will be showed

View File

@ -332,7 +332,7 @@ DLL_LINKAGE std::string MetaString::buildList () const
}
void MetaString::addCreReplacement(CreatureID::CreatureID id, TQuantity count) //adds sing or plural name;
void MetaString::addCreReplacement(CreatureID id, TQuantity count) //adds sing or plural name;
{
if (!count)
addReplacement (CRE_PL_NAMES, id); //no creatures - just empty name (eg. defeat Angels)
@ -348,7 +348,7 @@ void MetaString::addReplacement(const CStackBasicDescriptor &stack)
addCreReplacement(stack.type->idNumber, stack.count);
}
static CGObjectInstance * createObject(Obj::Obj id, int subid, int3 pos, int owner)
static CGObjectInstance * createObject(Obj id, int subid, int3 pos, int owner)
{
CGObjectInstance * nobj;
switch(id)
@ -367,7 +367,7 @@ static CGObjectInstance * createObject(Obj::Obj id, int subid, int3 pos, int own
break;
default: //rest of objects
nobj = new CGObjectInstance;
nobj->defInfo = VLC->dobjinfo->gobjs[id][subid];
nobj->defInfo = id.toDefObjInfo()[subid];
break;
}
nobj->ID = id;
@ -383,7 +383,7 @@ static CGObjectInstance * createObject(Obj::Obj id, int subid, int3 pos, int own
//assigning defhandler
if(nobj->ID==Obj::HERO || nobj->ID==Obj::TOWN)
return nobj;
nobj->defInfo = VLC->dobjinfo->gobjs[id][subid];
nobj->defInfo = id.toDefObjInfo()[subid];
return nobj;
}
@ -516,7 +516,7 @@ int CGameState::pickHero(int owner)
}
std::pair<Obj::Obj,int> CGameState::pickObject (CGObjectInstance *obj)
std::pair<Obj,int> CGameState::pickObject (CGObjectInstance *obj)
{
switch(obj->ID)
{
@ -630,7 +630,7 @@ std::pair<Obj::Obj,int> CGameState::pickObject (CGObjectInstance *obj)
delete dwl->info;
dwl->info = nullptr;
std::pair<Obj::Obj,int> result(Obj::NO_OBJ, -1);
std::pair<Obj,int> result(Obj::NO_OBJ, -1);
int cid = VLC->townh->towns[faction].creatures[level][0];
//golem factory is not in list of cregens but can be placed as random object
@ -661,8 +661,8 @@ std::pair<Obj::Obj,int> CGameState::pickObject (CGObjectInstance *obj)
void CGameState::randomizeObject(CGObjectInstance *cur)
{
std::pair<Obj::Obj,int> ran = pickObject(cur);
if(ran.first<0 || ran.second<0) //this is not a random object, or we couldn't find anything
std::pair<Obj,int> ran = pickObject(cur);
if(ran.first == Obj::NO_OBJ || ran.second<0) //this is not a random object, or we couldn't find anything
{
if(cur->ID==Obj::TOWN) //town - set def
{
@ -710,7 +710,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
cur->ID = ran.first;
cur->subID = ran.second;
map->removeBlockVisTiles(cur); //recalculate blockvis tiles - picked object might have different than random placeholder
map->customDefs.push_back(cur->defInfo = VLC->dobjinfo->gobjs[ran.first][ran.second]);
map->customDefs.push_back(cur->defInfo = ran.first.toDefObjInfo()[ran.second]);
if(!cur->defInfo)
{
tlog1<<"*BIG* WARNING: Missing def declaration for "<<cur->ID<<" "<<cur->subID<<std::endl;
@ -798,7 +798,7 @@ void CGameState::init(StartInfo * si)
switch (curBonus->type)
{
case CScenarioTravel::STravelBonus::SPELL:
hero->spells.insert(curBonus->info2);
hero->spells.insert(SpellID(curBonus->info2));
break;
case CScenarioTravel::STravelBonus::MONSTER:
{
@ -806,7 +806,7 @@ void CGameState::init(StartInfo * si)
{
if(hero->slotEmpty(i))
{
hero->addToSlot(i, static_cast<CreatureID::CreatureID>(curBonus->info2), curBonus->info3);
hero->addToSlot(i, CreatureID(curBonus->info2), curBonus->info3);
break;
}
}
@ -1458,15 +1458,15 @@ void CGameState::init(StartInfo * si)
if(vti->builtBuildings.find(-50)!=vti->builtBuildings.end()) //give standard set of buildings
{
vti->builtBuildings.erase(-50);
vti->builtBuildings.insert(EBuilding::VILLAGE_HALL);
vti->builtBuildings.insert(EBuilding::TAVERN);
vti->builtBuildings.insert(EBuilding::DWELL_FIRST);
vti->builtBuildings.insert(BuildingID::VILLAGE_HALL);
vti->builtBuildings.insert(BuildingID::TAVERN);
vti->builtBuildings.insert(BuildingID::DWELL_FIRST);
if(ran()%2)
vti->builtBuildings.insert(EBuilding::DWELL_FIRST+1);
vti->builtBuildings.insert(BuildingID::DWELL_FIRST+1);
}
if (vstd::contains(vti->builtBuildings, EBuilding::SHIPYARD) && vti->state()==IBoatGenerator::TILE_BLOCKED)
vti->builtBuildings.erase(EBuilding::SHIPYARD);//if we have harbor without water - erase it (this is H3 behaviour)
if (vstd::contains(vti->builtBuildings, BuildingID::SHIPYARD) && vti->state()==IBoatGenerator::TILE_BLOCKED)
vti->builtBuildings.erase(BuildingID::SHIPYARD);//if we have harbor without water - erase it (this is H3 behaviour)
//init hordes
for (int i = 0; i<GameConstants::CREATURES_PER_TOWN; i++)
@ -1475,15 +1475,15 @@ void CGameState::init(StartInfo * si)
vti->builtBuildings.erase(-31-i);//remove old ID
if (vti->town->hordeLvl[0] == i)//if town first horde is this one
{
vti->builtBuildings.insert(EBuilding::HORDE_1);//add it
if (vstd::contains(vti->builtBuildings,(EBuilding::DWELL_UP_FIRST+i)))//if we have upgraded dwelling as well
vti->builtBuildings.insert(EBuilding::HORDE_1_UPGR);//add it as well
vti->builtBuildings.insert(BuildingID::HORDE_1);//add it
if (vstd::contains(vti->builtBuildings,(BuildingID::DWELL_UP_FIRST+i)))//if we have upgraded dwelling as well
vti->builtBuildings.insert(BuildingID::HORDE_1_UPGR);//add it as well
}
if (vti->town->hordeLvl[1] == i)//if town second horde is this one
{
vti->builtBuildings.insert(EBuilding::HORDE_2);
if (vstd::contains(vti->builtBuildings,(EBuilding::DWELL_UP_FIRST+i)))
vti->builtBuildings.insert(EBuilding::HORDE_2_UPGR);
vti->builtBuildings.insert(BuildingID::HORDE_2);
if (vstd::contains(vti->builtBuildings,(BuildingID::DWELL_UP_FIRST+i)))
vti->builtBuildings.insert(BuildingID::HORDE_2_UPGR);
}
}
@ -1495,9 +1495,9 @@ void CGameState::init(StartInfo * si)
{
ev->buildings.erase(-31-i);
if (vti->town->hordeLvl[0] == i)
ev->buildings.insert(EBuilding::HORDE_1);
ev->buildings.insert(BuildingID::HORDE_1);
if (vti->town->hordeLvl[1] == i)
ev->buildings.insert(EBuilding::HORDE_2);
ev->buildings.insert(BuildingID::HORDE_2);
}
}
//init spells
@ -1707,7 +1707,7 @@ void CGameState::initDuel()
for(int j = 0; j < ARRAY_COUNT(dp.sides[i].stacks); j++)
{
CreatureID::CreatureID cre = dp.sides[i].stacks[j].type;
CreatureID cre = dp.sides[i].stacks[j].type;
TQuantity count = dp.sides[i].stacks[j].count;
if(count || obj->hasStackAtSlot(j))
obj->setCreature(j, cre, count);
@ -1829,7 +1829,7 @@ UpgradeInfo CGameState::getUpgradeInfo(const CStackInstance &stack)
TBonusListPtr lista = h->getBonuses(Selector::typeSubtype(Bonus::SPECIAL_UPGRADE, base->idNumber));
BOOST_FOREACH(const Bonus *it, *lista)
{
auto nid = static_cast<CreatureID::CreatureID>(it->additionalInfo);
auto nid = CreatureID(it->additionalInfo);
if (nid != base->idNumber) //in very specific case the upgrade is available by default (?)
{
ret.newID.push_back(nid);
@ -2252,7 +2252,7 @@ int CGameState::victoryCheck( ui8 player ) const
BOOST_FOREACH(const CGTownInstance *t, map->towns)
if((t == map->victoryCondition.obj || !map->victoryCondition.obj)
&& t->tempOwner == player
&& t->hasBuilt(EBuilding::GRAIL))
&& t->hasBuilt(BuildingID::GRAIL))
return 1;
break;
@ -2277,8 +2277,9 @@ int CGameState::victoryCheck( ui8 player ) const
{
switch(map->objects[i]->ID)
{
case 17: case 18: case 19: case 20: //dwellings
case 216: case 217: case 218:
case Obj::CREATURE_GENERATOR1: case Obj::CREATURE_GENERATOR2:
case Obj::CREATURE_GENERATOR3: case Obj::CREATURE_GENERATOR4:
case Obj::RANDOM_DWELLING: case Obj::RANDOM_DWELLING_LVL: case Obj::RANDOM_DWELLING_FACTION:
return 0; //found not flagged dwelling - player not won
}
}
@ -2292,7 +2293,7 @@ int CGameState::victoryCheck( ui8 player ) const
{
switch(map->objects[i]->ID)
{
case 53: case 220:
case Obj::MINE: case Obj::ABANDONED_MINE:
return 0; //found not flagged mine - player not won
}
}
@ -2870,7 +2871,7 @@ void InfoAboutTown::initFromTown(const CGTownInstance *t, bool detailed)
//include details about hero
details = new Details;
details->goldIncome = t->dailyIncome();
details->customRes = t->hasBuilt(EBuilding::RESOURCE_SILO);
details->customRes = t->hasBuilt(BuildingID::RESOURCE_SILO);
details->hallLevel = t->hallLevel();
details->garrisonedHero = t->garrisonHero;
}
@ -2915,7 +2916,7 @@ DuelParameters::SideSettings::StackSettings::StackSettings()
{
}
DuelParameters::SideSettings::StackSettings::StackSettings(CreatureID::CreatureID Type, si32 Count)
DuelParameters::SideSettings::StackSettings::StackSettings(CreatureID Type, si32 Count)
: type(Type), count(Count)
{
}
@ -2944,7 +2945,7 @@ DuelParameters DuelParameters::fromJSON(const std::string &fname)
int i = 0;
BOOST_FOREACH(const JsonNode &stackNode, n["army"].Vector())
{
ss.stacks[i].type = static_cast<CreatureID::CreatureID>((si32)stackNode.Vector()[0].Float());
ss.stacks[i].type = CreatureID((si32)stackNode.Vector()[0].Float());
ss.stacks[i].count = stackNode.Vector()[1].Float();
i++;
}
@ -2973,12 +2974,12 @@ DuelParameters DuelParameters::fromJSON(const std::string &fname)
if(spells.getType() == JsonNode::DATA_STRING && spells.String() == "all")
{
BOOST_FOREACH(auto spell, VLC->spellh->spells)
if(spell->id <= Spells::SUMMON_AIR_ELEMENTAL)
if(spell->id <= SpellID::SUMMON_AIR_ELEMENTAL)
ss.spells.insert(spell->id);
}
else
BOOST_FOREACH(const JsonNode &spell, n["spells"].Vector())
ss.spells.insert(spell.Float());
ss.spells.insert(SpellID(spell.Float()));
}
}

View File

@ -215,8 +215,8 @@ public:
struct UpgradeInfo
{
CreatureID::CreatureID oldID; //creature to be upgraded
std::vector<CreatureID::CreatureID> newID; //possible upgrades
CreatureID oldID; //creature to be upgraded
std::vector<CreatureID> newID; //possible upgrades
std::vector<TResources> cost; // cost[upgrade_serial] -> set of pairs<resource_ID,resource_amount>; cost is for single unit (not entire stack)
UpgradeInfo(){oldID = CreatureID::NONE;};
};
@ -273,7 +273,7 @@ struct DLL_EXPORT DuelParameters
{
struct DLL_EXPORT StackSettings
{
CreatureID::CreatureID type;
CreatureID type;
si32 count;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -281,14 +281,14 @@ struct DLL_EXPORT DuelParameters
}
StackSettings();
StackSettings(CreatureID::CreatureID Type, si32 Count);
StackSettings(CreatureID Type, si32 Count);
} stacks[GameConstants::ARMY_SIZE];
si32 heroId; //-1 if none
std::vector<si32> heroPrimSkills; //may be empty
std::map<si32, CArtifactInstance*> artifacts;
std::vector<std::pair<si32, si8> > heroSecSkills; //may be empty; pairs <id, level>, level [0-3]
std::set<si32> spells;
std::set<SpellID> spells;
SideSettings();
template <typename Handler> void serialize(Handler &h, const int version)
@ -392,7 +392,7 @@ public:
void initDuel();
void randomizeObject(CGObjectInstance *cur);
std::pair<Obj::Obj,int> pickObject(CGObjectInstance *obj); //chooses type of object to be randomized, returns <type, subtype>
std::pair<Obj,int> pickObject(CGObjectInstance *obj); //chooses type of object to be randomized, returns <type, subtype>
int pickHero(int owner);
void giveHeroArtifact(CGHeroInstance *h, int aid);

View File

@ -255,7 +255,7 @@ CHero * CHeroHandler::loadHero(const JsonNode & node)
VLC->modh->identifiers.requestIdentifier(std::string("creature.") + source["creature"].String(), [=](si32 creature)
{
hero->initialArmy[i].creature = static_cast<CreatureID::CreatureID>(creature);
hero->initialArmy[i].creature = CreatureID(creature);
});
}
@ -280,7 +280,7 @@ void CHeroHandler::loadHeroJson(CHero * hero, const JsonNode & node)
BOOST_FOREACH(const JsonNode & spell, node["spellbook"].Vector())
{
hero->spells.insert(spell.Float());
hero->spells.insert(SpellID(spell.Float()));
}
//deprecated, used only for original spciealties
@ -404,7 +404,7 @@ void CHeroHandler::loadHeroes()
refName[0] = std::tolower(refName[0]); // to camelCase
VLC->modh->identifiers.requestIdentifier(std::string("creature.") + refName, [=](si32 creature)
{
hero->initialArmy[x].creature = static_cast<CreatureID::CreatureID>(creature);
hero->initialArmy[x].creature = CreatureID(creature);
});
}
parser.endLine();

View File

@ -50,7 +50,7 @@ public:
{
ui32 minAmount;
ui32 maxAmount;
CreatureID::CreatureID creature;
CreatureID creature;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -67,7 +67,7 @@ public:
std::vector<std::pair<SecondarySkill::SecondarySkill, ui8> > secSkillsInit; //initial secondary skills; first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert)
std::vector<SSpecialtyInfo> spec;
std::vector<SSpecialtyBonus> specialty;
std::set<si32> spells;
std::set<SpellID> spells;
ui8 sex; // default sex: 0=male, 1=female
ui8 special; // hero is special and won't be placed in game (unless preset on map), e.g. campaign heroes

View File

@ -138,12 +138,12 @@ bool CPlayersVisited::wasVisited( TPlayerColor player ) const
// Bank helper. Find the creature ID and their number, and store the
// result in storage (either guards or reward creatures).
static void readCreatures(const JsonNode &creature, std::vector< std::pair <CreatureID::CreatureID, ui32> > &storage)
static void readCreatures(const JsonNode &creature, std::vector< std::pair <CreatureID, ui32> > &storage)
{
std::pair<CreatureID::CreatureID, si32> creInfo = std::make_pair(CreatureID::NONE, 0);
std::pair<CreatureID, si32> creInfo = std::make_pair(CreatureID::NONE, 0);
creInfo.second = creature["number"].Float();
creInfo.first = static_cast<CreatureID::CreatureID>((si32)creature["id"].Float());
creInfo.first = CreatureID((si32)creature["id"].Float());
storage.push_back(creInfo);
}
@ -195,7 +195,7 @@ void CObjectHandler::loadObjects()
const JsonNode config(ResourceID("config/dwellings.json"));
BOOST_FOREACH(const JsonNode &dwelling, config["dwellings"].Vector())
{
cregens[dwelling["dwelling"].Float()] = static_cast<CreatureID::CreatureID>((si32)dwelling["creature"].Float());
cregens[dwelling["dwelling"].Float()] = CreatureID((si32)dwelling["creature"].Float());
}
tlog5 << "\t\tDone loading cregens!\n";
@ -405,7 +405,7 @@ void CGObjectInstance::setProperty( ui8 what, ui32 val )
blockVisit = val;
break;
case ObjProperty::ID:
ID = static_cast<Obj::Obj>(val);
ID = Obj(val);
break;
case ObjProperty::SUBID:
subID = val;
@ -732,13 +732,13 @@ void CGHeroInstance::initHero()
if(!type)
type = VLC->heroh->heroes[subID];
if(!vstd::contains(spells, 0xffffffff)) //hero starts with a spell
if(!vstd::contains(spells, SpellID::PRESET)) //hero starts with a spell
{
BOOST_FOREACH(auto spellID, type->spells)
spells.insert(spellID);
}
else //remove placeholder
spells -= 0xffffffff;
spells -= SpellID::PRESET;
if(!getArt(ArtifactPosition::MACH4) && !getArt(ArtifactPosition::SPELLBOOK) && !type->spells.empty()) //no catapult means we haven't read pre-existent set -> use default rules for spellbook
putArtifact(ArtifactPosition::SPELLBOOK, CArtifactInstance::createNewArtifactInstance(0));
@ -831,7 +831,7 @@ void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= NULL*/)
continue;
int slot = -1;
ArtifactID::ArtifactID aid = ArtifactID::NONE;
ArtifactID aid = ArtifactID::NONE;
switch (stack.creature)
{
case CreatureID::CATAPULT:
@ -1328,7 +1328,7 @@ ui8 CGHeroInstance::getSpellSchoolLevel(const CSpell * spell, int *outSelectedSc
vstd::amax(skill, valOfBonuses(Bonus::MAGIC_SCHOOL_SKILL, 0)); //any school bonus
vstd::amax(skill, valOfBonuses(Bonus::SPELL, spell->id)); //given by artifact or other effect
vstd::amax(skill, valOfBonuses(Bonus::SPELL, spell->id.toEnum())); //given by artifact or other effect
if (hasBonusOfType(Bonus::MAXED_SPELL, spell->id))//hero specialty (Daremyth, Melodia)
skill = 3;
assert(skill >= 0 && skill <= 3);
@ -1588,7 +1588,7 @@ void CGDwelling::initObj()
{
case Obj::CREATURE_GENERATOR1:
{
CreatureID::CreatureID crid = VLC->objh->cregens[subID];
CreatureID crid = VLC->objh->cregens[subID];
const CCreature *crs = VLC->creh->creatures[crid];
creatures.resize(1);
@ -1672,7 +1672,7 @@ void CGDwelling::setProperty(ui8 what, ui32 val)
case ObjProperty::AVAILABLE_CREATURE:
creatures.resize(1);
creatures[0].second.resize(1);
creatures[0].second[0] = static_cast<CreatureID::CreatureID>(val);
creatures[0].second[0] = CreatureID(val);
break;
}
CGObjectInstance::setProperty(what,val);
@ -1777,7 +1777,7 @@ void CGDwelling::heroAcceptsCreatures( const CGHeroInstance *h, ui32 answer ) co
if(!answer)
return;
CreatureID::CreatureID crid = creatures[0].second[0];
CreatureID crid = creatures[0].second[0];
CCreature *crs = VLC->creh->creatures[crid];
TQuantity count = creatures[0].first;
@ -1864,9 +1864,9 @@ int CGTownInstance::getSightRadious() const //returns sight distance
{
if (subID == ETownType::TOWER)
{
if (hasBuilt(EBuilding::GRAIL)) //skyship
if (hasBuilt(BuildingID::GRAIL)) //skyship
return -1; //entire map
else if (hasBuilt(EBuilding::LOOKOUT_TOWER)) //lookout tower
else if (hasBuilt(BuildingID::LOOKOUT_TOWER)) //lookout tower
return 20;
}
return 5;
@ -1896,38 +1896,38 @@ void CGTownInstance::setPropertyDer(ui8 what, ui32 val)
}
CGTownInstance::EFortLevel CGTownInstance::fortLevel() const //0 - none, 1 - fort, 2 - citadel, 3 - castle
{
if (hasBuilt(EBuilding::CASTLE))
if (hasBuilt(BuildingID::CASTLE))
return CASTLE;
if (hasBuilt(EBuilding::CITADEL))
if (hasBuilt(BuildingID::CITADEL))
return CITADEL;
if (hasBuilt(EBuilding::FORT))
if (hasBuilt(BuildingID::FORT))
return FORT;
return NONE;
}
int CGTownInstance::hallLevel() const // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
{
if (hasBuilt(EBuilding::CAPITOL))
if (hasBuilt(BuildingID::CAPITOL))
return 3;
if (hasBuilt(EBuilding::CITY_HALL))
if (hasBuilt(BuildingID::CITY_HALL))
return 2;
if (hasBuilt(EBuilding::TOWN_HALL))
if (hasBuilt(BuildingID::TOWN_HALL))
return 1;
if (hasBuilt(EBuilding::VILLAGE_HALL))
if (hasBuilt(BuildingID::VILLAGE_HALL))
return 0;
return -1;
}
int CGTownInstance::mageGuildLevel() const
{
if (hasBuilt(EBuilding::MAGES_GUILD_5))
if (hasBuilt(BuildingID::MAGES_GUILD_5))
return 5;
if (hasBuilt(EBuilding::MAGES_GUILD_4))
if (hasBuilt(BuildingID::MAGES_GUILD_4))
return 4;
if (hasBuilt(EBuilding::MAGES_GUILD_3))
if (hasBuilt(BuildingID::MAGES_GUILD_3))
return 3;
if (hasBuilt(EBuilding::MAGES_GUILD_2))
if (hasBuilt(BuildingID::MAGES_GUILD_2))
return 2;
if (hasBuilt(EBuilding::MAGES_GUILD_1))
if (hasBuilt(BuildingID::MAGES_GUILD_1))
return 1;
return 0;
}
@ -1938,7 +1938,7 @@ int CGTownInstance::creatureDwellingLevel(int dwelling) const
return -1;
for (int i=0; ; i++)
{
if (!hasBuilt(EBuilding::DWELL_FIRST+dwelling+i*GameConstants::CREATURES_PER_TOWN))
if (!hasBuilt(BuildingID::DWELL_FIRST+dwelling+i*GameConstants::CREATURES_PER_TOWN))
return i-1;
}
}
@ -1957,7 +1957,7 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const
if (level<0 || level >=GameConstants::CREATURES_PER_TOWN)
return ret;
if (!hasBuilt(EBuilding::DWELL_FIRST+level))
if (!hasBuilt(BuildingID::DWELL_FIRST+level))
return ret; //no dwelling
const CCreature *creature = VLC->creh->creatures[creatures[level].second.back()];
@ -1966,18 +1966,18 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const
ret.entries.push_back(GrowthInfo::Entry(VLC->generaltexth->allTexts[590], base));// \n\nBasic growth %d"
if (hasBuilt(EBuilding::CASTLE))
ret.entries.push_back(GrowthInfo::Entry(subID, EBuilding::CASTLE, castleBonus = base));
else if (hasBuilt(EBuilding::CITADEL))
ret.entries.push_back(GrowthInfo::Entry(subID, EBuilding::CITADEL, castleBonus = base / 2));
if (hasBuilt(BuildingID::CASTLE))
ret.entries.push_back(GrowthInfo::Entry(subID, BuildingID::CASTLE, castleBonus = base));
else if (hasBuilt(BuildingID::CITADEL))
ret.entries.push_back(GrowthInfo::Entry(subID, BuildingID::CITADEL, castleBonus = base / 2));
if(town->hordeLvl[0] == level)//horde 1
if(hasBuilt(EBuilding::HORDE_1))
ret.entries.push_back(GrowthInfo::Entry(subID, EBuilding::HORDE_1, creature->hordeGrowth));
if(hasBuilt(BuildingID::HORDE_1))
ret.entries.push_back(GrowthInfo::Entry(subID, BuildingID::HORDE_1, creature->hordeGrowth));
if(town->hordeLvl[1] == level)//horde 2
if(hasBuilt(EBuilding::HORDE_2))
ret.entries.push_back(GrowthInfo::Entry(subID, EBuilding::HORDE_2, creature->hordeGrowth));
if(hasBuilt(BuildingID::HORDE_2))
ret.entries.push_back(GrowthInfo::Entry(subID, BuildingID::HORDE_2, creature->hordeGrowth));
int dwellingBonus = 0;
if(const PlayerState *p = cb->getPlayer(tempOwner, false))
@ -2000,8 +2000,8 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const
BOOST_FOREACH(const Bonus *b, *bonuses2)
ret.entries.push_back(GrowthInfo::Entry(b->Description() + " %+d", b->val * (base + castleBonus) / 100));
if(hasBuilt(EBuilding::GRAIL)) //grail - +50% to ALL (so far added) growth
ret.entries.push_back(GrowthInfo::Entry(subID, EBuilding::GRAIL, ret.totalGrowth() / 2));
if(hasBuilt(BuildingID::GRAIL)) //grail - +50% to ALL (so far added) growth
ret.entries.push_back(GrowthInfo::Entry(subID, BuildingID::GRAIL, ret.totalGrowth() / 2));
return ret;
}
@ -2009,26 +2009,26 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const
int CGTownInstance::dailyIncome() const
{
int ret = 0;
if (hasBuilt(EBuilding::GRAIL))
if (hasBuilt(BuildingID::GRAIL))
ret+=5000;
if (hasBuilt(EBuilding::CAPITOL))
if (hasBuilt(BuildingID::CAPITOL))
ret+=4000;
else if (hasBuilt(EBuilding::CITY_HALL))
else if (hasBuilt(BuildingID::CITY_HALL))
ret+=2000;
else if (hasBuilt(EBuilding::TOWN_HALL))
else if (hasBuilt(BuildingID::TOWN_HALL))
ret+=1000;
else if (hasBuilt(EBuilding::VILLAGE_HALL))
else if (hasBuilt(BuildingID::VILLAGE_HALL))
ret+=500;
return ret;
}
bool CGTownInstance::hasFort() const
{
return hasBuilt(EBuilding::FORT);
return hasBuilt(BuildingID::FORT);
}
bool CGTownInstance::hasCapitol() const
{
return hasBuilt(EBuilding::CAPITOL);
return hasBuilt(BuildingID::CAPITOL);
}
CGTownInstance::CGTownInstance()
:IShipyard(this), IMarket(this), town(nullptr), builded(0), destroyed(0), identifier(0), alignment(0xff)
@ -2048,7 +2048,7 @@ int CGTownInstance::spellsAtLevel(int level, bool checkGuild) const
return 0;
int ret = 6 - level; //how many spells are available at this level
if (hasBuilt(EBuilding::LIBRARY, ETownType::TOWER))
if (hasBuilt(BuildingID::LIBRARY, ETownType::TOWER))
ret++;
return ret;
@ -2153,7 +2153,7 @@ void CGTownInstance::newTurn() const
if (cb->getDate(Date::DAY_OF_WEEK) == 1) //reset on new week
{
//give resources for Rampart, Mystic Pond
if (hasBuilt(EBuilding::MYSTIC_POND, ETownType::RAMPART)
if (hasBuilt(BuildingID::MYSTIC_POND, ETownType::RAMPART)
&& cb->getDate(Date::DAY) != 1 && (tempOwner < GameConstants::PLAYER_LIMIT))
{
int resID = rand()%4+2;//bonus to random rare resource
@ -2167,7 +2167,7 @@ void CGTownInstance::newTurn() const
if ( subID == ETownType::DUNGEON )
for (std::vector<CGTownBuilding*>::const_iterator i = bonusingBuildings.begin(); i!=bonusingBuildings.end(); i++)
{
if ((*i)->ID == EBuilding::MANA_VORTEX)
if ((*i)->ID == BuildingID::MANA_VORTEX)
cb->setObjProperty (id, 12, (*i)->id); //reset visitors for Mana Vortex
}
@ -2199,7 +2199,7 @@ void CGTownInstance::newTurn() const
if ((stacksCount() < GameConstants::ARMY_SIZE && rand()%100 < 25) || Slots().empty()) //add new stack
{
int i = rand() % std::min (GameConstants::ARMY_SIZE, cb->getDate(Date::MONTH)<<1);
CreatureID::CreatureID c = town->creatures[i][0];
CreatureID c = town->creatures[i][0];
TSlot n = -1;
TQuantity count = creatureGrowth(i);
@ -2294,7 +2294,7 @@ int CGTownInstance::getBoatType() const
int CGTownInstance::getMarketEfficiency() const
{
if (!hasBuilt(EBuilding::MARKETPLACE))
if (!hasBuilt(BuildingID::MARKETPLACE))
return 0;
const PlayerState *p = cb->getPlayer(tempOwner);
@ -2302,7 +2302,7 @@ int CGTownInstance::getMarketEfficiency() const
int marketCount = 0;
BOOST_FOREACH(const CGTownInstance *t, p->towns)
if(t->hasBuilt(EBuilding::MARKETPLACE))
if(t->hasBuilt(BuildingID::MARKETPLACE))
marketCount++;
return marketCount;
@ -2314,22 +2314,22 @@ bool CGTownInstance::allowsTrade(EMarketMode::EMarketMode mode) const
{
case EMarketMode::RESOURCE_RESOURCE:
case EMarketMode::RESOURCE_PLAYER:
return hasBuilt(EBuilding::MARKETPLACE);
return hasBuilt(BuildingID::MARKETPLACE);
case EMarketMode::ARTIFACT_RESOURCE:
case EMarketMode::RESOURCE_ARTIFACT:
return hasBuilt(EBuilding::ARTIFACT_MERCHANT, ETownType::TOWER)
|| hasBuilt(EBuilding::ARTIFACT_MERCHANT, ETownType::DUNGEON)
|| hasBuilt(EBuilding::ARTIFACT_MERCHANT, ETownType::CONFLUX);
return hasBuilt(BuildingID::ARTIFACT_MERCHANT, ETownType::TOWER)
|| hasBuilt(BuildingID::ARTIFACT_MERCHANT, ETownType::DUNGEON)
|| hasBuilt(BuildingID::ARTIFACT_MERCHANT, ETownType::CONFLUX);
case EMarketMode::CREATURE_RESOURCE:
return hasBuilt(EBuilding::FREELANCERS_GUILD, ETownType::STRONGHOLD);
return hasBuilt(BuildingID::FREELANCERS_GUILD, ETownType::STRONGHOLD);
case EMarketMode::CREATURE_UNDEAD:
return hasBuilt(EBuilding::SKELETON_TRANSFORMER, ETownType::NECROPOLIS);
return hasBuilt(BuildingID::SKELETON_TRANSFORMER, ETownType::NECROPOLIS);
case EMarketMode::RESOURCE_SKILL:
return hasBuilt(EBuilding::MAGIC_UNIVERSITY, ETownType::CONFLUX);
return hasBuilt(BuildingID::MAGIC_UNIVERSITY, ETownType::CONFLUX);
default:
assert(0);
return false;
@ -2378,47 +2378,47 @@ void CGTownInstance::recreateBuildingsBonuses()
removeBonus(b);
//tricky! -> checks tavern only if no bratherhood of sword or not a castle
if(subID != ETownType::CASTLE || !addBonusIfBuilt(EBuilding::BROTHERHOOD, Bonus::MORALE, +2))
addBonusIfBuilt(EBuilding::TAVERN, Bonus::MORALE, +1);
if(subID != ETownType::CASTLE || !addBonusIfBuilt(BuildingID::BROTHERHOOD, Bonus::MORALE, +2))
addBonusIfBuilt(BuildingID::TAVERN, Bonus::MORALE, +1);
if(subID == ETownType::CASTLE) //castle
{
addBonusIfBuilt(EBuilding::LIGHTHOUSE, Bonus::SEA_MOVEMENT, +500, make_shared<CPropagatorNodeType>(PLAYER));
addBonusIfBuilt(EBuilding::GRAIL, Bonus::MORALE, +2, make_shared<CPropagatorNodeType>(PLAYER)); //colossus
addBonusIfBuilt(BuildingID::LIGHTHOUSE, Bonus::SEA_MOVEMENT, +500, make_shared<CPropagatorNodeType>(PLAYER));
addBonusIfBuilt(BuildingID::GRAIL, Bonus::MORALE, +2, make_shared<CPropagatorNodeType>(PLAYER)); //colossus
}
else if(subID == ETownType::RAMPART) //rampart
{
addBonusIfBuilt(EBuilding::FOUNTAIN_OF_FORTUNE, Bonus::LUCK, +2); //fountain of fortune
addBonusIfBuilt(EBuilding::GRAIL, Bonus::LUCK, +2, make_shared<CPropagatorNodeType>(PLAYER)); //guardian spirit
addBonusIfBuilt(BuildingID::FOUNTAIN_OF_FORTUNE, Bonus::LUCK, +2); //fountain of fortune
addBonusIfBuilt(BuildingID::GRAIL, Bonus::LUCK, +2, make_shared<CPropagatorNodeType>(PLAYER)); //guardian spirit
}
else if(subID == ETownType::TOWER) //tower
{
addBonusIfBuilt(EBuilding::GRAIL, Bonus::PRIMARY_SKILL, +15, PrimarySkill::KNOWLEDGE); //grail
addBonusIfBuilt(BuildingID::GRAIL, Bonus::PRIMARY_SKILL, +15, PrimarySkill::KNOWLEDGE); //grail
}
else if(subID == ETownType::INFERNO) //Inferno
{
addBonusIfBuilt(EBuilding::STORMCLOUDS, Bonus::PRIMARY_SKILL, +2, PrimarySkill::SPELL_POWER); //Brimstone Clouds
addBonusIfBuilt(BuildingID::STORMCLOUDS, Bonus::PRIMARY_SKILL, +2, PrimarySkill::SPELL_POWER); //Brimstone Clouds
}
else if(subID == ETownType::NECROPOLIS) //necropolis
{
addBonusIfBuilt(EBuilding::COVER_OF_DARKNESS, Bonus::DARKNESS, +20);
addBonusIfBuilt(EBuilding::NECROMANCY_AMPLIFIER, Bonus::SECONDARY_SKILL_PREMY, +10, make_shared<CPropagatorNodeType>(PLAYER), SecondarySkill::NECROMANCY); //necromancy amplifier
addBonusIfBuilt(EBuilding::GRAIL, Bonus::SECONDARY_SKILL_PREMY, +20, make_shared<CPropagatorNodeType>(PLAYER), SecondarySkill::NECROMANCY); //Soul prison
addBonusIfBuilt(BuildingID::COVER_OF_DARKNESS, Bonus::DARKNESS, +20);
addBonusIfBuilt(BuildingID::NECROMANCY_AMPLIFIER, Bonus::SECONDARY_SKILL_PREMY, +10, make_shared<CPropagatorNodeType>(PLAYER), SecondarySkill::NECROMANCY); //necromancy amplifier
addBonusIfBuilt(BuildingID::GRAIL, Bonus::SECONDARY_SKILL_PREMY, +20, make_shared<CPropagatorNodeType>(PLAYER), SecondarySkill::NECROMANCY); //Soul prison
}
else if(subID == ETownType::DUNGEON) //Dungeon
{
addBonusIfBuilt(EBuilding::GRAIL, Bonus::PRIMARY_SKILL, +12, PrimarySkill::SPELL_POWER); //grail
addBonusIfBuilt(BuildingID::GRAIL, Bonus::PRIMARY_SKILL, +12, PrimarySkill::SPELL_POWER); //grail
}
else if(subID == ETownType::STRONGHOLD) //Stronghold
{
addBonusIfBuilt(EBuilding::GRAIL, Bonus::PRIMARY_SKILL, +20, PrimarySkill::ATTACK); //grail
addBonusIfBuilt(BuildingID::GRAIL, Bonus::PRIMARY_SKILL, +20, PrimarySkill::ATTACK); //grail
}
else if(subID == ETownType::FORTRESS) //Fortress
{
addBonusIfBuilt(EBuilding::GLYPHS_OF_FEAR, Bonus::PRIMARY_SKILL, +2, PrimarySkill::DEFENSE); //Glyphs of Fear
addBonusIfBuilt(EBuilding::BLOOD_OBELISK, Bonus::PRIMARY_SKILL, +2, PrimarySkill::ATTACK); //Blood Obelisk
addBonusIfBuilt(EBuilding::GRAIL, Bonus::PRIMARY_SKILL, +10, PrimarySkill::ATTACK); //grail
addBonusIfBuilt(EBuilding::GRAIL, Bonus::PRIMARY_SKILL, +10, PrimarySkill::DEFENSE); //grail
addBonusIfBuilt(BuildingID::GLYPHS_OF_FEAR, Bonus::PRIMARY_SKILL, +2, PrimarySkill::DEFENSE); //Glyphs of Fear
addBonusIfBuilt(BuildingID::BLOOD_OBELISK, Bonus::PRIMARY_SKILL, +2, PrimarySkill::ATTACK); //Blood Obelisk
addBonusIfBuilt(BuildingID::GRAIL, Bonus::PRIMARY_SKILL, +10, PrimarySkill::ATTACK); //grail
addBonusIfBuilt(BuildingID::GRAIL, Bonus::PRIMARY_SKILL, +10, PrimarySkill::DEFENSE); //grail
}
else if(subID == ETownType::CONFLUX)
{
@ -2918,7 +2918,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
int val=0, mid=0;
switch (ID)
{
case EBuilding::SPECIAL_4:
case BuildingID::SPECIAL_4:
switch(town->subID)
{
case ETownType::TOWER: //wall
@ -2947,7 +2947,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
break;
}
break;
case EBuilding::SPECIAL_1:
case BuildingID::SPECIAL_1:
switch(town->subID)
{
case ETownType::FORTRESS: //cage of warlords
@ -3120,7 +3120,7 @@ void CGCreature::initObj()
break;
}
stacks[0]->setType(static_cast<CreatureID::CreatureID>(subID));
stacks[0]->setType(CreatureID(subID));
TQuantity &amount = stacks[0]->count;
CCreature &c = *VLC->creh->creatures[subID];
if(!amount)
@ -4736,15 +4736,15 @@ void CGSeerHut::completeQuest (const CGHeroInstance * h) const //reward
break;
case SPELL:
{
std::set<ui32> spell;
spell.insert (rID);
std::set<SpellID> spell;
spell.insert (SpellID(rID));
cb->changeSpells(h, true, spell);
}
break;
case CREATURE:
{
CCreatureSet creatures;
creatures.setCreature(0, static_cast<CreatureID::CreatureID>(rID), rVal);
creatures.setCreature(0, CreatureID(rID), rVal);
cb->giveCreatures(this, h, creatures, false);
}
break;
@ -5209,7 +5209,7 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
if(spells.size())
{
std::set<ui32> spellsToGive;
std::set<SpellID> spellsToGive;
iw.components.clear();
if (spells.size() > 1)
{
@ -5221,7 +5221,7 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
}
iw.text.addReplacement(h->name);
std::vector<ConstTransitivePtr<CSpell> > * sp = &VLC->spellh->spells;
for(std::vector<si32>::const_iterator i=spells.begin(); i != spells.end(); i++)
for(auto i=spells.cbegin(); i != spells.cend(); i++)
{
if ((*sp)[*i]->level <= h->getSecSkillLevel(SecondarySkill::WISDOM) + 2) //enough wisdom
{
@ -5475,8 +5475,8 @@ void CGShrine::onHeroVisit( const CGHeroInstance * h ) const
}
else //give spell
{
std::set<ui32> spells;
spells.insert(spell);
std::set<SpellID> spells;
spells.insert(SpellID(spell));
cb->changeSpells(h, true, spells);
iw.components.push_back(Component(Component::SPELL,spell,0,0));
@ -5490,7 +5490,7 @@ void CGShrine::initObj()
if(spell == 255) //spell not set
{
int level = ID-87;
std::vector<ui16> possibilities;
std::vector<SpellID> possibilities;
cb->getAllowedSpells (possibilities, level);
if(!possibilities.size())
@ -5582,8 +5582,8 @@ void CGScholar::onHeroVisit( const CGHeroInstance * h ) const
break;
case SPELL:
{
std::set<ui32> hlp;
hlp.insert(bid);
std::set<SpellID> hlp;
hlp.insert(SpellID(bid));
cb->changeSpells(h,true,hlp);
iw.components.push_back(Component(Component::SPELL,bid,0,0));
}
@ -5612,7 +5612,7 @@ void CGScholar::initObj()
bonusID = ran() % GameConstants::SKILL_QUANTITY;
break;
case SPELL:
std::vector<ui16> possibilities;
std::vector<SpellID> possibilities;
for (int i = 1; i < 6; ++i)
cb->getAllowedSpells (possibilities, i);
bonusID = possibilities[ran() % possibilities.size()];
@ -5927,7 +5927,7 @@ void CBank::setPropertyDer (ui8 what, ui32 val)
case 1:
for (int i = 0; i < 4; ++i)
setCreature (i, bc->guards[0].first, bc->guards[0].second / 5 );
setCreature (4, static_cast<CreatureID::CreatureID>(bc->guards[0].first + upgraded), bc->guards[0].second / 5 );
setCreature (4, CreatureID(bc->guards[0].first + upgraded), bc->guards[0].second / 5 );
break;
case 4:
{
@ -5942,7 +5942,7 @@ void CBank::setPropertyDer (ui8 what, ui32 val)
{
setCreature (0, bc->guards[0].first, bc->guards[0].second / 2 );
setCreature (1, bc->guards[1].first, bc->guards[1].second / 2);
setCreature (2, static_cast<CreatureID::CreatureID>(bc->guards[2].first + upgraded), bc->guards[2].second);
setCreature (2, CreatureID(bc->guards[2].first + upgraded), bc->guards[2].second);
setCreature (3, bc->guards[1].first, bc->guards[1].second / 2 );
setCreature (4, bc->guards[0].first, bc->guards[0].second - (bc->guards[0].second / 2) );
@ -6213,7 +6213,7 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
void CGPyramid::initObj()
{
std::vector<ui16> available;
std::vector<SpellID> available;
cb->getAllowedSpells (available, 5);
if (available.size())
{
@ -6269,8 +6269,8 @@ void CGPyramid::endBattle (const CGHeroInstance *h, const BattleResult *result)
iw.text.addTxt (MetaString::ADVOB_TXT, 108); //no expert Wisdom
else
{
std::set<ui32> spells;
spells.insert (spell);
std::set<SpellID> spells;
spells.insert (SpellID(spell));
cb->changeSpells (h, true, spells);
iw.components.push_back(Component (Component::SPELL, spell, 0, 0));
}
@ -7229,7 +7229,7 @@ GrowthInfo::Entry::Entry(const std::string &format, int _count)
description = boost::str(boost::format(format) % count);
}
GrowthInfo::Entry::Entry(int subID, EBuilding::EBuilding building, int _count)
GrowthInfo::Entry::Entry(int subID, BuildingID building, int _count)
: count(_count)
{
description = boost::str(boost::format("%s %+d") % VLC->townh->towns[subID].buildings[building]->Name() % count);

View File

@ -168,7 +168,7 @@ class DLL_LINKAGE CGObjectInstance : public IObjectInterface
public:
mutable std::string hoverName;
int3 pos; //h3m pos
Obj::Obj ID;
Obj ID;
si32 subID; //normal subID (this one from OH3 maps ;])
si32 id;//number of object in map's vector
CGDefInfo * defInfo;
@ -308,7 +308,7 @@ public:
//std::vector<const CArtifact*> artifacts; //hero's artifacts from bag
//std::map<ui16, const CArtifact*> artifWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
std::set<ui32> spells; //known spells (spell IDs)
std::set<SpellID> spells; //known spells (spell IDs)
struct DLL_LINKAGE Patrol
@ -460,7 +460,7 @@ class DLL_LINKAGE CCreGenLeveledCastleInfo : public CCreGenAsCastleInfo, public
class DLL_LINKAGE CGDwelling : public CArmedInstance
{
public:
typedef std::vector<std::pair<ui32, std::vector<CreatureID::CreatureID> > > TCreaturesSet;
typedef std::vector<std::pair<ui32, std::vector<CreatureID> > > TCreaturesSet;
CSpecObjInfo * info; //h3m info about dewlling
TCreaturesSet creatures; //creatures[level] -> <vector of alternative ids (base creature and upgrades, creatures amount>
@ -567,7 +567,7 @@ struct DLL_LINKAGE GrowthInfo
int count;
std::string description;
Entry(const std::string &format, int _count);
Entry(int subID, EBuilding::EBuilding building, int _count);
Entry(int subID, BuildingID building, int _count);
};
std::vector<Entry> entries;
@ -590,7 +590,7 @@ public:
std::set<si32> forbiddenBuildings, builtBuildings;
std::vector<CGTownBuilding*> bonusingBuildings;
std::vector<ui32> possibleSpells, obligatorySpells;
std::vector<std::vector<ui32> > spells; //spells[level] -> vector of spells, first will be available in guild
std::vector<std::vector<SpellID> > spells; //spells[level] -> vector of spells, first will be available in guild
std::list<CCastleEvent*> events;
std::pair<si32, si32> bonusValue;//var to store town bonuses (rampart = resources from mystic pond);
@ -684,8 +684,8 @@ public:
std::vector<si32> primskills;//gained / lost prim skills
std::vector<SecondarySkill::SecondarySkill> abilities; //gained abilities
std::vector<si32> abilityLevels; //levels of gained abilities
std::vector<si32> artifacts; //gained artifacts
std::vector<si32> spells; //gained spells
std::vector<ArtifactID> artifacts; //gained artifacts
std::vector<SpellID> spells; //gained spells
CCreatureSet creatures; //gained creatures
void initObj() override;
@ -732,7 +732,7 @@ public:
si8 character; //character of this set of creatures (0 - the most friendly, 4 - the most hostile) => on init changed to -4 (compliant) ... 10 value (savage)
std::string message; //message printed for attacking hero
TResources resources; // resources given to hero that has won with monsters
ArtifactID::ArtifactID gainedArtifact; //ID of artifact gained to hero, -1 if none
ArtifactID gainedArtifact; //ID of artifact gained to hero, -1 if none
bool neverFlees; //if true, the troops will never flee
bool notGrowingTeam; //if true, number of units won't grow
ui64 temppower; //used to handle fractional stack growth for tiny stacks
@ -1373,10 +1373,10 @@ struct BankConfig
ui8 level; //1 - 4, how hard the battle will be
ui8 chance; //chance for this level being chosen
ui8 upgradeChance; //chance for creatures to be in upgraded versions
std::vector< std::pair <CreatureID::CreatureID, ui32> > guards; //creature ID, amount
std::vector< std::pair <CreatureID, ui32> > guards; //creature ID, amount
ui32 combatValue; //how hard are guards of this level
std::vector<si32> resources; //resources given in case of victory
std::vector< std::pair <CreatureID::CreatureID, ui32> > creatures; //creatures granted in case of victory (creature ID, amount)
std::vector< std::pair <CreatureID, ui32> > creatures; //creatures granted in case of victory (creature ID, amount)
std::vector<ui16> artifacts; //number of artifacts given in case of victory [0] -> treasure, [1] -> minor [2] -> major [3] -> relic
ui32 value; //overall value of given things
ui32 rewardDifficulty; //proportion of reward value to difficulty of guards; how profitable is this creature Bank config
@ -1391,7 +1391,7 @@ struct BankConfig
class DLL_LINKAGE CObjectHandler
{
public:
std::map<si32, CreatureID::CreatureID> cregens; //type 17. dwelling subid -> creature ID
std::map<si32, CreatureID> cregens; //type 17. dwelling subid -> creature ID
std::map <ui32, std::vector < ConstTransitivePtr<BankConfig> > > banksInfo; //[index][preset]
std::map <ui32, std::string> creBanksNames; //[crebank index] -> name of this creature bank
std::vector<ui32> resVals; //default values of resources in gold

View File

@ -129,7 +129,7 @@ std::vector<BattleHex> SpellCreatedObstacle::getAffectedTiles() const
case FIRE_WALL:
return std::vector<BattleHex>(1, pos);
case FORCE_FIELD:
return VLC->spellh->spells[Spells::FORCE_FIELD]->rangeInHexes(pos, spellLevel, casterSide);
return VLC->spellh->spells[SpellID::FORCE_FIELD]->rangeInHexes(pos, spellLevel, casterSide);
//TODO Fire Wall
default:
assert(0);

View File

@ -139,7 +139,7 @@ std::vector<BattleHex> CSpell::rangeInHexes(BattleHex centralHex, ui8 schoolLvl,
{
std::vector<BattleHex> ret;
if(id == Spells::FIRE_WALL || id == Spells::FORCE_FIELD)
if(id == SpellID::FIRE_WALL || id == SpellID::FORCE_FIELD)
{
//Special case - shape of obstacle depends on caster's side
//TODO make it possible through spell_info config
@ -389,7 +389,7 @@ void CSpellHandler::loadSpells()
do
{
CSpell * spell = loadSpell(parser);
spell->id = spells.size();
spell->id = SpellID(spells.size());
spell->combatSpell = combat;
spell->creatureAbility = alility;
spells.push_back(spell);
@ -410,10 +410,10 @@ void CSpellHandler::loadSpells()
skip(3);
read(true,true);//read creature abilities
boost::replace_first (spells[Spells::DISRUPTING_RAY]->attributes, "2", ""); // disrupting ray will now affect single creature
boost::replace_first (spells[SpellID::DISRUPTING_RAY]->attributes, "2", ""); // disrupting ray will now affect single creature
spells.push_back(spells[Spells::ACID_BREATH_DEFENSE]); //clone Acid Breath attributes for Acid Breath damage effect
spells.push_back(spells[SpellID::ACID_BREATH_DEFENSE]); //clone Acid Breath attributes for Acid Breath damage effect
//loading of additional spell traits
const JsonNode config(ResourceID("config/spell_info.json"));
@ -432,7 +432,7 @@ void CSpellHandler::loadSpells()
BOOST_FOREACH(const JsonNode &range, spell.second["ranges"].Vector())
s->range[idx++] = range.String();
s->counteredSpells = spell.second["counters"].convertTo<std::vector<TSpell> >();
s->counteredSpells = spell.second["counters"].convertTo<std::vector<SpellID> >();
s->identifier = spell.first;
VLC->modh->identifiers.registerObject("spell." + spell.first, spellID);
@ -524,7 +524,7 @@ void CSpellHandler::loadSpells()
//spell fixes
//forgetfulness needs to get targets automatically on expert level
boost::replace_first(spells[Spells::FORGETFULNESS]->attributes, "CREATURE_TARGET", "CREATURE_TARGET_2"); //TODO: use flags instead?
boost::replace_first(spells[SpellID::FORGETFULNESS]->attributes, "CREATURE_TARGET", "CREATURE_TARGET_2"); //TODO: use flags instead?
}
std::vector<bool> CSpellHandler::getDefaultAllowedSpells() const

View File

@ -23,7 +23,7 @@ class DLL_LINKAGE CSpell
public:
enum ETargetType {NO_TARGET, CREATURE, CREATURE_EXPERT_MASSIVE, OBSTACLE};
enum ESpellPositiveness {NEGATIVE = -1, NEUTRAL = 0, POSITIVE = 1};
TSpell id;
SpellID id;
std::string identifier;
std::string name;
std::string abbName; //abbreviated name
@ -43,7 +43,7 @@ public:
bool creatureAbility; //if true, only creatures can use this spell
si8 positiveness; //1 if spell is positive for influenced stacks, 0 if it is indifferent, -1 if it's negative
std::vector<std::string> range; //description of spell's range in SRSL by magic school level
std::vector<TSpell> counteredSpells; //spells that are removed when effect of this spell is placed on creature (for bless-curse, haste-slow, and similar pairs)
std::vector<SpellID> counteredSpells; //spells that are removed when effect of this spell is placed on creature (for bless-curse, haste-slow, and similar pairs)
CSpell();

View File

@ -339,7 +339,7 @@ void CTownHandler::loadSiegeScreen(CTown &town, const JsonNode & source)
town.clientInfo.siegePrefix = source["imagePrefix"].String();
VLC->modh->identifiers.requestIdentifier(std::string("creature.") + source["shooter"].String(), [&town](si32 creature)
{
town.clientInfo.siegeShooter = static_cast<CreatureID::CreatureID>(creature);
town.clientInfo.siegeShooter = CreatureID(creature);
});
town.clientInfo.siegeShooterCropHeight = source["shooterHeight"].Float();
@ -418,7 +418,7 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
VLC->modh->identifiers.requestIdentifier(std::string("creature." + source["warMachine"].String()),
[&town](si32 creature)
{
town.warMachine = CArtHandler::creatureToMachineID(static_cast<CreatureID::CreatureID>(creature));
town.warMachine = CArtHandler::creatureToMachineID(CreatureID(creature));
});
town.moatDamage = source["moatDamage"].Float();
@ -446,7 +446,7 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
{
VLC->modh->identifiers.requestIdentifier(std::string("creature.") + level[j].String(), [=, &town](si32 creature)
{
town.creatures[i][j] = static_cast<CreatureID::CreatureID>(creature);
town.creatures[i][j] = CreatureID(creature);
});
}
}
@ -521,7 +521,7 @@ void CTownHandler::load(const JsonNode &source)
VLC->modh->identifiers.requestIdentifier ("creature." + node.second["commander"].String(),
[=](si32 commanderID)
{
factions[id].commander = static_cast<CreatureID::CreatureID>(commanderID);
factions[id].commander = CreatureID(commanderID);
});
faction.creatureBg120 = node.second["creatureBackground"]["120px"].String();

View File

@ -90,7 +90,7 @@ public:
/// level -> list of creatures on this tier
// TODO: replace with pointers to CCreature
std::vector<std::vector<CreatureID::CreatureID> > creatures;
std::vector<std::vector<CreatureID> > creatures;
bmap<int, ConstTransitivePtr<CBuilding> > buildings;
@ -101,7 +101,7 @@ public:
std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
ui32 mageLevel; //max available mage guild level
ui16 primaryRes;
ArtifactID::ArtifactID warMachine;
ArtifactID warMachine;
si32 moatDamage;
// Client-only data. Should be moved away from lib
@ -137,7 +137,7 @@ public:
std::string siegePrefix;
std::vector<Point> siegePositions;
CreatureID::CreatureID siegeShooter; // shooter creature ID
CreatureID siegeShooter; // shooter creature ID
si32 siegeShooterCropHeight; //trim height for shooters in turrets
template <typename Handler> void serialize(Handler &h, const int version)
@ -178,7 +178,7 @@ public:
ETerrainType::ETerrainType nativeTerrain;
EAlignment::EAlignment alignment;
CreatureID::CreatureID commander;
CreatureID commander;
std::string creatureBg120;
std::string creatureBg130;

View File

@ -378,7 +378,7 @@ public:
U getIdFromVectorItem(const VectorisedObjectInfo<T, U> &oInfo, const T* obj) const
{
if(!obj)
return static_cast<U>(-1);
return U(-1);
return obj->*oInfo.idPtr;
}
@ -427,10 +427,10 @@ struct VectorizedIDType
typedef typename
//if
mpl::eval_if<boost::is_same<CArtifact,U>,
mpl::identity<ArtifactID::ArtifactID>,
mpl::identity<ArtifactID>,
//else if
mpl::eval_if<boost::is_same<CCreature,U>,
mpl::identity<CreatureID::CreatureID>,
mpl::identity<CreatureID>,
//else
mpl::identity<si32>
>
@ -965,7 +965,7 @@ public:
*this >> id;
if(id != -1)
{
data = static_cast<T>(getVectorItemFromId<VType, IDType>(*info, static_cast<IDType>(id)));
data = static_cast<T>(getVectorItemFromId<VType, IDType>(*info, IDType(id)));
return;
}
}

68
lib/GameConstants.cpp Normal file
View File

@ -0,0 +1,68 @@
#include "StdInc.h"
#include "VCMI_Lib.h"
#include "CDefObjInfoHandler.h"
#include "CArtHandler.h"
#include "CCreatureHandler.h"
#include "CSpellHandler.h"
#define ID_LIKE_OPERATORS_INTERNAL(A, B, AN, BN) \
bool operator==(const A & a, const B & b) \
{ \
return AN == BN ; \
} \
bool operator!=(const A & a, const B & b) \
{ \
return AN != BN ; \
} \
bool operator<(const A & a, const B & b) \
{ \
return AN < BN ; \
} \
bool operator<=(const A & a, const B & b) \
{ \
return AN <= BN ; \
} \
bool operator>(const A & a, const B & b) \
{ \
return AN > BN ; \
} \
bool operator>=(const A & a, const B & b) \
{ \
return AN >= BN ; \
}
#define ID_LIKE_OPERATORS(CLASS_NAME, ENUM_NAME) \
ID_LIKE_OPERATORS_INTERNAL(CLASS_NAME, CLASS_NAME, a.num, b.num) \
ID_LIKE_OPERATORS_INTERNAL(CLASS_NAME, ENUM_NAME, a.num, b) \
ID_LIKE_OPERATORS_INTERNAL(ENUM_NAME, CLASS_NAME, a, b.num)
ID_LIKE_OPERATORS(Obj, Obj::EObj)
ID_LIKE_OPERATORS(ArtifactID, ArtifactID::EArtifactID)
ID_LIKE_OPERATORS(CreatureID, CreatureID::ECreatureID)
ID_LIKE_OPERATORS(SpellID, SpellID::ESpellID)
bmap<int, ConstTransitivePtr<CGDefInfo> > & Obj::toDefObjInfo() const
{
return VLC->dobjinfo->gobjs[*this];
}
CArtifact * ArtifactID::toArtifact() const
{
return VLC->arth->artifacts[*this];
}
CCreature * CreatureID::toCreature() const
{
return VLC->creh->creatures[*this];
}
CSpell * SpellID::toSpell() const
{
return VLC->spellh->spells[*this];
}

View File

@ -10,6 +10,8 @@
*
*/
#include "ConstTransitivePtr.h"
namespace GameConstants
{
const std::string VCMI_VERSION = "VCMI 0.91b";
@ -91,6 +93,58 @@ namespace GameConstants
}
class CArtifact;
class CGDefInfo;
class CCreature;
class CSpell;
#define ID_LIKE_CLASS_COMMON(CLASS_NAME, ENUM_NAME) \
CLASS_NAME(const CLASS_NAME & other) \
{ \
num = other.num; \
} \
CLASS_NAME & operator=(const CLASS_NAME & other) \
{ \
num = other.num; \
return *this; \
} \
explicit CLASS_NAME(si32 id) \
: num(static_cast<ENUM_NAME>(id)) \
{} \
operator ENUM_NAME() const \
{ \
return num; \
} \
ENUM_NAME toEnum() const \
{ \
return num; \
} \
template <typename Handler> void serialize(Handler &h, const int version) \
{ \
h & num; \
} \
CLASS_NAME & advance(int i) \
{ \
num = (ENUM_NAME)((int)num + i); \
return *this; \
}
#define ID_LIKE_OPERATORS_INTERNAL_DECLS(A, B) \
bool DLL_LINKAGE operator==(const A & a, const B & b); \
bool DLL_LINKAGE operator!=(const A & a, const B & b); \
bool DLL_LINKAGE operator<(const A & a, const B & b); \
bool DLL_LINKAGE operator<=(const A & a, const B & b); \
bool DLL_LINKAGE operator>(const A & a, const B & b); \
bool DLL_LINKAGE operator>=(const A & a, const B & b);
#define ID_LIKE_OPERATORS_DECLS(CLASS_NAME, ENUM_NAME) \
ID_LIKE_OPERATORS_INTERNAL_DECLS(CLASS_NAME, CLASS_NAME) \
ID_LIKE_OPERATORS_INTERNAL_DECLS(CLASS_NAME, ENUM_NAME) \
ID_LIKE_OPERATORS_INTERNAL_DECLS(ENUM_NAME, CLASS_NAME)
// Enum declarations
namespace PrimarySkill
{
@ -135,13 +189,15 @@ namespace ETownType
};
}
namespace EBuilding
class BuildingID
{
public:
//Quite useful as long as most of building mechanics hardcoded
// NOTE: all building with completely configurable mechanics will be removed from list
enum EBuilding
enum EBuildingID
{
MAGES_GUILD_1, MAGES_GUILD_2, MAGES_GUILD_3, MAGES_GUILD_4, MAGES_GUILD_5,
NONE = -1,
MAGES_GUILD_1 = 0, MAGES_GUILD_2, MAGES_GUILD_3, MAGES_GUILD_4, MAGES_GUILD_5,
TAVERN, SHIPYARD, FORT, CITADEL, CASTLE,
VILLAGE_HALL, TOWN_HALL, CITY_HALL, CAPITOL, MARKETPLACE,
RESOURCE_SILO, BLACKSMITH, SPECIAL_1, HORDE_1, HORDE_1_UPGR,
@ -188,7 +244,16 @@ namespace EBuilding
//ARTIFACT_MERCHANT - same ID as in tower
MAGIC_UNIVERSITY = SPECIAL_2, // Conflux
};
}
BuildingID(EBuildingID _num = NONE) : num(_num)
{}
ID_LIKE_CLASS_COMMON(BuildingID, EBuildingID)
EBuildingID num;
};
ID_LIKE_OPERATORS_DECLS(BuildingID, BuildingID::EBuildingID)
namespace EBuildingState
{
@ -261,9 +326,10 @@ namespace EWallState
};
}
namespace Obj
class Obj
{
enum Obj
public:
enum EObj
{
NO_OBJ = -1,
ALTAR_OF_SACRIFICE = 2,
@ -402,7 +468,17 @@ namespace Obj
MAGIC_PLAINS2 = 230,
ROCKLANDS = 231,
};
}
Obj(EObj _num = NO_OBJ) : num(_num)
{}
ID_LIKE_CLASS_COMMON(Obj, EObj)
bmap<int, ConstTransitivePtr<CGDefInfo> > & toDefObjInfo() const;
EObj num;
};
ID_LIKE_OPERATORS_DECLS(Obj, Obj::EObj)
namespace SecSkillLevel
{
@ -504,9 +580,10 @@ namespace ArtifactPosition
};
}
namespace ArtifactID
class ArtifactID
{
enum ArtifactID
public:
enum EArtifactID
{
NONE = -1,
SPELLBOOK = 0,
@ -531,11 +608,23 @@ namespace ArtifactID
HARDENED_SHIELD = 154,
SLAVAS_RING_OF_POWER = 155
};
}
namespace CreatureID
ArtifactID(EArtifactID _num = NONE) : num(_num)
{}
DLL_LINKAGE CArtifact * toArtifact() const;
ID_LIKE_CLASS_COMMON(ArtifactID, EArtifactID)
EArtifactID num;
};
ID_LIKE_OPERATORS_DECLS(ArtifactID, ArtifactID::EArtifactID)
class CreatureID
{
enum CreatureID
public:
enum ECreatureID
{
NONE = -1,
CAVALIER = 10,
@ -556,12 +645,26 @@ namespace CreatureID
AMMO_CART = 148,
ARROW_TOWERS = 149
};
}
namespace Spells
CreatureID(ECreatureID _num = NONE) : num(_num)
{}
DLL_LINKAGE CCreature * toCreature() const;
ID_LIKE_CLASS_COMMON(CreatureID, ECreatureID)
ECreatureID num;
};
ID_LIKE_OPERATORS_DECLS(CreatureID, CreatureID::ECreatureID)
class SpellID
{
enum Spells
public:
enum ESpellID
{
PRESET = -2,
NONE = -1,
SUMMON_BOAT=0, SCUTTLE_BOAT=1, VISIONS=2, VIEW_EARTH=3, DISGUISE=4, VIEW_AIR=5,
FLY=6, WATER_WALK=7, DIMENSION_DOOR=8, TOWN_PORTAL=9,
@ -583,12 +686,22 @@ namespace Spells
STONE_GAZE=70, POISON=71, BIND=72, DISEASE=73, PARALYZE=74, AGE=75, DEATH_CLOUD=76, THUNDERBOLT=77,
DISPEL_HELPFUL_SPELLS=78, DEATH_STARE=79, ACID_BREATH_DEFENSE=80, ACID_BREATH_DAMAGE=81
};
}
SpellID(ESpellID _num = NONE) : num(_num)
{}
DLL_LINKAGE CSpell * toSpell() const;
ID_LIKE_CLASS_COMMON(SpellID, ESpellID)
ESpellID num;
};
ID_LIKE_OPERATORS_DECLS(SpellID, SpellID::ESpellID)
// Typedef declarations
typedef si8 TFaction;
typedef si64 TExpType;
typedef ui32 TSpell;
typedef std::pair<ui32, ui32> TDmgRange;
typedef ui8 TBonusType;
typedef si32 TBonusSubtype;
@ -596,3 +709,8 @@ typedef si32 TSlot;
typedef si32 TQuantity;
typedef si32 TArtifactInstanceID;
typedef ui8 TPlayerColor;
#undef ID_LIKE_CLASS_COMMON
#undef ID_LIKE_OPERATORS_DECLS
#undef ID_LIKE_OPERATORS_INTERNAL_DECLS

View File

@ -1356,7 +1356,7 @@ CCreatureTypeLimiter::CCreatureTypeLimiter()
includeUpgrades = false;
}
void CCreatureTypeLimiter::setCreature (CreatureID::CreatureID id)
void CCreatureTypeLimiter::setCreature (CreatureID id)
{
creature = VLC->creh->creatures[id];
}

View File

@ -766,7 +766,7 @@ public:
CCreatureTypeLimiter();
CCreatureTypeLimiter(const CCreature &Creature, bool IncludeUpgrades = true);
void setCreature (CreatureID::CreatureID id);
void setCreature (CreatureID id);
int limit(const BonusLimitationContext &context) const OVERRIDE;

View File

@ -203,7 +203,7 @@ void CPrivilagedInfoCallback::erasePickedArt (si32 id)
}
void CPrivilagedInfoCallback::getAllowedSpells(std::vector<ui16> &out, ui16 level)
void CPrivilagedInfoCallback::getAllowedSpells(std::vector<SpellID> &out, ui16 level)
{
CSpell *spell;
@ -231,7 +231,7 @@ const PlayerState * CGameInfoCallback::getPlayer(TPlayerColor color, bool verbos
return &gs->players[color];
}
const CTown * CGameInfoCallback::getNativeTown(int color) const
const CTown * CGameInfoCallback::getNativeTown(TPlayerColor color) const
{
const PlayerSettings *ps = getPlayerSettings(color);
ERROR_RET_VAL_IF(!ps, "There is no such player!", NULL);
@ -561,21 +561,21 @@ EBuildingState::EBuildingState CGameInfoCallback::canBuildStructure( const CGTow
if (notAllBuilt)
return EBuildingState::PREREQUIRES;
if(ID == EBuilding::CAPITOL)
if(ID == BuildingID::CAPITOL)
{
const PlayerState *ps = getPlayer(t->tempOwner);
if(ps)
{
BOOST_FOREACH(const CGTownInstance *t, ps->towns)
{
if(t->hasBuilt(EBuilding::CAPITOL))
if(t->hasBuilt(BuildingID::CAPITOL))
{
return EBuildingState::HAVE_CAPITAL; //no more than one capitol
}
}
}
}
else if(ID == EBuilding::SHIPYARD)
else if(ID == BuildingID::SHIPYARD)
{
const TerrainTile *tile = getTile(t->bestLocation(), false);
@ -884,9 +884,9 @@ const TeamState * CGameInfoCallback::getTeam( ui8 teamID ) const
return ret;
}
const TeamState * CGameInfoCallback::getPlayerTeam( ui8 teamID ) const
const TeamState * CGameInfoCallback::getPlayerTeam( TPlayerColor color ) const
{
const PlayerState * ps = getPlayer(teamID);
const PlayerState * ps = getPlayer(color);
if (ps)
return getTeam(ps->team);
return NULL;
@ -933,7 +933,7 @@ void IGameEventRealizer::setObjProperty(int objid, int prop, si64 val)
commitPackage(&sob);
}
const CGObjectInstance * IGameCallback::putNewObject(Obj::Obj ID, int subID, int3 pos)
const CGObjectInstance * IGameCallback::putNewObject(Obj ID, int subID, int3 pos)
{
NewObject no;
no.ID = ID; //creature

View File

@ -130,11 +130,11 @@ public:
EBuildingState::EBuildingState canBuildStructure(const CGTownInstance *t, int ID);//// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
std::set<int> getBuildingRequiments(const CGTownInstance *t, int ID);
virtual bool getTownInfo(const CGObjectInstance *town, InfoAboutTown &dest) const;
const CTown *getNativeTown(int color) const;
const CTown *getNativeTown(TPlayerColor color) const;
//from gs
const TeamState *getTeam(ui8 teamID) const;
const TeamState *getPlayerTeam(ui8 color) const;
const TeamState *getPlayerTeam(TPlayerColor color) const;
std::set<int> getBuildingRequiments(const CGTownInstance *t, int ID) const;
EBuildingState::EBuildingState canBuildStructure(const CGTownInstance *t, int ID) const;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
};
@ -160,7 +160,7 @@ public:
int getResourceAmount(Res::ERes type) const;
TResources getResourceAmount() const;
const std::vector< std::vector< std::vector<ui8> > > & getVisibilityMap()const; //returns visibility map
const PlayerSettings * getPlayerSettings(int color) const;
const PlayerSettings * getPlayerSettings(TPlayerColor color) const;
};
class DLL_LINKAGE CPrivilagedInfoCallback : public CGameInfoCallback
@ -174,7 +174,7 @@ public:
ui16 getArtSync (ui32 rand, int flags); //synchronous
void pickAllowedArtsSet(std::vector<const CArtifact*> &out); //gives 3 treasures, 3 minors, 1 major -> used by Black Market and Artifact Merchant
void erasePickedArt (si32 id);
void getAllowedSpells(std::vector<ui16> &out, ui16 level);
void getAllowedSpells(std::vector<SpellID> &out, ui16 level);
};
class DLL_LINKAGE CNonConstInfoCallback : public CPrivilagedInfoCallback
@ -203,7 +203,7 @@ public:
class DLL_LINKAGE IGameEventCallback : public IGameEventRealizer
{
public:
virtual void changeSpells(const CGHeroInstance * hero, bool give, const std::set<ui32> &spells)=0;
virtual void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells)=0;
virtual bool removeObject(const CGObjectInstance * obj)=0;
virtual void setBlockVis(int objid, bool bv)=0;
virtual void setOwner(const CGObjectInstance * objid, TPlayerColor owner)=0;
@ -240,7 +240,7 @@ public:
virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, boost::function<void(BattleResult*)> cb = 0, bool creatureBank = false)=0; //if any of armies is hero, hero will be used
virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, boost::function<void(BattleResult*)> cb = 0, bool creatureBank = false)=0; //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle
virtual void setAmount(int objid, ui32 val)=0;
virtual bool moveHero(si32 hid, int3 dst, ui8 instant, ui8 asker = 255)=0;
virtual bool moveHero(si32 hid, int3 dst, ui8 instant, TPlayerColor asker = GameConstants::NEUTRAL_PLAYER)=0;
virtual void giveHeroBonus(GiveBonus * bonus)=0;
virtual void setMovePoints(SetMovePoints * smp)=0;
virtual void setManaPoints(int hid, int val)=0;
@ -258,7 +258,7 @@ public:
virtual ~IGameCallback(){};
//do sth
const CGObjectInstance *putNewObject(Obj::Obj ID, int subID, int3 pos);
const CGObjectInstance *putNewObject(Obj ID, int subID, int3 pos);
const CGCreature *putNewMonster(int creID, int count, int3 pos);
friend struct CPack;

View File

@ -1055,7 +1055,7 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
const JsonVector vec = limiter["parameters"].Vector();
VLC->modh->identifiers.requestIdentifier(std::string("creature.") + vec[0].String(), [=](si32 creature)
{
l2->setCreature (static_cast<CreatureID::CreatureID>(creature));
l2->setCreature (CreatureID(creature));
});
if (vec.size() > 1)
{

View File

@ -156,16 +156,16 @@ namespace JsonDetail
struct JsonConvImpl;
template <typename T>
struct JsonConvImpl<T, 0>
struct JsonConvImpl<T, 1>
{
static T convertImpl(const JsonNode & node)
{
return (T)(int)node.Float();
return T((int)node.Float());
}
};
template <typename T>
struct JsonConvImpl<T, 1>
struct JsonConvImpl<T, 0>
{
static T convertImpl(const JsonNode & node)
{
@ -179,8 +179,8 @@ namespace JsonDetail
static Type convert(const JsonNode & node)
{
///this should be triggered only for numeric types and enums
static_assert(boost::mpl::or_<std::is_arithmetic<Type>, std::is_enum<Type> >::value, "Unsupported type for JsonNode::convertTo()!");
return JsonConvImpl<Type, std::is_arithmetic<Type>::value>::convertImpl(node);
static_assert(boost::mpl::or_<std::is_arithmetic<Type>, std::is_enum<Type>, boost::is_class<Type> >::value, "Unsupported type for JsonNode::convertTo()!");
return JsonConvImpl<Type, boost::mpl::or_<std::is_enum<Type>, boost::is_class<Type> >::value >::convertImpl(node);
}
};

View File

@ -747,7 +747,7 @@ void CMapLoaderH3M::readDefInfo()
defInfo->terrainAllowed = reader.readUInt16();
defInfo->terrainMenu = reader.readUInt16();
defInfo->id = static_cast<Obj::Obj>(reader.readUInt32());
defInfo->id = Obj(reader.readUInt32());
defInfo->subid = reader.readUInt32();
defInfo->type = reader.readUInt8();
defInfo->printPriority = reader.readUInt8();
@ -854,18 +854,18 @@ void CMapLoaderH3M::readObjects()
{
if(map->version == EMapFormat::ROE)
{
evnt->artifacts.push_back(reader.readUInt8());
evnt->artifacts.push_back(ArtifactID(reader.readUInt8()));
}
else
{
evnt->artifacts.push_back(reader.readUInt16());
evnt->artifacts.push_back(ArtifactID(reader.readUInt16()));
}
}
int gspel = reader.readUInt8(); // Number of gained spells
for(int oo = 0; oo < gspel; ++oo)
{
evnt->spells.push_back(reader.readUInt8());
evnt->spells.push_back(SpellID(reader.readUInt8()));
}
int gcre = reader.readUInt8(); //number of gained creatures
@ -984,7 +984,7 @@ void CMapLoaderH3M::readObjects()
{
if(artID != 0xff)
{
cre->gainedArtifact = static_cast<ArtifactID::ArtifactID>(artID);
cre->gainedArtifact = ArtifactID(artID);
}
else
{
@ -995,7 +995,7 @@ void CMapLoaderH3M::readObjects()
{
if(artID != 0xffff)
{
cre->gainedArtifact = static_cast<ArtifactID::ArtifactID>(artID);
cre->gainedArtifact = ArtifactID(artID);
}
else
{
@ -1200,17 +1200,17 @@ void CMapLoaderH3M::readObjects()
{
if(map->version > EMapFormat::ROE)
{
box->artifacts.push_back(reader.readUInt16());
box->artifacts.push_back(ArtifactID(reader.readUInt16()));
}
else
{
box->artifacts.push_back(reader.readUInt8());
box->artifacts.push_back(ArtifactID(reader.readUInt8()));
}
}
int gspel = reader.readUInt8(); //number of gained spells
for(int oo = 0; oo < gspel; ++oo)
{
box->spells.push_back(reader.readUInt8());
box->spells.push_back(SpellID(reader.readUInt8()));
}
int gcre = reader.readUInt8(); //number of gained creatures
readCreatureSet(&box->creatures, gcre);
@ -1475,16 +1475,16 @@ void CMapLoaderH3M::readCreatureSet(CCreatureSet * out, int number)
for(int ir = 0; ir < number; ++ir)
{
CreatureID::CreatureID creID;
CreatureID creID;
int count;
if (version)
{
creID = static_cast<CreatureID::CreatureID>(reader.readUInt16());
creID = CreatureID(reader.readUInt16());
}
else
{
creID = static_cast<CreatureID::CreatureID>(reader.readUInt8());
creID = CreatureID(reader.readUInt8());
}
count = reader.readUInt16();
@ -1497,7 +1497,7 @@ void CMapLoaderH3M::readCreatureSet(CCreatureSet * out, int number)
if(creID > maxID - 0xf)
{
//this will happen when random object has random army
creID = static_cast<CreatureID::CreatureID>(maxID + 1 - creID + VLC->creh->creatures.size());
creID = CreatureID(maxID + 1 - creID + VLC->creh->creatures.size());
hlp->idRand = creID;
}
else
@ -1639,7 +1639,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(int idToBeGiven)
bool hasCustomSpells = reader.readBool();
if(hasCustomSpells)
{
nhi->spells.insert(0xffffffff); //placeholder "preset spells"
nhi->spells.insert(SpellID::PRESET); //placeholder "preset spells"
readSpells(nhi->spells);
}
@ -1650,10 +1650,10 @@ CGObjectInstance * CMapLoaderH3M::readHero(int idToBeGiven)
ui8 buff = reader.readUInt8();
if(buff != 254)
{
nhi->spells.insert(0xffffffff); //placeholder "preset spells"
nhi->spells.insert(SpellID::PRESET); //placeholder "preset spells"
if(buff < 254) //255 means no spells
{
nhi->spells.insert(buff);
nhi->spells.insert(SpellID(buff));
}
}
}
@ -1904,7 +1904,7 @@ CGTownInstance * CMapLoaderH3M::readTown(int castleID)
bool hasFort = reader.readBool();
if(hasFort)
{
nt->builtBuildings.insert(EBuilding::FORT);
nt->builtBuildings.insert(BuildingID::FORT);
}
//means that set of standard building should be included
@ -2038,20 +2038,20 @@ std::set<si32> CMapLoaderH3M::convertBuildings(const std::set<si32> h3m, int cas
if(addAuxiliary)
{
//village hall is always present
ret.insert(EBuilding::VILLAGE_HALL);
ret.insert(BuildingID::VILLAGE_HALL);
}
if(ret.find(EBuilding::CITY_HALL) != ret.end())
if(ret.find(BuildingID::CITY_HALL) != ret.end())
{
ret.insert(EBuilding::EXTRA_CITY_HALL);
ret.insert(BuildingID::EXTRA_CITY_HALL);
}
if(ret.find(EBuilding::TOWN_HALL) != ret.end())
if(ret.find(BuildingID::TOWN_HALL) != ret.end())
{
ret.insert(EBuilding::EXTRA_TOWN_HALL);
ret.insert(BuildingID::EXTRA_TOWN_HALL);
}
if(ret.find(EBuilding::CAPITOL) != ret.end())
if(ret.find(BuildingID::CAPITOL) != ret.end())
{
ret.insert(EBuilding::EXTRA_CAPITOL);
ret.insert(BuildingID::EXTRA_CAPITOL);
}
return ret;
@ -2102,7 +2102,7 @@ void CMapLoaderH3M::readMessageAndGuards(std::string& message, CCreatureSet* gua
}
void CMapLoaderH3M::readSpells(std::set<TSpell>& dest)
void CMapLoaderH3M::readSpells(std::set<SpellID>& dest)
{
readBitmask(dest,9,GameConstants::SPELLS_QUANTITY,false);
}

View File

@ -215,7 +215,7 @@ private:
*/
void readMessageAndGuards(std::string& message, CCreatureSet * guards);
void readSpells(std::set<TSpell> & dest);
void readSpells(std::set<SpellID> & dest);
void readResourses(TResources& resources);

View File

@ -151,7 +151,7 @@ public:
message.push_back(TREPLACE_PLUSNUMBER);
numbers.push_back(txt);
}
DLL_LINKAGE void addCreReplacement(CreatureID::CreatureID id, TQuantity count); //adds sing or plural name;
DLL_LINKAGE void addCreReplacement(CreatureID id, TQuantity count); //adds sing or plural name;
DLL_LINKAGE void addReplacement(const CStackBasicDescriptor &stack); //adds sing or plural name;
DLL_LINKAGE std::string buildList () const;
void clear()
@ -355,7 +355,7 @@ struct ChangeSpells : public CPackForClient //109
ui8 learn; //1 - gives spell, 0 - takes
ui32 hid;
std::set<ui32> spells;
std::set<SpellID> spells;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -674,7 +674,7 @@ struct SetAvailableCreatures : public CPackForClient //506
DLL_LINKAGE void applyGs(CGameState *gs);
si32 tid;
std::vector<std::pair<ui32, std::vector<CreatureID::CreatureID> > > creatures;
std::vector<std::pair<ui32, std::vector<CreatureID> > > creatures;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -773,7 +773,7 @@ struct NewObject : public CPackForClient //518
void applyCl(CClient *cl);
DLL_LINKAGE void applyGs(CGameState *gs);
Obj::Obj ID;
Obj ID;
ui32 subID;
int3 pos;
@ -1076,7 +1076,7 @@ struct NewTurn : public CPackForClient //101
ui32 day;
bool resetBuilded;
ui8 specialWeek; //weekType
CreatureID::CreatureID creatureid; //for creature weeks
CreatureID creatureid; //for creature weeks
NewTurn(){type = 101;};
@ -1523,7 +1523,7 @@ struct BattleSpellCast : public CPackForClient//3009
BattleHex tile; //destination tile (may not be set in some global/mass spells
std::vector<ui32> resisted; //ids of creatures that resisted this spell
std::set<ui32> affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure)
CreatureID::CreatureID attackerType;//id of caster to generate console message; -1 if not set (eg. spell casted by artifact)
CreatureID attackerType;//id of caster to generate console message; -1 if not set (eg. spell casted by artifact)
bool castedByHero; //if true - spell has been casted by hero, otherwise by a creature
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -1629,7 +1629,7 @@ struct BattleStackAdded : public CPackForClient //3017
void applyCl(CClient *cl);
int attacker; // if true, stack belongs to attacker
CreatureID::CreatureID creID;
CreatureID creID;
int amount;
int pos;
int summoned; //if true, remove it afterwards
@ -1857,9 +1857,9 @@ struct RazeStructure : public BuildStructure
struct RecruitCreatures : public CPackForServer
{
RecruitCreatures(){};
RecruitCreatures(si32 TID, CreatureID::CreatureID CRID, si32 Amount, si32 Level):tid(TID),crid(CRID),amount(Amount),level(Level){};
RecruitCreatures(si32 TID, CreatureID CRID, si32 Amount, si32 Level):tid(TID),crid(CRID),amount(Amount),level(Level){};
si32 tid; //town id
CreatureID::CreatureID crid;
CreatureID crid;
ui32 amount;//creature amount
si32 level;//dwelling level to buy from, -1 if any
bool applyGh(CGameHandler *gh);
@ -1872,10 +1872,10 @@ struct RecruitCreatures : public CPackForServer
struct UpgradeCreature : public CPackForServer
{
UpgradeCreature(){};
UpgradeCreature(ui8 Pos, si32 ID, CreatureID::CreatureID CRID):pos(Pos),id(ID), cid(CRID){};
UpgradeCreature(ui8 Pos, si32 ID, CreatureID CRID):pos(Pos),id(ID), cid(CRID){};
ui8 pos; //stack pos
si32 id; //object id
CreatureID::CreatureID cid; //id of type to which we want make upgrade
CreatureID cid; //id of type to which we want make upgrade
bool applyGh(CGameHandler *gh);
template <typename Handler> void serialize(Handler &h, const int version)
@ -1930,9 +1930,9 @@ struct AssembleArtifacts : public CPackForServer
struct BuyArtifact : public CPackForServer
{
BuyArtifact(){};
BuyArtifact(si32 HID, ArtifactID::ArtifactID AID):hid(HID),aid(AID){};
BuyArtifact(si32 HID, ArtifactID AID):hid(HID),aid(AID){};
si32 hid;
ArtifactID::ArtifactID aid;
ArtifactID aid;
bool applyGh(CGameHandler *gh);
template <typename Handler> void serialize(Handler &h, const int version)
@ -2055,7 +2055,7 @@ struct CastAdvSpell : public CPackForServer
{
CastAdvSpell(){}
si32 hid; //hero id
ui32 sid; //spell id
SpellID sid; //spell id
int3 pos; //selected tile (not always used)
bool applyGh(CGameHandler *gh);

View File

@ -132,10 +132,10 @@ DLL_LINKAGE void ChangeSpells::applyGs( CGameState *gs )
CGHeroInstance *hero = gs->getHero(hid);
if(learn)
BOOST_FOREACH(ui32 sid, spells)
BOOST_FOREACH(auto sid, spells)
hero->spells.insert(sid);
else
BOOST_FOREACH(ui32 sid, spells)
BOOST_FOREACH(auto sid, spells)
hero->spells.erase(sid);
}
@ -537,7 +537,7 @@ DLL_LINKAGE void NewObject::applyGs( CGameState *gs )
cre->character = 2;
cre->gainedArtifact = ArtifactID::NONE;
cre->identifier = -1;
cre->addToSlot(0, new CStackInstance(static_cast<CreatureID::CreatureID>(subID), -1)); //add placeholder stack
cre->addToSlot(0, new CStackInstance(CreatureID(subID), -1)); //add placeholder stack
}
break;
default:
@ -1241,8 +1241,8 @@ DLL_LINKAGE void BattleSpellCast::applyGs( CGameState *gs )
//Handle spells removing effects from stacks
const CSpell *spell = VLC->spellh->spells[id];
const bool removeAllSpells = id == Spells::DISPEL;
const bool removeHelpful = id == Spells::DISPEL_HELPFUL_SPELLS;
const bool removeAllSpells = id == SpellID::DISPEL;
const bool removeHelpful = id == SpellID::DISPEL_HELPFUL_SPELLS;
BOOST_FOREACH(auto stackID, affectedCres)
{
@ -1299,7 +1299,7 @@ DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
CStack *s = gs->curB->getStack(id);
if(s)
{
if(spellid == Spells::DISRUPTING_RAY || spellid == Spells::ACID_BREATH_DEFENSE || !s->hasBonus(Selector::source(Bonus::SPELL_EFFECT, spellid)))//disrupting ray or acid breath or not on the list - just add
if(spellid == SpellID::DISRUPTING_RAY || spellid == SpellID::ACID_BREATH_DEFENSE || !s->hasBonus(Selector::source(Bonus::SPELL_EFFECT, spellid)))//disrupting ray or acid breath or not on the list - just add
{
BOOST_FOREACH(Bonus &fromEffect, effect)
{

View File

@ -316,7 +316,7 @@ void CMapGenerator::genTowns()
town->subID = townTypes[side];
town->tempOwner = owner;
town->defInfo = VLC->dobjinfo->gobjs[town->ID][town->subID];
town->builtBuildings.insert(EBuilding::FORT);
town->builtBuildings.insert(BuildingID::FORT);
town->builtBuildings.insert(-50);
mapMgr->insertObject(town, townPos[side].x, townPos[side].y + (pos / 2) * 5, false);

View File

@ -193,6 +193,7 @@
<ClCompile Include="Filesystem\CLodArchiveLoader.cpp" />
<ClCompile Include="Filesystem\CMemoryStream.cpp" />
<ClCompile Include="Filesystem\CResourceLoader.cpp" />
<ClCompile Include="GameConstants.cpp" />
<ClCompile Include="Mapping\CCampaignHandler.cpp" />
<ClCompile Include="Mapping\CMap.cpp" />
<ClCompile Include="Mapping\CMapInfo.cpp" />

View File

@ -676,10 +676,10 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
iw.text.addReplacement(names.str());
std::set<ui32>::iterator it = cs.spells.begin();
auto it = cs.spells.begin();
for(int i = 0; i < cs.spells.size(); i++, it++)
{
iw.text.addReplacement(MetaString::SPELL_NAME, *it);
iw.text.addReplacement(MetaString::SPELL_NAME, it->toEnum());
if(i == cs.spells.size() - 2) //we just added pre-last name
iw.text.addReplacement(MetaString::GENERAL_TXT, 141); // " and "
iw.components.push_back(Component(Component::SPELL, *it, 0, 0));
@ -1141,7 +1141,7 @@ void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=fa
ui32 dwellpos = rand()%dwellings.size();//take random dwelling
ui32 creapos = rand()%dwellings[dwellpos]->creatures.size();//for multi-creature dwellings like Golem Factory
CreatureID::CreatureID creature = dwellings[dwellpos]->creatures[creapos].second[0];
CreatureID creature = dwellings[dwellpos]->creatures[creapos].second[0];
if (clear)
ssi.creatures[GameConstants::CREATURES_PER_TOWN].first = std::max((ui32)1, (VLC->creh->creatures[creature]->growth)/2);
@ -1184,7 +1184,7 @@ void CGameHandler::newTurn()
bool deityOfFireBuilt = false;
BOOST_FOREACH(const CGTownInstance *t, gs->map->towns)
{
if(t->hasBuilt(EBuilding::GRAIL, ETownType::INFERNO))
if(t->hasBuilt(BuildingID::GRAIL, ETownType::INFERNO))
{
deityOfFireBuilt = true;
break;
@ -1206,7 +1206,7 @@ void CGameHandler::newTurn()
n.specialWeek = NewTurn::DOUBLE_GROWTH;
if (VLC->modh->settings.ALL_CREATURES_GET_DOUBLE_MONTHS)
{
std::pair<int,CreatureID::CreatureID> newMonster(54, VLC->creh->pickRandomMonster(boost::ref(rand)));
std::pair<int,CreatureID> newMonster(54, VLC->creh->pickRandomMonster(boost::ref(rand)));
n.creatureid = newMonster.second;
}
else
@ -1224,7 +1224,7 @@ void CGameHandler::newTurn()
if (monthType < 25)
{
n.specialWeek = NewTurn::BONUS_GROWTH; //+5
std::pair<int, CreatureID::CreatureID> newMonster (54, VLC->creh->pickRandomMonster(boost::ref(rand)));
std::pair<int, CreatureID> newMonster (54, VLC->creh->pickRandomMonster(boost::ref(rand)));
//TODO do not pick neutrals
n.creatureid = newMonster.second;
}
@ -1277,7 +1277,7 @@ void CGameHandler::newTurn()
hth.id = h->id;
hth.move = h->maxMovePoints(gs->map->getTile(h->getPosition(false)).terType != ETerrainType::WATER);
if(h->visitedTown && h->visitedTown->hasBuilt(EBuilding::MAGES_GUILD_1)) //if hero starts turn in town with mage guild
if(h->visitedTown && h->visitedTown->hasBuilt(BuildingID::MAGES_GUILD_1)) //if hero starts turn in town with mage guild
hth.mana = std::max(h->mana, h->manaLimit()); //restore all mana
else
hth.mana = std::max((si32)(0), std::max(h->mana, std::min((si32)(h->mana + h->manaRegain()), h->manaLimit())));
@ -1304,11 +1304,11 @@ void CGameHandler::newTurn()
handleTownEvents(t, n, newCreas);
if(newWeek) //first day of week
{
if(t->hasBuilt(EBuilding::PORTAL_OF_SUMMON, ETownType::DUNGEON))
if(t->hasBuilt(BuildingID::PORTAL_OF_SUMMON, ETownType::DUNGEON))
setPortalDwelling(t, true, (n.specialWeek == NewTurn::PLAGUE ? true : false)); //set creatures for Portal of Summoning
if(!firstTurn)
if (t->hasBuilt(EBuilding::TREASURY, ETownType::RAMPART) && player < GameConstants::PLAYER_LIMIT)
if (t->hasBuilt(BuildingID::TREASURY, ETownType::RAMPART) && player < GameConstants::PLAYER_LIMIT)
n.res[player][Res::GOLD] += hadGold[player]/10; //give 10% of starting gold
SetAvailableCreatures sac;
@ -1353,7 +1353,7 @@ void CGameHandler::newTurn()
}
if(!firstTurn && player < GameConstants::PLAYER_LIMIT)//not the first day and town not neutral
{
if(t->hasBuilt(EBuilding::RESOURCE_SILO)) //there is resource silo
if(t->hasBuilt(BuildingID::RESOURCE_SILO)) //there is resource silo
{
if(t->town->primaryRes == 127) //we'll give wood and ore
{
@ -1368,7 +1368,7 @@ void CGameHandler::newTurn()
n.res[player][Res::GOLD] += t->dailyIncome();
}
if(t->hasBuilt(EBuilding::GRAIL, ETownType::TOWER))
if(t->hasBuilt(BuildingID::GRAIL, ETownType::TOWER))
{
// Skyship, probably easier to handle same as Veil of darkness
//do it every new day after veils apply
@ -1628,9 +1628,9 @@ void CGameHandler::giveSpells( const CGTownInstance *t, const CGHeroInstance *h
cs.learn = true;
for(int i=0; i<std::min(t->mageGuildLevel(),h->getSecSkillLevel(SecondarySkill::WISDOM)+2);i++)
{
if (t->hasBuilt(EBuilding::GRAIL, ETownType::CONFLUX)) //Aurora Borealis
if (t->hasBuilt(BuildingID::GRAIL, ETownType::CONFLUX)) //Aurora Borealis
{
std::vector<ui16> spells;
std::vector<SpellID> spells;
getAllowedSpells(spells, i);
for (int j = 0; j < spells.size(); ++j)
cs.spells.insert(spells[j]);
@ -1846,9 +1846,9 @@ bool CGameHandler::teleportHero(si32 hid, si32 dstid, ui8 source, TPlayerColor a
const CGTownInstance *from = h->visitedTown;
if(((h->getOwner() != t->getOwner())
&& complain("Cannot teleport hero to another player"))
|| ((!from || from->hasBuilt(EBuilding::CASTLE_GATE, ETownType::INFERNO))
|| ((!from || from->hasBuilt(BuildingID::CASTLE_GATE, ETownType::INFERNO))
&& complain("Hero must be in town with Castle gate for teleporting"))
|| (t->hasBuilt(EBuilding::CASTLE_GATE, ETownType::INFERNO)
|| (t->hasBuilt(BuildingID::CASTLE_GATE, ETownType::INFERNO)
&& complain("Cannot teleport hero to town without Castle gate in it")))
return false;
int3 pos = t->visitablePos();
@ -1867,7 +1867,7 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, TPlayerColor owner)
if(owner < GameConstants::PLAYER_LIMIT && dynamic_cast<const CGTownInstance *>(obj)) //town captured
{
const CGTownInstance * town = dynamic_cast<const CGTownInstance *>(obj);
if (town->hasBuilt(EBuilding::PORTAL_OF_SUMMON, ETownType::DUNGEON))
if (town->hasBuilt(BuildingID::PORTAL_OF_SUMMON, ETownType::DUNGEON))
setPortalDwelling(town, true, false);
if (!gs->getPlayer(owner)->towns.size())//player lost last town
@ -1885,7 +1885,7 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, TPlayerColor owner)
{
BOOST_FOREACH(const CGTownInstance *t, gs->getPlayer(owner)->towns)
{
if (t->hasBuilt(EBuilding::PORTAL_OF_SUMMON, ETownType::DUNGEON))
if (t->hasBuilt(BuildingID::PORTAL_OF_SUMMON, ETownType::DUNGEON))
setPortalDwelling(t);//set initial creatures for all portals of summoning
}
}
@ -2052,7 +2052,7 @@ void CGameHandler::startBattleI( const CArmedInstance *army1, const CArmedInstan
startBattleI(army1, army2, army2->visitablePos(), cb, creatureBank);
}
void CGameHandler::changeSpells( const CGHeroInstance * hero, bool give, const std::set<ui32> &spells )
void CGameHandler::changeSpells( const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells )
{
ChangeSpells cs;
cs.hid = hero->id;
@ -2125,17 +2125,17 @@ void CGameHandler::useScholarSkill(si32 fromHero, si32 toHero)
ChangeSpells cs1;
cs1.learn = true;
cs1.hid = toHero;//giving spells to first hero
for(std::set<ui32>::const_iterator it=h1->spells.begin(); it!=h1->spells.end();it++)
if ( h2Lvl >= VLC->spellh->spells[*it]->level && !vstd::contains(h2->spells, *it))//hero can learn it and don't have it yet
cs1.spells.insert(*it);//spell to learn
BOOST_FOREACH(auto it, h1->spells)
if ( h2Lvl >= it.toSpell()->level && !vstd::contains(h2->spells, it))//hero can learn it and don't have it yet
cs1.spells.insert(it);//spell to learn
ChangeSpells cs2;
cs2.learn = true;
cs2.hid = fromHero;
for(std::set<ui32>::const_iterator it=h2->spells.begin(); it!=h2->spells.end();it++)
if ( h1Lvl >= VLC->spellh->spells[*it]->level && !vstd::contains(h1->spells, *it))
cs2.spells.insert(*it);
BOOST_FOREACH(auto it, h2->spells)
if ( h1Lvl >= it.toSpell()->level && !vstd::contains(h1->spells, it))
cs2.spells.insert(it);
if (cs1.spells.size() || cs2.spells.size())//create a message
{
@ -2150,10 +2150,10 @@ void CGameHandler::useScholarSkill(si32 fromHero, si32 toHero)
{
iw.text.addTxt(MetaString::GENERAL_TXT, 140);//learns
int size = cs2.spells.size();
for(std::set<ui32>::const_iterator it=cs2.spells.begin(); it!=cs2.spells.end();it++)
BOOST_FOREACH(auto it, cs2.spells)
{
iw.components.push_back(Component(Component::SPELL, (*it), 1, 0));
iw.text.addTxt(MetaString::SPELL_NAME, (*it));
iw.components.push_back(Component(Component::SPELL, it, 1, 0));
iw.text.addTxt(MetaString::SPELL_NAME, it.toEnum());
switch (size--)
{
case 2: iw.text.addTxt(MetaString::GENERAL_TXT, 141);
@ -2175,10 +2175,10 @@ void CGameHandler::useScholarSkill(si32 fromHero, si32 toHero)
{
iw.text.addTxt(MetaString::GENERAL_TXT, 147);//teaches
int size = cs1.spells.size();
for(std::set<ui32>::const_iterator it=cs1.spells.begin(); it!=cs1.spells.end();it++)
BOOST_FOREACH(auto it, cs1.spells)
{
iw.components.push_back(Component(Component::SPELL, (*it), 1, 0));
iw.text.addTxt(MetaString::SPELL_NAME, (*it));
iw.components.push_back(Component(Component::SPELL, it, 1, 0));
iw.text.addTxt(MetaString::SPELL_NAME, it.toEnum());
switch (size--)
{
case 2: iw.text.addTxt(MetaString::GENERAL_TXT, 141);
@ -2496,10 +2496,10 @@ bool CGameHandler::buildStructure( si32 tid, si32 bid, bool force /*=false*/ )
NewStructures ns;
ns.tid = tid;
if(bid >= EBuilding::DWELL_FIRST) //dwelling
if(bid >= BuildingID::DWELL_FIRST) //dwelling
{
int level = (bid - EBuilding::DWELL_FIRST) % GameConstants::CREATURES_PER_TOWN;
int upgradeNumber = (bid - EBuilding::DWELL_FIRST) / GameConstants::CREATURES_PER_TOWN;
int level = (bid - BuildingID::DWELL_FIRST) % GameConstants::CREATURES_PER_TOWN;
int upgradeNumber = (bid - BuildingID::DWELL_FIRST) / GameConstants::CREATURES_PER_TOWN;
if (upgradeNumber >= t->town->creatures[level].size())
COMPLAIN_RET("Cannot build dwelling: no creature found!");
@ -2509,12 +2509,12 @@ bool CGameHandler::buildStructure( si32 tid, si32 bid, bool force /*=false*/ )
SetAvailableCreatures ssi;
ssi.tid = tid;
ssi.creatures = t->creatures;
if (bid <= EBuilding::DWELL_LAST)
if (bid <= BuildingID::DWELL_LAST)
ssi.creatures[level].first = crea->growth;
ssi.creatures[level].second.push_back(crea->idNumber);
sendAndApply(&ssi);
}
else if ( t->subID == ETownType::DUNGEON && bid == EBuilding::PORTAL_OF_SUMMON )
else if ( t->subID == ETownType::DUNGEON && bid == BuildingID::PORTAL_OF_SUMMON )
{
setPortalDwelling(t);
}
@ -2604,7 +2604,7 @@ void CGameHandler::sendMessageToAll( const std::string &message )
sendToAllClients(&sm);
}
bool CGameHandler::recruitCreatures( si32 objid, CreatureID::CreatureID crid, ui32 cram, si32 fromLvl )
bool CGameHandler::recruitCreatures( si32 objid, CreatureID crid, ui32 cram, si32 fromLvl )
{
const CGDwelling *dw = static_cast<CGDwelling*>(gs->map->objects[objid].get());
const CArmedInstance *dst = NULL;
@ -2923,13 +2923,13 @@ bool CGameHandler::assembleArtifacts (si32 heroID, ArtifactPosition::ArtifactPos
return false;
}
bool CGameHandler::buyArtifact( ui32 hid, ArtifactID::ArtifactID aid )
bool CGameHandler::buyArtifact( ui32 hid, ArtifactID aid )
{
CGHeroInstance *hero = gs->getHero(hid);
CGTownInstance *town = hero->visitedTown;
if(aid==ArtifactID::SPELLBOOK)
{
if((!town->hasBuilt(EBuilding::MAGES_GUILD_1) && complain("Cannot buy a spellbook, no mage guild in the town!"))
if((!town->hasBuilt(BuildingID::MAGES_GUILD_1) && complain("Cannot buy a spellbook, no mage guild in the town!"))
|| (getResource(hero->getOwner(), Res::GOLD) < GameConstants::SPELLBOOK_GOLD_COST && complain("Cannot buy a spellbook, not enough gold!") )
|| (hero->getArt(ArtifactPosition::SPELLBOOK) && complain("Cannot buy a spellbook, hero already has a one!"))
)
@ -2950,8 +2950,8 @@ bool CGameHandler::buyArtifact( ui32 hid, ArtifactID::ArtifactID aid )
{
return false;
}
if ((town->hasBuilt(EBuilding::BLACKSMITH) && town->town->warMachine == aid )
|| ((town->hasBuilt(EBuilding::BALLISTA_YARD, ETownType::STRONGHOLD)) && aid == ArtifactID::BALLISTA))
if ((town->hasBuilt(BuildingID::BLACKSMITH) && town->town->warMachine == aid )
|| ((town->hasBuilt(BuildingID::BALLISTA_YARD, ETownType::STRONGHOLD)) && aid == ArtifactID::BALLISTA))
{
giveResource(hero->getOwner(),Res::GOLD,-price);
giveHeroNewArtifact(hero, VLC->arth->artifacts[aid], static_cast<ArtifactPosition::ArtifactPosition>(9+aid));
@ -2963,7 +2963,7 @@ bool CGameHandler::buyArtifact( ui32 hid, ArtifactID::ArtifactID aid )
return false;
}
bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, Res::ERes rid, ArtifactID::ArtifactID aid)
bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, Res::ERes rid, ArtifactID aid)
{
if(!vstd::contains(m->availableItemsIds(EMarketMode::RESOURCE_ARTIFACT), aid))
COMPLAIN_RET("That artifact is unavailable!");
@ -3202,7 +3202,7 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, TPlayerColor p
if(t) //tavern in town
{
if( (!t->hasBuilt(EBuilding::TAVERN) && complain("No tavern!"))
if( (!t->hasBuilt(BuildingID::TAVERN) && complain("No tavern!"))
|| (t->visitingHero && complain("There is visiting hero - no place!")))
return false;
}
@ -3698,8 +3698,8 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
BattleStackAdded bsa;
bsa.attacker = summoner->attackerOwned;
bsa.creID = static_cast<CreatureID::CreatureID>(summoner->getBonusLocalFirst(Selector::type(Bonus::DAEMON_SUMMONING))->subtype); //in case summoner can summon more than one type of monsters... scream!
ui64 risedHp = summoner->count * summoner->valOfBonuses(Bonus::DAEMON_SUMMONING, bsa.creID);
bsa.creID = CreatureID(summoner->getBonusLocalFirst(Selector::type(Bonus::DAEMON_SUMMONING))->subtype); //in case summoner can summon more than one type of monsters... scream!
ui64 risedHp = summoner->count * summoner->valOfBonuses(Bonus::DAEMON_SUMMONING, bsa.creID.toEnum());
bsa.amount = std::min ((ui32)(risedHp / VLC->creh->creatures[bsa.creID]->MaxHealth()), destStack->baseAmount);
bsa.pos = gs->curB->getAvaliableHex(bsa.creID, bsa.attacker, destStack->position);
@ -3783,10 +3783,10 @@ void CGameHandler::playerMessage( TPlayerColor player, const std::string &messag
//give all spells
cs.learn = 1;
for(int i=0;i<VLC->spellh->spells.size();i++)
BOOST_FOREACH(auto spell, VLC->spellh->spells)
{
if(!VLC->spellh->spells[i]->creatureAbility)
cs.spells.insert(i);
if(!spell->creatureAbility)
cs.spells.insert(spell->id);
}
//give mana
@ -3926,22 +3926,22 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
auto obstacle = make_shared<SpellCreatedObstacle>();
switch(spellID) // :/
{
case Spells::QUICKSAND:
case SpellID::QUICKSAND:
obstacle->obstacleType = CObstacleInstance::QUICKSAND;
obstacle->turnsRemaining = -1;
obstacle->visibleForAnotherSide = false;
break;
case Spells::LAND_MINE:
case SpellID::LAND_MINE:
obstacle->obstacleType = CObstacleInstance::LAND_MINE;
obstacle->turnsRemaining = -1;
obstacle->visibleForAnotherSide = false;
break;
case Spells::FIRE_WALL:
case SpellID::FIRE_WALL:
obstacle->obstacleType = CObstacleInstance::FIRE_WALL;
obstacle->turnsRemaining = 2;
obstacle->visibleForAnotherSide = true;
break;
case Spells::FORCE_FIELD:
case SpellID::FORCE_FIELD:
obstacle->obstacleType = CObstacleInstance::FORCE_FIELD;
obstacle->turnsRemaining = 2;
obstacle->visibleForAnotherSide = true;
@ -4028,10 +4028,10 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
continue;
sc.dmgToDisplay += gs->curB->calculateSpellDmg(spell, caster, *it, spellLvl, usedSpellPower);
}
if (spellID == Spells::DEATH_STARE || spellID == Spells::ACID_BREATH_DAMAGE)
if (spellID == SpellID::DEATH_STARE || spellID == SpellID::ACID_BREATH_DAMAGE)
{
sc.dmgToDisplay = usedSpellPower;
if (spellID == Spells::DEATH_STARE)
if (spellID == SpellID::DEATH_STARE)
vstd::amin(sc.dmgToDisplay, (*attackedCres.begin())->count); //stack is already reduced after attack
}
StacksInjured si;
@ -4080,7 +4080,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
(*it)->prepareAttacked(bsa);
si.stacks.push_back(bsa);
if (spellID == Spells::CHAIN_LIGHTNING)
if (spellID == SpellID::CHAIN_LIGHTNING)
++chainLightningModifier;
}
}
@ -4097,11 +4097,11 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
pseudoBonus.val = spellLvl;
pseudoBonus.turnsRemain = gs->curB->calculateSpellDuration(spell, caster, stackSpellPower ? stackSpellPower : usedSpellPower);
CStack::stackEffectToFeature(sse.effect, pseudoBonus);
if (spellID == Spells::SHIELD || spellID == Spells::AIR_SHIELD)
if (spellID == SpellID::SHIELD || spellID == SpellID::AIR_SHIELD)
{
sse.effect.back().val = (100 - sse.effect.back().val); //fix to original config: shiled should display damage reduction
}
if (spellID == Spells::BIND && stack)//bind
if (spellID == SpellID::BIND && stack)//bind
{
sse.effect.back().additionalInfo = stack->ID; //we need to know who casted Bind
}
@ -4166,7 +4166,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
sendAndApply(&sse);
}
else if (spell->isRisingSpell() || spell->id == Spells::CURE)
else if (spell->isRisingSpell() || spell->id == SpellID::CURE)
{
int hpGained = 0;
if (stack)
@ -4183,7 +4183,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
for(auto it = attackedCres.begin(); it != attackedCres.end(); ++it)
{
if(vstd::contains(sc.resisted, (*it)->ID) //this creature resisted the spell
|| (spellID == Spells::ANIMATE_DEAD && !(*it)->hasBonusOfType(Bonus::UNDEAD)) //we try to cast animate dead on living stack, TODO: showuld be not affected earlier
|| (spellID == SpellID::ANIMATE_DEAD && !(*it)->hasBonusOfType(Bonus::UNDEAD)) //we try to cast animate dead on living stack, TODO: showuld be not affected earlier
)
continue;
StacksHealedOrResurrected::HealInfo hi;
@ -4204,7 +4204,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
}
if(!shr.healedStacks.empty())
sendAndApply(&shr);
if (spellID == Spells::SACRIFICE) //remove victim
if (spellID == SpellID::SACRIFICE) //remove victim
{
BattleStacksRemoved bsr;
bsr.stackIDs.insert (selectedStack); //somehow it works for teleport?
@ -4214,8 +4214,8 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
else
switch (spellID)
{
case Spells::QUICKSAND:
case Spells::LAND_MINE:
case SpellID::QUICKSAND:
case SpellID::LAND_MINE:
{
std::vector<BattleHex> availableTiles;
for(int i = 0; i < GameConstants::BFIELD_SIZE; i += 1)
@ -4235,10 +4235,10 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
}
break;
case Spells::FORCE_FIELD:
case SpellID::FORCE_FIELD:
placeObstacle(destination);
break;
case Spells::FIRE_WALL:
case SpellID::FIRE_WALL:
{
//fire wall is build from multiple obstacles - one fire piece for each affected hex
auto affectedHexes = spell->rangeInHexes(destination, spellLvl, casterSide);
@ -4246,7 +4246,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
placeObstacle(hex);
}
break;
case Spells::TELEPORT:
case SpellID::TELEPORT:
{
BattleStackMoved bsm;
bsm.distance = -1;
@ -4258,24 +4258,24 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
sendAndApply(&bsm);
break;
}
case Spells::SUMMON_FIRE_ELEMENTAL:
case Spells::SUMMON_EARTH_ELEMENTAL:
case Spells::SUMMON_WATER_ELEMENTAL:
case Spells::SUMMON_AIR_ELEMENTAL:
case SpellID::SUMMON_FIRE_ELEMENTAL:
case SpellID::SUMMON_EARTH_ELEMENTAL:
case SpellID::SUMMON_WATER_ELEMENTAL:
case SpellID::SUMMON_AIR_ELEMENTAL:
{ //elemental summoning
CreatureID::CreatureID creID;
CreatureID creID;
switch(spellID)
{
case Spells::SUMMON_FIRE_ELEMENTAL:
case SpellID::SUMMON_FIRE_ELEMENTAL:
creID = CreatureID::FIRE_ELEMENTAL;
break;
case Spells::SUMMON_EARTH_ELEMENTAL:
case SpellID::SUMMON_EARTH_ELEMENTAL:
creID = CreatureID::EARTH_ELEMENTAL;
break;
case Spells::SUMMON_WATER_ELEMENTAL:
case SpellID::SUMMON_WATER_ELEMENTAL:
creID = CreatureID::WATER_ELEMENTAL;
break;
case Spells::SUMMON_AIR_ELEMENTAL:
case SpellID::SUMMON_AIR_ELEMENTAL:
creID = CreatureID::AIR_ELEMENTAL;
break;
}
@ -4297,7 +4297,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
complain("Summoning elementals didn't summon any!");
}
break;
case Spells::CLONE:
case SpellID::CLONE:
{
const CStack * clonedStack = NULL;
if (attackedCres.size())
@ -4324,7 +4324,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
sendAndApply(&ssp);
}
break;
case Spells::REMOVE_OBSTACLE:
case SpellID::REMOVE_OBSTACLE:
{
ObstaclesRemoved obr;
BOOST_FOREACH(auto &obstacle, battleGetAllObstacles())
@ -4340,7 +4340,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
break;
}
break;
case Spells::DEATH_STARE: //handled in a bit different way
case SpellID::DEATH_STARE: //handled in a bit different way
{
for(auto it = attackedCres.begin(); it != attackedCres.end(); ++it)
{
@ -4361,7 +4361,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
}
}
break;
case Spells::ACID_BREATH_DAMAGE: //new effect, separate from acid breath defense reduction
case SpellID::ACID_BREATH_DAMAGE: //new effect, separate from acid breath defense reduction
{
for(auto it = attackedCres.begin(); it != attackedCres.end(); ++it) //no immunities
{
@ -4440,7 +4440,7 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
}
const CSpell *s = VLC->spellh->spells[ba.additionalInfo];
if (s->mainEffectAnim > -1 || (s->id >= 66 || s->id <= 69) || s->id == Spells::CLONE) //allow summon elementals
if (s->mainEffectAnim > -1 || (s->id >= 66 || s->id <= 69) || s->id == SpellID::CLONE) //allow summon elementals
//TODO: special effects, like Clone
{
ui8 skill = h->getSpellSchoolLevel(s); //skill level
@ -4536,7 +4536,7 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
if(st->hasBonusOfType(Bonus::POISON))
{
const Bonus * b = st->getBonusLocalFirst(Selector::source(Bonus::SPELL_EFFECT, Spells::POISON) && Selector::type(Bonus::STACK_HEALTH));
const Bonus * b = st->getBonusLocalFirst(Selector::source(Bonus::SPELL_EFFECT, SpellID::POISON) && Selector::type(Bonus::STACK_HEALTH));
if (b) //TODO: what if not?...
{
bte.val = std::max (b->val - 10, -(st->valOfBonuses(Bonus::POISON)));
@ -4653,14 +4653,14 @@ void CGameHandler::handleDamageFromObstacle(const CObstacleInstance &obstacle, c
oneTimeObstacle = true;
effect = 82; //makes
damage = gs->curB->calculateSpellDmg(VLC->spellh->spells[Spells::LAND_MINE], hero, curStack,
damage = gs->curB->calculateSpellDmg(VLC->spellh->spells[SpellID::LAND_MINE], hero, curStack,
spellObstacle->spellLevel, spellObstacle->casterSpellPower);
//TODO even if obstacle wasn't created by hero (Tower "moat") it should deal dmg as if casted by hero,
//if it is bigger than default dmg. Or is it just irrelevant H3 implementation quirk
}
else if(obstacle.obstacleType == CObstacleInstance::FIRE_WALL)
{
damage = gs->curB->calculateSpellDmg(VLC->spellh->spells[Spells::FIRE_WALL], hero, curStack,
damage = gs->curB->calculateSpellDmg(VLC->spellh->spells[SpellID::FIRE_WALL], hero, curStack,
spellObstacle->spellLevel, spellObstacle->casterSpellPower);
}
else
@ -4947,7 +4947,7 @@ bool CGameHandler::buildBoat( ui32 objid )
return false;
}
else if(obj->o->ID == Obj::TOWN
&& !static_cast<const CGTownInstance*>(obj)->hasBuilt(EBuilding::SHIPYARD))
&& !static_cast<const CGTownInstance*>(obj)->hasBuilt(BuildingID::SHIPYARD))
{
complain("Cannot build boat in the town - no shipyard!");
return false;
@ -5354,7 +5354,7 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
if (staredCreatures)
{
if (bat.bsa.size() && bat.bsa[0].newAmount > 0) //TODO: death stare was not originally available for multiple-hex attacks, but...
handleSpellCasting(Spells::DEATH_STARE, 0, gs->curB->battleGetStackByID(bat.bsa[0].stackAttacked)->position,
handleSpellCasting(SpellID::DEATH_STARE, 0, gs->curB->battleGetStackByID(bat.bsa[0].stackAttacked)->position,
!attacker->attackerOwned, attacker->owner, NULL, NULL, staredCreatures, ECastingMode::AFTER_ATTACK_CASTING, attacker);
}
}
@ -5368,15 +5368,15 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
}
if (acidDamage)
{
handleSpellCasting(Spells::ACID_BREATH_DAMAGE, 0, gs->curB->battleGetStackByID(bat.bsa[0].stackAttacked)->position,
handleSpellCasting(SpellID::ACID_BREATH_DAMAGE, 0, gs->curB->battleGetStackByID(bat.bsa[0].stackAttacked)->position,
!attacker->attackerOwned, attacker->owner, NULL, NULL,
acidDamage * attacker->count, ECastingMode::AFTER_ATTACK_CASTING, attacker);
}
}
bool CGameHandler::castSpell(const CGHeroInstance *h, int spellID, const int3 &pos)
bool CGameHandler::castSpell(const CGHeroInstance *h, SpellID spellID, const int3 &pos)
{
const CSpell *s = VLC->spellh->spells[spellID];
const CSpell *s = spellID.toSpell();
int cost = h->getSpellCost(s);
int schoolLevel = h->getSpellSchoolLevel(s);
@ -5392,10 +5392,9 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, int spellID, const int3 &p
asc.spellID = spellID;
sendAndApply(&asc);
using namespace Spells;
switch(spellID)
{
case SUMMON_BOAT: //Summon Boat
case SpellID::SUMMON_BOAT:
{
//check if spell works at all
if(rand() % 100 >= s->powers[schoolLevel]) //power is % chance of success
@ -5457,7 +5456,7 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, int spellID, const int3 &p
break;
}
case SCUTTLE_BOAT: //Scuttle Boat
case SpellID::SCUTTLE_BOAT:
{
//check if spell works at all
if(rand() % 100 >= s->powers[schoolLevel]) //power is % chance of success
@ -5482,7 +5481,7 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, int spellID, const int3 &p
sendAndApply(&ro);
break;
}
case DIMENSION_DOOR: //Dimension Door
case SpellID::DIMENSION_DOOR:
{
const TerrainTile *dest = getTile(pos);
const TerrainTile *curr = getTile(h->getSightCenter());
@ -5491,7 +5490,7 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, int spellID, const int3 &p
COMPLAIN_RET("Destination tile doesn't exist!");
if(!h->movement)
COMPLAIN_RET("Hero needs movement points to cast Dimension Door!");
if(h->getBonusesCount(Bonus::SPELL_EFFECT, DIMENSION_DOOR) >= s->powers[schoolLevel]) //limit casts per turn
if(h->getBonusesCount(Bonus::SPELL_EFFECT, SpellID::DIMENSION_DOOR) >= s->powers[schoolLevel]) //limit casts per turn
{
InfoWindow iw;
iw.player = h->tempOwner;
@ -5503,7 +5502,7 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, int spellID, const int3 &p
GiveBonus gb;
gb.id = h->id;
gb.bonus = Bonus(Bonus::ONE_DAY, Bonus::NONE, Bonus::SPELL_EFFECT, 0, DIMENSION_DOOR);
gb.bonus = Bonus(Bonus::ONE_DAY, Bonus::NONE, Bonus::SPELL_EFFECT, 0, SpellID::DIMENSION_DOOR);
sendAndApply(&gb);
if(!dest->isClear(curr)) //wrong dest tile
@ -5524,28 +5523,28 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, int spellID, const int3 &p
}
}
break;
case FLY: //Fly
case SpellID::FLY:
{
int subtype = schoolLevel >= 2 ? 1 : 2; //adv or expert
GiveBonus gb;
gb.id = h->id;
gb.bonus = Bonus(Bonus::ONE_DAY, Bonus::FLYING_MOVEMENT, Bonus::SPELL_EFFECT, 0, FLY, subtype);
gb.bonus = Bonus(Bonus::ONE_DAY, Bonus::FLYING_MOVEMENT, Bonus::SPELL_EFFECT, 0, SpellID::FLY, subtype);
sendAndApply(&gb);
}
break;
case WATER_WALK: //Water Walk
case SpellID::WATER_WALK:
{
int subtype = schoolLevel >= 2 ? 1 : 2; //adv or expert
GiveBonus gb;
gb.id = h->id;
gb.bonus = Bonus(Bonus::ONE_DAY, Bonus::WATER_WALKING, Bonus::SPELL_EFFECT, 0, WATER_WALK, subtype);
gb.bonus = Bonus(Bonus::ONE_DAY, Bonus::WATER_WALKING, Bonus::SPELL_EFFECT, 0, SpellID::WATER_WALK, subtype);
sendAndApply(&gb);
}
break;
case TOWN_PORTAL: //Town Portal
case SpellID::TOWN_PORTAL:
{
if (!gs->map->isInTheMap(pos))
COMPLAIN_RET("Destination tile not present!")
@ -5579,10 +5578,10 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, int spellID, const int3 &p
}
break;
case VISIONS: //Visions
case VIEW_EARTH: //View Earth
case DISGUISE: //Disguise
case VIEW_AIR: //View Air
case SpellID::VISIONS:
case SpellID::VIEW_EARTH:
case SpellID::DISGUISE:
case SpellID::VIEW_AIR:
default:
COMPLAIN_RET("This spell is not implemented yet!");
break;
@ -6143,7 +6142,7 @@ void CGameHandler::commitPackage( CPackForClient *pack )
sendAndApply(pack);
}
void CGameHandler::spawnWanderingMonsters(CreatureID::CreatureID creatureID)
void CGameHandler::spawnWanderingMonsters(CreatureID creatureID)
{
std::vector<int3>::iterator tile;
std::vector<int3> tiles;

View File

@ -129,7 +129,7 @@ public:
//////////////////////////////////////////////////////////////////////////
//from IGameCallback
//do sth
void changeSpells(const CGHeroInstance * hero, bool give, const std::set<ui32> &spells) OVERRIDE;
void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells) OVERRIDE;
bool removeObject(const CGObjectInstance * obj) OVERRIDE;
void setBlockVis(int objid, bool bv) OVERRIDE;
void setOwner(const CGObjectInstance * obj, TPlayerColor owner) OVERRIDE;
@ -214,14 +214,14 @@ public:
bool sellCreatures(ui32 count, const IMarket *market, const CGHeroInstance * hero, ui32 slot, Res::ERes resourceID);
bool transformInUndead(const IMarket *market, const CGHeroInstance * hero, ui32 slot);
bool assembleArtifacts (si32 heroID, ArtifactPosition::ArtifactPosition artifactSlot, bool assemble, ui32 assembleTo);
bool buyArtifact( ui32 hid, ArtifactID::ArtifactID aid ); //for blacksmith and mage guild only -> buying for gold in common buildings
bool buyArtifact( const IMarket *m, const CGHeroInstance *h, Res::ERes rid, ArtifactID::ArtifactID aid); //for artifact merchant and black market -> buying for any resource in special building / advobject
bool buyArtifact( ui32 hid, ArtifactID aid ); //for blacksmith and mage guild only -> buying for gold in common buildings
bool buyArtifact( const IMarket *m, const CGHeroInstance *h, Res::ERes rid, ArtifactID aid); //for artifact merchant and black market -> buying for any resource in special building / advobject
bool sellArtifact( const IMarket *m, const CGHeroInstance *h, TArtifactInstanceID aid, Res::ERes rid); //for artifact merchant selling
//void lootArtifacts (TArtHolder source, TArtHolder dest, std::vector<ui32> &arts); //after battle - move al arts to winer
bool buySecSkill( const IMarket *m, const CGHeroInstance *h, SecondarySkill::SecondarySkill skill);
bool garrisonSwap(si32 tid);
bool upgradeCreature( ui32 objid, ui8 pos, ui32 upgID );
bool recruitCreatures(si32 objid, CreatureID::CreatureID crid, ui32 cram, si32 level);
bool recruitCreatures(si32 objid, CreatureID crid, ui32 cram, si32 level);
bool buildStructure(si32 tid, si32 bid, bool force=false);//force - for events: no cost, no checkings
bool razeStructure(si32 tid, si32 bid);
bool disbandCreature( si32 id, ui8 pos );
@ -234,7 +234,7 @@ public:
void objectVisited( const CGObjectInstance * obj, const CGHeroInstance * h );
void engageIntoBattle( TPlayerColor player );
bool dig(const CGHeroInstance *h);
bool castSpell(const CGHeroInstance *h, int spellID, const int3 &pos);
bool castSpell(const CGHeroInstance *h, SpellID spellID, const int3 &pos);
void moveArmy(const CArmedInstance *src, const CArmedInstance *dst, bool allowMerging);
template <typename Handler> void serialize(Handler &h, const int version)
@ -262,7 +262,7 @@ public:
void handleAfterAttackCasting (const BattleAttack & bat);
void attackCasting(const BattleAttack & bat, Bonus::BonusType attackMode, const CStack * attacker);
bool sacrificeArtifact(const IMarket * m, const CGHeroInstance * hero, ArtifactPosition::ArtifactPosition slot);
void spawnWanderingMonsters(CreatureID::CreatureID creatureID);
void spawnWanderingMonsters(CreatureID creatureID);
friend class CVCMIServer;
friend class CScriptCallback;
};

View File

@ -184,7 +184,7 @@ bool TradeOnMarketplace::applyGh( CGameHandler *gh )
case EMarketMode::RESOURCE_ARTIFACT:
if(!hero)
COMPLAIN_AND_RETURN("Only hero can buy artifacts!");
return gh->buyArtifact(m, hero, static_cast<Res::ERes>(r1), static_cast<ArtifactID::ArtifactID>(r2));
return gh->buyArtifact(m, hero, static_cast<Res::ERes>(r1), ArtifactID(r2));
case EMarketMode::ARTIFACT_RESOURCE:
if(!hero)
COMPLAIN_AND_RETURN("Only hero can sell artifacts!");