Sfoglia il codice sorgente

- build system update
- compile fix for quests (vector can't be used to store const data)
- fixed several "unitialized" warnings

Ivan Savenko 13 anni fa
parent
commit
50e8bc1704

+ 1 - 1
Scripting/ERM/ERMInterpreter.cpp

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

+ 3 - 3
client/CCreatureWindow.cpp

@@ -150,10 +150,10 @@ CCreatureWindow::CCreatureWindow (const CCommanderInstance * Commander):
 CCreatureWindow::CCreatureWindow (std::vector<ui32> &skills, const CCommanderInstance * Commander, boost::function<void(ui32)> &callback):
     CWindowObject(PLAYER_COLORED),
     type(COMMANDER_LEVEL_UP),
-	upgradeOptions(skills), //copy skills to choose from
 	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;
 

+ 1 - 1
client/CQuestLog.cpp

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

+ 13 - 13
client/CQuestLog.h

@@ -30,23 +30,23 @@ struct QuestInfo;
 
 class CQuestMinimap : public CMinimap
 {
-	void clickLeft(tribool down, bool previousState){};
-	void mouseMoved (const SDL_MouseMotionEvent & sEvent){};
-
-public:
-
-	CQuestMinimap (const Rect & position) : CMinimap (position){};
-	//should be called to invalidate whole map - different player or level
-	void update(){};
-	void setLevel(int level){};
-	void addQuestMarks (QuestInfo q){};
-
+	void clickLeft(tribool down, bool previousState){};
+	void mouseMoved (const SDL_MouseMotionEvent & sEvent){};
+
+public:
+
+	CQuestMinimap (const Rect & position) : CMinimap (position){};
+	//should be called to invalidate whole map - different player or level
+	void update(){};
+	void setLevel(int level){};
+	void addQuestMarks (QuestInfo q){};
+
 	void showAll(SDL_Surface * to){};
 };
 
 class CQuestLog : public CWindowObject
 {
-	std::vector<const QuestInfo> & quests;
+	const std::vector<QuestInfo> quests;
 	CTextBox * description;
 	CQuestMinimap * minimap;
 	CSlider * slider; //scrolls quests
@@ -54,7 +54,7 @@ class CQuestLog : public CWindowObject
 
 public:
 
-	CQuestLog (std::vector<const QuestInfo> & Quests);
+	CQuestLog (const std::vector<QuestInfo> & Quests);
 
 	~CQuestLog(){};
 

+ 2 - 0
client/Makefile.am

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

+ 19 - 1
client/Makefile.in

@@ -89,7 +89,8 @@ am_vcmiclient_OBJECTS = vcmiclient-CCallback.$(OBJEXT) \
 	vcmiclient-CPreGame.$(OBJEXT) vcmiclient-CSndHandler.$(OBJEXT) \
 	vcmiclient-CSpellWindow.$(OBJEXT) \
 	vcmiclient-CVideoHandler.$(OBJEXT) \
-	vcmiclient-Graphics.$(OBJEXT) vcmiclient-GUIClasses.$(OBJEXT) \
+	vcmiclient-CQuestLog.$(OBJEXT) vcmiclient-Graphics.$(OBJEXT) \
+	vcmiclient-GUIClasses.$(OBJEXT) \
 	vcmiclient-mapHandler.$(OBJEXT) \
 	vcmiclient-NetPacksClient.$(OBJEXT)
 vcmiclient_OBJECTS = $(am_vcmiclient_OBJECTS)
@@ -386,6 +387,8 @@ vcmiclient_SOURCES = \
 	CSpellWindow.h \
 	CVideoHandler.cpp \
 	CVideoHandler.h \
+	CQuestLog.cpp \
+	CQuestLog.h \
 	FontBase.h \
 	FunctionList.h \
 	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-CPlayerInterface.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-CSpellWindow.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@
 @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
 @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

+ 1 - 1
lib/BattleState.cpp

@@ -39,7 +39,7 @@ static const CStack *takeStack(std::vector<const CStack *> &st, int &curside, in
 {
 	const CStack *ret = NULL;
 	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++)
 		if(st[i])
 			break;

+ 3 - 1
lib/CGameState.cpp

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

+ 1 - 1
lib/CGameState.h

@@ -449,7 +449,7 @@ struct DLL_LINKAGE QuestInfo //universal interface for human and AI
 
 	QuestInfo(){};
 	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?
 

+ 14 - 6
lib/CObjectHandler.cpp

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

+ 2 - 2
lib/IGameCallback.cpp

@@ -1217,9 +1217,9 @@ std::vector < const CGDwelling * > CPlayerSpecificInfoCallback::getMyDwellings()
 	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)
 	{
 		ret.push_back (quest);

+ 1 - 1
lib/IGameCallback.h

@@ -234,7 +234,7 @@ public:
 	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 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;
 	TResources getResourceAmount() const;

+ 3 - 1
lib/map.cpp

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