1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Style tweaks.

This commit is contained in:
AlexVinS 2016-10-02 15:22:55 +03:00
parent 34a494ade0
commit cd5c0b3297
7 changed files with 17 additions and 19 deletions

View File

@ -1798,7 +1798,7 @@ void CGameState::initTowns()
for(ui32 z=0; z<vti->obligatorySpells.size();z++)
{
CSpell *s = vti->obligatorySpells[z].toSpell();
auto s = vti->obligatorySpells[z].toSpell();
vti->spells[s->level-1].push_back(s->id);
vti->possibleSpells -= s->id;
}
@ -1826,7 +1826,7 @@ void CGameState::initTowns()
if(sel<0)
sel=0;
CSpell *s = vti->possibleSpells[sel].toSpell();
auto s = vti->possibleSpells[sel].toSpell();
vti->spells[s->level-1].push_back(s->id);
vti->possibleSpells -= s->id;
}

View File

@ -605,7 +605,7 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
VLC->modh->identifiers.requestIdentifier(node.second.meta, "spell", node.first, [=, &town](si32 spellID)
{
SpellID(spellID).toSpell()->probabilities[town.faction->index] = chance;
VLC->spellh->objects.at(spellID)->probabilities[town.faction->index] = chance;
});
}

View File

@ -31,17 +31,17 @@ const PlayerColor PlayerColor::NEUTRAL = PlayerColor(255);
const PlayerColor PlayerColor::PLAYER_LIMIT = PlayerColor(PLAYER_LIMIT_I);
const TeamID TeamID::NO_TEAM = TeamID(255);
CArtifact * ArtifactID::toArtifact() const
const CArtifact * ArtifactID::toArtifact() const
{
return VLC->arth->artifacts[*this];
return VLC->arth->artifacts.at(*this);
}
CCreature * CreatureID::toCreature() const
const CCreature * CreatureID::toCreature() const
{
return VLC->creh->creatures[*this];
return VLC->creh->creatures.at(*this);
}
CSpell * SpellID::toSpell() const
const CSpell * SpellID::toSpell() const
{
if(num < 0 || num >= VLC->spellh->objects.size())
{

View File

@ -961,7 +961,7 @@ public:
ArtifactID(EArtifactID _num = NONE) : num(_num)
{}
DLL_LINKAGE CArtifact * toArtifact() const;
DLL_LINKAGE const CArtifact * toArtifact() const;
ID_LIKE_CLASS_COMMON(ArtifactID, EArtifactID)
@ -1006,7 +1006,7 @@ public:
CreatureID(ECreatureID _num = NONE) : num(_num)
{}
DLL_LINKAGE CCreature * toCreature() const;
DLL_LINKAGE const CCreature * toCreature() const;
ID_LIKE_CLASS_COMMON(CreatureID, ECreatureID)
@ -1049,8 +1049,7 @@ public:
SpellID(ESpellID _num = NONE) : num(_num)
{}
//TODO: should this be const?
DLL_LINKAGE CSpell * toSpell() const;
DLL_LINKAGE const CSpell * toSpell() const;
ID_LIKE_CLASS_COMMON(SpellID, ESpellID)

View File

@ -196,8 +196,8 @@ bool CureMechanics::dispellSelector(const Bonus * b)
{
if(b->source == Bonus::SPELL_EFFECT)
{
CSpell * sp = SpellID(b->sid).toSpell();
return sp->isNegative();
const CSpell * sp = SpellID(b->sid).toSpell();
return sp && sp->isNegative();
}
return false; //not a spell effect
}

View File

@ -99,8 +99,8 @@ bool DispellHelpfulMechanics::positiveSpellEffects(const Bonus *b)
{
if(b->source == Bonus::SPELL_EFFECT)
{
CSpell *sp = SpellID(b->sid).toSpell();
return sp->isPositive();
const CSpell * sp = SpellID(b->sid).toSpell();
return sp && sp->isPositive();
}
return false; //not a spell effect
}

View File

@ -4426,14 +4426,13 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
const CGHeroInstance *h = gs->curB->battleGetFightingHero(ba.side);
COMPLAIN_RET_FALSE_IF((!h), "Wrong caster!");
if(ba.additionalInfo < 0 || ba.additionalInfo >= VLC->spellh->objects.size())
const CSpell * s = SpellID(ba.additionalInfo).toSpell();
if(!s)
{
logGlobal->error("Wrong spell id (%d)!", ba.additionalInfo);
return false;
}
const CSpell * s = SpellID(ba.additionalInfo).toSpell();
BattleSpellCastParameters parameters(gs->curB, h, s);
parameters.aimToHex(ba.destinationTile);//todo: allow multiple destinations
parameters.mode = ECastingMode::HERO_CASTING;