1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Synchronization with trunk (again), elimination of some warnings

This commit is contained in:
paracelsus 2013-03-07 19:17:23 +00:00
parent 2ad2fc83f1
commit 9ec431c37b
41 changed files with 677 additions and 538 deletions

View File

@ -22,13 +22,13 @@
#include "../lib/CArtHandler.h"
#include "../lib/NetPacks.h" //ArtifactLocation
#include "../lib/CModHandler.h"
#include "../lib/IBonusTypeHandler.h"
#include "UIFramework/CGuiHandler.h"
#include "UIFramework/CIntObjectClasses.h"
using namespace CSDL_Ext;
class CBonusItem;
class CCreatureArtifactInstance;
class CSelectableSkill;
@ -269,24 +269,24 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
}
}
int magicResistance = 0; //handle it separately :/
//handle Magic resistance separately :/
const IBonusBearer *temp = stack;
if (battleStack)
{
magicResistance = battleStack->magicResistance(); //include Aura of Resistance
}
else
{
magicResistance = stack->magicResistance(); //include Resiatance hero skill
temp = battleStack;
}
int magicResistance = temp->magicResistance();
if (magicResistance)
{
std::map<Bonus::BonusType, std::pair<std::string, std::string> >::const_iterator it = CGI->creh->stackBonuses.find(Bonus::MAGIC_RESISTANCE);
std::string description;
text = it->second.first;
description = it->second.second;
boost::algorithm::replace_first(description, "%d", boost::lexical_cast<std::string>(magicResistance));
Bonus b;
b.type = Bonus::MAGIC_RESISTANCE;
text = VLC->getBth()->bonusToString(&b,temp,false);
const std::string description = VLC->getBth()->bonusToString(&b,temp,true);
bonusItems.push_back (new CBonusItem(genRect(0, 0, 251, 57), text, description, stack->bonusToGraphics(&b)));
}
@ -392,7 +392,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
}
}
if (CGI->modh->modules.STACK_EXP)
if (CGI->modh->modules.STACK_ARTIFACT)
{
creArt = true;
}

View File

@ -117,7 +117,6 @@ public:
CBonusItem(const Rect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName);
~CBonusItem();
void setBonus(const Bonus &bonus);
void showAll();
};

View File

@ -3467,7 +3467,7 @@ void CBonusSelection::updateBonusSelection()
desc = CGI->generaltexth->allTexts[715];
std::string substitute; //text to be printed instead of %s
for (int v=0; v<toPrint.size(); ++v)
for (size_t v=0; v<toPrint.size(); ++v)
{
substitute += boost::lexical_cast<std::string>(toPrint[v].second);
substitute += " " + CGI->generaltexth->primarySkillNames[toPrint[v].first];

View File

@ -136,7 +136,7 @@ void CQuestLog::init()
if (quests.size() > QUEST_COUNT)
slider = new CSlider(203, 199, 230, boost::bind (&CQuestLog::sliderMoved, this, _1), QUEST_COUNT, quests.size(), false, 0);
for (int i = 0; i < quests.size(); ++i)
for (size_t i = 0; i < quests.size(); ++i)
{
MetaString text;
quests[i].quest->getRolloverText (text, false);
@ -169,7 +169,7 @@ void CQuestLog::showAll()
void CQuestLog::recreateQuestList (int newpos)
{
for (int i = 0; i < labels.size(); ++i)
for (size_t i = 0; i < labels.size(); ++i)
{
labels[i]->pos = Rect (pos.x + 28, pos.y + 207 + (i-newpos) * 25, 173, 23);
if (i >= newpos && i < newpos + QUEST_COUNT)

View File

@ -5110,10 +5110,10 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2)
}
//heroes related thing
for(int b=0; b<ARRAY_COUNT(heroInst); b++)
for(size_t b=0; b<ARRAY_COUNT(heroInst); ++b)
{
//secondary skill's clickable areas
for(int g=0; g<heroInst[b]->secSkills.size(); ++g)
for(size_t g=0; g<heroInst[b]->secSkills.size(); ++g)
{
int skill = heroInst[b]->secSkills[g].first,
level = heroInst[b]->secSkills[g].second; // <1, 3>
@ -5242,7 +5242,7 @@ CPuzzleWindow::CPuzzleWindow(const int3 &GrailPos, double discoveredRatio):
auto & puzzleMap = CGI->townh->factions[faction].puzzleMap;
for(int g=0; g<puzzleMap.size(); ++g)
for(size_t g=0; g<puzzleMap.size(); ++g)
{
const SPuzzleInfo & info = puzzleMap[g];

View File

@ -114,7 +114,7 @@ void CGuiHandler::pushInt( IShowActivatable *newInt )
totalRedraw();
}
void CGuiHandler::popInts( int howMany )
void CGuiHandler::popInts(size_t howMany)
{
if(!howMany) return; //senseless but who knows...
@ -335,7 +335,7 @@ void CGuiHandler::handleMouseMotion(SDL_Event *sEvent)
(*i)->hovered = false;
}
}
for(int i=0; i<hlp.size();i++)
for(size_t i=0; i<hlp.size();i++)
{
hlp[i]->hover(true);
hlp[i]->hovered = true;

View File

@ -84,7 +84,7 @@ public:
void popInt(IShowActivatable *top); //removes given interface from the top and activates next
void popIntTotally(IShowActivatable *top); //deactivates, deletes, removes given interface from the top and activates next
void pushInt(IShowActivatable *newInt); //deactivate old top interface, activates this one and pushes to the top
void popInts(int howMany); //pops one or more interfaces - deactivates top, deletes and removes given number of interfaces, activates new front
void popInts(size_t howMany); //pops one or more interfaces - deactivates top, deletes and removes given number of interfaces, activates new front
IShowActivatable *topInt(); //returns top interface
void updateTime(); //handles timeInterested

View File

@ -1342,8 +1342,8 @@ void CTextBox::recalculateLines(const std::string &Txt)
vstd::clear_pointer(slider);
lines.clear();
const IFont * f = graphics->fonts[font];
int lineHeight = f->getLineHeight();
int lineCapacity = pos.h / lineHeight;
size_t lineHeight = f->getLineHeight();
size_t lineCapacity = pos.h / lineHeight;
lines = CMessage::breakText(Txt, pos.w, font);
if (lines.size() > lineCapacity) //we need to add a slider

View File

@ -371,7 +371,7 @@ void CMapHandler::init()
offsetX = (mapW - (2*frameW+1)*32)/2;
offsetY = (mapH - (2*frameH+1)*32)/2;
for(int i=0;i<map->heroes.size();i++)
for(size_t i=0; i<map->heroes.size(); ++i)
{
if( !graphics->getDef(map->heroes[i]) )
{
@ -461,7 +461,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
// printing terrain
srx = srx_init;
for (int bx = 0; bx < dx; bx++, srx+=32)
for (size_t bx = 0; bx < dx; bx++, srx+=32)
{
// Skip column if not in map
if (top_tile.x+bx < 0 || top_tile.x+bx >= sizes.x)
@ -469,7 +469,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
sry = sry_init;
for (int by=0; by < dy; by++, sry+=32)
for (size_t by=0; by < dy; by++, sry+=32)
{
int3 pos(top_tile.x+bx, top_tile.y+by, top_tile.z); //blitted tile position
@ -518,7 +518,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
//blit objects
const std::vector < std::pair<const CGObjectInstance*,SDL_Rect> > &objects = tile.objects;
for(int h=0; h < objects.size(); ++h)
for(size_t h=0; h < objects.size(); ++h)
{
const CGObjectInstance *obj = objects[h].first;
if (!graphics->getDef(obj))
@ -676,11 +676,11 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
// printing borders
srx = srx_init;
for (int bx = 0; bx < dx; bx++, srx+=32)
for (size_t bx = 0; bx < dx; bx++, srx+=32)
{
sry = sry_init;
for (int by = 0; by<dy; by++, sry+=32)
for (size_t by = 0; by<dy; by++, sry+=32)
{
int3 pos(top_tile.x+bx, top_tile.y+by, top_tile.z); //blitted tile position
@ -755,11 +755,11 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
{
srx = srx_init;
for (int bx = 0; bx < dx; bx++, srx+=32)
for (size_t bx = 0; bx < dx; bx++, srx+=32)
{
sry = sry_init;
for (int by = 0; by<dy; by++, sry+=32)
for (size_t by = 0; by<dy; by++, sry+=32)
{
SDL_Rect sr;
@ -1060,15 +1060,15 @@ CMapHandler::~CMapHandler()
delete graphics->FoWfullHide;
delete graphics->FoWpartialHide;
for(int i=0; i < roadDefs.size(); i++)
for(size_t i=0; i < roadDefs.size(); i++)
delete roadDefs[i];
for(int i=0; i < staticRiverDefs.size(); i++)
for(size_t i=0; i < staticRiverDefs.size(); i++)
delete staticRiverDefs[i];
for(int i=0; i < terrainGraphics.size(); ++i)
for(size_t i=0; i < terrainGraphics.size(); ++i)
{
for(int j=0; j < terrainGraphics[i].size(); ++j)
for(size_t j=0; j < terrainGraphics[i].size(); ++j)
SDL_FreeSurface(terrainGraphics[i][j]);
}
terrainGraphics.clear();

View File

@ -55,7 +55,7 @@ int BattleInfo::getAvaliableHex(CreatureID creID, bool attackerOwned, int initia
auto accessibility = getAccesibility();
std::set<BattleHex> occupyable;
for(int i = 0; i < accessibility.size(); i++)
for(size_t i = 0; i < accessibility.size(); ++i)
if(accessibility.accessible(i, twoHex, attackerOwned))
occupyable.insert(i);

View File

@ -79,8 +79,6 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
BattleInfo();
~BattleInfo(){};
//////////////////////////////////////////////////////////////////////////
//void getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root = NULL) const;
//////////////////////////////////////////////////////////////////////////
CStack * getStackT(BattleHex tileID, bool onlyAlive = true);
CStack * getStack(int stackID, bool onlyAlive = true);

View File

@ -161,7 +161,7 @@ CArtHandler::~CArtHandler()
{
}
void CArtHandler::loadArtifacts(bool onlyTxt)
void CArtHandler::load(bool onlyTxt)
{
if (onlyTxt)
return; // looks to be broken anyway...
@ -203,7 +203,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
art->price= parser.readNumber();
for(int j=0; j<artSlots.size(); j++)
for(size_t j=0; j<artSlots.size(); ++j)
{
if(parser.readString() == "x")
art->possibleSlots[ArtBearer::HERO].push_back(ArtifactPosition(artSlots[j]));
@ -416,7 +416,7 @@ ArtifactID CArtHandler::getArtSync (ui32 rand, int flags, bool erasePicked)
if (arts->empty()) //restock available arts
fillList(*arts, flag);
for (int i = 0; i < arts->size(); ++i)
for (size_t i = 0; i < arts->size(); ++i)
{
CArtifact *art = (*arts)[i];
out.push_back(art);
@ -553,7 +553,7 @@ void CArtHandler::initAllowedArtifactsList(const std::vector<bool> &allowed)
allowedArtifacts.push_back(artifacts[i]);
}
}
for (int i = GameConstants::ARTIFACTS_QUANTITY; i < artifacts.size(); ++i) //allow all new artifacts by default
for (size_t i = GameConstants::ARTIFACTS_QUANTITY; i < artifacts.size(); ++i) //allow all new artifacts by default
{
if (legalArtifact(ArtifactID(i)))
allowedArtifacts.push_back(artifacts[i]);
@ -612,7 +612,7 @@ boost::optional<std::vector<CArtifact*>&> CArtHandler::listFromClass( CArtifact:
void CArtHandler::fillList( std::vector<CArtifact*> &listToBeFilled, CArtifact::EartClass artifactClass )
{
assert(listToBeFilled.empty());
for (int i = 0; i < allowedArtifacts.size(); ++i)
for (size_t i = 0; i < allowedArtifacts.size(); ++i)
{
if (allowedArtifacts[i]->aClass == artifactClass)
listToBeFilled.push_back(allowedArtifacts[i]);
@ -1022,7 +1022,7 @@ ArtifactPosition CArtifactSet::getArtPos(int aid, bool onlyWorn /*= true*/) cons
if(onlyWorn)
return ArtifactPosition::PRE_FIRST;
for(int i = 0; i < artifactsInBackpack.size(); i++)
for(size_t i = 0; i < artifactsInBackpack.size(); ++i)
if(artifactsInBackpack[i].artifact->artType->id == aid)
return ArtifactPosition(GameConstants::BACKPACK_START + i);
@ -1035,7 +1035,7 @@ ArtifactPosition CArtifactSet::getArtPos(const CArtifactInstance *art) const
if(i.second.artifact == art)
return i.first;
for(int i = 0; i < artifactsInBackpack.size(); i++)
for(size_t i = 0; i < artifactsInBackpack.size(); ++i)
if(artifactsInBackpack[i].artifact == art)
return ArtifactPosition(GameConstants::BACKPACK_START + i);

View File

@ -59,8 +59,8 @@ public:
bool isBig () const;
int getArtClassSerial() const; //0 - treasure, 1 - minor, 2 - major, 3 - relic, 4 - spell scroll, 5 - other
std::string nodeName() const override;
void addNewBonus(Bonus *b) override;
std::string nodeName() const OVERRIDE;
void addNewBonus(Bonus *b) OVERRIDE;
virtual void levelUpArtifact (CArtifactInstance * art){};
@ -198,7 +198,7 @@ public:
std::set<ArtifactID> bigArtifacts; // Artifacts that cannot be moved to backpack, e.g. war machines.
std::set<ArtifactID> growingArtifacts;
void loadArtifacts(bool onlyTxt);
void load(bool onlyTxt = false);
/// load artifact from json structure
void load(std::string objectID, const JsonNode & node);
/// load one artifact from json config

View File

@ -493,7 +493,7 @@ const CStack* CBattleInfoCallback::battleGetStackByPos(BattleHex pos, bool onlyA
return nullptr;
}
void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out, const int howMany, const int turn /*= 0*/, int lastMoved /*= -1*/) const
void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out, const size_t howMany, const int turn /*= 0*/, int lastMoved /*= -1*/) const
{
RETURN_IF_NOT_BATTLE();
@ -606,10 +606,10 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
toMove++;
}
for(int i = 0; i < 4; i++)
for(size_t i = 0; i < 4; ++i)
boost::sort(phase[i], CMP_stack(i, turn > 0 ? turn : 0));
for(size_t i = 0; i < phase[0].size() && i < howMany; i++)
for(size_t i = 0; i < phase[0].size() && i < howMany; ++i)
out.push_back(phase[0][i]);
if(out.size() == howMany)

View File

@ -221,7 +221,7 @@ public:
//battle
shared_ptr<const CObstacleInstance> battleGetObstacleOnPos(BattleHex tile, bool onlyBlocking = true) const; //blocking obstacles makes tile inaccessible, others cause special effects (like Land Mines, Moat, Quicksands)
const CStack * battleGetStackByPos(BattleHex pos, bool onlyAlive = true) const; //returns stack info by given pos
void battleGetStackQueue(std::vector<const CStack *> &out, const int howMany, const int turn = 0, int lastMoved = -1) const;
void battleGetStackQueue(std::vector<const CStack *> &out, const size_t howMany, const int turn = 0, int lastMoved = -1) const;
void battleGetStackCountOutsideHexes(bool *ac) const; // returns hexes which when in front of a stack cause us to move the amount box back

337
lib/CBonusTypeHandler.cpp Normal file
View File

@ -0,0 +1,337 @@
/*
* CBonusTypeHandler.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "CBonusTypeHandler.h"
#include "JsonNode.h"
#include "Filesystem/CResourceLoader.h"
#include "Filesystem/ISimpleResourceLoader.h"
#include "VCMI_Lib.h"
#include "CCreatureHandler.h"
#include "CSpellHandler.h"
///Helpers
static inline void jsonSetString(const JsonNode& source, const std::string& name, std::string& dest)
{
const JsonNode& val = source[name];
if(!val.isNull())
{
dest = val.String();
}
}
static inline void jsonSetBool(const JsonNode& source, const std::string& name, bool& dest)
{
const JsonNode& val = source[name];
if(!val.isNull())
{
dest = val.Bool();
}
}
///MacroString
MacroString::MacroString(const std::string &format)
{
static const std::string MACRO_START = "${";
static const std::string MACRO_END = "}";
static const size_t MACRO_START_L = 2;
static const size_t MACRO_END_L = 1;
size_t end_pos = 0;
size_t start_pos = std::string::npos;
tlog5 << "Parsing format " << format << std::endl;
do
{
start_pos = format.find(MACRO_START, end_pos);
if (!(start_pos == std::string::npos))
{
//chunk before macro
items.push_back(Item(Item::STRING,format.substr(end_pos, start_pos-end_pos)));
start_pos += MACRO_START_L;
end_pos = format.find(MACRO_END, start_pos);
if (end_pos == std::string::npos)
{
tlog2 << "Format error in: " << format <<std::endl;
end_pos = start_pos;
break;
}
else
{
items.push_back(Item(Item::MACRO,format.substr(start_pos,end_pos-start_pos)));
end_pos += MACRO_END_L;
}
}
}
while (!start_pos == std::string::npos);
//no more macros
items.push_back(Item(Item::STRING,format.substr(end_pos)));
}
std::string MacroString::build(const GetValue& getValue) const
{
std::string result;
BOOST_FOREACH(const Item &i, items)
{
switch (i.type)
{
case Item::MACRO:
{
result += getValue(i.value);
break;
}
case Item::STRING:
{
result += i.value;
break;
}
}
}
return result;
}
///CBonusType
CBonusType::CBonusType()
{
hidden = true;
icon = nameTemplate = descriptionTemplate = "";
}
CBonusType::~CBonusType()
{
}
void CBonusType::buildMacros()
{
name = MacroString(nameTemplate);
description = MacroString(descriptionTemplate);
}
///CBonusTypeHandler
CBonusTypeHandler::CBonusTypeHandler()
{
//register predefined bonus types
#define BONUS_NAME(x) \
do{\
bonusTypes.push_back(CBonusType());\
}while (0);
BONUS_LIST;
#undef BONUS_NAME
}
CBonusTypeHandler::~CBonusTypeHandler()
{
//dtor
}
std::string CBonusTypeHandler::bonusToString(Bonus *bonus, const IBonusBearer *bearer, bool description) const
{
auto getValue = [=](const std::string &name) -> std::string
{
if (name == "val")
{
return boost::lexical_cast<std::string>(bearer->valOfBonuses(Selector::typeSubtype(bonus->type, bonus->subtype)));
}
else if (name == "subtype.creature")
{
return VLC->creh->creatures[bonus->subtype]->namePl;
}
else if (name == "subtype.spell")
{
return VLC->spellh->spells[bonus->subtype]->name;
}
else if (name == "MR")
{
return boost::lexical_cast<std::string>(bearer->magicResistance());
}
else
{
tlog2 << "Unknown macro in bonus config: " << name << std::endl;
return "[error]";
}
};
const CBonusType& bt = bonusTypes[bonus->type];
std::string text;
if (description)
{
text = bt.description.build(getValue);
}
else
{
text = bt.name.build(getValue);
}
return text;
}
std::string CBonusTypeHandler::bonusToGraphics(Bonus* bonus) const
{
std::string fileName;
bool fullPath = false;
switch (bonus->type)
{
case Bonus::SECONDARY_SKILL_PREMY:
if (bonus->subtype == SecondarySkill::RESISTANCE)
{
fileName = "E_DWARF.bmp";
}
break;
case Bonus::SPELL_IMMUNITY:
{
fullPath = true;
const CSpell * sp = SpellID(bonus->subtype).toSpell();
fileName = sp->getIconImmune();
break;
}
case Bonus::FIRE_IMMUNITY:
switch (bonus->subtype)
{
case 0:
fileName = "E_SPFIRE.bmp"; break; //all
case 1:
fileName = "E_SPFIRE1.bmp"; break; //not positive
case 2:
fileName = "E_FIRE.bmp"; break; //direct damage
}
break;
case Bonus::WATER_IMMUNITY:
switch (bonus->subtype)
{
case 0:
fileName = "E_SPWATER.bmp"; break; //all
case 1:
fileName = "E_SPWATER1.bmp"; break; //not positive
case 2:
fileName = "E_SPCOLD.bmp"; break; //direct damage
}
break;
case Bonus::AIR_IMMUNITY:
switch (bonus->subtype)
{
case 0:
fileName = "E_SPAIR.bmp"; break; //all
case 1:
fileName = "E_SPAIR1.bmp"; break; //not positive
case 2:
fileName = "E_LIGHT.bmp"; break;//direct damage
}
break;
case Bonus::EARTH_IMMUNITY:
switch (bonus->subtype)
{
case 0:
fileName = "E_SPEATH.bmp"; break; //all
case 1:
case 2: //no specific icon for direct damage immunity
fileName = "E_SPEATH1.bmp"; break; //not positive
}
break;
case Bonus::LEVEL_SPELL_IMMUNITY:
{
if (vstd::iswithin(bonus->val, 1 , 5))
{
fileName = "E_SPLVL" + boost::lexical_cast<std::string>(bonus->val) + ".bmp";
}
break;
}
default:
{
const CBonusType& bt = bonusTypes[bonus->type];
fileName = bt.icon;
fullPath = true;
break;
}
}
if(!fileName.empty() && !fullPath)
fileName = "zvs/Lib1.res/" + fileName;
return fileName;
}
void CBonusTypeHandler::load()
{
const JsonNode gameConf(ResourceID("config/gameConfig.json"));
const JsonNode config(JsonUtils::assembleFromFiles(gameConf["bonuses"].convertTo<std::vector<std::string> >()));
load(config);
}
void CBonusTypeHandler::load(const JsonNode& config)
{
BOOST_FOREACH(auto & node, config.Struct())
{
auto it = bonusNameMap.find(node.first);
if(it == bonusNameMap.end())
{
//TODO: new bonus
CBonusType bt;
loadItem(node.second, bt);
auto new_id = bonusTypes.size();
bonusTypes.push_back(bt);
tlog2 << "Adding new bonuses not implemented (" << node.first << ")" << std::endl;
}
else
{
CBonusType& bt = bonusTypes[it->second];
loadItem(node.second, bt);
tlog5 << "Loaded bonus type " << node.first << std::endl;
}
}
}
void CBonusTypeHandler::loadItem(const JsonNode& source, CBonusType& dest)
{
dest.hidden = false;
jsonSetString(source,"name", dest.nameTemplate);
jsonSetString(source,"description", dest.descriptionTemplate);
jsonSetBool(source,"hidden", dest.hidden);
const JsonNode& graphics = source["graphics"];
if(!graphics.isNull())
{
jsonSetString(graphics,"icon", dest.icon);
}
dest.buildMacros();
}

93
lib/CBonusTypeHandler.h Normal file
View File

@ -0,0 +1,93 @@
/*
* CBonusTypeHandler.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "IBonusTypeHandler.h"
#include "HeroBonus.h"
class JsonNode;
typedef Bonus::BonusType BonusTypeID;
class MacroString
{
struct Item
{
enum ItemType
{
STRING, MACRO
};
Item(ItemType _type, std::string _value): type(_type), value(_value){};
ItemType type;
std::string value; //consant string or macro name
};
std::vector<Item> items;
public:
typedef std::function <std::string(const std::string&)> GetValue;
MacroString(){};
MacroString(const std::string &format);
std::string build(const GetValue& getValue) const;
};
class DLL_LINKAGE CBonusType
{
public:
CBonusType();
~CBonusType();
template <typename Handler> void serialize(Handler &h, const int version)
{
h & icon & nameTemplate & descriptionTemplate & hidden;
if (!h.saving)
buildMacros();
}
protected:
private:
void buildMacros();
MacroString name, description;
friend class CBonusTypeHandler;
std::string icon;
std::string nameTemplate, descriptionTemplate;
bool hidden;
};
class DLL_LINKAGE CBonusTypeHandler : public IBonusTypeHandler
{
public:
CBonusTypeHandler();
virtual ~CBonusTypeHandler();
std::string bonusToString(Bonus *bonus, const IBonusBearer *bearer, bool description) const override;
std::string bonusToGraphics(Bonus *bonus) const override;
void load();
void load(const JsonNode& config);
template <typename Handler> void serialize(Handler &h, const int version)
{
h & bonusTypes;
}
private:
void loadItem(const JsonNode &source, CBonusType &dest);
std::vector<CBonusType> bonusTypes; //index = BonusTypeID
};

View File

@ -127,10 +127,7 @@ void CCreature::addBonus(int val, Bonus::BonusType type, int subtype /*= -1*/)
Bonus *added = new Bonus(Bonus::PERMANENT, type, Bonus::CREATURE_ABILITY, val, idNumber, subtype, Bonus::BASE_NUMBER);
addNewBonus(added);
}
// void CCreature::getParents(TCNodes &out, const CBonusSystemNode *root /*= NULL*/) const
// {
// out.insert (VLC->creh->globalEffects);
// }
bool CCreature::isMyUpgrade(const CCreature *anotherCre) const
{
//TODO upgrade of upgrade?
@ -251,7 +248,8 @@ void CCreatureHandler::loadBonuses(CCreature & ncre, std::string bonuses)
}
}
void CCreatureHandler::loadCreatures()
void CCreatureHandler::load()
{
tlog5 << "\t\tReading ZCRTRAIT.TXT" << std::endl;
@ -373,24 +371,6 @@ void CCreatureHandler::loadCreatures()
loadAnimationInfo();
//reading creature ability names
const JsonNode config2(ResourceID("config/bonusnames.json"));
BOOST_FOREACH(const JsonNode &bonus, config2["bonuses"].Vector())
{
const std::string bonusID = bonus["id"].String();
auto it_map = bonusNameMap.find(bonusID);
if (it_map != bonusNameMap.end())
stackBonuses[it_map->second] = std::pair<std::string, std::string>(bonus["name"].String(), bonus["description"].String());
else
tlog2 << "Bonus " << bonusID << " not recognized, ignoring\n";
}
//handle magic resistance secondary skill premy, potentialy may be buggy
//std::map<Bonus::BonusType, std::pair<std::string, std::string> >::iterator it = stackBonuses.find(Bonus::MAGIC_RESISTANCE);
//stackBonuses[Bonus::SECONDARY_SKILL_PREMY] = std::pair<std::string, std::string>(it->second.first, it->second.second);
if (VLC->modh->modules.STACK_EXP) //reading default stack experience bonuses
{
CLegacyConfigParser parser("DATA/CREXPBON.TXT");

View File

@ -106,7 +106,6 @@ public:
void addBonus(int val, Bonus::BonusType type, int subtype = -1);
std::string nodeName() const override;
//void getParents(TCNodes &out, const CBonusSystemNode *root /*= NULL*/) const;
template<typename RanGen>
int getRandomAmount(RanGen ranGen) const
@ -148,7 +147,6 @@ public:
std::vector<ConstTransitivePtr<CCreature> > creatures; //creature ID -> creature info.
//stack exp
std::map<Bonus::BonusType, std::pair<std::string, std::string> > stackBonuses; // bonus => name, description
std::vector<std::vector<ui32> > expRanks; // stack experience needed for certain rank, index 0 for other tiers (?)
std::vector<ui32> maxExpPerBattle; //%, tiers same as above
si8 expAfterUpgrade;//multiplier in %
@ -163,7 +161,7 @@ public:
/// adding abilities from ZCRTRAIT.TXT
void loadBonuses(CCreature & creature, std::string bonuses);
/// load all creatures from H3 files
void loadCreatures();
void load();
/// load creature from json structure
void load(std::string creatureID, const JsonNode & node);
/// load one creature from json config
@ -191,7 +189,7 @@ public:
{
//TODO: should be optimized, not all these informations needs to be serialized (same for ccreature)
h & doubledCreatures & creatures;
h & stackBonuses & expRanks & maxExpPerBattle & expAfterUpgrade;
h & expRanks & maxExpPerBattle & expAfterUpgrade;
h & skillLevels & skillRequirements & commanderLevelPremy;
h & allCreatures;
h & creaturesOfLevel;

View File

@ -10,6 +10,7 @@
#include "CGeneralTextHandler.h"
#include "CSpellHandler.h"
#include "CHeroHandler.h"
#include "IBonusTypeHandler.h"
/*
* CCreatureSet.cpp, part of VCMI engine
@ -561,341 +562,20 @@ void CStackInstance::setType(const CCreature *c)
}
std::string CStackInstance::bonusToString(Bonus *bonus, bool description) const
{
std::map<Bonus::BonusType, std::pair<std::string, std::string> >::iterator it = VLC->creh->stackBonuses.find(bonus->type);
if (it != VLC->creh->stackBonuses.end())
if(Bonus::MAGIC_RESISTANCE == bonus->type)
{
std::string text;
if (description) //long ability description
{
text = it->second.second;
switch (bonus->type)
{
//no additional modifiers needed
case Bonus::FLYING:
case Bonus::UNLIMITED_RETALIATIONS:
case Bonus::SHOOTER:
case Bonus::FREE_SHOOTING:
case Bonus::NO_MELEE_PENALTY:
case Bonus::NO_DISTANCE_PENALTY:
case Bonus::NO_WALL_PENALTY:
case Bonus::JOUSTING: //TODO: percent bonus?
case Bonus::RETURN_AFTER_STRIKE:
case Bonus::BLOCKS_RETALIATION:
case Bonus::TWO_HEX_ATTACK_BREATH:
case Bonus::THREE_HEADED_ATTACK:
case Bonus::ATTACKS_ALL_ADJACENT:
case Bonus::ADDITIONAL_ATTACK: //TODO: what with more than one attack? Axe of Ferocity for example
case Bonus::FULL_HP_REGENERATION:
case Bonus::MANA_DRAIN:
case Bonus::LIFE_DRAIN:
case Bonus::REBIRTH:
case Bonus::SELF_MORALE:
case Bonus::SELF_LUCK:
case Bonus::FEAR:
case Bonus::FEARLESS:
case Bonus::CHARGE_IMMUNITY:
case Bonus::HEALER:
case Bonus::CATAPULT:
case Bonus::DRAGON_NATURE:
case Bonus::NON_LIVING:
case Bonus::UNDEAD:
case Bonus::FIRE_IMMUNITY:
case Bonus::WATER_IMMUNITY:
case Bonus::AIR_IMMUNITY:
case Bonus::EARTH_IMMUNITY:
case Bonus::RECEPTIVE:
case Bonus::DIRECT_DAMAGE_IMMUNITY:
break;
//One numeric value. magic resistance handled separately
case Bonus::SPELL_RESISTANCE_AURA:
case Bonus::SPELL_DAMAGE_REDUCTION:
case Bonus::LEVEL_SPELL_IMMUNITY:
case Bonus::HP_REGENERATION:
case Bonus::ADDITIONAL_RETALIATION:
case Bonus::DEFENSIVE_STANCE:
case Bonus::DOUBLE_DAMAGE_CHANCE:
case Bonus::DARKNESS: //Darkness Dragons any1?
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(valOfBonuses(Selector::typeSubtype(bonus->type, bonus->subtype))));
break;
//Complex descriptions
//case Bonus::SECONDARY_SKILL_PREMY: //only if there's no simple MR
// if (bonus->subtype == CGHeroInstance::RESISTANCE)
// {
// if (!hasBonusOfType(Bonus::MAGIC_RESISTANCE))
// boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>( magicResistance() ));
// }
// break;
//case Bonus::MAGIC_RESISTANCE:
// boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>( magicResistance() ));
// break;
case Bonus::HATE:
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(valOfBonuses(Selector::typeSubtype(bonus->type, bonus->subtype))));
boost::algorithm::replace_first(text, "%s", VLC->creh->creatures[bonus->subtype]->namePl);
break;
case Bonus::SPELL_AFTER_ATTACK:
case Bonus::SPELL_BEFORE_ATTACK:
{
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(valOfBonuses(Selector::typeSubtype(bonus->type, bonus->subtype))));
boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name);
break;
}
case Bonus::SPELL_LIKE_ATTACK:
{
boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name);
break;
}
default:
{}//TODO: allow custom bonus types... someday, somehow
}
}
else //short name
{
text = it->second.first;
switch (bonus->type)
{
case Bonus::MANA_CHANNELING:
case Bonus::MAGIC_MIRROR:
case Bonus::CHANGES_SPELL_COST_FOR_ALLY:
case Bonus::CHANGES_SPELL_COST_FOR_ENEMY:
case Bonus::ENEMY_DEFENCE_REDUCTION:
case Bonus::REBIRTH:
case Bonus::DEATH_STARE:
case Bonus::LIFE_DRAIN:
case Bonus::FIRE_SHIELD:
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(valOfBonuses(Selector::typeSubtype(bonus->type, bonus->subtype))));
break;
case Bonus::HATE:
case Bonus::DAEMON_SUMMONING:
boost::algorithm::replace_first(text, "%s", VLC->creh->creatures[bonus->subtype]->namePl);
break;
case Bonus::LEVEL_SPELL_IMMUNITY:
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(bonus->val));
break;
case Bonus::SPELL_AFTER_ATTACK:
case Bonus::SPELL_BEFORE_ATTACK:
case Bonus::SPELL_IMMUNITY:
case Bonus::SPELLCASTER:
case Bonus::ENCHANTER:
case Bonus::ENCHANTED:
boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name);
break;
case Bonus::MAGIC_RESISTANCE:
text = ""; //handled separately
break;
//case Bonus::SECONDARY_SKILL_PREMY:
// if (bonus->subtype != CGHeroInstance::RESISTANCE || hasBonusOfType(Bonus::MAGIC_RESISTANCE)) //handle it there
// text = "";
// break;
}
}
return text;
return "";
}
else
return "";
{
return VLC->getBth()->bonusToString(bonus, this, description);
}
}
std::string CStackInstance::bonusToGraphics(Bonus *bonus) const
{
std::string fileName;
bool fullPath = false;
switch (bonus->type)
{
//"E_ALIVE.bmp"
//"E_ART.bmp"
case Bonus::ENCHANTED:
fileName = "E_BLESS.bmp"; break;
//"E_BLOCK.bmp"
//"E_BLOCK1.bmp"
//"E_BLOCK2.bmp"
case Bonus::TWO_HEX_ATTACK_BREATH:
fileName = "E_BREATH.bmp"; break;
case Bonus::SPELL_AFTER_ATTACK:
fileName = "E_CAST.bmp"; break;
case Bonus::ENCHANTER:
fileName = "E_CAST1.bmp"; break;
case Bonus::RANDOM_SPELLCASTER:
fileName = "RandomBoost.bmp"; break;
case Bonus::SPELL_BEFORE_ATTACK:
fileName ="E_CAST2.bmp"; break;
case Bonus::SPELLCASTER:
fileName = "E_CASTER.bmp"; break;
case Bonus::JOUSTING:
fileName = "E_CHAMP.bmp"; break;
case Bonus::DOUBLE_DAMAGE_CHANCE:
fileName = "E_DBLOW.bmp"; break;
case Bonus::DEATH_STARE:
fileName = "E_DEATH.bmp"; break;
case Bonus::DEFENSIVE_STANCE:
fileName = "E_DEFBON.bmp"; break;
case Bonus::NO_DISTANCE_PENALTY:
fileName = "E_DIST.bmp"; break;
case Bonus::ADDITIONAL_ATTACK:
fileName = "E_DOUBLE.bmp"; break;
case Bonus::DRAGON_NATURE:
fileName = "E_DRAGON.bmp"; break;
case Bonus::MAGIC_RESISTANCE:
fileName = "E_DWARF.bmp"; break;
case Bonus::SECONDARY_SKILL_PREMY:
if (bonus->subtype == SecondarySkill::RESISTANCE)
{
fileName = "E_DWARF.bmp";
}
break;
case Bonus::FEAR:
fileName = "E_FEAR.bmp"; break;
case Bonus::FEARLESS:
fileName = "E_FEARL.bmp"; break;
case Bonus::FLYING:
fileName = "E_FLY.bmp"; break;
case Bonus::SPELL_DAMAGE_REDUCTION:
fileName = "E_GOLEM.bmp"; break;
case Bonus::RETURN_AFTER_STRIKE:
fileName = "E_HARPY.bmp"; break;
case Bonus::HATE:
fileName = "E_HATE.bmp"; break;
case Bonus::KING1:
fileName = "E_KING1.bmp"; break;
case Bonus::KING2:
fileName = "E_KING2.bmp"; break;
case Bonus::KING3:
fileName = "E_KING3.bmp"; break;
case Bonus::CHANGES_SPELL_COST_FOR_ALLY:
fileName = "E_MANA.bmp"; break;
case Bonus::CHANGES_SPELL_COST_FOR_ENEMY:
fileName = "MagicDamper.bpm"; break;
case Bonus::NO_MELEE_PENALTY:
fileName = "E_MELEE.bmp"; break;
case Bonus::MIND_IMMUNITY:
fileName = "E_MIND.bmp"; break;
case Bonus::SELF_MORALE:
fileName = "E_MINOT.bmp"; break;
case Bonus::NO_MORALE:
fileName = "E_MORAL.bmp"; break;
case Bonus::RECEPTIVE:
fileName = "E_NOFRIM.bmp"; break;
case Bonus::NO_WALL_PENALTY:
fileName = "E_OBST.bmp"; break;
case Bonus::ENEMY_DEFENCE_REDUCTION:
fileName = "E_RDEF.bmp"; break;
case Bonus::REBIRTH:
fileName = "E_REBIRTH.bmp"; break;
case Bonus::BLOCKS_RETALIATION:
fileName = "E_RETAIL.bmp"; break;
case Bonus::UNLIMITED_RETALIATIONS:
case Bonus::ADDITIONAL_RETALIATION:
fileName = "E_RETAIL1.bmp"; break;
case Bonus::ATTACKS_ALL_ADJACENT:
fileName = "E_ROUND.bmp"; break;
//"E_SGNUM.bmp"
//"E_SGTYPE.bmp"
case Bonus::SHOOTER:
fileName = "E_SHOOT.bmp"; break;
case Bonus::FREE_SHOOTING: //shooter is not blocked by enemy
fileName = "E_SHOOTA.bmp"; break;
//"E_SHOOTN.bmp"
case Bonus::SPELL_IMMUNITY:
{
fullPath = true;
const CSpell * sp = SpellID(bonus->subtype).toSpell();
fileName = sp->getIconImmune();
break;
}
//"E_SPAWILL.bmp"
case Bonus::DIRECT_DAMAGE_IMMUNITY:
fileName = "E_SPDIR.bmp"; break;
//"E_SPDISB.bmp"
//"E_SPDISP.bmp"
//"E_SPEATH.bmp"
//"E_SPEATH1.bmp"
case Bonus::FIRE_IMMUNITY:
switch (bonus->subtype)
{
case 0:
fileName = "E_SPFIRE.bmp"; break; //all
case 1:
fileName = "E_SPFIRE1.bmp"; break; //not positive
case 2:
fileName = "E_FIRE.bmp"; break; //direct damage
}
break;
case Bonus::WATER_IMMUNITY:
switch (bonus->subtype)
{
case 0:
fileName = "E_SPWATER.bmp"; break; //all
case 1:
fileName = "E_SPWATER1.bmp"; break; //not positive
case 2:
fileName = "E_SPCOLD.bmp"; break; //direct damage
}
break;
case Bonus::AIR_IMMUNITY:
switch (bonus->subtype)
{
case 0:
fileName = "E_SPAIR.bmp"; break; //all
case 1:
fileName = "E_SPAIR1.bmp"; break; //not positive
case 2:
fileName = "E_LIGHT.bmp"; break;//direct damage
}
break;
case Bonus::EARTH_IMMUNITY:
switch (bonus->subtype)
{
case 0:
fileName = "E_SPEATH.bmp"; break; //all
case 1:
case 2: //no specific icon for direct damage immunity
fileName = "E_SPEATH1.bmp"; break; //not positive
}
break;
case Bonus::LEVEL_SPELL_IMMUNITY:
{
if (vstd::iswithin(bonus->val, 1 , 5))
{
fileName = "E_SPLVL" + boost::lexical_cast<std::string>(bonus->val) + ".bmp";
}
break;
}
//"E_SUMMON.bmp"
//"E_SUMMON1.bmp"
//"E_SUMMON2.bmp"
case Bonus::FULL_HP_REGENERATION:
case Bonus::HP_REGENERATION:
fileName = "E_TROLL.bmp"; break;
case Bonus::UNDEAD:
fileName = "E_UNDEAD.bmp"; break;
case Bonus::SPELL_RESISTANCE_AURA:
fileName = "E_UNIC.bmp"; break;
case Bonus::THREE_HEADED_ATTACK:
fileName = "ThreeHeaded.bmp"; break;
case Bonus::DAEMON_SUMMONING:
fileName = "RiseDemons.bmp"; break;
case Bonus::CHARGE_IMMUNITY:
fileName = "ChargeImmune.bmp"; break;
case Bonus::HEALER:
fileName = "Healer.bmp"; break;
case Bonus::CATAPULT:
fileName = "Catapult.bmp"; break;
case Bonus::MANA_CHANNELING:
fileName = "ManaChannel.bmp"; break;
case Bonus::MANA_DRAIN:
fileName = "ManaDrain.bmp"; break;
case Bonus::LIFE_DRAIN:
fileName = "DrainLife.bmp"; break;
case Bonus::FIRE_SHIELD:
fileName = "FireShield.bmp"; break;
case Bonus::MAGIC_MIRROR:
fileName = "MagicMirror.bmp"; break;
case Bonus::NON_LIVING:
fileName = "NonLiving.bmp"; break;
case Bonus::SPELL_LIKE_ATTACK:
fileName = "SpellLikeAttack.bmp"; break;
}
if(!fileName.empty() && !fullPath)
fileName = "zvs/Lib1.res/" + fileName;
return fileName;
return VLC->getBth()->bonusToGraphics(bonus);
}
void CStackInstance::setArmyObj(const CArmedInstance *ArmyObj)

View File

@ -56,8 +56,7 @@ public:
}
//overrides CBonusSystemNode
//void getParents(TCNodes &out, const CBonusSystemNode *source = NULL) const; //retrieves list of parent nodes (nodes to inherit bonuses from), source is the prinary asker
std::string bonusToString(Bonus *bonus, bool description) const; // how would bonus description look for this particular type of node
std::string bonusToString(Bonus *bonus, bool description) const override; // how would bonus description look for this particular type of node
std::string bonusToGraphics(Bonus *bonus) const; //file name of graphics from StackSkills , in future possibly others
virtual ui64 getPower() const;

View File

@ -481,7 +481,7 @@ int CGameState::pickHero(PlayerColor owner)
size_t lastHero = std::min(firstHero + GameConstants::HEROES_PER_TYPE*2, VLC->heroh->heroes.size());
//generate list of heroes
for (si32 i=firstHero; i<lastHero; i++)
for (size_t i=firstHero; i<lastHero; ++i)
factionHeroes.push_back(i);
// we need random order to select hero
std::random_shuffle(factionHeroes.begin(), factionHeroes.end(), [](size_t range)
@ -496,7 +496,7 @@ int CGameState::pickHero(PlayerColor owner)
}
tlog3 << "Warning: cannot find free hero - trying to get first available..."<<std::endl;
for(int j=0; j<VLC->heroh->heroes.size(); j++)
for(size_t j=0; j<VLC->heroh->heroes.size(); ++j)
if(!map->getHero(j))
return j;
@ -885,7 +885,7 @@ void CGameState::init(StartInfo * si)
map = mapGen.generate().release();
// Update starting options
for(int i = 0; i < map->players.size(); ++i)
for(size_t i = 0; i < map->players.size(); ++i)
{
const PlayerInfo & pInfo = map->players[i];
if(pInfo.canComputerPlay || pInfo.canHumanPlay)
@ -1107,7 +1107,7 @@ void CGameState::init(StartInfo * si)
}
//selecting heroes by type
for(int g=0; g<map->objects.size(); ++g)
for(size_t g=0; g<map->objects.size(); ++g)
{
const ObjectInstanceID gid = ObjectInstanceID(g);
CGObjectInstance * obj = map->objects[g];
@ -1146,7 +1146,7 @@ void CGameState::init(StartInfo * si)
return a->getHeroStrength() > b->getHeroStrength();
}); //sort, descending strength
for(int g=0; g<map->objects.size(); ++g)
for(size_t g=0; g<map->objects.size(); ++g)
{
const ObjectInstanceID gid = ObjectInstanceID(g);
CGObjectInstance * obj = map->objects[g];
@ -1158,7 +1158,7 @@ void CGameState::init(StartInfo * si)
if (hp->subID == 0xFF) //select by power
{
if(Xheroes.size() > hp->power - 1)
if(Xheroes.size() >= hp->power)
replaceHero(gid, Xheroes[hp->power - 1]);
else
{
@ -1219,7 +1219,7 @@ void CGameState::init(StartInfo * si)
break;
}
//increasing resource quantity
for (int n=0; n<res.size(); ++n)
for (size_t n=0; n<res.size(); ++n)
{
players[ps->color].resources[res[n]] += chosenBonus->info2;
}
@ -1336,7 +1336,7 @@ void CGameState::init(StartInfo * si)
if (chosenBonus->info1 == 0xFFFD) //most powerful
{
int maxB = -1;
for (int b=0; b<heroes.size(); ++b)
for (size_t b=0; b<heroes.size(); ++b)
{
if (maxB == -1 || heroes[b]->getTotalStrength() > heroes[maxB]->getTotalStrength())
{
@ -1350,7 +1350,7 @@ void CGameState::init(StartInfo * si)
}
else //specific hero
{
for (int b=0; b<heroes.size(); ++b)
for (size_t b=0; b<heroes.size(); ++b)
{
if (heroes[b]->subID == chosenBonus->info1)
{
@ -1443,7 +1443,7 @@ void CGameState::init(StartInfo * si)
if (chosenBonus.is_initialized() && chosenBonus->type == CScenarioTravel::STravelBonus::BUILDING)
{
for (int g=0; g<map->towns.size(); ++g)
for (size_t g=0; g<map->towns.size(); ++g)
{
PlayerState * owner = getPlayer(map->towns[g]->getOwner());
if (owner)
@ -1669,7 +1669,7 @@ void CGameState::initDuel()
armies[i] = heroes[i] = h;
obj = h;
h->subID = ss.heroId;
for(int i = 0; i < ss.heroPrimSkills.size(); i++)
for(size_t i = 0; i < ss.heroPrimSkills.size(); ++i)
h->pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(i), ss.heroPrimSkills[i]);
if(ss.spells.size())
@ -2359,7 +2359,7 @@ struct statsHLP
ret.push_back( tmp );
//the rest of elements
for(int g=1; g<stats.size(); ++g)
for(size_t g=1; g<stats.size(); ++g)
{
if(stats[g].second == stats[g-1].second)
{
@ -2389,7 +2389,7 @@ struct statsHLP
return NULL;
//best hero will be that with highest exp
int best = 0;
for(int b=1; b<h.size(); ++b)
for(size_t b=1; b<h.size(); ++b)
{
if(h[b]->exp > h[best]->exp)
{
@ -2522,7 +2522,7 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
if(g->second.color == PlayerColor::NEUTRAL) //do nothing for neutral player
continue;
int bestCre = -1; //best creature's ID
for(int b=0; b<g->second.heroes.size(); ++b)
for(size_t b=0; b<g->second.heroes.size(); ++b)
{
for(TSlots::const_iterator it = g->second.heroes[b]->Slots().begin(); it != g->second.heroes[b]->Slots().end(); ++it)
{
@ -2736,20 +2736,6 @@ std::string PlayerState::nodeName() const
return "Player " + (color.getNum() < VLC->generaltexth->capColors.size() ? VLC->generaltexth->capColors[color.getNum()] : boost::lexical_cast<std::string>(color));
}
// void PlayerState::getParents(TCNodes &out, const CBonusSystemNode *root /*= NULL*/) const
// {
// return; //no loops possible
// }
//
// void PlayerState::getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root /*= NULL*/) const
// {
// for (std::vector<CGHeroInstance *>::const_iterator it = heroes.begin(); it != heroes.end(); it++)
// {
// if (*it != root)
// (*it)->getBonuses(out, selector, this);
// }
// }
InfoAboutArmy::InfoAboutArmy():
owner(PlayerColor::NEUTRAL)
{}
@ -3027,11 +3013,11 @@ TeamState::TeamState()
void CPathfinder::initializeGraph()
{
CGPathNode ***graph = out.nodes;
for(size_t i=0; i < out.sizes.x; ++i)
for(si32 i=0; i < out.sizes.x; ++i)
{
for(size_t j=0; j < out.sizes.y; ++j)
for(si32 j=0; j < out.sizes.y; ++j)
{
for(size_t k=0; k < out.sizes.z; ++k)
for(si32 k=0; k < out.sizes.z; ++k)
{
curPos = int3(i,j,k);
const TerrainTile *tinfo = &gs->map->terrain[i][j][k];

View File

@ -181,10 +181,6 @@ public:
PlayerState();
std::string nodeName() const OVERRIDE;
//override
//void getParents(TCNodes &out, const CBonusSystemNode *root = NULL) const;
//void getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root = NULL) const;
template <typename Handler> void serialize(Handler &h, const int version)
{
h & color & human & currentSelection & team & resources & status;

View File

@ -26,6 +26,7 @@ set(lib_SRCS
BattleState.cpp
CArtHandler.cpp
CBattleCallback.cpp
CBonusTypeHandler.cpp
CBuildingHandler.cpp
CConfigHandler.cpp
CConsoleHandler.cpp
@ -67,6 +68,7 @@ set(lib_HEADERS
AI_Base.h
CondSh.h
ConstTransitivePtr.h
CBonusTypeHandler.h
CRandomGenerator.h
CScriptingModule.h
CStopWatch.h

View File

@ -13,7 +13,7 @@
#include "StringConstants.h"
/*
* CModHandler.h, part of VCMI engine
* CModHandler.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*

View File

@ -198,7 +198,7 @@ static void readBankLevel(const JsonNode &level, BankConfig &bc)
bc.easiest = level["easiest"].Float();
}
void CObjectHandler::loadObjects()
void CObjectHandler::load()
{
tlog5 << "\t\tReading cregens \n";
@ -3787,13 +3787,13 @@ void CGTeleport::postInit() //matches subterranean gates into pairs
//sort by position
std::sort(gatesSplit[0].begin(), gatesSplit[0].end(), boost::bind(&CGObjectInstance::pos, _1) < boost::bind(&CGObjectInstance::pos, _2));
for(size_t i = 0; i < gatesSplit[0].size(); i++)
for(size_t i = 0; i < gatesSplit[0].size(); ++i)
{
const CGObjectInstance *cur = gatesSplit[0][i];
//find nearest underground exit
std::pair<int,double> best(-1,150000); //pair<pos_in_vector, distance>
for(int j = 0; j < gatesSplit[1].size(); j++)
for(size_t j = 0; j < gatesSplit[1].size(); ++j)
{
const CGObjectInstance *checked = gatesSplit[1][j];
if(!checked)
@ -3821,7 +3821,7 @@ void CGTeleport::postInit() //matches subterranean gates into pairs
ObjectInstanceID CGTeleport::getMatchingGate(ObjectInstanceID id)
{
for(int i=0; i < gates.size(); i++)
for(size_t i=0; i < gates.size(); ++i)
{
if(gates[i].first == id)
return gates[i].second;
@ -4158,7 +4158,7 @@ bool CQuest::checkQuest (const CGHeroInstance * h) const
return true;
return false;
case MISSION_ART:
for (int i = 0; i < m5arts.size(); ++i)
for (size_t i = 0; i < m5arts.size(); ++i)
{
if (h->hasArt(m5arts[i]))
continue;
@ -5188,7 +5188,7 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
std::string msg = message; //in case box is removed in the meantime
bool changesPrimSkill = false;
for (int i = 0; i < primskills.size(); i++)
for (size_t i = 0; i < primskills.size(); i++)
{
if(primskills[i])
{
@ -5206,11 +5206,11 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
if(expVal)
iw.components.push_back(Component(Component::EXPERIENCE,0,expVal,0));
for(int i=0; i<primskills.size(); i++)
for(size_t i=0; i<primskills.size(); ++i)
if(primskills[i])
iw.components.push_back(Component(Component::PRIM_SKILL,i,primskills[i],0));
for(int i=0; i<abilities.size(); i++)
for(size_t i=0; i<abilities.size(); ++i)
iw.components.push_back(Component(Component::SEC_SKILL,abilities[i],abilityLevels[i],0));
cb->showInfoDialog(&iw);
@ -5219,12 +5219,12 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
if(expVal)
cb->changePrimSkill(h, PrimarySkill::EXPERIENCE, expVal, false);
//give prim skills
for(int i=0; i<primskills.size(); i++)
for(size_t i=0; i<primskills.size(); ++i)
if(primskills[i])
cb->changePrimSkill(h,static_cast<PrimarySkill::PrimarySkill>(i),primskills[i],false);
//give sec skills
for(int i=0; i<abilities.size(); i++)
for(size_t i=0; i<abilities.size(); ++i)
{
int curLev = h->getSecSkillLevel(abilities[i]);
@ -5297,7 +5297,7 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
iw.components.clear();
iw.text.clear();
for(int i=0; i<resources.size(); i++)
for(size_t i=0; i<resources.size(); ++i)
{
if(resources[i] < 0)
iw.components.push_back(Component(Component::RESOURCE,i,resources[i],0));
@ -5310,7 +5310,7 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
iw.components.clear();
iw.text.clear();
for(int i=0; i<resources.size(); i++)
for(size_t i=0; i<resources.size(); ++i)
{
if(resources[i] > 0)
iw.components.push_back(Component(Component::RESOURCE,i,resources[i],0));
@ -5325,7 +5325,7 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
// getText(iw,afterBattle,183,h);
iw.text.addTxt(MetaString::ADVOB_TXT, 183); //% has found treasure
iw.text.addReplacement(h->name);
for(int i=0; i<artifacts.size(); i++)
for(size_t i=0; i<artifacts.size(); ++i)
{
iw.components.push_back(Component(Component::ARTIFACT,artifacts[i],0,0));
if(iw.components.size() >= 14)
@ -5341,11 +5341,11 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con
cb->showInfoDialog(&iw);
}
for(int i=0; i<resources.size(); i++)
for(size_t i=0; i<resources.size(); ++i)
if(resources[i])
cb->giveResource(h->getOwner(),static_cast<Res::ERes>(i),resources[i]);
for(int i=0; i<artifacts.size(); i++)
for(size_t i=0; i<artifacts.size(); ++i)
cb->giveHeroNewArtifact(h, VLC->arth->artifacts[artifacts[i]],ArtifactPosition::FIRST_AVAILABLE);
iw.components.clear();
@ -6164,7 +6164,7 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
//grant resources
if (textID != 42) //empty derelict ship gives no cash
{
for (int it = 0; it < bc->resources.size(); it++)
for (size_t it = 0; it < bc->resources.size(); ++it)
{
if (bc->resources[it] != 0)
{
@ -6526,7 +6526,7 @@ int3 IBoatGenerator::bestLocation() const
std::vector<int3> offsets;
getOutOffsets(offsets);
for (int i = 0; i < offsets.size(); ++i)
for (size_t i = 0; i < offsets.size(); ++i)
{
if (const TerrainTile *tile = IObjectInterface::cb->getTile(o->pos + offsets[i], false)) //tile is in the map
{

View File

@ -353,9 +353,6 @@ public:
//visitied town pointer will be restored by map serialization method
}
//////////////////////////////////////////////////////////////////////////
// void getParents(TCNodes &out, const CBonusSystemNode *root = NULL) const;
// void getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root = NULL) const;
//////////////////////////////////////////////////////////////////////////
int3 getSightCenter() const; //"center" tile from which the sight distance is calculated
int getSightRadious() const; //sight distance (should be used if player-owned structure)
//////////////////////////////////////////////////////////////////////////
@ -622,8 +619,7 @@ public:
void setVisitingHero(CGHeroInstance *h);
void setGarrisonedHero(CGHeroInstance *h);
const CArmedInstance *getUpperArmy() const; //garrisoned hero if present or the town itself
// void getParents(TCNodes &out, const CBonusSystemNode *root = NULL) const;
// void getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root = NULL) const;
//////////////////////////////////////////////////////////////////////////
ui8 getPassableness() const; //bitmap - if the bit is set the corresponding player can pass through the visitable tiles of object, even if it's blockvis; if not set - default properties from definfo are used
@ -1398,7 +1394,7 @@ public:
std::map <ui32, std::string> creBanksNames; //[crebank index] -> name of this creature bank
std::vector<ui32> resVals; //default values of resources in gold
void loadObjects();
void load();
int bankObjToIndex (const CGObjectInstance * obj);
template <typename Handler> void serialize(Handler &h, const int version)

View File

@ -177,7 +177,7 @@ std::vector<BattleHex> CSpell::rangeInHexes(BattleHex centralHex, ui8 schoolLvl,
std::string number1, number2;
int beg, end;
bool readingFirst = true;
for(int it=0; it<rng.size(); ++it)
for(size_t it=0; it<rng.size(); ++it)
{
if( std::isdigit(rng[it]) ) //reading numer
{
@ -397,7 +397,7 @@ CSpell * CSpellHandler::loadSpell(CLegacyConfigParser & parser, const SpellID id
return spell;
}
void CSpellHandler::loadSpells()
void CSpellHandler::load()
{
CLegacyConfigParser parser("DATA/SPTRAITS.TXT");

View File

@ -168,7 +168,7 @@ public:
CSpellHandler();
std::vector< ConstTransitivePtr<CSpell> > spells;
void loadSpells();
void load();
/**
* Gets a list of default allowed spells. OH3 spells are all allowed by default.

View File

@ -1030,7 +1030,7 @@ void CBonusSystemNode::limitBonuses(const BonusList &allBonuses, BonusList &out)
while(true)
{
int undecidedCount = undecided.size();
for(int i = 0; i < undecided.size(); i++)
for(size_t i = 0; i < undecided.size(); ++i)
{
Bonus *b = undecided[i];
BonusLimitationContext context = {b, *this, out};

25
lib/IBonusTypeHandler.h Normal file
View File

@ -0,0 +1,25 @@
/*
* IBonusTypeHandler.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
class IBonusBearer;
struct Bonus;
///High level interface for BonusTypeHandler
class IBonusTypeHandler
{
public:
virtual ~IBonusTypeHandler(){};
virtual std::string bonusToString(Bonus *bonus, const IBonusBearer *bearer, bool description) const = 0;
virtual std::string bonusToGraphics(Bonus *bonus) const = 0;
};

View File

@ -18,6 +18,7 @@
#include "GameConstants.h"
#include "CModHandler.h"
#include "CDefObjInfoHandler.h"
#include "CBonusTypeHandler.h"
#include "Connection.h"
@ -861,7 +862,7 @@ const CGHeroInstance* CPlayerSpecificInfoCallback::getHeroBySerial(int serialId,
if (!includeGarrisoned)
{
for(ui32 i = 0; i < p->heroes.size() && i<=serialId; i++)
for(size_t i = 0; i < p->heroes.size() && i<=serialId; ++i)
if(p->heroes[i]->inTownGarrison)
serialId++;
}

View File

@ -303,7 +303,7 @@ bool CCampaign::conquerable( int whichScenario ) const
return false;
}
//check preconditioned regions
for (int g=0; g<scenarios.size(); ++g)
for (size_t g=0; g<scenarios.size(); ++g)
{
if( vstd::contains(scenarios[whichScenario].preconditionRegions, g) && !scenarios[g].conquered)
return false; //prerequisite does not met
@ -462,7 +462,7 @@ CCampaignState::CCampaignState()
CCampaignState::CCampaignState( unique_ptr<CCampaign> _camp ) : camp(std::move(_camp))
{
for(int i = 0; i < camp->scenarios.size(); i++)
for(size_t i = 0; i < camp->scenarios.size(); i++)
{
if(vstd::contains(camp->mapPieces, i)) //not all maps must be present in a campaign
mapsRemaining.push_back(i);

View File

@ -50,7 +50,7 @@ CTerrainViewPatternConfig::CTerrainViewPatternConfig()
{
throw std::runtime_error("Size of pattern's data vector has to be 9.");
}
for(int i = 0; i < data.size(); ++i)
for(size_t i = 0; i < data.size(); ++i)
{
std::string cell = data[i].String();
boost::algorithm::erase_all(cell, " ");
@ -169,7 +169,7 @@ void CMapEditManager::updateTerrainViews(int posx, int posy, int width, int heig
// Detect a pattern which fits best
int bestPattern = -1, bestFlip = -1;
std::string transitionReplacement;
for(int k = 0; k < patterns.size(); ++k)
for(size_t k = 0; k < patterns.size(); ++k)
{
const TerrainViewPattern & pattern = patterns[k];
@ -275,7 +275,7 @@ CMapEditManager::ValidationResult CMapEditManager::validateTerrainView(int posx,
// Validate all rules per cell
int topPoints = -1;
for(int j = 0; j < pattern.data[i].size(); ++j)
for(size_t j = 0; j < pattern.data[i].size(); ++j)
{
TerrainViewPattern::WeightedRule rule = pattern.data[i][j];
if(!rule.isStandardRule())

View File

@ -281,7 +281,7 @@ DLL_LINKAGE void RemoveBonus::applyGs( CGameState *gs )
BonusList &bonuses = node->getBonusList();
for (int i = 0; i < bonuses.size(); i++)
for (size_t i = 0; i < bonuses.size(); ++i)
{
Bonus *b = bonuses[i];
if(b->source == source && b->sid == id)
@ -735,6 +735,32 @@ DLL_LINKAGE void RebalanceStacks::applyGs( CGameState *gs )
if(const CCreature *c = dst.army->getCreature(dst.slot)) //stack at dest -> merge
{
assert(c == srcType);
auto alHere = ArtifactLocation (src.getStack(), ArtifactPosition::CREATURE_SLOT);
auto alDest = ArtifactLocation (dst.getStack(), ArtifactPosition::CREATURE_SLOT);
auto artHere = alHere.getArt();
auto artDest = alDest.getArt();
if (artHere)
{
if (alDest.getArt())
{
auto hero = dynamic_cast <CGHeroInstance *>(src.army.get());
if (hero)
{
artDest->move (alDest, ArtifactLocation (hero, alDest.getArt()->firstBackpackSlot (hero)));
}
//else - artifact cna be lost :/
else
{
tlog2 << "Artifact is present at destination slot!";
}
artHere->move (alHere, alDest);
//TODO: choose from dialog
}
else //just move to the other slot before stack gets erased
{
artHere->move (alHere, alDest);
}
}
if (stackExp)
{
ui64 totalExp = srcCount * src.army->getStackExperience(src.slot) + dst.army->getStackCount(dst.slot) * dst.army->getStackExperience(dst.slot);
@ -1142,7 +1168,7 @@ DLL_LINKAGE void BattleStackAttacked::applyGs( CGameState *gs )
at->state -= EBattleStackState::ALIVE;
}
//life drain handling
for (int g=0; g<healedStacks.size(); ++g)
for (size_t g=0; g<healedStacks.size(); ++g)
{
healedStacks[g].applyGs(gs);
}
@ -1358,7 +1384,7 @@ DLL_LINKAGE void StacksInjured::applyGs( CGameState *gs )
DLL_LINKAGE void StacksHealedOrResurrected::applyGs( CGameState *gs )
{
for(int g=0; g<healedStacks.size(); ++g)
for(size_t g=0; g<healedStacks.size(); ++g)
{
CStack * changedStack = gs->curB->getStack(healedStacks[g].stackID, false);
@ -1426,7 +1452,7 @@ DLL_LINKAGE void ObstaclesRemoved::applyGs( CGameState *gs )
{
BOOST_FOREACH(const si32 rem_obst,obstacles)
{
for(int i=0; i<gs->curB->obstacles.size(); ++i)
for(size_t i=0; i<gs->curB->obstacles.size(); ++i)
{
if(gs->curB->obstacles[i]->uniqueID == rem_obst) //remove this obstacle
{
@ -1456,7 +1482,7 @@ DLL_LINKAGE void BattleStacksRemoved::applyGs( CGameState *gs )
return;
BOOST_FOREACH(ui32 rem_stack, stackIDs)
{
for(int b=0; b<gs->curB->stacks.size(); ++b) //find it in vector of stacks
for(size_t b=0; b<gs->curB->stacks.size(); ++b) //find it in vector of stacks
{
if(gs->curB->stacks[b]->ID == rem_stack) //if found
{

View File

@ -38,7 +38,7 @@ namespace Res
ResourceSet operator OPSIGN(const TResource &rhs) const \
{ \
ResourceSet ret = *this; \
for(int i = 0; i < size(); i++) \
for(size_t i = 0; i < size(); i++) \
ret[i] = at(i) OPSIGN rhs; \
\
return ret; \
@ -50,7 +50,7 @@ namespace Res
ResourceSet operator OPSIGN(const ResourceSet &rhs) const \
{ \
ResourceSet ret = *this; \
for(int i = 0; i < size(); i++) \
for(size_t i = 0; i < size(); i++) \
ret[i] = at(i) OPSIGN rhs[i]; \
\
return ret; \
@ -83,7 +83,7 @@ namespace Res
int operator/(const ResourceSet &rhs)
{
int ret = INT_MAX;
for(int i = 0; i < size(); i++)
for(size_t i = 0; i < size(); i++)
if(rhs[i])
vstd::amin(ret, at(i) / rhs[i]);
@ -92,7 +92,7 @@ namespace Res
ResourceSet & operator=(const TResource &rhs)
{
for(int i = 0; i < size(); i++)
for(size_t i = 0; i < size(); i++)
at(i) = rhs;
return *this;

View File

@ -67,7 +67,7 @@ std::string VCMIDirs::localPath() const
if (getenv("HOME") != NULL )
home_dir = getenv("HOME");
return path(home_dir + "/Library/Application Support/vcmi").string();
return boost::filesystem::path(home_dir + "/Library/Application Support/vcmi").string();
}
std::string VCMIDirs::libraryPath() const

View File

@ -1,8 +1,18 @@
/*
* VCMI_Lib.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "VCMI_Lib.h"
#include "CArtHandler.h"
#include "CBonusTypeHandler.h"
#include "CCreatureHandler.h"
#include "CDefObjInfoHandler.h"
#include "CHeroHandler.h"
@ -17,15 +27,6 @@
#include "VCMIDirs.h"
#include "Filesystem/CResourceLoader.h"
/*
* VCMI_Lib.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
LibClasses * VLC = NULL;
@ -50,6 +51,11 @@ DLL_LINKAGE void loadDLLClasses()
HANDLE_EXCEPTION;
}
const IBonusTypeHandler * LibClasses::getBth() const
{
return bth;
}
void LibClasses::loadFilesystem()
{
CStopWatch totalTime;
@ -71,41 +77,40 @@ void LibClasses::loadFilesystem()
tlog0<<"Basic initialization: "<<totalTime.getDiff()<<std::endl;
}
static void logHandlerLoaded(const std::string& name, CStopWatch &timer)
{
tlog0<<"\t" << name << " handler: "<<timer.getDiff()<<std::endl;
};
template <class Handler> void createHandler(Handler *&handler, const std::string &name, CStopWatch &timer)
{
handler = new Handler();
handler->load();
logHandlerLoaded(name, timer);
}
void LibClasses::init()
{
CStopWatch pomtime;
createHandler(bth, "Bonus type", pomtime);
createHandler(generaltexth, "General text", pomtime);
generaltexth = new CGeneralTextHandler;
generaltexth->load();
tlog0<<"\tGeneral text handler: "<<pomtime.getDiff()<<std::endl;
createHandler(heroh, "Hero", pomtime);
heroh = new CHeroHandler;
heroh->load();
tlog0 <<"\tHero handler: "<<pomtime.getDiff()<<std::endl;
createHandler(arth, "Artifact", pomtime);
arth = new CArtHandler;
arth->loadArtifacts(false);
tlog0<<"\tArtifact handler: "<<pomtime.getDiff()<<std::endl;
createHandler(creh, "Creature", pomtime);
creh = new CCreatureHandler();
creh->loadCreatures();
tlog0<<"\tCreature handler: "<<pomtime.getDiff()<<std::endl;
createHandler(townh, "Town", pomtime);
createHandler(objh, "Object", pomtime);
createHandler(dobjinfo, "Def information", pomtime);
townh = new CTownHandler;
townh->load();
tlog0<<"\tTown handler: "<<pomtime.getDiff()<<std::endl;
createHandler(spellh, "Spell", pomtime);
objh = new CObjectHandler;
objh->loadObjects();
tlog0<<"\tObject handler: "<<pomtime.getDiff()<<std::endl;
dobjinfo = new CDefObjInfoHandler;
dobjinfo->load();
tlog0<<"\tDef information handler: "<<pomtime.getDiff()<<std::endl;
spellh = new CSpellHandler;
spellh->loadSpells();
tlog0<<"\tSpell handler: "<<pomtime.getDiff()<<std::endl;
modh->loadActiveMods();
modh->reload();
@ -126,20 +131,22 @@ void LibClasses::clear()
delete dobjinfo;
delete spellh;
delete modh;
delete bth;
makeNull();
}
void LibClasses::makeNull()
{
generaltexth = NULL;
heroh = NULL;
arth = NULL;
creh = NULL;
townh = NULL;
objh = NULL;
dobjinfo = NULL;
spellh = NULL;
modh = NULL;
generaltexth = nullptr;
heroh = nullptr;
arth = nullptr;
creh = nullptr;
townh = nullptr;
objh = nullptr;
dobjinfo = nullptr;
spellh = nullptr;
modh = nullptr;
bth = nullptr;
}
LibClasses::LibClasses()
@ -152,7 +159,7 @@ void LibClasses::callWhenDeserializing()
{
generaltexth = new CGeneralTextHandler;
generaltexth->load();
arth->loadArtifacts(true);
arth->load(true);
//modh->recreateHandlers();
//modh->loadConfigFromFile ("defaultMods"); //TODO: remember last saved config
}

View File

@ -20,14 +20,21 @@ class CDefObjInfoHandler;
class CTownHandler;
class CGeneralTextHandler;
class CModHandler;
class IBonusTypeHandler;
class CBonusTypeHandler;
/// Loads and constructs several handlers
class DLL_LINKAGE LibClasses
{
CBonusTypeHandler * bth;
void callWhenDeserializing(); //should be called only by serialize !!!
void makeNull(); //sets all handler pointers to null
public:
bool IS_AI_ENABLED; //VLC is the only object visible from both CMT and GeniusAI
const IBonusTypeHandler * getBth() const;
CArtHandler * arth;
CHeroHandler * heroh;
CCreatureHandler * creh;
@ -49,7 +56,8 @@ public:
template <typename Handler> void serialize(Handler &h, const int version)
{
h & heroh & arth & creh & townh & objh & dobjinfo & spellh & modh & IS_AI_ENABLED;;
h & heroh & arth & creh & townh & objh & dobjinfo & spellh & modh & IS_AI_ENABLED;
h & bth;
if(!h.saving)
{
callWhenDeserializing();

View File

@ -13,6 +13,8 @@
<Option object_output="../obj/Debug/Lib" />
<Option type="3" />
<Option compiler="gcc" />
<Option host_application="D:/projects/vcmi/engine/VCMI_client.exe" />
<Option run_host_application_in_terminal="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-O1" />
@ -73,6 +75,8 @@
<Unit filename="CArtHandler.h" />
<Unit filename="CBattleCallback.cpp" />
<Unit filename="CBattleCallback.h" />
<Unit filename="CBonusTypeHandler.cpp" />
<Unit filename="CBonusTypeHandler.h" />
<Unit filename="CBuildingHandler.cpp" />
<Unit filename="CBuildingHandler.h" />
<Unit filename="CConfigHandler.cpp" />
@ -136,6 +140,7 @@
<Unit filename="GameConstants.h" />
<Unit filename="HeroBonus.cpp" />
<Unit filename="HeroBonus.h" />
<Unit filename="IBonusTypeHandler.h" />
<Unit filename="IGameCallback.cpp" />
<Unit filename="IGameCallback.h" />
<Unit filename="IGameEventsReceiver.h" />
@ -171,6 +176,7 @@
</Unit>
<Unit filename="StringConstants.h" />
<Unit filename="UnlockGuard.h" />
<Unit filename="VCMIDirs.cpp" />
<Unit filename="VCMIDirs.h" />
<Unit filename="VCMI_Lib.cpp" />
<Unit filename="VCMI_Lib.h" />

View File

@ -38,7 +38,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@ -228,6 +228,7 @@
<ClInclude Include="BattleHex.h" />
<ClInclude Include="BattleState.h" />
<ClInclude Include="CArtHandler.h" />
<ClInclude Include="CBonusTypeHandler.h" />
<ClInclude Include="CBuildingHandler.h" />
<ClInclude Include="CConfigHandler.h" />
<ClInclude Include="CConsoleHandler.h" />
@ -261,6 +262,7 @@
<ClInclude Include="Filesystem\CMemoryStream.h" />
<ClInclude Include="Filesystem\CResourceLoader.h" />
<ClInclude Include="Filesystem\ISimpleResourceLoader.h" />
<ClInclude Include="IBonusTypeHandler.h" />
<ClInclude Include="Mapping\CCampaignHandler.h" />
<ClInclude Include="Mapping\CMap.h" />
<ClInclude Include="Mapping\CMapInfo.h" />