From 46eb0b3daf9b20f88c470cd360d3a4e370e50d6a Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 20 Jan 2013 22:49:34 +0000 Subject: [PATCH] - wrokaround/fix for #1177 - removed assert in Fonts.cpp (can be triggered a lot by old pregame\battles code) - fixed battle console text positioning - fixed some new compiler warnings --- client/BattleInterface/CBattleAnimations.cpp | 6 +++--- client/BattleInterface/CBattleAnimations.h | 3 --- client/BattleInterface/CBattleInterfaceClasses.cpp | 9 ++------- client/BattleInterface/CBattleInterfaceClasses.h | 2 -- client/BattleInterface/CCreatureAnimation.h | 1 - client/CDefHandler.h | 2 -- client/CKingdomInterface.h | 1 - client/CMT.cpp | 9 +++++++++ client/CPlayerInterface.cpp | 4 ++-- client/Client.cpp | 4 ++-- client/GUIClasses.cpp | 4 ++-- client/UIFramework/Fonts.cpp | 7 +++---- lib/CObjectHandler.cpp | 2 +- 13 files changed, 24 insertions(+), 30 deletions(-) diff --git a/client/BattleInterface/CBattleAnimations.cpp b/client/BattleInterface/CBattleAnimations.cpp index 97f3a2899..42dcb9200 100644 --- a/client/BattleInterface/CBattleAnimations.cpp +++ b/client/BattleInterface/CBattleAnimations.cpp @@ -106,8 +106,8 @@ CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attac } CDefenceAnimation::CDefenceAnimation(StackAttackedInfo _attackedInfo, CBattleInterface * _owner) -: CBattleStackAnimation(_owner, _attackedInfo.defender), dmg(_attackedInfo.dmg), -amountKilled(_attackedInfo.amountKilled), attacker(_attackedInfo.attacker), byShooting(_attackedInfo.byShooting), +: CBattleStackAnimation(_owner, _attackedInfo.defender), +attacker(_attackedInfo.attacker), byShooting(_attackedInfo.byShooting), killed(_attackedInfo.killed) {} @@ -689,7 +689,7 @@ void CReverseAnimation::setupSecondPart() } CShootingAnimation::CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked, bool _catapult, int _catapultDmg) -: CAttackAnimation(_owner, attacker, _dest, _attacked), catapultDamage(_catapultDmg), catapult(_catapult) +: CAttackAnimation(_owner, attacker, _dest, _attacked), catapultDamage(_catapultDmg) {} bool CShootingAnimation::init() diff --git a/client/BattleInterface/CBattleAnimations.h b/client/BattleInterface/CBattleAnimations.h index 01503a807..69c843df1 100644 --- a/client/BattleInterface/CBattleAnimations.h +++ b/client/BattleInterface/CBattleAnimations.h @@ -70,8 +70,6 @@ class CDefenceAnimation : public CBattleStackAnimation { private: //std::vector attackedInfos; - int dmg; //damage dealt - int amountKilled; //how many creatures in stack has been killed const CStack * attacker; //attacking stack bool byShooting; //if true, stack has been attacked by shooting bool killed; //if true, stack has been killed @@ -196,7 +194,6 @@ class CShootingAnimation : public CAttackAnimation { private: int catapultDamage; - bool catapult; public: bool init(); void nextFrame(); diff --git a/client/BattleInterface/CBattleInterfaceClasses.cpp b/client/BattleInterface/CBattleInterfaceClasses.cpp index e031197c9..5e98f0b5a 100644 --- a/client/BattleInterface/CBattleInterfaceClasses.cpp +++ b/client/BattleInterface/CBattleInterfaceClasses.cpp @@ -25,14 +25,9 @@ #include "../CCreatureWindow.h" #include "../CMessage.h" -CBattleConsole::~CBattleConsole() -{ - texts.clear(); -} - void CBattleConsole::showAll(SDL_Surface * to) { - Point textPos(pos.x + pos.w/2, pos.y + 11); + Point textPos(pos.x + pos.w/2, pos.y + 17); if(ingcAlter.size()) { @@ -246,7 +241,7 @@ CBattleHero::~CBattleHero() delete flag; } -CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner): myInt(owner) +CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner) { OBJ_CONSTRUCTION_CAPTURING_ALL; pos = position; diff --git a/client/BattleInterface/CBattleInterfaceClasses.h b/client/BattleInterface/CBattleInterfaceClasses.h index 12feccb49..12c5b0b12 100644 --- a/client/BattleInterface/CBattleInterfaceClasses.h +++ b/client/BattleInterface/CBattleInterfaceClasses.h @@ -36,7 +36,6 @@ public: std::string ingcAlter; //alternative text set by in-game console - very important! int whoSetAlter; //who set alter text; 0 - battle interface or none, 1 - button CBattleConsole(); - ~CBattleConsole(); //d-tor void showAll(SDL_Surface * to = 0); bool addText(const std::string &text); //adds text at the last position; returns false if failed (e.g. text longer than 70 characters) void alterText(const std::string &text); //place string at alterTxt @@ -70,7 +69,6 @@ public: class CBattleOptionsWindow : public CIntObject { private: - CBattleInterface * myInt; CPicture * background; CAdventureMapButton * setToDefault, * exit; CHighlightableButton * viewGrid, * movementShadow, * mouseShadow; diff --git a/client/BattleInterface/CCreatureAnimation.h b/client/BattleInterface/CCreatureAnimation.h index 87ac66e9d..80ecf9300 100644 --- a/client/BattleInterface/CCreatureAnimation.h +++ b/client/BattleInterface/CCreatureAnimation.h @@ -23,7 +23,6 @@ class CCreatureAnimation : public CIntObject { private: int totalEntries, DEFType, totalBlocks; - int length; BMPPalette palette[256]; struct SEntry { diff --git a/client/CDefHandler.h b/client/CDefHandler.h index a1c6f5706..79fd62879 100644 --- a/client/CDefHandler.h +++ b/client/CDefHandler.h @@ -75,8 +75,6 @@ class CDefHandler { private: ui32 DEFType; - int length; - //ui32 * RWEntries; struct SEntry { std::string name; diff --git a/client/CKingdomInterface.h b/client/CKingdomInterface.h index 9172a88da..9b42984a0 100644 --- a/client/CKingdomInterface.h +++ b/client/CKingdomInterface.h @@ -281,7 +281,6 @@ class CHeroItem : public CIntObject, public CWindowWithGarrison std::vector artTabs; - CAnimImage *background; CAnimImage *portrait; CLabel *name; CHeroArea *heroArea; diff --git a/client/CMT.cpp b/client/CMT.cpp index 24cb2ad09..341f15058 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -239,6 +239,12 @@ int main(int argc, char** argv) putenv((char*)"SDL_VIDEO_WINDOW_POS"); putenv((char*)"SDL_VIDEO_CENTERED=1"); + // Have effect on X11 system only (Linux). + // For whatever reason in fullscreen mode SDL takes "raw" mouse input from DGA X11 extension + // (DGA = Direct graphics access). Because this is raw input (before any speed\acceleration proceesing) + // it may result in very small \ very fast mouse when game in fullscreen mode + putenv((char*)"SDL_VIDEO_X11_DGAMOUSE=0"); + CStopWatch total, pomtime; std::cout.flags(std::ios::unitbuf); logfile = new std::ofstream((GVCMIDirs.UserPath + "/VCMI_Client_log.txt").c_str()); @@ -797,6 +803,9 @@ static void listenForEvents() delete CGI->dobjinfo.get(); const_cast(CGI)->dobjinfo = new CDefObjInfoHandler; + + VLC->dobjinfo = const_cast(CGI)->dobjinfo; // update dobjinfo pointer in VLC (used by modHandler::reload()) + const_cast(CGI)->dobjinfo->load(); const_cast(CGI)->modh->reload(); //add info about new creatures to dobjinfo }; diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 290b345dd..657120fd1 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1147,7 +1147,7 @@ template void CPlayerInterface::serializeTempl( Handler &h, c h & spellbookSettings; //sleeping heroes - ui8 sleepingSize; + ui8 sleepingSize = 0; //fix for uninitialized warning if (h.saving) sleepingSize = sleepingHeroes.size(); h & sleepingSize; @@ -1165,7 +1165,7 @@ template void CPlayerInterface::serializeTempl( Handler &h, c } //hero list order - ui8 heroListSize; + ui8 heroListSize = 0; //fix for uninitialized warning if (h.saving) heroListSize = wanderingHeroes.size(); else diff --git a/client/Client.cpp b/client/Client.cpp index fd2b977da..a3125795e 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -453,13 +453,13 @@ void CClient::serialize( Handler &h, const int version ) } else { - ui8 players; + ui8 players = 0; //fix for uninitialized warning h & players; for(int i=0; i < players; i++) { std::string dllname; - ui8 pid; + ui8 pid = 0; //fix for uninitialized warning h & pid & dllname; diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index 4fe546223..926b3cf98 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -4390,8 +4390,8 @@ void CArtPlace::setArtifact(const CArtifactInstance *art) // so we want to replace text in [...] with a spell name // however other language versions don't have name placeholder at all, so we have to be careful int spellID = art->getGivenSpellID(); - int nameStart = text.find_first_of('['); - int nameEnd = text.find_first_of(']', nameStart); + size_t nameStart = text.find_first_of('['); + size_t nameEnd = text.find_first_of(']', nameStart); if(spellID >= 0) { if(nameStart != std::string::npos && nameEnd != std::string::npos) diff --git a/client/UIFramework/Fonts.cpp b/client/UIFramework/Fonts.cpp index 6b9b6e691..4e7f66eb4 100644 --- a/client/UIFramework/Fonts.cpp +++ b/client/UIFramework/Fonts.cpp @@ -182,10 +182,9 @@ void CBitmapFont::renderText(SDL_Surface * surface, const std::string & data, co int posX = pos.x; int posY = pos.y; - // Safe to remove but I would like to trace all cases of this. Please report on Mantis or send note to me - // Ivan - assert(data[0] != '{'); - assert(data[data.size()-1] != '}'); + // Should be used to detect incorrect text parsing. Disabled right now due to some old UI code (mostly pregame and battles) + //assert(data[0] != '{'); + //assert(data[data.size()-1] != '}'); SDL_LockSurface(surface); // for each symbol diff --git a/lib/CObjectHandler.cpp b/lib/CObjectHandler.cpp index 6bca4cb57..9bc22f92e 100644 --- a/lib/CObjectHandler.cpp +++ b/lib/CObjectHandler.cpp @@ -1135,7 +1135,7 @@ void CGHeroInstance::Updatespecialty() //TODO: calculate special value of bonuse { if (hs->growsWithLevel) { - const auto &creatures = VLC->creh->creatures; + //const auto &creatures = VLC->creh->creatures; BOOST_FOREACH(Bonus * b, hs->getBonusList()) {