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

* fixed vector<bool> serialization

* refactoring
This commit is contained in:
mateuszb 2013-02-04 19:43:16 +00:00
parent 5b00d74e1a
commit 25663ce7af
34 changed files with 300 additions and 288 deletions

View File

@ -886,7 +886,7 @@ void VCAI::yourTurn()
makingTurn = new boost::thread(&VCAI::makeTurn, this);
}
void VCAI::heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, int queryID)
void VCAI::heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill::SecondarySkill> &skills, int queryID)
{
NET_EVENT_HANDLER;
LOG_ENTRY;

View File

@ -285,7 +285,7 @@ public:
virtual void init(CCallback * CB) OVERRIDE;
virtual void yourTurn() OVERRIDE;
virtual void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, int queryID) OVERRIDE; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
virtual void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill::SecondarySkill> &skills, int queryID) OVERRIDE; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, int queryID) OVERRIDE; //TODO
virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, const int soundID, bool selection, bool cancel) OVERRIDE; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, int queryID) OVERRIDE; //all stacks operations between these objects become allowed, interface has to call onEnd when done

View File

@ -213,7 +213,7 @@ void CCallback::buyArtifact(const CGHeroInstance *hero, int aid)
sendRequest(&pack);
}
void CCallback::trade(const CGObjectInstance *market, int mode, int id1, int id2, int val1, const CGHeroInstance *hero/* = NULL*/)
void CCallback::trade(const CGObjectInstance *market, EMarketMode::EMarketMode mode, int id1, int id2, int val1, const CGHeroInstance *hero/* = NULL*/)
{
TradeOnMarketplace pack;
pack.market = market;

View File

@ -54,7 +54,7 @@ public:
virtual bool upgradeCreature(const CArmedInstance *obj, int stackPos, int newID=-1)=0; //if newID==-1 then best possible upgrade will be made
virtual void swapGarrisonHero(const CGTownInstance *town)=0;
virtual void trade(const CGObjectInstance *market, int mode, int id1, int id2, int val1, const CGHeroInstance *hero = NULL)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce
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
virtual int selectionMade(int selection, int queryID) =0;
virtual int swapCreatures(const CArmedInstance *s1, const CArmedInstance *s2, int p1, int p2)=0;//swaps creatures between two possibly different garrisons // TODO: AI-unsafe code - fix it!
@ -135,7 +135,7 @@ public:
void endTurn();
void swapGarrisonHero(const CGTownInstance *town);
void buyArtifact(const CGHeroInstance *hero, int aid);
void trade(const CGObjectInstance *market, int mode, int id1, int id2, int val1, const CGHeroInstance *hero = NULL);
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);
void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero);

View File

@ -222,7 +222,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
for(size_t g=0; g< secSkillAreas.size(); ++g)
{
int skill = curHero->secSkills[g].first,
level = curHero->getSecSkillLevel(static_cast<CGHeroInstance::SecondarySkill>(curHero->secSkills[g].first));
level = curHero->getSecSkillLevel(static_cast<SecondarySkill::SecondarySkill>(curHero->secSkills[g].first));
secSkillAreas[g]->type = skill;
secSkillAreas[g]->bonusValue = level;
secSkillAreas[g]->text = CGI->generaltexth->skillInfoTexts[skill][level-1];
@ -256,7 +256,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
}
dismissButton->block(!!curHero->visitedTown || noDismiss);
if(curHero->getSecSkillLevel(CGHeroInstance::TACTICS) == 0)
if(curHero->getSecSkillLevel(SecondarySkill::TACTICS) == 0)
tacticsButton->block(true);
else
{

View File

@ -574,7 +574,7 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
std::vector<const CGHeroInstance*> heroes = LOCPLINT->cb->getHeroesInfo(true);
for(size_t i=0; i<heroes.size(); i++)
{
totalIncome += heroes[i]->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ESTATES));
totalIncome += heroes[i]->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ESTATES));
totalIncome += heroes[i]->valOfBonuses(Selector::typeSubtype(Bonus::GENERATE_RESOURCE, Res::GOLD));
}

View File

@ -468,7 +468,7 @@ void CPlayerInterface::receivedResource(int type, int val)
GH.totalRedraw();
}
void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16>& skills, int queryID)
void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill::SecondarySkill>& skills, int queryID)
{
EVENT_HANDLER_CALLED_BY_CLIENT;
waitWhileDialog();

View File

@ -143,7 +143,7 @@ public:
void artifactDisassembled(const ArtifactLocation &al);
void heroCreated(const CGHeroInstance* hero) OVERRIDE;
void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, int queryID) OVERRIDE;
void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill::SecondarySkill> &skills, int queryID) OVERRIDE;
void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, int queryID) OVERRIDE;
void heroInGarrisonChange(const CGTownInstance *town) OVERRIDE;
void heroMoved(const TryMoveHero & details) OVERRIDE;

View File

@ -165,15 +165,15 @@ public:
void changeSpells(int hid, bool give, const std::set<ui32> &spells) OVERRIDE {};
bool removeObject(int objid) OVERRIDE {return false;};
void setBlockVis(int objid, bool bv) OVERRIDE {};
void setOwner(int objid, ui8 owner) OVERRIDE {};
void setOwner(int objid, TPlayerColor owner) OVERRIDE {};
void setHoverName(int objid, MetaString * name) OVERRIDE {};
void changePrimSkill(int ID, int which, si64 val, bool abs=false) OVERRIDE {};
void changeSecSkill(int ID, int which, int val, bool abs=false) OVERRIDE {};
void changePrimSkill(int ID, PrimarySkill::PrimarySkill which, si64 val, bool abs=false) OVERRIDE {};
void changeSecSkill(int ID, SecondarySkill::SecondarySkill which, int val, bool abs=false) OVERRIDE {};
void showBlockingDialog(BlockingDialog *iw, const CFunctionList<void(ui32)> &callback) OVERRIDE {};
ui32 showBlockingDialog(BlockingDialog *iw) OVERRIDE {return 0;}; //synchronous version of above
void showGarrisonDialog(int upobj, int hid, bool removableUnits, const boost::function<void()> &cb) OVERRIDE {};
void showThievesGuildWindow(int player, int requestingObjId) OVERRIDE {};
void giveResource(int player, int which, int val) OVERRIDE {};
void giveResource(int player, Res::ERes which, int val) OVERRIDE {};
void giveCreatures(const CArmedInstance * objid, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove) OVERRIDE {};
void takeCreatures(int objid, const std::vector<CStackBasicDescriptor> &creatures) OVERRIDE {};

View File

@ -1695,7 +1695,7 @@ void CSplitWindow::sliderMoved(int to)
setAmount(rightMin + to, false);
}
CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> callback):
CLevelWindow::CLevelWindow(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill::SecondarySkill> &skills, boost::function<void(ui32)> callback):
CWindowObject(PLAYER_COLORED, "LVLUPBKG"),
cb(callback)
{
@ -1728,7 +1728,7 @@ CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<u
comps.push_back(new CSelectableComponent(
CComponent::secskill,
skills[i],
hero->getSecSkillLevel( static_cast<CGHeroInstance::SecondarySkill>(skills[i]) )+1,
hero->getSecSkillLevel( static_cast<SecondarySkill::SecondarySkill>(skills[i]) )+1,
CComponent::medium));
}
box = new CComponentBox(comps, Rect(75, 300, pos.w - 150, 100));
@ -5407,7 +5407,7 @@ void CUniversityWindow::CItem::hover(bool on)
int CUniversityWindow::CItem::state()
{
if (parent->hero->getSecSkillLevel(static_cast<CGHeroInstance::SecondarySkill>(ID)))//hero know this skill
if (parent->hero->getSecSkillLevel(static_cast<SecondarySkill::SecondarySkill>(ID)))//hero know this skill
return 1;
if (!parent->hero->canLearnSkill())//can't learn more skills
return 0;

View File

@ -497,7 +497,7 @@ class CLevelWindow : public CWindowObject
void selectionChanged(unsigned to);
public:
CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> callback); //c-tor
CLevelWindow(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill::SecondarySkill> &skills, boost::function<void(ui32)> callback); //c-tor
~CLevelWindow(); //d-tor
};

View File

@ -535,7 +535,7 @@ void HeroLevelUp::applyCl( CClient *cl )
//INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroGotLevel, h, primskill, skills, id);
if(vstd::contains(cl->playerint,h->tempOwner))
{
cl->playerint[h->tempOwner]->heroGotLevel(h, static_cast<int>(primskill), skills, queryID);
cl->playerint[h->tempOwner]->heroGotLevel(h, primskill, skills, queryID);
}
//else
// cb->selectionMade(0, queryID);

View File

@ -1,5 +1,5 @@
#pragma once
#include "../global.h"
#include "GameConstants.h"

View File

@ -668,7 +668,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType::ETerrainType terr
for(int i = 0; i < ARRAY_COUNT(tacticLvls); i++)
{
if(heroes[i])
tacticLvls[i] += heroes[i]->getSecSkillLevel(CGHeroInstance::TACTICS);
tacticLvls[i] += heroes[i]->getSecSkillLevel(SecondarySkill::TACTICS);
}
int tacticsSkillDiff = tacticLvls[0] - tacticLvls[1];

View File

@ -369,7 +369,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
BOOST_FOREACH(ui32 constituentID, *artifact->constituents)
{
if (artifacts[constituentID]->constituentOf == NULL)
artifacts[constituentID]->constituentOf = new std::vector<ui32>();
artifacts[constituentID]->constituentOf = new std::vector<TArtifactID>();
artifacts[constituentID]->constituentOf->push_back(artifact->id);
}
}
@ -747,7 +747,7 @@ void CArtHandler::readComponents (const JsonNode & node, CArtifact * art)
value = &node["components"];
if (!value->isNull())
{
art->constituents = new std::vector<ui32>();
art->constituents = new std::vector<TArtifactID>();
BOOST_FOREACH (auto component, value->Vector())
{
VLC->modh->identifiers.requestIdentifier(std::string("artifact.") + component.String(),

View File

@ -97,10 +97,10 @@ public:
ui32 price;
bmap<ui8, std::vector<ui16> > possibleSlots; //Bearer Type => ids of slots where artifact can be placed
std::vector<ui32> * constituents; // Artifacts IDs a combined artifact consists of, or NULL.
std::vector<ui32> * constituentOf; // Reverse map of constituents.
std::vector<TArtifactID> * constituents; // Artifacts IDs a combined artifact consists of, or NULL.
std::vector<TArtifactID> * constituentOf; // Reverse map of constituents.
EartClass aClass;
si32 id;
TArtifactID id;
template <typename Handler> void serialize(Handler &h, const int version)
{

View File

@ -890,12 +890,12 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
//handling secondary abilities and artifacts giving premies to them
if(info.shooting)
additiveBonus += info.attackerBonuses->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ARCHERY) / 100.0;
additiveBonus += info.attackerBonuses->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ARCHERY) / 100.0;
else
additiveBonus += info.attackerBonuses->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::OFFENCE) / 100.0;
additiveBonus += info.attackerBonuses->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::OFFENCE) / 100.0;
if(info.defenderBonuses)
multBonus *= (std::max(0, 100 - info.defenderBonuses->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ARMORER))) / 100.0;
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.;
@ -1818,7 +1818,7 @@ ui32 CBattleInfoCallback::calculateSpellBonus(ui32 baseDamage, const CSpell * sp
//applying sorcery secondary skill
if(caster)
{
ret *= (100.0 + caster->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::SORCERY)) / 100.0;
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;
if(sp->air)

View File

@ -525,7 +525,7 @@ si32 CStackInstance::magicResistance() const
if (const CGHeroInstance * hero = dynamic_cast<const CGHeroInstance *>(_armyObj))
{
//resistance skill
val += hero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::RESISTANCE);
val += hero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::RESISTANCE);
}
vstd::amin (val, 100);
return val;
@ -740,7 +740,7 @@ std::string CStackInstance::bonusToGraphics(Bonus *bonus) const
case Bonus::MAGIC_RESISTANCE:
fileName = "E_DWARF.bmp"; break;
case Bonus::SECONDARY_SKILL_PREMY:
if (bonus->subtype == CGHeroInstance::RESISTANCE)
if (bonus->subtype == SecondarySkill::RESISTANCE)
{
fileName = "E_DWARF.bmp";
}

View File

@ -76,7 +76,7 @@ public:
virtual void yourTurn(){}; //called AFTER playerStartsTurn(player)
//pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
virtual void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, int queryID)=0;
virtual void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill::SecondarySkill> &skills, int queryID)=0;
virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, int queryID)=0;
// Show a dialog, player must take decision. If selection then he has to choose between one of given components,

View File

@ -834,7 +834,7 @@ void CGameState::init(StartInfo * si)
}
break;
case CScenarioTravel::STravelBonus::SECONDARY_SKILL:
hero->setSecSkillLevel(static_cast<CGHeroInstance::SecondarySkill>(curBonus->info2), curBonus->info3, true);
hero->setSecSkillLevel(static_cast<SecondarySkill::SecondarySkill>(curBonus->info2), curBonus->info3, true);
break;
}
}
@ -1619,7 +1619,7 @@ void CGameState::initDuel()
obj = h;
h->subID = ss.heroId;
for(int i = 0; i < ss.heroPrimSkills.size(); i++)
h->pushPrimSkill(i, ss.heroPrimSkills[i]);
h->pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(i), ss.heroPrimSkills[i]);
if(ss.spells.size())
{
@ -1634,7 +1634,7 @@ void CGameState::initDuel()
typedef const std::pair<si32, si8> &TSecSKill;
BOOST_FOREACH(TSecSKill secSkill, ss.heroSecSkills)
h->setSecSkillLevel((CGHeroInstance::SecondarySkill)secSkill.first, secSkill.second, 1);
h->setSecSkillLevel(static_cast<SecondarySkill::SecondarySkill>(secSkill.first), secSkill.second, 1);
h->initHero(h->subID);
obj->initObj();

View File

@ -21,17 +21,17 @@
*
*/
int CHeroClass::chooseSecSkill(const std::set<int> & possibles) const //picks secondary skill out from given possibilities
SecondarySkill::SecondarySkill CHeroClass::chooseSecSkill(const std::set<SecondarySkill::SecondarySkill> & possibles) const //picks secondary skill out from given possibilities
{
if(possibles.size()==1)
return *possibles.begin();
int totalProb = 0;
for(std::set<int>::const_iterator i=possibles.begin(); i!=possibles.end(); i++)
for(auto i=possibles.begin(); i!=possibles.end(); i++)
{
totalProb += secSkillProbability[*i];
}
int ran = rand()%totalProb;
for(std::set<int>::const_iterator i=possibles.begin(); i!=possibles.end(); i++)
for(auto i=possibles.begin(); i!=possibles.end(); i++)
{
ran -= secSkillProbability[*i];
if(ran<0)
@ -271,7 +271,8 @@ void CHeroHandler::loadHeroJson(CHero * hero, const JsonNode & node)
BOOST_FOREACH(const JsonNode &set, node["skills"].Vector())
{
int skillID = boost::range::find(SecondarySkill::names, set["skill"].String()) - boost::begin(SecondarySkill::names);
SecondarySkill::SecondarySkill skillID = static_cast<SecondarySkill::SecondarySkill>(
boost::range::find(SecondarySkill::names, set["skill"].String()) - boost::begin(SecondarySkill::names));
int skillLevel = boost::range::find(SecondarySkill::levels, set["level"].String()) - boost::begin(SecondarySkill::levels);
hero->secSkillsInit.push_back(std::make_pair(skillID, skillLevel));

View File

@ -64,7 +64,7 @@ public:
std::vector<InitialArmyStack> initialArmy;
CHeroClass * heroClass;
std::vector<std::pair<ui8,ui8> > secSkillsInit; //initial secondary skills; first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert)
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;
@ -114,7 +114,7 @@ public:
std::string imageMapMale;
std::string imageMapFemale;
int chooseSecSkill(const std::set<int> & possibles) const; //picks secondary skill out from given possibilities
SecondarySkill::SecondarySkill chooseSecSkill(const std::set<SecondarySkill::SecondarySkill> & possibles) const; //picks secondary skill out from given possibilities
template <typename Handler> void serialize(Handler &h, const int version)
{

View File

@ -629,7 +629,7 @@ bool CGHeroInstance::canWalkOnSea() const
return hasBonusOfType(Bonus::FLYING_MOVEMENT) || hasBonusOfType(Bonus::WATER_WALKING);
}
ui8 CGHeroInstance::getSecSkillLevel(SecondarySkill skill) const
ui8 CGHeroInstance::getSecSkillLevel(SecondarySkill::SecondarySkill skill) const
{
for(size_t i=0; i < secSkills.size(); ++i)
if(secSkills[i].first == skill)
@ -637,11 +637,11 @@ ui8 CGHeroInstance::getSecSkillLevel(SecondarySkill skill) const
return 0;
}
void CGHeroInstance::setSecSkillLevel(SecondarySkill which, int val, bool abs)
void CGHeroInstance::setSecSkillLevel(SecondarySkill::SecondarySkill which, int val, bool abs)
{
if(getSecSkillLevel(which) == 0)
{
secSkills.push_back(std::pair<int,int>(which, val));
secSkills.push_back(std::pair<SecondarySkill::SecondarySkill,ui8>(which, val));
updateSkill(which, val);
}
else
@ -693,7 +693,7 @@ int CGHeroInstance::maxMovePoints(bool onLand) const
const Bonus::BonusType bt = onLand ? Bonus::LAND_MOVEMENT : Bonus::SEA_MOVEMENT;
const int bonus = valOfBonuses(Bonus::MOVEMENT) + valOfBonuses(bt);
const int subtype = onLand ? LOGISTICS : NAVIGATION;
const int subtype = onLand ? SecondarySkill::LOGISTICS : SecondarySkill::NAVIGATION;
const double modifier = valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, subtype) / 100.0;
return int(base* (1+modifier)) + bonus;
@ -714,7 +714,7 @@ CGHeroInstance::CGHeroInstance()
boat = NULL;
commander = NULL;
sex = 0xff;
secSkills.push_back(std::make_pair(-1, -1));
secSkills.push_back(std::make_pair(SecondarySkill::DEFAULT, -1));
}
void CGHeroInstance::initHero(int SUBID)
@ -754,7 +754,7 @@ void CGHeroInstance::initHero()
pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(g), type->heroClass->primarySkillInitial[g]);
}
}
if(secSkills.size() == 1 && secSkills[0] == std::pair<ui8,ui8>(-1, -1)) //set secondary skills to default
if(secSkills.size() == 1 && secSkills[0] == std::pair<SecondarySkill::SecondarySkill,ui8>(SecondarySkill::DEFAULT, -1)) //set secondary skills to default
secSkills = type->secSkillsInit;
if (!name.length())
name = type->name;
@ -1091,7 +1091,7 @@ void CGHeroInstance::initObj() //TODO: use bonus system
hs->addNewBonus(bonus);
break;
case 11://starting skill with mastery (Adrienne)
cb->changeSecSkill(id, spec.val, spec.additionalinfo); //simply give it and forget
cb->changeSecSkill(id, static_cast<SecondarySkill::SecondarySkill>(spec.val), spec.additionalinfo); //simply give it and forget
break;
case 12://army speed
bonus->type = Bonus::STACKS_SPEED;
@ -1135,7 +1135,7 @@ void CGHeroInstance::initObj() //TODO: use bonus system
//initialize bonuses
BOOST_FOREACH(auto skill_info, secSkills)
updateSkill(static_cast<CGHeroInstance::SecondarySkill>(skill_info.first), skill_info.second);
updateSkill(static_cast<SecondarySkill::SecondarySkill>(skill_info.first), skill_info.second);
Updatespecialty();
mana = manaLimit(); //after all bonuses are taken into account, make sure this line is the last one
@ -1196,11 +1196,11 @@ void CGHeroInstance::Updatespecialty() //TODO: calculate special value of bonuse
}
}
}
void CGHeroInstance::updateSkill(SecondarySkill which, int val)
void CGHeroInstance::updateSkill(SecondarySkill::SecondarySkill which, int val)
{
if(which == LEADERSHIP || which == LUCK)
if(which == SecondarySkill::LEADERSHIP || which == SecondarySkill::LUCK)
{ //luck-> VLC->generaltexth->arraytxt[73+luckSkill]; VLC->generaltexth->arraytxt[104+moraleSkill]
bool luck = which == LUCK;
bool luck = which == SecondarySkill::LUCK;
Bonus::BonusType type[] = {Bonus::MORALE, Bonus::LUCK};
Bonus *b = getBonusLocalFirst(Selector::type(type[luck]) && Selector::sourceType(Bonus::SECONDARY_SKILL));
@ -1212,7 +1212,7 @@ void CGHeroInstance::updateSkill(SecondarySkill which, int val)
else
b->val = +val;
}
else if(which == DIPLOMACY) //surrender discount: 20% per level
else if(which == SecondarySkill::DIPLOMACY) //surrender discount: 20% per level
{
if(Bonus *b = getBonusLocalFirst(Selector::type(Bonus::SURRENDER_DISCOUNT) && Selector::sourceType(Bonus::SECONDARY_SKILL)))
@ -1224,43 +1224,43 @@ void CGHeroInstance::updateSkill(SecondarySkill which, int val)
int skillVal = 0;
switch (which)
{
case ARCHERY:
switch (val)
{
case 1:
skillVal = 10; break;
case 2:
skillVal = 25; break;
case 3:
skillVal = 50; break;
}
break;
case LOGISTICS:
skillVal = 10 * val; break;
case NAVIGATION:
skillVal = 50 * val; break;
case MYSTICISM:
skillVal = val; break;
case EAGLE_EYE:
skillVal = 30 + 10 * val; break;
case NECROMANCY:
skillVal = 10 * val; break;
case LEARNING:
skillVal = 5 * val; break;
case OFFENCE:
skillVal = 10 * val; break;
case ARMORER:
skillVal = 5 * val; break;
case INTELLIGENCE:
skillVal = 25 << (val-1); break;
case SORCERY:
skillVal = 5 * val; break;
case RESISTANCE:
skillVal = 5 << (val-1); break;
case FIRST_AID:
skillVal = 25 + 25*val; break;
case ESTATES:
skillVal = 125 << (val-1); break;
case SecondarySkill::ARCHERY:
switch (val)
{
case 1:
skillVal = 10; break;
case 2:
skillVal = 25; break;
case 3:
skillVal = 50; break;
}
break;
case SecondarySkill::LOGISTICS:
skillVal = 10 * val; break;
case SecondarySkill::NAVIGATION:
skillVal = 50 * val; break;
case SecondarySkill::MYSTICISM:
skillVal = val; break;
case SecondarySkill::EAGLE_EYE:
skillVal = 30 + 10 * val; break;
case SecondarySkill::NECROMANCY:
skillVal = 10 * val; break;
case SecondarySkill::LEARNING:
skillVal = 5 * val; break;
case SecondarySkill::OFFENCE:
skillVal = 10 * val; break;
case SecondarySkill::ARMORER:
skillVal = 5 * val; break;
case SecondarySkill::INTELLIGENCE:
skillVal = 25 << (val-1); break;
case SecondarySkill::SORCERY:
skillVal = 5 * val; break;
case SecondarySkill::RESISTANCE:
skillVal = 5 << (val-1); break;
case SecondarySkill::FIRST_AID:
skillVal = 25 + 25*val; break;
case SecondarySkill::ESTATES:
skillVal = 125 << (val-1); break;
}
@ -1297,7 +1297,7 @@ ui64 CGHeroInstance::getTotalStrength() const
TExpType CGHeroInstance::calculateXp(TExpType exp) const
{
return exp * (100 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::LEARNING))/100.0;
return exp * (100 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::LEARNING))/100.0;
}
ui8 CGHeroInstance::getSpellSchoolLevel(const CSpell * spell, int *outSelectedSchool) const
@ -1308,7 +1308,7 @@ ui8 CGHeroInstance::getSpellSchoolLevel(const CSpell * spell, int *outSelectedSc
if(spell-> schoolName) \
{ \
int thisSchool = std::max<int>(getSecSkillLevel( \
static_cast<CGHeroInstance::SecondarySkill>(14 + (schoolMechanicsId))), \
static_cast<SecondarySkill::SecondarySkill>(14 + (schoolMechanicsId))), \
valOfBonuses(Bonus::MAGIC_SCHOOL_SKILL, 1 << (schoolMechanicsId))); \
if(thisSchool > skill) \
{ \
@ -1360,12 +1360,12 @@ bool CGHeroInstance::canCastThisSpell(const CSpell * spell) const
*/
CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &battleResult) const
{
const ui8 necromancyLevel = getSecSkillLevel(CGHeroInstance::NECROMANCY);
const ui8 necromancyLevel = getSecSkillLevel(SecondarySkill::NECROMANCY);
// Hero knows necromancy.
if (necromancyLevel > 0)
{
double necromancySkill = valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, NECROMANCY)/100.0;
double necromancySkill = valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::NECROMANCY)/100.0;
vstd::amin(necromancySkill, 1.0); //it's impossible to raise more creatures than all...
const std::map<ui32,si32> &casualties = battleResult.casualties[!battleResult.winner];
ui32 raisedUnits = 0;
@ -1440,7 +1440,7 @@ int3 CGHeroInstance::getSightCenter() const
int CGHeroInstance::getSightRadious() const
{
return 5 + getSecSkillLevel(CGHeroInstance::SCOUTING) + valOfBonuses(Bonus::SIGHT_RADIOUS); //default + scouting
return 5 + getSecSkillLevel(SecondarySkill::SCOUTING) + valOfBonuses(Bonus::SIGHT_RADIOUS); //default + scouting
}
si32 CGHeroInstance::manaRegain() const
@ -1489,7 +1489,7 @@ int CGHeroInstance::getSpellCost(const CSpell *sp) const
return sp->costs[getSpellSchoolLevel(sp)];
}
void CGHeroInstance::pushPrimSkill( int which, int val )
void CGHeroInstance::pushPrimSkill( PrimarySkill::PrimarySkill which, int val )
{
addNewBonus(new Bonus(Bonus::PERMANENT, Bonus::PRIMARY_SKILL, Bonus::HERO_BASE_SKILL, val, id, which));
}
@ -2157,7 +2157,7 @@ void CGTownInstance::newTurn() const
int resID = rand()%4+2;//bonus to random rare resource
resID = (resID==2)?1:resID;
int resVal = rand()%4+1;//with size 1..4
cb->giveResource(tempOwner, resID, resVal);
cb->giveResource(tempOwner, static_cast<Res::ERes>(resID), resVal);
cb->setObjProperty (id, 14, resID);
cb->setObjProperty (id, 15, resVal);
}
@ -2400,8 +2400,8 @@ void CGTownInstance::recreateBuildingsBonuses()
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), CGHeroInstance::NECROMANCY); //necromancy amplifier
addBonusIfBuilt(EBuilding::GRAIL, Bonus::SECONDARY_SKILL_PREMY, +20, make_shared<CPropagatorNodeType>(PLAYER), CGHeroInstance::NECROMANCY); //Soul prison
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
}
else if(subID == ETownType::DUNGEON) //Dungeon
{
@ -2569,8 +2569,8 @@ void CGVisitableOPH::treeSelected( int heroID, int resType, int resVal, TExpType
{
if(result) //player agreed to give res for exp
{
cb->giveResource(cb->getOwner(heroID),resType,-resVal); //take resource
cb->changePrimSkill(heroID,4,expVal); //give exp
cb->giveResource(cb->getOwner(heroID), static_cast<Res::ERes>(resType), -resVal); //take resource
cb->changePrimSkill(heroID, PrimarySkill::EXPERIENCE, expVal);
cb->setObjProperty(id, ObjProperty::VISITORS, heroID); //add to the visitors
}
}
@ -2652,10 +2652,10 @@ void CGVisitableOPH::onNAHeroVisit(int heroID, bool alreadyVisited) const
case Obj::STAR_AXIS:
case Obj::GARDEN_OF_REVELATION:
{
cb->changePrimSkill(heroID,subid,val);
cb->changePrimSkill(heroID, static_cast<PrimarySkill::PrimarySkill>(subid), val);
InfoWindow iw;
iw.soundID = sound;
iw.components.push_back(Component(c_id, subid,val,0));
iw.components.push_back(Component(c_id, subid, val, 0));
iw.text.addTxt(MetaString::ADVOB_TXT,ot);
iw.player = cb->getOwner(heroID);
cb->showInfoDialog(&iw);
@ -2671,7 +2671,7 @@ void CGVisitableOPH::onNAHeroVisit(int heroID, bool alreadyVisited) const
iw.player = cb->getOwner(heroID);
iw.text.addTxt(MetaString::ADVOB_TXT,ot);
cb->showInfoDialog(&iw);
cb->changePrimSkill(heroID,4,val);
cb->changePrimSkill(heroID, PrimarySkill::EXPERIENCE, val);
break;
}
case Obj::TREE_OF_KNOWLEDGE:
@ -2687,13 +2687,13 @@ void CGVisitableOPH::onNAHeroVisit(int heroID, bool alreadyVisited) const
iw.player = cb->getOwner(heroID);
iw.text.addTxt(MetaString::ADVOB_TXT,148);
cb->showInfoDialog(&iw);
cb->changePrimSkill(heroID,4,val);
cb->changePrimSkill(heroID, PrimarySkill::EXPERIENCE, val);
break;
}
else
{
ui32 res;
TExpType resval;
si32 resval;
if(ttype==1)
{
res = Res::GOLD;
@ -2727,7 +2727,7 @@ void CGVisitableOPH::onNAHeroVisit(int heroID, bool alreadyVisited) const
{
const CGHeroInstance *h = cb->getHero(heroID);
int txt_id = 66;
if(h->level < 10 - 2*h->getSecSkillLevel(CGHeroInstance::DIPLOMACY)) //not enough level
if(h->level < 10 - 2*h->getSecSkillLevel(SecondarySkill::DIPLOMACY)) //not enough level
{
txt_id += 2;
}
@ -2824,7 +2824,7 @@ const std::string & CGVisitableOPH::getHoverText() const
void CGVisitableOPH::arenaSelected( int heroID, int primSkill ) const
{
cb->setObjProperty(id, ObjProperty::VISITORS, heroID); //add to the visitors
cb->changePrimSkill(heroID,primSkill-1,2);
cb->changePrimSkill(heroID, static_cast<PrimarySkill::PrimarySkill>(primSkill-1), 2);
}
void CGVisitableOPH::setPropertyDer( ui8 what, ui32 val )
@ -2841,7 +2841,7 @@ void CGVisitableOPH::schoolSelected(int heroID, ui32 which) const
int base = (ID == Obj::SCHOOL_OF_MAGIC ? 2 : 0);
cb->setObjProperty(id, ObjProperty::VISITORS, heroID); //add to the visitors
cb->giveResource(cb->getOwner(heroID),Res::GOLD,-1000); //take 1000 gold
cb->changePrimSkill(heroID, base + which-1, +1); //give appropriate skill
cb->changePrimSkill(heroID, static_cast<PrimarySkill::PrimarySkill>(base + which-1), +1); //give appropriate skill
}
COPWBonus::COPWBonus (int index, CGTownInstance *TOWN)
@ -2912,32 +2912,33 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
if (town->hasBuilt(ID) && visitors.find(heroID) == visitors.end())
{
InfoWindow iw;
int what=0, val=0, mid=0;
PrimarySkill::PrimarySkill what = PrimarySkill::ATTACK;
int val=0, mid=0;
switch (ID)
{
case EBuilding::SPECIAL_4:
switch(town->subID)
{
case ETownType::TOWER: //wall
what = 3;
what = PrimarySkill::KNOWLEDGE;
val = 1;
mid = 581;
iw.components.push_back (Component(Component::PRIM_SKILL, 3, 1, 0));
break;
case ETownType::INFERNO: //order of fire
what = 2;
what = PrimarySkill::SPELL_POWER;
val = 1;
mid = 582;
iw.components.push_back (Component(Component::PRIM_SKILL, 2, 1, 0));
break;
case ETownType::STRONGHOLD://hall of valhalla
what = 0;
what = PrimarySkill::ATTACK;
val = 1;
mid = 584;
iw.components.push_back (Component(Component::PRIM_SKILL, 0, 1, 0));
break;
case ETownType::DUNGEON://academy of battle scholars
what = 4;
what = PrimarySkill::EXPERIENCE;
val = h->calculateXp(1000);
mid = 583;
iw.components.push_back (Component(Component::EXPERIENCE, 0, val, 0));
@ -2948,7 +2949,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
switch(town->subID)
{
case ETownType::FORTRESS: //cage of warlords
what = 1;
what = PrimarySkill::DEFENSE;
val = 1;
mid = 585;
iw.components.push_back (Component(Component::PRIM_SKILL, 1, 1, 0));
@ -3206,17 +3207,17 @@ int CGCreature::takenAction(const CGHeroInstance *h, bool allowJoin) const
if(count*2 > totalCount)
sympathy++; // 2 - hero have similar creatures more that 50%
int charisma = powerFactor + h->getSecSkillLevel(CGHeroInstance::DIPLOMACY) + sympathy;
int charisma = powerFactor + h->getSecSkillLevel(SecondarySkill::DIPLOMACY) + sympathy;
if(charisma < character) //creatures will fight
return -2;
if (allowJoin)
{
if(h->getSecSkillLevel(CGHeroInstance::DIPLOMACY) + sympathy + 1 >= character)
if(h->getSecSkillLevel(SecondarySkill::DIPLOMACY) + sympathy + 1 >= character)
return 0; //join for free
else if(h->getSecSkillLevel(CGHeroInstance::DIPLOMACY) * 2 + sympathy + 1 >= character)
else if(h->getSecSkillLevel(SecondarySkill::DIPLOMACY) * 2 + sympathy + 1 >= character)
return VLC->creh->creatures[subID]->cost[6] * getStackCount(0); //join for gold
}
@ -3270,7 +3271,7 @@ void CGCreature::joinDecision(const CGHeroInstance *h, int cost, ui32 accept) co
//take gold
if(cost)
cb->giveResource(h->tempOwner,6,-cost);
cb->giveResource(h->tempOwner,Res::GOLD,-cost);
cb->tryJoiningArmy(this, h, true, true);
}
@ -3401,10 +3402,10 @@ void CGMine::initObj()
putStack(0, troglodytes);
//after map reading tempOwner placeholds bitmask for allowed resources
std::vector<int> possibleResources;
std::vector<Res::ERes> possibleResources;
for (int i = 0; i < 8; i++)
if(tempOwner & 1<<i)
possibleResources.push_back(i);
possibleResources.push_back(static_cast<Res::ERes>(i));
assert(possibleResources.size());
producedResource = possibleResources[ran()%possibleResources.size()];
@ -3413,7 +3414,7 @@ void CGMine::initObj()
}
else
{
producedResource = subID;
producedResource = static_cast<Res::ERes>(subID);
MetaString ms;
ms << std::pair<ui8,ui32>(9,producedResource);
@ -3432,7 +3433,7 @@ void CGMine::fight(ui32 agreed, const CGHeroInstance *h) const
cb->startBattleI(h, this, boost::bind(&CGMine::endBattle, this, _1, h->tempOwner));
}
void CGMine::endBattle(BattleResult *result, ui8 attackingPlayer) const
void CGMine::endBattle(BattleResult *result, TPlayerColor attackingPlayer) const
{
if(result->winner == 0) //attacker won
{
@ -3444,7 +3445,7 @@ void CGMine::endBattle(BattleResult *result, ui8 attackingPlayer) const
}
}
void CGMine::flagMine(ui8 player) const
void CGMine::flagMine(TPlayerColor player) const
{
assert(tempOwner != player);
cb->setOwner(id,player); //not ours? flag it!
@ -3533,7 +3534,7 @@ void CGResource::onHeroVisit( const CGHeroInstance * h ) const
void CGResource::collectRes( int player ) const
{
cb->giveResource(player,subID,amount);
cb->giveResource(player, static_cast<Res::ERes>(subID), amount);
ShowInInfobox sii;
sii.player = player;
sii.c = Component(Component::RESOURCE,subID,amount,0);
@ -3601,36 +3602,37 @@ void CGVisitableOPW::onHeroVisit( const CGHeroInstance * h ) const
else
{
Component::EComponentType type = Component::RESOURCE;
int sub=0, val=0;
Res::ERes sub=Res::WOOD;
int val=0;
switch (ID)
{
case Obj::MYSTICAL_GARDEN:
if (rand()%2)
{
sub = 5;
sub = Res::GEMS;
val = 5;
}
else
{
sub = 6;
sub = Res::GOLD;
val = 500;
}
break;
case Obj::WINDMILL:
mid = 170;
sub = (rand() % 5) + 1;
sub = static_cast<Res::ERes>((rand() % 5) + 1);
val = (rand() % 4) + 3;
break;
case Obj::WATER_WHEEL:
mid = 164;
sub = 6;
sub = Res::GOLD;
if(cb->getDate(Date::DAY)<8)
val = 500;
else
val = 1000;
}
cb->giveResource(h->tempOwner,sub,val);
cb->giveResource(h->tempOwner, sub, val);
InfoWindow iw;
iw.soundID = sound;
iw.player = h->tempOwner;
@ -3986,7 +3988,7 @@ void CGPickable::onHeroVisit( const CGHeroInstance * h ) const
{
case Obj::CAMPFIRE:
{
cb->giveResource(h->tempOwner,type,val2); //non-gold resource
cb->giveResource(h->tempOwner,static_cast<Res::ERes>(type),val2); //non-gold resource
cb->giveResource(h->tempOwner,Res::GOLD,val1);//gold
InfoWindow iw;
iw.soundID = soundBase::experience;
@ -4023,7 +4025,7 @@ void CGPickable::onHeroVisit( const CGHeroInstance * h ) const
if(val1) //there is gold
{
iw.components.push_back(Component(Component::RESOURCE,Res::GOLD,val1,0));
cb->giveResource(h->tempOwner,6,val1);
cb->giveResource(h->tempOwner,Res::GOLD,val1);
}
if(type == 1) //art
{
@ -4091,10 +4093,10 @@ void CGPickable::chosen( int which, int heroID ) const
switch(which)
{
case 1: //player pick gold
cb->giveResource(cb->getOwner(heroID),6,val1);
cb->giveResource(cb->getOwner(heroID), Res::GOLD, val1);
break;
case 2: //player pick exp
cb->changePrimSkill(heroID, 4, h->calculateXp(val2));
cb->changePrimSkill(heroID, PrimarySkill::EXPERIENCE, h->calculateXp(val2));
break;
default:
throw std::runtime_error("Unhandled treasure choice");
@ -4682,7 +4684,7 @@ void CGSeerHut::finishQuest(const CGHeroInstance * h, ui32 accept) const
case CQuest::MISSION_RESOURCES:
for (int i = 0; i < 7; ++i)
{
cb->giveResource(h->getOwner(), i, -quest->m7resources[i]);
cb->giveResource(h->getOwner(), static_cast<Res::ERes>(i), -quest->m7resources[i]);
}
break;
default:
@ -4700,7 +4702,7 @@ void CGSeerHut::completeQuest (const CGHeroInstance * h) const //reward
case EXPERIENCE:
{
TExpType expVal = h->calculateXp(rVal);
cb->changePrimSkill(h->id, 4, expVal, false);
cb->changePrimSkill(h->id, PrimarySkill::EXPERIENCE, expVal, false);
break;
}
case MANA_POINTS:
@ -4719,13 +4721,13 @@ void CGSeerHut::completeQuest (const CGHeroInstance * h) const //reward
}
break;
case RESOURCES:
cb->giveResource(h->getOwner(), rID, rVal);
cb->giveResource(h->getOwner(), static_cast<Res::ERes>(rID), rVal);
break;
case PRIMARY_SKILL:
cb->changePrimSkill(h->id, rID, rVal, false);
cb->changePrimSkill(h->id, static_cast<PrimarySkill::PrimarySkill>(rID), rVal, false);
break;
case SECONDARY_SKILL:
cb->changeSecSkill(h->id, rID, rVal, false);
cb->changeSecSkill(h->id, static_cast<SecondarySkill::SecondarySkill>(rID), rVal, false);
break;
case ARTIFACT:
cb->giveHeroNewArtifact(h, VLC->arth->artifacts[rID],-2);
@ -4801,7 +4803,7 @@ void CGWitchHut::onHeroVisit( const CGHeroInstance * h ) const
if(!wasVisited(h->tempOwner))
cb->setObjProperty(id,10,h->tempOwner);
ui32 txt_id;
if(h->getSecSkillLevel(static_cast<CGHeroInstance::SecondarySkill>(ability))) //you alredy know this skill
if(h->getSecSkillLevel(static_cast<SecondarySkill::SecondarySkill>(ability))) //you alredy know this skill
{
txt_id =172;
}
@ -4813,7 +4815,7 @@ void CGWitchHut::onHeroVisit( const CGHeroInstance * h ) const
{
iw.components.push_back(Component(Component::SEC_SKILL, ability, 1, 0));
txt_id = 171;
cb->changeSecSkill(h->id,ability,1,true);
cb->changeSecSkill(h->id, static_cast<SecondarySkill::SecondarySkill>(ability), 1, true);
}
iw.text.addTxt(MetaString::ADVOB_TXT,txt_id);
@ -4829,7 +4831,7 @@ const std::string & CGWitchHut::getHoverText() const
hoverName += "\n" + VLC->generaltexth->allTexts[356]; // + (learn %s)
boost::algorithm::replace_first(hoverName,"%s",VLC->generaltexth->skillName[ability]);
const CGHeroInstance *h = cb->getSelectedHero(cb->getCurrentPlayer());
if(h && h->getSecSkillLevel(static_cast<CGHeroInstance::SecondarySkill>(ability))) //hero knows that ability
if(h && h->getSecSkillLevel(static_cast<SecondarySkill::SecondarySkill>(ability))) //hero knows that ability
hoverName += "\n\n" + VLC->generaltexth->allTexts[357]; // (Already learned)
}
return hoverName;
@ -5184,16 +5186,16 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
//give exp
if(expVal)
cb->changePrimSkill(h->id,4,expVal,false);
cb->changePrimSkill(h->id, PrimarySkill::EXPERIENCE, expVal, false);
//give prim skills
for(int i=0; i<primskills.size(); i++)
if(primskills[i])
cb->changePrimSkill(h->id,i,primskills[i],false);
cb->changePrimSkill(h->id,static_cast<PrimarySkill::PrimarySkill>(i),primskills[i],false);
//give sec skills
for(int i=0; i<abilities.size(); i++)
{
int curLev = h->getSecSkillLevel(static_cast<CGHeroInstance::SecondarySkill>(abilities[i]));
int curLev = h->getSecSkillLevel(abilities[i]);
if( (curLev && curLev < abilityLevels[i]) || (h->canLearnSkill() ))
{
@ -5219,7 +5221,7 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
std::vector<ConstTransitivePtr<CSpell> > * sp = &VLC->spellh->spells;
for(std::vector<si32>::const_iterator i=spells.begin(); i != spells.end(); i++)
{
if ((*sp)[*i]->level <= h->getSecSkillLevel(CGHeroInstance::WISDOM) + 2) //enough wisdom
if ((*sp)[*i]->level <= h->getSecSkillLevel(SecondarySkill::WISDOM) + 2) //enough wisdom
{
iw.components.push_back(Component(Component::SPELL,*i,0,0));
spellsToGive.insert(*i);
@ -5310,7 +5312,7 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
for(int i=0; i<resources.size(); i++)
if(resources[i])
cb->giveResource(h->getOwner(),i,resources[i]);
cb->giveResource(h->getOwner(),static_cast<Res::ERes>(i),resources[i]);
for(int i=0; i<artifacts.size(); i++)
cb->giveHeroNewArtifact(h, VLC->arth->artifacts[artifacts[i]],-2);
@ -5461,7 +5463,7 @@ void CGShrine::onHeroVisit( const CGHeroInstance * h ) const
{
iw.text.addTxt(MetaString::ADVOB_TXT,131);
}
else if(ID == Obj::SHRINE_OF_MAGIC_THOUGHT && !h->getSecSkillLevel(CGHeroInstance::WISDOM)) //it's third level spell and hero doesn't have wisdom
else if(ID == Obj::SHRINE_OF_MAGIC_THOUGHT && !h->getSecSkillLevel(SecondarySkill::WISDOM)) //it's third level spell and hero doesn't have wisdom
{
iw.text.addTxt(MetaString::ADVOB_TXT,130);
}
@ -5549,11 +5551,11 @@ void CGScholar::onHeroVisit( const CGHeroInstance * h ) const
EBonusType type = bonusType;
int bid = bonusID;
//check if the bonus if applicable, if not - give primary skill (always possible)
int ssl = h->getSecSkillLevel(static_cast<CGHeroInstance::SecondarySkill>(bid)); //current sec skill level, used if bonusType == 1
int ssl = h->getSecSkillLevel(static_cast<SecondarySkill::SecondarySkill>(bid)); //current sec skill level, used if bonusType == 1
if((type == SECONDARY_SKILL
&& ((ssl == 3) || (!ssl && !h->canLearnSkill()))) ////hero already has expert level in the skill or (don't know skill and doesn't have free slot)
|| (type == SPELL && (!h->getArt(17) || vstd::contains(h->spells, (ui32) bid)
|| (VLC->spellh->spells[bid]->level > h->getSecSkillLevel(CGHeroInstance::WISDOM) + 2)
|| (VLC->spellh->spells[bid]->level > h->getSecSkillLevel(SecondarySkill::WISDOM) + 2)
))) //hero doesn't have a spellbook or already knows the spell or doesn't have Wisdom
{
type = PRIM_SKILL;
@ -5569,11 +5571,11 @@ void CGScholar::onHeroVisit( const CGHeroInstance * h ) const
switch (type)
{
case PRIM_SKILL:
cb->changePrimSkill(h->id,bid,+1);
cb->changePrimSkill(h->id,static_cast<PrimarySkill::PrimarySkill>(bid),+1);
iw.components.push_back(Component(Component::PRIM_SKILL,bid,+1,0));
break;
case SECONDARY_SKILL:
cb->changeSecSkill(h->id,bid,+1);
cb->changeSecSkill(h->id,static_cast<SecondarySkill::SecondarySkill>(bid),+1);
iw.components.push_back(Component(Component::SEC_SKILL,bid,ssl+1,0));
break;
case SPELL:
@ -5724,7 +5726,7 @@ void CGOnceVisitable::onHeroVisit( const CGHeroInstance * h ) const
case 2: //res
iw.text.addTxt(MetaString::ADVOB_TXT, txtid);
iw.components.push_back (Component(Component::RESOURCE, bonusType, bonusVal, 0));
cb->giveResource(h->getOwner(), bonusType, bonusVal);
cb->giveResource(h->getOwner(), static_cast<Res::ERes>(bonusType), bonusVal);
break;
}
if(ID == Obj::WAGON && artOrRes == 1)
@ -6150,7 +6152,7 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
loot << "%d %s";
loot.addReplacement(iw.components.back().val);
loot.addReplacement(MetaString::RES_NAMES, iw.components.back().subtype);
cb->giveResource (h->getOwner(), it, bc->resources[it]);
cb->giveResource (h->getOwner(), static_cast<Res::ERes>(it), bc->resources[it]);
}
}
}
@ -6262,7 +6264,7 @@ void CGPyramid::endBattle (const CGHeroInstance *h, const BattleResult *result)
iw.text.addTxt (MetaString::SPELL_NAME, spell);
if (!h->getArt(17))
iw.text.addTxt (MetaString::ADVOB_TXT, 109); //no spellbook
else if (h->getSecSkillLevel(CGHeroInstance::WISDOM) < 3)
else if (h->getSecSkillLevel(SecondarySkill::WISDOM) < 3)
iw.text.addTxt (MetaString::ADVOB_TXT, 108); //no expert Wisdom
else
{
@ -6460,7 +6462,7 @@ void CGSirens::onHeroVisit( const CGHeroInstance * h ) const
else
{
giveDummyBonus(h->id, Bonus::ONE_BATTLE);
int xp = 0;
TExpType xp = 0;
for (TSlots::const_iterator i = h->Slots().begin(); i != h->Slots().end(); i++)
{
@ -6477,7 +6479,7 @@ void CGSirens::onHeroVisit( const CGHeroInstance * h ) const
xp = h->calculateXp(xp);
iw.text.addTxt(MetaString::ADVOB_TXT,132);
iw.text.addReplacement(xp);
cb->changePrimSkill(h->id, 4, xp, false);
cb->changePrimSkill(h->id, PrimarySkill::EXPERIENCE, xp, false);
}
else
{
@ -6679,7 +6681,7 @@ void CCartographer::buyMap (const CGHeroInstance *h, ui32 accept) const
{
if (accept) //if hero wants to buy map
{
cb->giveResource (h->tempOwner, 6, -1000);
cb->giveResource (h->tempOwner, Res::GOLD, -1000);
FoWChange fw;
fw.mode = 1;
fw.player = h->tempOwner;

View File

@ -5,6 +5,7 @@
#include "../lib/ConstTransitivePtr.h"
#include "int3.h"
#include "GameConstants.h"
#include "ResourceSet.h"
/*
* CObjectHandler.h, part of VCMI engine
@ -275,13 +276,6 @@ public:
class DLL_LINKAGE CGHeroInstance : public CArmedInstance, public IBoatGenerator, public CArtifactSet
{
public:
enum SecondarySkill
{
PATHFINDING = 0, ARCHERY, LOGISTICS, SCOUTING, DIPLOMACY, NAVIGATION, LEADERSHIP, WISDOM, MYSTICISM,
LUCK, BALLISTICS, EAGLE_EYE, NECROMANCY, ESTATES, FIRE_MAGIC, AIR_MAGIC, WATER_MAGIC, EARTH_MAGIC,
SCHOLAR, TACTICS, ARTILLERY, LEARNING, OFFENCE, ARMORER, INTELLIGENCE, SORCERY, RESISTANCE,
FIRST_AID
};
enum ECanDig
{
CAN_DIG, LACK_OF_MOVEMENT, WRONG_TERRAIN, TILE_OCCUPIED
@ -302,7 +296,7 @@ public:
std::string biography; //if custom
si32 portrait; //may be custom
si32 mana; // remaining spell points
std::vector<std::pair<ui8,ui8> > secSkills; //first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert); if hero has ability (-1, -1) it meansthat it should have default secondary abilities
std::vector<std::pair<SecondarySkill::SecondarySkill,ui8> > secSkills; //first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert); if hero has ability (-1, -1) it meansthat it should have default secondary abilities
ui32 movement; //remaining movement points
ui8 sex;
bool inTownGarrison; // if hero is in town garrison
@ -382,8 +376,8 @@ public:
int getCurrentLuck(int stack=-1, bool town=false) const;
int getSpellCost(const CSpell *sp) const; //do not use during battles -> bonuses from army would be ignored
ui8 getSecSkillLevel(SecondarySkill skill) const; //0 - no skill
void setSecSkillLevel(SecondarySkill which, int val, bool abs);// abs == 0 - changes by value; 1 - sets to value
ui8 getSecSkillLevel(SecondarySkill::SecondarySkill skill) const; //0 - no skill
void setSecSkillLevel(SecondarySkill::SecondarySkill which, int val, bool abs);// abs == 0 - changes by value; 1 - sets to value
bool canLearnSkill() const; ///true if hero has free secondary skill slot
int maxMovePoints(bool onLand) const;
@ -416,9 +410,9 @@ public:
void initArmy(IArmyDescriptor *dst = NULL);
//void giveArtifact (ui32 aid);
void initHeroDefInfo();
void pushPrimSkill(int which, int val);
void pushPrimSkill(PrimarySkill::PrimarySkill which, int val);
void Updatespecialty();
void updateSkill(SecondarySkill which, int val);
void updateSkill(SecondarySkill::SecondarySkill which, int val);
CGHeroInstance();
virtual ~CGHeroInstance();
@ -686,8 +680,8 @@ public:
si32 moraleDiff; //morale modifier
si32 luckDiff; //luck modifier
std::vector<si32> resources;//gained / lost resources
std::vector<si32> primskills;//gained / lost resources
std::vector<si32> abilities; //gained abilities
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
@ -977,16 +971,16 @@ public:
class DLL_LINKAGE CGMine : public CArmedInstance
{
public:
ui8 producedResource;
Res::ERes producedResource;
ui32 producedQuantity;
void offerLeavingGuards(const CGHeroInstance *h) const;
void endBattle(BattleResult *result, ui8 attackingPlayer) const;
void endBattle(BattleResult *result, TPlayerColor attackingPlayer) const;
void fight(ui32 agreed, const CGHeroInstance *h) const;
void onHeroVisit(const CGHeroInstance * h) const override;
void flagMine(ui8 player) const;
void flagMine(TPlayerColor player) const;
void newTurn() const override;
void initObj() override;
template <typename Handler> void serialize(Handler &h, const int version)

View File

@ -141,7 +141,7 @@ struct LoadBoolean
template<typename Ser>
struct SaveBooleanVector
{
static void invoke(Ser &s, const bool &data)
static void invoke(Ser &s, const std::vector<bool> &data)
{
s.saveBooleanVector(data);
}
@ -149,7 +149,7 @@ struct SaveBooleanVector
template<typename Ser>
struct LoadBooleanVector
{
static void invoke(Ser &s, bool &data)
static void invoke(Ser &s, std::vector<bool> &data)
{
s.loadBooleanVector(data);
}

View File

@ -98,6 +98,18 @@ namespace PrimarySkill
EXPERIENCE = 4}; //for some reason changePrimSkill uses it
}
namespace SecondarySkill
{
enum SecondarySkill
{
DEFAULT = -1,
PATHFINDING = 0, ARCHERY, LOGISTICS, SCOUTING, DIPLOMACY, NAVIGATION, LEADERSHIP, WISDOM, MYSTICISM,
LUCK, BALLISTICS, EAGLE_EYE, NECROMANCY, ESTATES, FIRE_MAGIC, AIR_MAGIC, WATER_MAGIC, EARTH_MAGIC,
SCHOLAR, TACTICS, ARTILLERY, LEARNING, OFFENCE, ARMORER, INTELLIGENCE, SORCERY, RESISTANCE,
FIRST_AID
};
}
namespace EVictoryConditionType
{
enum EVictoryConditionType { ARTIFACT, GATHERTROOP, GATHERRESOURCE, BUILDCITY, BUILDGRAIL, BEATHERO,

View File

@ -462,7 +462,7 @@ ui32 IBonusBearer::getMaxDamage() const
si32 IBonusBearer::manaLimit() const
{
return si32(getPrimSkillLevel(PrimarySkill::KNOWLEDGE)
* (100.0 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::INTELLIGENCE))
* (100.0 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::INTELLIGENCE))
/ 10.0);
}

View File

@ -207,15 +207,15 @@ public:
virtual void changeSpells(int hid, bool give, const std::set<ui32> &spells)=0;
virtual bool removeObject(int objid)=0;
virtual void setBlockVis(int objid, bool bv)=0;
virtual void setOwner(int objid, ui8 owner)=0;
virtual void setOwner(int objid, TPlayerColor owner)=0;
virtual void setHoverName(int objid, MetaString * name)=0;
virtual void changePrimSkill(int ID, int which, si64 val, bool abs=false)=0;
virtual void changeSecSkill(int ID, int which, int val, bool abs=false)=0;
virtual void changePrimSkill(int ID, PrimarySkill::PrimarySkill which, si64 val, bool abs=false)=0;
virtual void changeSecSkill(int ID, SecondarySkill::SecondarySkill which, int val, bool abs=false)=0;
virtual void showBlockingDialog(BlockingDialog *iw, const CFunctionList<void(ui32)> &callback)=0;
virtual ui32 showBlockingDialog(BlockingDialog *iw) =0; //synchronous version of above //TODO:
virtual void showGarrisonDialog(int upobj, int hid, bool removableUnits, const boost::function<void()> &cb) =0; //cb will be called when player closes garrison window
virtual void showThievesGuildWindow(int player, int requestingObjId) =0;
virtual void giveResource(int player, int which, int val)=0;
virtual void giveResource(int player, Res::ERes which, int val)=0;
virtual void giveCreatures(const CArmedInstance *objid, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove) =0;
virtual void takeCreatures(int objid, const std::vector<CStackBasicDescriptor> &creatures) =0;

View File

@ -610,7 +610,7 @@ void CMapLoaderH3M::readPredefinedHeroes()
hero->secSkills.resize(howMany);
for(int yy = 0; yy < howMany; ++yy)
{
hero->secSkills[yy].first = readUI8();
hero->secSkills[yy].first = static_cast<SecondarySkill::SecondarySkill>(readUI8());
hero->secSkills[yy].second = readUI8();
}
}
@ -650,7 +650,7 @@ void CMapLoaderH3M::readPredefinedHeroes()
{
for(int xx = 0; xx < GameConstants::PRIMARY_SKILLS; xx++)
{
hero->pushPrimSkill(xx, readUI8());
hero->pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(xx), readUI8());
}
}
map->predefinedHeroes.push_back(hero);
@ -932,13 +932,13 @@ void CMapLoaderH3M::readObjects()
evnt->primskills.resize(GameConstants::PRIMARY_SKILLS);
for(int x = 0; x < 4; ++x)
{
evnt->primskills[x] = readUI8();
evnt->primskills[x] = static_cast<PrimarySkill::PrimarySkill>(readUI8());
}
int gabn = readUI8(); // Number of gained abilities
for(int oo = 0; oo < gabn; ++oo)
{
evnt->abilities.push_back(readUI8());
evnt->abilities.push_back(static_cast<SecondarySkill::SecondarySkill>(readUI8()));
evnt->abilityLevels.push_back(readUI8());
}
@ -1308,13 +1308,13 @@ void CMapLoaderH3M::readObjects()
box->primskills.resize(GameConstants::PRIMARY_SKILLS);
for(int x = 0; x < 4; ++x)
{
box->primskills[x] = readUI8();
box->primskills[x] = static_cast<PrimarySkill::PrimarySkill>(readUI8());
}
int gabn = readUI8();//number of gained abilities
for(int oo = 0; oo < gabn; ++oo)
{
box->abilities.push_back(readUI8());
box->abilities.push_back(static_cast<SecondarySkill::SecondarySkill>(readUI8()));
box->abilityLevels.push_back(readUI8());
}
int gart = readUI8(); //number of gained artifacts
@ -1712,7 +1712,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(int idToBeGiven)
nhi->secSkills.resize(howMany);
for(int yy = 0; yy < howMany; ++yy)
{
nhi->secSkills[yy].first = readUI8();
nhi->secSkills[yy].first = static_cast<SecondarySkill::SecondarySkill>(readUI8());
nhi->secSkills[yy].second = readUI8();
}
}
@ -1798,7 +1798,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(int idToBeGiven)
{
for(int xx = 0; xx < GameConstants::PRIMARY_SKILLS; ++xx)
{
nhi->pushPrimSkill(xx, readUI8());
nhi->pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(xx), readUI8());
}
}
}

View File

@ -65,7 +65,7 @@ struct CPackForClient : public CPack
struct CPackForServer : public CPack
{
ui8 player;
TPlayerColor player;
CConnection *c;
CGameState* GS(CGameHandler *gh);
CPackForServer()
@ -210,7 +210,7 @@ struct PackageApplied : public CPackForClient //94
ui8 result; //0 - something went wrong, request hasn't been realized; 1 - OK
ui32 packType; //type id of applied package
ui32 requestID; //an ID given by client to the request that was applied
ui8 player;
TPlayerColor player;
template <typename Handler> void serialize(Handler &h, const int version)
@ -241,7 +241,7 @@ struct PlayerBlocked : public CPackForClient //96
enum EReason { UPCOMING_BATTLE };
ui8 reason;
ui8 player;
TPlayerColor player;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -269,7 +269,8 @@ struct SetResource : public CPackForClient //102
void applyCl(CClient *cl);
DLL_LINKAGE void applyGs(CGameState *gs);
ui8 player, resid;
TPlayerColor player;
Res::ERes resid;
TResourceCap val;
template <typename Handler> void serialize(Handler &h, const int version)
@ -283,7 +284,7 @@ struct SetResource : public CPackForClient //102
void applyCl(CClient *cl);
DLL_LINKAGE void applyGs(CGameState *gs);
ui8 player;
TPlayerColor player;
TResources res; //res[resid] => res amount
template <typename Handler> void serialize(Handler &h, const int version)
@ -300,7 +301,7 @@ struct SetPrimSkill : public CPackForClient //105
ui8 abs; //0 - changes by value; 1 - sets to value
si32 id;
ui16 which;
PrimarySkill::PrimarySkill which;
si64 val;
template <typename Handler> void serialize(Handler &h, const int version)
@ -316,7 +317,8 @@ struct SetSecSkill : public CPackForClient //106
ui8 abs; //0 - changes by value; 1 - sets to value
si32 id;
ui16 which, val;
SecondarySkill::SecondarySkill which;
ui16 val;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -545,7 +547,7 @@ struct SetCommanderProperty : public CPackForClient //120
si32 heroid; //for commander attached to hero
StackLocation sl; //for commander not on the hero?
ui8 which; // use ECommanderProperty
ECommanderProperty which;
TExpType amount; //0 for dead, >0 for alive
si32 additionalInfo; //for secondary skills choice
Bonus accumulatedBonus;
@ -561,7 +563,7 @@ struct AddQuest : public CPackForClient //121
void applyCl(CClient *cl){};
DLL_LINKAGE void applyGs(CGameState *gs);
ui8 player;
TPlayerColor player;
QuestInfo quest;
template <typename Handler> void serialize(Handler &h, const int version)
@ -598,7 +600,7 @@ struct TryMoveHero : public CPackForClient //501
};
ui32 id, movePoints;
ui8 result; //uses EResult
EResult result; //uses EResult
int3 start, end; //h3m format
boost::unordered_set<int3, ShashInt3> fowRevealed; //revealed tiles
int3 attackedFrom; // Set when stepping into endangered tile.
@ -711,7 +713,7 @@ struct HeroRecruited : public CPackForClient //515
si32 hid, tid; //subID of hero
int3 tile;
ui8 player;
TPlayerColor player;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -727,7 +729,7 @@ struct GiveHero : public CPackForClient //516
DLL_LINKAGE void applyGs(CGameState *gs);
ui32 id; //object id
ui8 player;
TPlayerColor player;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -1059,7 +1061,7 @@ struct NewTurn : public CPackForClient //101
std::set<Hero> heroes; //updates movement and mana points
//std::vector<SetResources> res;//resource list
std::map<ui8, TResources> res; //player ID => resource value[res_id]
std::map<TPlayerColor, TResources> res; //player ID => resource value[res_id]
std::vector<SetAvailableCreatures> cres;//creatures to be placed in towns
ui32 day;
bool resetBuilded;
@ -1103,7 +1105,7 @@ struct InfoWindow : public CPackForClient //103 - displays simple info window
MetaString text;
std::vector<Component> components;
ui8 player;
TPlayerColor player;
ui16 soundID;
template <typename Handler> void serialize(Handler &h, const int version)
@ -1161,8 +1163,9 @@ struct HeroLevelUp : public Query//2000
DLL_LINKAGE void applyGs(CGameState *gs);
si32 heroid;
ui8 primskill, level;
std::vector<ui16> skills;
PrimarySkill::PrimarySkill primskill;
ui8 level;
std::vector<SecondarySkill::SecondarySkill> skills;
HeroLevelUp(){type = 2000;};
@ -1217,7 +1220,7 @@ struct BlockingDialog : public Query//2003
MetaString text;
std::vector<Component> components;
ui8 player;
TPlayerColor player;
ui8 flags;
ui16 soundID;
@ -1319,7 +1322,7 @@ struct BattleResult : public CPackForClient//3003
void applyFirstCl(CClient *cl);
void applyGs(CGameState *gs);
ui8 result; //EResult values
EResult result;
ui8 winner; //0 - attacker, 1 - defender, [2 - draw (should be possible?)]
std::map<ui32,si32> casualties[2]; //first => casualties of attackers - map crid => number
TExpType exp[2]; //exp for attacker and defender
@ -1511,7 +1514,7 @@ struct BattleSpellCast : public CPackForClient//3009
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)
TCreature attackerType;//id of caster to generate console message; -1 if not set (eg. spell casted by artifact)
ui8 castedByHero; //if true - spell has been casted by hero, otherwise by a creature
bool castedByHero; //if true - spell has been casted by hero, otherwise by a creature
template <typename Handler> void serialize(Handler &h, const int version)
{
h & dmgToDisplay & side & id & skill & spellCost & manaGained & tile & resisted & affectedCres & attackerType & castedByHero;
@ -1637,7 +1640,7 @@ struct BattleSetStackProperty : public CPackForClient //3018
//void applyCl(CClient *cl){};
int stackID;
int which; //using enum values
BattleStackProperty which;
int val;
int absolute;
@ -1932,7 +1935,7 @@ struct TradeOnMarketplace : public CPackForServer
const CGObjectInstance *market;
const CGHeroInstance *hero; //needed when trading artifacts / creatures
ui8 mode;//enum EEMarketMode
EMarketMode::EMarketMode mode;
ui32 r1, r2; //mode 0: r1 - sold resource, r2 - bought res (exception: when sacrificing art r1 is art id [todo: make r2 preferred slot?]
ui32 val; //units of sold resource
@ -1962,7 +1965,7 @@ struct HireHero : public CPackForServer
HireHero(){};
HireHero(si32 HID, si32 TID):hid(HID),tid(TID){};
si32 hid, tid; //available hero serial and town (tavern) id
ui8 player;
TPlayerColor player;
bool applyGh(CGameHandler *gh);
template <typename Handler> void serialize(Handler &h, const int version)
@ -1989,7 +1992,7 @@ struct QueryReply : public CPackForServer
QueryReply(){type = 6000;};
QueryReply(ui32 QID, ui32 Answer):qid(QID),answer(Answer){type = 6000;};
ui32 qid, answer; //hero and artifact id
ui8 player;
TPlayerColor player;
bool applyGh(CGameHandler *gh);
template <typename Handler> void serialize(Handler &h, const int version)
@ -2077,7 +2080,7 @@ struct PlayerMessage : public CPackForClient, public CPackForServer //513
void applyGs(CGameState *gs){};
bool applyGh(CGameHandler *gh);
ui8 player;
TPlayerColor player;
std::string text;
template <typename Handler> void serialize(Handler &h, const int version)
@ -2094,7 +2097,7 @@ struct SetSelection : public CPackForClient, public CPackForServer //514
bool applyGh(CGameHandler *gh);
void applyCl(CClient *cl);
ui8 player;
TPlayerColor player;
ui32 id;
template <typename Handler> void serialize(Handler &h, const int version)
@ -2108,7 +2111,7 @@ struct CenterView : public CPackForClient//515
CenterView(){CPackForClient::type = 515;};
void applyCl(CClient *cl);
ui8 player;
TPlayerColor player;
int3 pos;
ui32 focusTime; //ms
@ -2225,9 +2228,8 @@ struct UpdateStartOptions : public CPregamePackToPropagate
struct PregameGuiAction : public CPregamePackToPropagate
{
enum {NO_TAB, OPEN_OPTIONS, OPEN_SCENARIO_LIST, OPEN_RANDOM_MAP_OPTIONS};
ui8 action;
enum {NO_TAB, OPEN_OPTIONS, OPEN_SCENARIO_LIST, OPEN_RANDOM_MAP_OPTIONS}
action;
void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
@ -2239,12 +2241,12 @@ struct PregameGuiAction : public CPregamePackToPropagate
struct RequestOptionsChange : public CPregamePackToHost
{
enum {TOWN, HERO, BONUS};
enum EWhat {TOWN, HERO, BONUS};
ui8 what;
si8 direction; //-1 or +1
ui8 playerID;
TPlayerColor playerID;
RequestOptionsChange(ui8 What, si8 Dir, ui8 Player)
RequestOptionsChange(ui8 What, si8 Dir, TPlayerColor Player)
:what(What), direction(Dir), playerID(Player)
{}
RequestOptionsChange(){}
@ -2259,7 +2261,7 @@ struct RequestOptionsChange : public CPregamePackToHost
struct PlayerLeft : public CPregamePackToPropagate
{
ui8 playerID;
TPlayerColor playerID;
void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp

View File

@ -52,7 +52,7 @@ DLL_LINKAGE void SetPrimSkill::applyGs( CGameState *gs )
CGHeroInstance *hero = gs->getHero(id);
assert(hero);
if(which <4)
if(which < PrimarySkill::EXPERIENCE)
{
Bonus *skill = hero->getBonusLocalFirst(Selector::type(Bonus::PRIMARY_SKILL) && Selector::subtype(which) && Selector::sourceType(Bonus::HERO_BASE_SKILL));
assert(skill);
@ -62,7 +62,7 @@ DLL_LINKAGE void SetPrimSkill::applyGs( CGameState *gs )
else
skill->val += val;
}
else if(which == 4) //XP
else if(which == PrimarySkill::EXPERIENCE)
{
if(abs)
hero->exp = val;
@ -74,7 +74,7 @@ DLL_LINKAGE void SetPrimSkill::applyGs( CGameState *gs )
DLL_LINKAGE void SetSecSkill::applyGs( CGameState *gs )
{
CGHeroInstance *hero = gs->getHero(id);
hero->setSecSkillLevel(static_cast<CGHeroInstance::SecondarySkill>(which), val, abs);
hero->setSecSkillLevel(which, val, abs);
}
DLL_LINKAGE void SetCommanderProperty::applyGs(CGameState *gs)

View File

@ -195,7 +195,7 @@ void callWith(std::vector<T> args, boost::function<void(T)> fun, ui32 which)
fun(args[which]);
}
void CGameHandler::levelUpHero(int ID, int skill)
void CGameHandler::levelUpHero(int ID, SecondarySkill::SecondarySkill skill)
{
changeSecSkill(ID, skill, 1, 0);
levelUpHero(ID);
@ -227,21 +227,21 @@ void CGameHandler::levelUpHero(int ID)
tlog5 << "The hero gets the primary skill with the no. " << x << " with a probability of " << r << "%." << std::endl;
SetPrimSkill sps;
sps.id = ID;
sps.which = x;
sps.which = static_cast<PrimarySkill::PrimarySkill>(x);
sps.abs = false;
sps.val = 1;
sendAndApply(&sps);
HeroLevelUp hlu;
hlu.heroid = ID;
hlu.primskill = x;
hlu.primskill = static_cast<PrimarySkill::PrimarySkill>(x);
hlu.level = hero->level+1;
//picking sec. skills for choice
std::set<int> basicAndAdv, expert, none;
std::set<SecondarySkill::SecondarySkill> basicAndAdv, expert, none;
for(int i=0;i<GameConstants::SKILL_QUANTITY;i++)
if (isAllowed(2,i))
none.insert(i);
none.insert(static_cast<SecondarySkill::SecondarySkill>(i));
for(unsigned i=0;i<hero->secSkills.size();i++)
{
@ -255,7 +255,7 @@ void CGameHandler::levelUpHero(int ID)
//first offered skill
if(basicAndAdv.size())
{
int s = hero->type->heroClass->chooseSecSkill(basicAndAdv);//upgrade existing
SecondarySkill::SecondarySkill s = hero->type->heroClass->chooseSecSkill(basicAndAdv);//upgrade existing
hlu.skills.push_back(s);
basicAndAdv.erase(s);
}
@ -292,8 +292,9 @@ void CGameHandler::levelUpHero(int ID)
if(hlu.skills.size() > 1) //apply and ask for secondary skill
{
boost::function<void(ui32)> callback = boost::function<void(ui32)>(boost::bind
(callWith<ui16>, hlu.skills, boost::function<void(ui16)>(boost::bind
(&CGameHandler::levelUpHero, this, ID,_1) ), _1));
(callWith<SecondarySkill::SecondarySkill>, hlu.skills,
boost::function<void(SecondarySkill::SecondarySkill)>(boost::bind
(&CGameHandler::levelUpHero, this, ID,_1) ), _1));
applyAndAsk(&hlu,hero->tempOwner,callback); //call levelUpHero when client responds
}
else if(hlu.skills.size() == 1) //apply, give only possible skill and send info
@ -456,7 +457,7 @@ void CGameHandler::levelUpCommander(const CCommanderInstance * c)
}
}
void CGameHandler::changePrimSkill(int ID, int which, si64 val, bool abs)
void CGameHandler::changePrimSkill(int ID, PrimarySkill::PrimarySkill which, si64 val, bool abs)
{
SetPrimSkill sps;
sps.id = ID;
@ -466,7 +467,7 @@ void CGameHandler::changePrimSkill(int ID, int which, si64 val, bool abs)
sendAndApply(&sps);
//only for exp - hero may level up
if (which == 4)
if (which == PrimarySkill::EXPERIENCE)
{
levelUpHero(ID);
CGHeroInstance *h = static_cast<CGHeroInstance *>(gs->map->objects[ID].get());
@ -483,7 +484,7 @@ void CGameHandler::changePrimSkill(int ID, int which, si64 val, bool abs)
}
}
void CGameHandler::changeSecSkill( int ID, int which, int val, bool abs/*=false*/ )
void CGameHandler::changeSecSkill( int ID, SecondarySkill::SecondarySkill which, int val, bool abs/*=false*/ )
{
SetSecSkill sss;
sss.id = ID;
@ -492,7 +493,7 @@ void CGameHandler::changeSecSkill( int ID, int which, int val, bool abs/*=false*
sss.abs = abs;
sendAndApply(&sss);
if(which == 7) //Wisdom
if(which == SecondarySkill::WISDOM)
{
const CGHeroInstance *h = getHero(ID);
if(h && h->visitedTown)
@ -551,10 +552,10 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
if(victoriousHero)
{
if(int eagleEyeLevel = victoriousHero->getSecSkillLevel(CGHeroInstance::EAGLE_EYE))
if(int eagleEyeLevel = victoriousHero->getSecSkillLevel(SecondarySkill::EAGLE_EYE))
{
int maxLevel = eagleEyeLevel + 1;
double eagleEyeChance = victoriousHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::EAGLE_EYE);
double eagleEyeChance = victoriousHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::EAGLE_EYE);
BOOST_FOREACH(const CSpell *sp, gs->curB->usedSpellsHistory[!battleResult.data->winner])
if(sp->level <= maxLevel && !vstd::contains(victoriousHero->spells, sp->id) && rand() % 100 < eagleEyeChance)
cs.spells.insert(sp->id);
@ -712,9 +713,9 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
//give exp
if (battleResult.data->exp[0] && hero1)
changePrimSkill(hero1->id,4,battleResult.data->exp[0]);
changePrimSkill(hero1->id, PrimarySkill::EXPERIENCE, battleResult.data->exp[0]);
else if (battleResult.data->exp[1] && hero2)
changePrimSkill(hero2->id,4,battleResult.data->exp[1]);
changePrimSkill(hero2->id, PrimarySkill::EXPERIENCE, battleResult.data->exp[1]);
else
afterBattleCallback();
}
@ -798,7 +799,7 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
{
static const int artilleryLvlToChance[] = {0, 50, 75, 100};
const CGHeroInstance * owner = gs->curB->getHero(att->owner);
int chance = artilleryLvlToChance[owner->getSecSkillLevel(CGHeroInstance::ARTILLERY)];
int chance = artilleryLvlToChance[owner->getSecSkillLevel(SecondarySkill::ARTILLERY)];
if(chance > rand() % 100)
{
bat.flags |= BattleAttack::BALLISTA_DOUBLE_DMG;
@ -1284,7 +1285,7 @@ void CGameHandler::newTurn()
if(!firstTurn) //not first day
{
n.res[i->first][Res::GOLD] += h->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ESTATES)); //estates
n.res[i->first][Res::GOLD] += h->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ESTATES)); //estates
for (int k = 0; k < GameConstants::RESOURCE_QUANTITY; k++)
{
@ -1613,18 +1614,18 @@ void CGameHandler::checkForBattleEnd()
}
if(!hasStack[0] || !hasStack[1]) //somebody has won
{
setBattleResult(0, hasStack[1]);
setBattleResult(BattleResult::NORMAL, hasStack[1]);
}
}
void CGameHandler::giveSpells( const CGTownInstance *t, const CGHeroInstance *h )
{
if(!h->hasSpellbook())
return; //hero hasn't spellbok
return; //hero hasn't spellbook
ChangeSpells cs;
cs.hid = h->id;
cs.learn = true;
for(int i=0; i<std::min(t->mageGuildLevel(),h->getSecSkillLevel(CGHeroInstance::WISDOM)+2);i++)
for(int i=0; i<std::min(t->mageGuildLevel(),h->getSecSkillLevel(SecondarySkill::WISDOM)+2);i++)
{
if (t->hasBuilt(EBuilding::GRAIL, ETownType::CONFLUX)) //Aurora Borealis
{
@ -1917,7 +1918,7 @@ ui32 CGameHandler::showBlockingDialog( BlockingDialog *iw )
return 0;
}
void CGameHandler::giveResource(int player, int which, int val) //TODO: cap according to Bersy's suggestion
void CGameHandler::giveResource(int player, Res::ERes which, int val) //TODO: cap according to Bersy's suggestion
{
if(!val) return; //don't waste time on empty call
SetResource sr;
@ -2109,18 +2110,18 @@ void CGameHandler::useScholarSkill(si32 fromHero, si32 toHero)
const CGHeroInstance * h1 = getHero(fromHero);
const CGHeroInstance * h2 = getHero(toHero);
if ( h1->getSecSkillLevel(CGHeroInstance::SCHOLAR) < h2->getSecSkillLevel(CGHeroInstance::SCHOLAR) )
if ( h1->getSecSkillLevel(SecondarySkill::SCHOLAR) < h2->getSecSkillLevel(SecondarySkill::SCHOLAR) )
{
std::swap (h1,h2);//1st hero need to have higher scholar level for correct message
std::swap(fromHero, toHero);
}
int ScholarLevel = h1->getSecSkillLevel(CGHeroInstance::SCHOLAR);//heroes can trade up to this level
int ScholarLevel = h1->getSecSkillLevel(SecondarySkill::SCHOLAR);//heroes can trade up to this level
if (!ScholarLevel || !h1->hasSpellbook() || !h2->hasSpellbook() )
return;//no scholar skill or no spellbook
int h1Lvl = std::min(ScholarLevel+1, h1->getSecSkillLevel(CGHeroInstance::WISDOM)+2),
h2Lvl = std::min(ScholarLevel+1, h2->getSecSkillLevel(CGHeroInstance::WISDOM)+2);//heroes can receive this levels
int h1Lvl = std::min(ScholarLevel+1, h1->getSecSkillLevel(SecondarySkill::WISDOM)+2),
h2Lvl = std::min(ScholarLevel+1, h2->getSecSkillLevel(SecondarySkill::WISDOM)+2);//heroes can receive this levels
ChangeSpells cs1;
cs1.learn = true;
@ -2962,7 +2963,7 @@ bool CGameHandler::buyArtifact( ui32 hid, TArtifactID aid )
return false;
}
bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, int rid, int aid)
bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, Res::ERes rid, TArtifactID aid)
{
if(!vstd::contains(m->availableItemsIds(EMarketMode::RESOURCE_ARTIFACT), aid))
COMPLAIN_RET("That artifact is unavailable!");
@ -3014,7 +3015,7 @@ bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, int ri
return true;
}
bool CGameHandler::sellArtifact( const IMarket *m, const CGHeroInstance *h, TArtifactInstanceID aid, TResource rid )
bool CGameHandler::sellArtifact( const IMarket *m, const CGHeroInstance *h, TArtifactInstanceID aid, Res::ERes rid )
{
const CArtifactInstance *art = h->getArtByInstanceId(aid);
if(!art)
@ -3038,12 +3039,12 @@ bool CGameHandler::sellArtifact( const IMarket *m, const CGHeroInstance *h, TArt
// }
//}
bool CGameHandler::buySecSkill( const IMarket *m, const CGHeroInstance *h, int skill)
bool CGameHandler::buySecSkill( const IMarket *m, const CGHeroInstance *h, SecondarySkill::SecondarySkill skill)
{
if (!h)
COMPLAIN_RET("You need hero to buy a skill!");
if (h->getSecSkillLevel(static_cast<CGHeroInstance::SecondarySkill>(skill)))
if (h->getSecSkillLevel(static_cast<SecondarySkill::SecondarySkill>(skill)))
COMPLAIN_RET("Hero already know this skill");
if (!h->canLearnSkill())
@ -3087,18 +3088,18 @@ bool CGameHandler::tradeResources(const IMarket *market, ui32 val, ui8 player, u
SetResource sr;
sr.player = player;
sr.resid = id1;
sr.resid = static_cast<Res::ERes>(id1);
sr.val = r1 - b1 * units;
sendAndApply(&sr);
sr.resid = id2;
sr.resid = static_cast<Res::ERes>(id2);
sr.val = r2 + b2 * units;
sendAndApply(&sr);
return true;
}
bool CGameHandler::sellCreatures(ui32 count, const IMarket *market, const CGHeroInstance * hero, ui32 slot, ui32 resourceID)
bool CGameHandler::sellCreatures(ui32 count, const IMarket *market, const CGHeroInstance * hero, ui32 slot, Res::ERes resourceID)
{
if(!vstd::contains(hero->Slots(), slot))
COMPLAIN_RET("Hero doesn't have any creature in that slot!");
@ -3158,7 +3159,7 @@ bool CGameHandler::transformInUndead(const IMarket *market, const CGHeroInstance
return true;
}
bool CGameHandler::sendResources(ui32 val, ui8 player, ui32 r1, ui32 r2)
bool CGameHandler::sendResources(ui32 val, TPlayerColor player, Res::ERes r1, TPlayerColor r2)
{
const PlayerState *p2 = gs->getPlayer(r2, false);
if(!p2 || p2->status != PlayerState::INGAME)
@ -3379,7 +3380,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
if(!gs->curB->battleCanFlee(gs->curB->sides[ba.side]))
complain("Cannot retreat!");
else
setBattleResult(1, !ba.side); //surrendering side loses
setBattleResult(BattleResult::ESCAPE, !ba.side); //surrendering side loses
break;
}
case Battle::SURRENDER:
@ -3393,7 +3394,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
else
{
giveResource(player, Res::GOLD, -cost);
setBattleResult(2, !ba.side); //surrendering side loses
setBattleResult(BattleResult::SURRENDER, !ba.side); //surrendering side loses
}
break;
}
@ -3545,7 +3546,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
StartAction start_action(ba);
sendAndApply(&start_action);
const CGHeroInstance * attackingHero = gs->curB->heroes[ba.side];
CHeroHandler::SBallisticsLevelInfo sbi = VLC->heroh->ballistics[attackingHero->getSecSkillLevel(CGHeroInstance::BALLISTICS)];
CHeroHandler::SBallisticsLevelInfo sbi = VLC->heroh->ballistics[attackingHero->getSecSkillLevel(SecondarySkill::BALLISTICS)];
int attackedPart = gs->curB->battleHexToWallPart(ba.destinationTile);
if(attackedPart < 0)
@ -3656,7 +3657,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
complain("There is either no healer, no destination, or healer cannot heal :P");
}
int maxHealable = destStack->MaxHealth() - destStack->firstHPleft;
int maxiumHeal = healer->count * std::max(10, attackingHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::FIRST_AID));
int maxiumHeal = healer->count * std::max(10, attackingHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::FIRST_AID));
int healed = std::min(maxHealable, maxiumHeal);
@ -3881,7 +3882,7 @@ void CGameHandler::playerMessage( TPlayerColor player, const std::string &messag
else if(message == "vcmiglorfindel") //selected hero gains a new level
{
CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
changePrimSkill(hero->id,4,VLC->heroh->reqExp(hero->level+1) - VLC->heroh->reqExp(hero->level));
changePrimSkill(hero->id, PrimarySkill::EXPERIENCE, VLC->heroh->reqExp(hero->level+1) - VLC->heroh->reqExp(hero->level));
}
else if(message == "vcmisilmaril") //player wins
{
@ -5617,7 +5618,7 @@ bool CGameHandler::sacrificeCreatures(const IMarket *market, const CGHeroInstanc
int dump, exp;
market->getOffer(crid, 0, dump, exp, EMarketMode::CREATURE_EXP);
exp *= count;
changePrimSkill(hero->id, 4, hero->calculateXp(exp));
changePrimSkill(hero->id, PrimarySkill::EXPERIENCE, hero->calculateXp(exp));
return true;
}
@ -5635,7 +5636,7 @@ bool CGameHandler::sacrificeArtifact(const IMarket * m, const CGHeroInstance * h
m->getOffer(hero->getArtTypeId(slot), 0, dmp, expToGive, EMarketMode::ARTIFACT_EXP);
removeArtifact(al);
changePrimSkill(hero->id, 4, expToGive);
changePrimSkill(hero->id, PrimarySkill::EXPERIENCE, expToGive);
return true;
}
@ -5895,7 +5896,7 @@ void CGameHandler::runBattle()
const CGHeroInstance * curOwner = gs->curB->battleGetOwner(next);
if( (next->position < 0 || next->getCreature()->idNumber == 146) //arrow turret or ballista
&& (!curOwner || curOwner->getSecSkillLevel(CGHeroInstance::ARTILLERY) == 0)) //hero has no artillery
&& (!curOwner || curOwner->getSecSkillLevel(SecondarySkill::ARTILLERY) == 0)) //hero has no artillery
{
BattleAction attack;
attack.actionType = Battle::SHOOT;
@ -5915,7 +5916,7 @@ void CGameHandler::runBattle()
continue;
}
if(next->getCreature()->idNumber == 145 && (!curOwner || curOwner->getSecSkillLevel(CGHeroInstance::BALLISTICS) == 0)) //catapult, hero has no ballistics
if(next->getCreature()->idNumber == 145 && (!curOwner || curOwner->getSecSkillLevel(SecondarySkill::BALLISTICS) == 0)) //catapult, hero has no ballistics
{
BattleAction attack;
static const int wallHexes[] = {50, 183, 182, 130, 62, 29, 12, 95};
@ -5946,7 +5947,7 @@ void CGameHandler::runBattle()
continue;
}
if(!curOwner || curOwner->getSecSkillLevel(CGHeroInstance::FIRST_AID) == 0) //no hero or hero has no first aid
if(!curOwner || curOwner->getSecSkillLevel(SecondarySkill::FIRST_AID) == 0) //no hero or hero has no first aid
{
range::random_shuffle(possibleStacks);
const CStack * toBeHealed = possibleStacks.front();
@ -6106,7 +6107,7 @@ void CGameHandler::giveHeroNewArtifact(const CGHeroInstance *h, const CArtifact
giveHeroArtifact(h, a, pos);
}
void CGameHandler::setBattleResult(int resultType, int victoriusSide)
void CGameHandler::setBattleResult(BattleResult::EResult resultType, int victoriusSide)
{
if(battleResult.get())
{

View File

@ -121,7 +121,7 @@ public:
void applyBattleEffects(BattleAttack &bat, const CStack *att, const CStack *def, int distance, bool secondary); //damage, drain life & fire shield
void checkForBattleEnd();
void setupBattle(int3 tile, const CArmedInstance *armies[2], const CGHeroInstance *heroes[2], bool creatureBank, const CGTownInstance *town);
void setBattleResult(int resultType, int victoriusSide);
void setBattleResult(BattleResult::EResult resultType, int victoriusSide);
CGameHandler(void);
~CGameHandler(void);
@ -134,14 +134,14 @@ public:
void setBlockVis(int objid, bool bv) OVERRIDE;
void setOwner(int objid, ui8 owner) OVERRIDE;
void setHoverName(int objid, MetaString * name) OVERRIDE;
void changePrimSkill(int ID, int which, si64 val, bool abs=false) OVERRIDE;
void changeSecSkill(int ID, int which, int val, bool abs=false) OVERRIDE;
void changePrimSkill(int ID, PrimarySkill::PrimarySkill which, si64 val, bool abs=false) OVERRIDE;
void changeSecSkill(int ID, SecondarySkill::SecondarySkill which, int val, bool abs=false) OVERRIDE;
//void showInfoDialog(InfoWindow *iw) OVERRIDE;
void showBlockingDialog(BlockingDialog *iw, const CFunctionList<void(ui32)> &callback) OVERRIDE;
ui32 showBlockingDialog(BlockingDialog *iw) OVERRIDE; //synchronous version of above
void showGarrisonDialog(int upobj, int hid, bool removableUnits, const boost::function<void()> &cb) OVERRIDE;
void showThievesGuildWindow(int player, int requestingObjId) OVERRIDE;
void giveResource(int player, int which, int val) OVERRIDE;
void giveResource(int player, Res::ERes which, int val) OVERRIDE;
void giveCreatures(const CArmedInstance *objid, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove) OVERRIDE;
void takeCreatures(int objid, const std::vector<CStackBasicDescriptor> &creatures) OVERRIDE;
@ -182,7 +182,7 @@ public:
void visitObjectOnTile(const TerrainTile &t, const CGHeroInstance * h);
bool teleportHero(si32 hid, si32 dstid, ui8 source, ui8 asker = 255);
void vistiCastleObjects (const CGTownInstance *t, const CGHeroInstance *h);
void levelUpHero(int ID, int skill);//handle client respond and send one more request if needed
void levelUpHero(int ID, SecondarySkill::SecondarySkill skill);//handle client respond and send one more request if needed
void levelUpHero(int ID);//initial call - check if hero have remaining levelups & handle them
void levelUpCommander (const CCommanderInstance * c, int skill); //secondary skill 1 to 6, special skill : skill - 100
void levelUpCommander (const CCommanderInstance * c);
@ -210,15 +210,15 @@ public:
bool setFormation( si32 hid, ui8 formation );
bool tradeResources(const IMarket *market, ui32 val, ui8 player, ui32 id1, ui32 id2);
bool sacrificeCreatures(const IMarket *market, const CGHeroInstance *hero, TSlot slot, ui32 count);
bool sendResources(ui32 val, ui8 player, ui32 r1, ui32 r2);
bool sellCreatures(ui32 count, const IMarket *market, const CGHeroInstance * hero, ui32 slot, ui32 resourceID);
bool sendResources(ui32 val, TPlayerColor player, Res::ERes r1, TPlayerColor r2);
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, ui16 artifactSlot, bool assemble, ui32 assembleTo);
bool buyArtifact( ui32 hid, TArtifactID aid ); //for blacksmith and mage guild only -> buying for gold in common buildings
bool buyArtifact( const IMarket *m, const CGHeroInstance *h, TArtifactID rid, TArtifactID 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, TResource rid); //for artifact merchant selling
bool buyArtifact( const IMarket *m, const CGHeroInstance *h, Res::ERes rid, TArtifactID 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, int skill);
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, ui32 crid, ui32 cram, si32 level);

View File

@ -176,23 +176,23 @@ bool TradeOnMarketplace::applyGh( CGameHandler *gh )
case EMarketMode::RESOURCE_RESOURCE:
return gh->tradeResources(m, val, player, r1, r2);
case EMarketMode::RESOURCE_PLAYER:
return gh->sendResources(val, player, r1, r2);
return gh->sendResources(val, player, static_cast<Res::ERes>(r1), static_cast<Res::ERes>(r2));
case EMarketMode::CREATURE_RESOURCE:
if(!hero)
COMPLAIN_AND_RETURN("Only hero can sell creatures!");
return gh->sellCreatures(val, m, hero, r1, r2);
return gh->sellCreatures(val, m, hero, r1, static_cast<Res::ERes>(r2));
case EMarketMode::RESOURCE_ARTIFACT:
if(!hero)
COMPLAIN_AND_RETURN("Only hero can buy artifacts!");
return gh->buyArtifact(m, hero, r1, r2);
return gh->buyArtifact(m, hero, static_cast<Res::ERes>(r1), static_cast<Res::ERes>(r2));
case EMarketMode::ARTIFACT_RESOURCE:
if(!hero)
COMPLAIN_AND_RETURN("Only hero can sell artifacts!");
return gh->sellArtifact(m, hero, r1, r2);
return gh->sellArtifact(m, hero, r1, static_cast<Res::ERes>(r2));
case EMarketMode::CREATURE_UNDEAD:
return gh->transformInUndead(m, hero, r1);
case EMarketMode::RESOURCE_SKILL:
return gh->buySecSkill(m, hero, r2);
return gh->buySecSkill(m, hero, static_cast<SecondarySkill::SecondarySkill>(r2));
case EMarketMode::CREATURE_EXP:
return gh->sacrificeCreatures(m, hero, r1, val);
case EMarketMode::ARTIFACT_EXP: