1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

- build system update

- compile fix for quests (vector can't be used to store const data)
- fixed several "unitialized" warnings
This commit is contained in:
Ivan Savenko
2012-07-06 20:19:54 +00:00
parent 12511d8fee
commit 50e8bc1704
13 changed files with 64 additions and 32 deletions

View File

@ -1477,7 +1477,7 @@ IexpValStr ERMInterpreter::getVar(std::string toFollow, boost::optional<int> ini
IexpValStr ret; IexpValStr ret;
ret.type = IexpValStr::WRONGVAL; ret.type = IexpValStr::WRONGVAL;
int initV; int initV=0;
bool hasInit = false; bool hasInit = false;
if(initVal.is_initialized()) if(initVal.is_initialized())
{ {

View File

@ -150,10 +150,10 @@ CCreatureWindow::CCreatureWindow (const CCommanderInstance * Commander):
CCreatureWindow::CCreatureWindow (std::vector<ui32> &skills, const CCommanderInstance * Commander, boost::function<void(ui32)> &callback): CCreatureWindow::CCreatureWindow (std::vector<ui32> &skills, const CCommanderInstance * Commander, boost::function<void(ui32)> &callback):
CWindowObject(PLAYER_COLORED), CWindowObject(PLAYER_COLORED),
type(COMMANDER_LEVEL_UP), type(COMMANDER_LEVEL_UP),
upgradeOptions(skills), //copy skills to choose from
commander (Commander), commander (Commander),
levelUp (callback), selectedOption (0), //choose something before drawing
selectedOption (0) //choose something before drawing upgradeOptions(skills), //copy skills to choose from
levelUp (callback)
{ {
OBJ_CONSTRUCTION_CAPTURING_ALL; OBJ_CONSTRUCTION_CAPTURING_ALL;

View File

@ -22,7 +22,7 @@
struct QuestInfo; struct QuestInfo;
CQuestLog::CQuestLog (std::vector<const QuestInfo> & Quests) : CQuestLog::CQuestLog (const std::vector<QuestInfo> & Quests) :
CWindowObject(PLAYER_COLORED, "QuestLog.pcx"), CWindowObject(PLAYER_COLORED, "QuestLog.pcx"),
quests (Quests), slider (NULL) quests (Quests), slider (NULL)
{ {

View File

@ -46,7 +46,7 @@ public:
class CQuestLog : public CWindowObject class CQuestLog : public CWindowObject
{ {
std::vector<const QuestInfo> & quests; const std::vector<QuestInfo> quests;
CTextBox * description; CTextBox * description;
CQuestMinimap * minimap; CQuestMinimap * minimap;
CSlider * slider; //scrolls quests CSlider * slider; //scrolls quests
@ -54,7 +54,7 @@ class CQuestLog : public CWindowObject
public: public:
CQuestLog (std::vector<const QuestInfo> & Quests); CQuestLog (const std::vector<QuestInfo> & Quests);
~CQuestLog(){}; ~CQuestLog(){};

View File

@ -82,6 +82,8 @@ vcmiclient_SOURCES = \
CSpellWindow.h \ CSpellWindow.h \
CVideoHandler.cpp \ CVideoHandler.cpp \
CVideoHandler.h \ CVideoHandler.h \
CQuestLog.cpp \
CQuestLog.h \
FontBase.h \ FontBase.h \
FunctionList.h \ FunctionList.h \
Graphics.cpp \ Graphics.cpp \

View File

@ -89,7 +89,8 @@ am_vcmiclient_OBJECTS = vcmiclient-CCallback.$(OBJEXT) \
vcmiclient-CPreGame.$(OBJEXT) vcmiclient-CSndHandler.$(OBJEXT) \ vcmiclient-CPreGame.$(OBJEXT) vcmiclient-CSndHandler.$(OBJEXT) \
vcmiclient-CSpellWindow.$(OBJEXT) \ vcmiclient-CSpellWindow.$(OBJEXT) \
vcmiclient-CVideoHandler.$(OBJEXT) \ vcmiclient-CVideoHandler.$(OBJEXT) \
vcmiclient-Graphics.$(OBJEXT) vcmiclient-GUIClasses.$(OBJEXT) \ vcmiclient-CQuestLog.$(OBJEXT) vcmiclient-Graphics.$(OBJEXT) \
vcmiclient-GUIClasses.$(OBJEXT) \
vcmiclient-mapHandler.$(OBJEXT) \ vcmiclient-mapHandler.$(OBJEXT) \
vcmiclient-NetPacksClient.$(OBJEXT) vcmiclient-NetPacksClient.$(OBJEXT)
vcmiclient_OBJECTS = $(am_vcmiclient_OBJECTS) vcmiclient_OBJECTS = $(am_vcmiclient_OBJECTS)
@ -386,6 +387,8 @@ vcmiclient_SOURCES = \
CSpellWindow.h \ CSpellWindow.h \
CVideoHandler.cpp \ CVideoHandler.cpp \
CVideoHandler.h \ CVideoHandler.h \
CQuestLog.cpp \
CQuestLog.h \
FontBase.h \ FontBase.h \
FunctionList.h \ FunctionList.h \
Graphics.cpp \ Graphics.cpp \
@ -509,6 +512,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMusicHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMusicHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CPlayerInterface.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CPlayerInterface.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CPreGame.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CPreGame.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CQuestLog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CSndHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CSndHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CSpellWindow.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CSpellWindow.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CVideoHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CVideoHandler.Po@am__quote@
@ -975,6 +979,20 @@ vcmiclient-CVideoHandler.obj: CVideoHandler.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CVideoHandler.obj `if test -f 'CVideoHandler.cpp'; then $(CYGPATH_W) 'CVideoHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/CVideoHandler.cpp'; fi` @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CVideoHandler.obj `if test -f 'CVideoHandler.cpp'; then $(CYGPATH_W) 'CVideoHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/CVideoHandler.cpp'; fi`
vcmiclient-CQuestLog.o: CQuestLog.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CQuestLog.o -MD -MP -MF $(DEPDIR)/vcmiclient-CQuestLog.Tpo -c -o vcmiclient-CQuestLog.o `test -f 'CQuestLog.cpp' || echo '$(srcdir)/'`CQuestLog.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CQuestLog.Tpo $(DEPDIR)/vcmiclient-CQuestLog.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='CQuestLog.cpp' object='vcmiclient-CQuestLog.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CQuestLog.o `test -f 'CQuestLog.cpp' || echo '$(srcdir)/'`CQuestLog.cpp
vcmiclient-CQuestLog.obj: CQuestLog.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CQuestLog.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CQuestLog.Tpo -c -o vcmiclient-CQuestLog.obj `if test -f 'CQuestLog.cpp'; then $(CYGPATH_W) 'CQuestLog.cpp'; else $(CYGPATH_W) '$(srcdir)/CQuestLog.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CQuestLog.Tpo $(DEPDIR)/vcmiclient-CQuestLog.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='CQuestLog.cpp' object='vcmiclient-CQuestLog.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CQuestLog.obj `if test -f 'CQuestLog.cpp'; then $(CYGPATH_W) 'CQuestLog.cpp'; else $(CYGPATH_W) '$(srcdir)/CQuestLog.cpp'; fi`
vcmiclient-Graphics.o: Graphics.cpp vcmiclient-Graphics.o: Graphics.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-Graphics.o -MD -MP -MF $(DEPDIR)/vcmiclient-Graphics.Tpo -c -o vcmiclient-Graphics.o `test -f 'Graphics.cpp' || echo '$(srcdir)/'`Graphics.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-Graphics.o -MD -MP -MF $(DEPDIR)/vcmiclient-Graphics.Tpo -c -o vcmiclient-Graphics.o `test -f 'Graphics.cpp' || echo '$(srcdir)/'`Graphics.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-Graphics.Tpo $(DEPDIR)/vcmiclient-Graphics.Po @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-Graphics.Tpo $(DEPDIR)/vcmiclient-Graphics.Po

View File

@ -39,7 +39,7 @@ static const CStack *takeStack(std::vector<const CStack *> &st, int &curside, in
{ {
const CStack *ret = NULL; const CStack *ret = NULL;
unsigned i, //fastest stack unsigned i, //fastest stack
j; //fastest stack of the other side j=0; //fastest stack of the other side
for(i = 0; i < st.size(); i++) for(i = 0; i < st.size(); i++)
if(st[i]) if(st[i])
break; break;

View File

@ -1227,7 +1227,7 @@ void CGameState::init(StartInfo * si)
if (chosenBonus.isBonusForHero() && chosenBonus.info1 != 0xFFFE) //exclude generated heroes if (chosenBonus.isBonusForHero() && chosenBonus.info1 != 0xFFFE) //exclude generated heroes
{ {
//find human player //find human player
int humanPlayer; int humanPlayer=GameConstants::NEUTRAL_PLAYER;
for (std::map<ui8, PlayerState>::iterator it=players.begin(); it != players.end(); ++it) for (std::map<ui8, PlayerState>::iterator it=players.begin(); it != players.end(); ++it)
{ {
if(it->second.human) if(it->second.human)
@ -1236,6 +1236,8 @@ void CGameState::init(StartInfo * si)
break; break;
} }
} }
assert(humanPlayer != GameConstants::NEUTRAL_PLAYER);
std::vector<ConstTransitivePtr<CGHeroInstance> > & heroes = players[humanPlayer].heroes; std::vector<ConstTransitivePtr<CGHeroInstance> > & heroes = players[humanPlayer].heroes;
if (chosenBonus.info1 == 0xFFFD) //most powerful if (chosenBonus.info1 == 0xFFFD) //most powerful

View File

@ -449,7 +449,7 @@ struct DLL_LINKAGE QuestInfo //universal interface for human and AI
QuestInfo(){}; QuestInfo(){};
QuestInfo (const CQuest * Quest, const CGObjectInstance * Obj, int3 Tile) : QuestInfo (const CQuest * Quest, const CGObjectInstance * Obj, int3 Tile) :
quest (Quest), obj (obj), tile (tile){} quest (Quest), obj (Obj), tile (Tile){}
//std::vector<std::string> > texts //allow additional info for quest log? //std::vector<std::string> > texts //allow additional info for quest log?

View File

@ -1154,6 +1154,9 @@ void CGHeroInstance::UpdateSpeciality()
case PrimarySkill::DEFENSE: case PrimarySkill::DEFENSE:
param = creatures[it->additionalInfo]->defence; param = creatures[it->additionalInfo]->defence;
break; break;
default:
assert(0);
param = 0;
} }
it->val = ceil(param * (1 + primSkillModifier)) - param; //yep, overcomplicated but matches original it->val = ceil(param * (1 + primSkillModifier)) - param; //yep, overcomplicated but matches original
break; break;
@ -2857,7 +2860,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
if ((town->builtBuildings.find(ID) != town->builtBuildings.end()) && (visitors.find(heroID) == visitors.end())) if ((town->builtBuildings.find(ID) != town->builtBuildings.end()) && (visitors.find(heroID) == visitors.end()))
{ {
InfoWindow iw; InfoWindow iw;
int what, val, mid; int what=0, val=0, mid=0;
switch (ID) switch (ID)
{ {
case 23: case 23:
@ -2901,6 +2904,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
} }
break; break;
} }
assert(mid);
iw.player = cb->getOwner(heroID); iw.player = cb->getOwner(heroID);
iw.text << VLC->generaltexth->allTexts[mid]; iw.text << VLC->generaltexth->allTexts[mid];
cb->showInfoDialog(&iw); cb->showInfoDialog(&iw);
@ -3521,7 +3525,7 @@ bool CGVisitableOPW::wasVisited(ui8 player) const
void CGVisitableOPW::onHeroVisit( const CGHeroInstance * h ) const void CGVisitableOPW::onHeroVisit( const CGHeroInstance * h ) const
{ {
int mid, sound = 0; int mid=0, sound = 0;
switch (ID) switch (ID)
{ {
case 55: //mystical garden case 55: //mystical garden
@ -3536,6 +3540,8 @@ void CGVisitableOPW::onHeroVisit( const CGHeroInstance * h ) const
sound = soundBase::GENIE; sound = soundBase::GENIE;
mid = 164; mid = 164;
break; break;
default:
assert(0);
} }
if (visited) if (visited)
{ {
@ -3552,7 +3558,7 @@ void CGVisitableOPW::onHeroVisit( const CGHeroInstance * h ) const
} }
else else
{ {
int type, sub, val; int type, sub=0, val=0;
type = 2; type = 2;
switch (ID) switch (ID)
{ {
@ -4271,7 +4277,7 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
{ {
bool firstVisit = !progress; bool firstVisit = !progress;
bool failRequirements = !checkQuest(h); bool failRequirements = !checkQuest(h);
bool isCustom; bool isCustom=false;
std::string text; std::string text;
if (firstVisit) if (firstVisit)
{ {
@ -4732,7 +4738,7 @@ bool CGBonusingObject::wasVisited (const CGHeroInstance * h) const
void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
{ {
bool visited = h->hasBonusFrom(Bonus::OBJECT,ID); bool visited = h->hasBonusFrom(Bonus::OBJECT,ID);
int messageID; int messageID=0;
int bonusMove = 0, sound = -1; int bonusMove = 0, sound = -1;
InfoWindow iw; InfoWindow iw;
iw.player = h->tempOwner; iw.player = h->tempOwner;
@ -4880,6 +4886,7 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
gbonus.bdescr << std::pair<ui8,ui32>(6, 100); gbonus.bdescr << std::pair<ui8,ui32>(6, 100);
break; break;
} }
assert(messageID);
if(visited) if(visited)
{ {
if(ID==64 || ID==56 || ID==52 || ID==94) if(ID==64 || ID==56 || ID==52 || ID==94)
@ -6557,7 +6564,7 @@ void CCartographer::onHeroVisit( const CGHeroInstance * h ) const
if (cb->getResource(h->tempOwner, 6) >= 1000) //if he can afford a map if (cb->getResource(h->tempOwner, 6) >= 1000) //if he can afford a map
{ {
//ask if he wants to buy one //ask if he wants to buy one
int text; int text=0;
switch (subID) switch (subID)
{ {
case 0: case 0:
@ -6572,6 +6579,7 @@ void CCartographer::onHeroVisit( const CGHeroInstance * h ) const
default: default:
tlog2 << "Unrecognized subtype of cartographer" << std::endl; tlog2 << "Unrecognized subtype of cartographer" << std::endl;
} }
assert(text);
BlockingDialog bd (true, false); BlockingDialog bd (true, false);
bd.player = h->getOwner(); bd.player = h->getOwner();
bd.soundID = soundBase::LIGHTHOUSE; bd.soundID = soundBase::LIGHTHOUSE;

View File

@ -1217,9 +1217,9 @@ std::vector < const CGDwelling * > CPlayerSpecificInfoCallback::getMyDwellings()
return ret; return ret;
} }
std::vector <const QuestInfo> CPlayerSpecificInfoCallback::getMyQuests() const std::vector <QuestInfo> CPlayerSpecificInfoCallback::getMyQuests() const
{ {
std::vector <const QuestInfo> ret; std::vector <QuestInfo> ret;
BOOST_FOREACH (auto quest, gs->getPlayer(player)->quests) BOOST_FOREACH (auto quest, gs->getPlayer(player)->quests)
{ {
ret.push_back (quest); ret.push_back (quest);

View File

@ -234,7 +234,7 @@ public:
std::vector <const CGHeroInstance *> getHeroesInfo(bool onlyOur = true) const; //true -> only owned; false -> all visible std::vector <const CGHeroInstance *> getHeroesInfo(bool onlyOur = true) const; //true -> only owned; false -> all visible
std::vector <const CGDwelling *> getMyDwellings() const; //returns all dwellings that belong to player std::vector <const CGDwelling *> getMyDwellings() const; //returns all dwellings that belong to player
std::vector <const CGObjectInstance * > getMyObjects() const; //returns all objects flagged by belonging player std::vector <const CGObjectInstance * > getMyObjects() const; //returns all objects flagged by belonging player
std::vector <const QuestInfo> getMyQuests() const; std::vector <QuestInfo> getMyQuests() const;
int getResourceAmount(int type)const; int getResourceAmount(int type)const;
TResources getResourceAmount() const; TResources getResourceAmount() const;

View File

@ -293,7 +293,7 @@ void CMapHeader::loadViCLossConditions( const ui8 * bufor, int &i)
victoryCondition.condition = (EVictoryConditionType::EVictoryConditionType)bufor[i++]; victoryCondition.condition = (EVictoryConditionType::EVictoryConditionType)bufor[i++];
if (victoryCondition.condition != EVictoryConditionType::WINSTANDARD) //specific victory conditions if (victoryCondition.condition != EVictoryConditionType::WINSTANDARD) //specific victory conditions
{ {
int nr; int nr=0;
switch (victoryCondition.condition) //read victory conditions switch (victoryCondition.condition) //read victory conditions
{ {
case EVictoryConditionType::ARTIFACT: case EVictoryConditionType::ARTIFACT:
@ -366,6 +366,8 @@ void CMapHeader::loadViCLossConditions( const ui8 * bufor, int &i)
nr = 4; nr = 4;
break; break;
} }
default:
assert(0);
} }
victoryCondition.allowNormalVictory = bufor[i++]; victoryCondition.allowNormalVictory = bufor[i++];
victoryCondition.appliesToAI = bufor[i++]; victoryCondition.appliesToAI = bufor[i++];