mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
Style tweaks.
This commit is contained in:
@ -1798,7 +1798,7 @@ void CGameState::initTowns()
|
|||||||
|
|
||||||
for(ui32 z=0; z<vti->obligatorySpells.size();z++)
|
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->spells[s->level-1].push_back(s->id);
|
||||||
vti->possibleSpells -= s->id;
|
vti->possibleSpells -= s->id;
|
||||||
}
|
}
|
||||||
@ -1826,7 +1826,7 @@ void CGameState::initTowns()
|
|||||||
if(sel<0)
|
if(sel<0)
|
||||||
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->spells[s->level-1].push_back(s->id);
|
||||||
vti->possibleSpells -= s->id;
|
vti->possibleSpells -= s->id;
|
||||||
}
|
}
|
||||||
|
@ -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)
|
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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,17 +31,17 @@ const PlayerColor PlayerColor::NEUTRAL = PlayerColor(255);
|
|||||||
const PlayerColor PlayerColor::PLAYER_LIMIT = PlayerColor(PLAYER_LIMIT_I);
|
const PlayerColor PlayerColor::PLAYER_LIMIT = PlayerColor(PLAYER_LIMIT_I);
|
||||||
const TeamID TeamID::NO_TEAM = TeamID(255);
|
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())
|
if(num < 0 || num >= VLC->spellh->objects.size())
|
||||||
{
|
{
|
||||||
|
@ -961,7 +961,7 @@ public:
|
|||||||
ArtifactID(EArtifactID _num = NONE) : num(_num)
|
ArtifactID(EArtifactID _num = NONE) : num(_num)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
DLL_LINKAGE CArtifact * toArtifact() const;
|
DLL_LINKAGE const CArtifact * toArtifact() const;
|
||||||
|
|
||||||
ID_LIKE_CLASS_COMMON(ArtifactID, EArtifactID)
|
ID_LIKE_CLASS_COMMON(ArtifactID, EArtifactID)
|
||||||
|
|
||||||
@ -1006,7 +1006,7 @@ public:
|
|||||||
CreatureID(ECreatureID _num = NONE) : num(_num)
|
CreatureID(ECreatureID _num = NONE) : num(_num)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
DLL_LINKAGE CCreature * toCreature() const;
|
DLL_LINKAGE const CCreature * toCreature() const;
|
||||||
|
|
||||||
ID_LIKE_CLASS_COMMON(CreatureID, ECreatureID)
|
ID_LIKE_CLASS_COMMON(CreatureID, ECreatureID)
|
||||||
|
|
||||||
@ -1049,8 +1049,7 @@ public:
|
|||||||
SpellID(ESpellID _num = NONE) : num(_num)
|
SpellID(ESpellID _num = NONE) : num(_num)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//TODO: should this be const?
|
DLL_LINKAGE const CSpell * toSpell() const;
|
||||||
DLL_LINKAGE CSpell * toSpell() const;
|
|
||||||
|
|
||||||
ID_LIKE_CLASS_COMMON(SpellID, ESpellID)
|
ID_LIKE_CLASS_COMMON(SpellID, ESpellID)
|
||||||
|
|
||||||
|
@ -196,8 +196,8 @@ bool CureMechanics::dispellSelector(const Bonus * b)
|
|||||||
{
|
{
|
||||||
if(b->source == Bonus::SPELL_EFFECT)
|
if(b->source == Bonus::SPELL_EFFECT)
|
||||||
{
|
{
|
||||||
CSpell * sp = SpellID(b->sid).toSpell();
|
const CSpell * sp = SpellID(b->sid).toSpell();
|
||||||
return sp->isNegative();
|
return sp && sp->isNegative();
|
||||||
}
|
}
|
||||||
return false; //not a spell effect
|
return false; //not a spell effect
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,8 @@ bool DispellHelpfulMechanics::positiveSpellEffects(const Bonus *b)
|
|||||||
{
|
{
|
||||||
if(b->source == Bonus::SPELL_EFFECT)
|
if(b->source == Bonus::SPELL_EFFECT)
|
||||||
{
|
{
|
||||||
CSpell *sp = SpellID(b->sid).toSpell();
|
const CSpell * sp = SpellID(b->sid).toSpell();
|
||||||
return sp->isPositive();
|
return sp && sp->isPositive();
|
||||||
}
|
}
|
||||||
return false; //not a spell effect
|
return false; //not a spell effect
|
||||||
}
|
}
|
||||||
|
@ -4426,14 +4426,13 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
|
|||||||
const CGHeroInstance *h = gs->curB->battleGetFightingHero(ba.side);
|
const CGHeroInstance *h = gs->curB->battleGetFightingHero(ba.side);
|
||||||
COMPLAIN_RET_FALSE_IF((!h), "Wrong caster!");
|
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);
|
logGlobal->error("Wrong spell id (%d)!", ba.additionalInfo);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSpell * s = SpellID(ba.additionalInfo).toSpell();
|
|
||||||
|
|
||||||
BattleSpellCastParameters parameters(gs->curB, h, s);
|
BattleSpellCastParameters parameters(gs->curB, h, s);
|
||||||
parameters.aimToHex(ba.destinationTile);//todo: allow multiple destinations
|
parameters.aimToHex(ba.destinationTile);//todo: allow multiple destinations
|
||||||
parameters.mode = ECastingMode::HERO_CASTING;
|
parameters.mode = ECastingMode::HERO_CASTING;
|
||||||
|
Reference in New Issue
Block a user