1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-15 13:33:36 +02:00

Remove some deprecated fields from CSpell

* now only new SpellScholl API is used
(!) untested
This commit is contained in:
AlexVinS 2015-01-30 09:39:36 +03:00
parent 550df6360e
commit a3f2667376
8 changed files with 33 additions and 75 deletions

View File

@ -1502,7 +1502,7 @@ void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
} }
} }
void CBattleInterface::castThisSpell(int spellID) void CBattleInterface::castThisSpell(SpellID spellID)
{ {
auto ba = new BattleAction; auto ba = new BattleAction;
ba->actionType = Battle::HERO_SPELL; ba->actionType = Battle::HERO_SPELL;

View File

@ -317,7 +317,7 @@ public:
void displayBattleFinished(); //displays battle result void displayBattleFinished(); //displays battle result
void spellCast(const BattleSpellCast * sc); //called when a hero casts a spell void spellCast(const BattleSpellCast * sc); //called when a hero casts a spell
void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks
void castThisSpell(int spellID); //called when player has chosen a spell from spellbook void castThisSpell(SpellID spellID); //called when player has chosen a spell from spellbook
void displayEffect(ui32 effect, int destTile, bool areaEffect = true); //displays custom effect on the battlefield void displayEffect(ui32 effect, int destTile, bool areaEffect = true); //displays custom effect on the battlefield
void displaySpellEffect(SpellID spellID, BattleHex destinationTile, bool areaEffect = true); //displays spell`s affected animation void displaySpellEffect(SpellID spellID, BattleHex destinationTile, bool areaEffect = true); //displays spell`s affected animation
void displaySpellHit(SpellID spellID, BattleHex destinationTile, bool areaEffect = true); //displays spell`s affected animation void displaySpellHit(SpellID spellID, BattleHex destinationTile, bool areaEffect = true); //displays spell`s affected animation

View File

@ -107,15 +107,11 @@ CSpellWindow::CSpellWindow(const SDL_Rect &, const CGHeroInstance * _myHero, CPl
Uint8 *sitesPerOurTab = s.combatSpell ? sitesPerTabBattle : sitesPerTabAdv; Uint8 *sitesPerOurTab = s.combatSpell ? sitesPerTabBattle : sitesPerTabAdv;
++sitesPerOurTab[4]; ++sitesPerOurTab[4];
if(s.air) s.forEachSchool([&sitesPerOurTab](const SpellSchoolInfo & school, bool & stop)
++sitesPerOurTab[0]; {
if(s.fire) ++sitesPerOurTab[(ui8)school.id];
++sitesPerOurTab[1]; });
if(s.water)
++sitesPerOurTab[2];
if(s.earth)
++sitesPerOurTab[3];
} }
if(sitesPerTabAdv[4] % 12 == 0) if(sitesPerTabAdv[4] % 12 == 0)
sitesPerTabAdv[4]/=12; sitesPerTabAdv[4]/=12;
@ -382,23 +378,17 @@ public:
if(A.level<B.level) if(A.level<B.level)
return true; return true;
if(A.level>B.level) if(A.level>B.level)
return false; return false;
if(A.air && !B.air)
return true;
if(!A.air && B.air) for(ui8 schoolId = 0; schoolId < 4; schoolId++)
return false; {
if(A.fire && !B.fire) if(A.school.at((ESpellSchool)schoolId) && !B.school.at((ESpellSchool)schoolId))
return true; return true;
if(!A.fire && B.fire) if(!A.school.at((ESpellSchool)schoolId) && B.school.at((ESpellSchool)schoolId))
return false; return false;
if(A.water && !B.water) }
return true;
if(!A.water && B.water)
return false;
if(A.earth && !B.earth)
return true;
if(!A.earth && B.earth)
return false;
return A.name < B.name; return A.name < B.name;
} }
} spellsorter; } spellsorter;
@ -406,17 +396,15 @@ public:
void CSpellWindow::computeSpellsPerArea() void CSpellWindow::computeSpellsPerArea()
{ {
std::vector<SpellID> spellsCurSite; std::vector<SpellID> spellsCurSite;
for(auto it = mySpells.cbegin(); it != mySpells.cend(); ++it) for(const SpellID & spellID : mySpells)
{ {
if(CGI->spellh->objects[*it]->combatSpell ^ !battleSpellsOnly CSpell * s = spellID.toSpell();
&& ((CGI->spellh->objects[*it]->air && selectedTab == 0) ||
(CGI->spellh->objects[*it]->fire && selectedTab == 1) || if(s->combatSpell ^ !battleSpellsOnly
(CGI->spellh->objects[*it]->water && selectedTab == 2) || && ((selectedTab == 4) || (s->school[(ESpellSchool)selectedTab]))
(CGI->spellh->objects[*it]->earth && selectedTab == 3) ||
selectedTab == 4 )
) )
{ {
spellsCurSite.push_back(*it); spellsCurSite.push_back(spellID);
} }
} }
std::sort(spellsCurSite.begin(), spellsCurSite.end(), spellsorter); std::sort(spellsCurSite.begin(), spellsCurSite.end(), spellsorter);
@ -653,9 +641,8 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
{ {
case ESpellCastProblem::OK: case ESpellCastProblem::OK:
{ {
int spell = mySpell;
owner->fexitb(); owner->fexitb();
owner->myInt->battleInt->castThisSpell(spell); owner->myInt->battleInt->castThisSpell(mySpell);
} }
break; break;
case ESpellCastProblem::ANOTHER_ELEMENTAL_SUMMONED: case ESpellCastProblem::ANOTHER_ELEMENTAL_SUMMONED:

View File

@ -92,7 +92,6 @@ CSpell::LevelInfo::~LevelInfo()
///CSpell ///CSpell
CSpell::CSpell(): CSpell::CSpell():
id(SpellID::NONE), level(0), id(SpellID::NONE), level(0),
earth(false), water(false), fire(false), air(false),
combatSpell(false), creatureAbility(false), combatSpell(false), creatureAbility(false),
positiveness(ESpellPositiveness::NEUTRAL), positiveness(ESpellPositiveness::NEUTRAL),
defaultProbability(0), defaultProbability(0),
@ -566,11 +565,6 @@ void CSpell::setIsRising(const bool val)
void CSpell::setup() void CSpell::setup()
{ {
setupMechanics(); setupMechanics();
air = school[ESpellSchool::AIR];
fire = school[ESpellSchool::FIRE];
water = school[ESpellSchool::WATER];
earth = school[ESpellSchool::EARTH];
} }

View File

@ -208,11 +208,7 @@ public:
std::string name; std::string name;
si32 level; si32 level;
bool earth; //deprecated
bool water; //deprecated
bool fire; //deprecated
bool air; //deprecated
std::map<ESpellSchool, bool> school; //todo: use this instead of separate boolean fields std::map<ESpellSchool, bool> school; //todo: use this instead of separate boolean fields
si32 power; //spell's power si32 power; //spell's power

View File

@ -895,6 +895,8 @@ public:
ESpellID num; ESpellID num;
}; };
ID_LIKE_OPERATORS_DECLS(SpellID, SpellID::ESpellID)
enum class ESpellSchool: ui8 enum class ESpellSchool: ui8
{ {
AIR = 0, AIR = 0,
@ -903,8 +905,6 @@ enum class ESpellSchool: ui8
EARTH = 3 EARTH = 3
}; };
ID_LIKE_OPERATORS_DECLS(SpellID, SpellID::ESpellID)
// Typedef declarations // Typedef declarations
typedef ui8 TFaction; typedef ui8 TFaction;
typedef si64 TExpType; typedef si64 TExpType;

View File

@ -162,7 +162,7 @@ protected:
///ADVENTURE SPELLS ///ADVENTURE SPELLS
//todo: make configyrable //todo: make configurable
class AdventureBonusingMechanics: public DefaultSpellMechanics class AdventureBonusingMechanics: public DefaultSpellMechanics
{ {
public: public:

View File

@ -2173,9 +2173,9 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
} }
//Pandora with 15 spells of certain school //Pandora with 15 spells of certain school
for (int i = 1; i <= 4; i++) for (int i = 0; i < 4; i++)
{ {
oi.generateObject = [i, gen]() -> CGObjectInstance * oi.generateObject = [i,gen]() -> CGObjectInstance *
{ {
auto obj = new CGPandoraBox(); auto obj = new CGPandoraBox();
obj->ID = Obj::PANDORAS_BOX; obj->ID = Obj::PANDORAS_BOX;
@ -2184,27 +2184,8 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
std::vector <CSpell *> spells; std::vector <CSpell *> spells;
for (auto spell : VLC->spellh->objects) for (auto spell : VLC->spellh->objects)
{ {
if (!spell->isSpecialSpell()) if (!spell->isSpecialSpell() && spell->school[(ESpellSchool)i])
{ spells.push_back(spell);
bool school = false; //TODO: we could have better interface for iterating schools
switch (i)
{
case 1:
school = spell->air;
break;
case 2:
school = spell->earth;
break;
case 3:
school = spell->fire;
break;
case 4:
school = spell->water;
break;
}
if (school)
spells.push_back(spell);
}
} }
RandomGeneratorUtil::randomShuffle(spells, gen->rand); RandomGeneratorUtil::randomShuffle(spells, gen->rand);