1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14: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;
ba->actionType = Battle::HERO_SPELL;

View File

@ -317,7 +317,7 @@ public:
void displayBattleFinished(); //displays battle result
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 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 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

View File

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

View File

@ -92,7 +92,6 @@ CSpell::LevelInfo::~LevelInfo()
///CSpell
CSpell::CSpell():
id(SpellID::NONE), level(0),
earth(false), water(false), fire(false), air(false),
combatSpell(false), creatureAbility(false),
positiveness(ESpellPositiveness::NEUTRAL),
defaultProbability(0),
@ -566,11 +565,6 @@ void CSpell::setIsRising(const bool val)
void CSpell::setup()
{
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;
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
si32 power; //spell's power

View File

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

View File

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

View File

@ -2173,9 +2173,9 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
}
//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();
obj->ID = Obj::PANDORAS_BOX;
@ -2184,27 +2184,8 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
std::vector <CSpell *> spells;
for (auto spell : VLC->spellh->objects)
{
if (!spell->isSpecialSpell())
{
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);
}
if (!spell->isSpecialSpell() && spell->school[(ESpellSchool)i])
spells.push_back(spell);
}
RandomGeneratorUtil::randomShuffle(spells, gen->rand);