From a17936908ac8767439c8cd114a6991808aef4100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Mon, 1 Jun 2009 22:31:11 +0000 Subject: [PATCH] * updated changelog * version set to 0.72 * integrated save format version to the CLoadFile * fixed problems on entering non-number as resolution number * minor improvements --- ChangeLog | 11 +++++++++-- client/CMT.cpp | 9 ++++++--- client/CMessage.cpp | 2 +- client/CPlayerInterface.cpp | 1 + client/CPreGame.cpp | 10 ++++++---- client/Client.cpp | 2 +- global.h | 2 +- hch/CGeneralTextHandler.cpp | 2 ++ hch/CMusicHandler.cpp | 4 +++- lib/Connection.cpp | 26 ++++++++++++++++++++++++++ lib/Connection.h | 6 ++++-- server/CGameHandler.cpp | 2 +- server/CVCMIServer.cpp | 2 +- 13 files changed, 62 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 352738e90..87d099843 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -0.71 -> 0.72 (soon) +0.71 -> 0.72 (Jun 1 2009) GENERAL: * many sound effects and music * autosave (to 5 subsequent files) @@ -13,6 +13,7 @@ GENERAL: * timed events won't cause resources amount to be negative * support for sorcery secondary skill * reduntant quotation marks from artifact descriptions are removed +* no income at the first day ADVENTURE INTERFACE: * fixed crasbug occurring on revisiting objects (by pressing space) @@ -20,10 +21,12 @@ ADVENTURE INTERFACE: * fixed map scrolling with ctrl+arrows when some windows are opened * clicking scrolling arrows in town/hero list won't open town/hero window * pathfinder will now look for a path going via printed positions of roads when it's possible +* enter can be used to open window with selected hero/town BATTLES: +* many creatures special skills implemented * battle will end when one side has only war machines -* fixed problems with handling obstacles info +* fixed some problems with handling obstacles info * fixed bug with defending / waiting while no stack is active * spellbook button is inactive when hero cannot cast any spell * obstacles will be placed more properly when resolution is different than 800x600 @@ -50,15 +53,19 @@ TOWNS: * resting in town with mage guild will replenih all the mana points * fixed Blacksmith * the number of creatures at the beginning of game is their base growth +* it's possible to enter Tavern via Brotherhood of Sword HERO WINDOW: * fixed mana limit info in the hero window +* war machines can't be removed +* fixed problems with removing artifacts when all visible slots in backpack are full PREGAME: * clicking on "advanced options" a second time now closes the tab instead of refreshing it. * Fix position of maps names. * Made the slider cursor much more responsive. Speedup the map select screen. * Try to behave when no maps/saves are present. +* Page Up / Page Down / Home / End hotkeys for scrolling through scenarios / games list OBJECTS: * Neutral creatures can join or escape depending on hero strength (escape formula needs to be improved) diff --git a/client/CMT.cpp b/client/CMT.cpp index 7d82a03b4..ef1bc56ea 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -297,12 +297,15 @@ void processCommand(const std::string &message, CClient *&client) tlog4 << i++ <<". " << j->first.first << " x " << j->first.second << std::endl; tlog4 << "Type number from 1 to " << i-1 << " to set appropriate resolution or 0 to cancel.\n"; std::cin >> i; - if(!i) - return; - else if(i < 0 || i > conf.guiOptions.size()) + if(i < 0 || i > conf.guiOptions.size() || std::cin.bad() || std::cin.fail()) { + std::cin.clear(); tlog1 << "Invalid resolution ID! Not a number between 0 and " << conf.guiOptions.size() << ". No settings changed.\n"; } + else if(!i) + { + return; + } else { for(j=conf.guiOptions.begin(); j!=conf.guiOptions.end() && hlp++pos.h=ret->bitmap->h; ret->pos.w=ret->bitmap->w; int curh = ret->bitmap->h/2 - (fontHeight*txtg->size())/2; - blitTextOnSur(txtg,fontHeight,curh,ret->bitmap, fontHeight); + blitTextOnSur(txtg,fontHeight,curh,ret->bitmap); delete brtext; delete txtg; return ret; diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 834437e09..f03240756 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1355,6 +1355,7 @@ void CPlayerInterface::battleAttack(BattleAttack *ba) tlog5 << "CPlayerInterface::battleAttack - locking..."; boost::unique_lock un(*pim); tlog5 << "done!\n"; + assert(curAction); if(ba->lucky()) //lucky hit { CStack *stack = cb->battleGetStackByID(ba->stackAttacking); diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index c5b4bf520..6d2daba6a 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -1089,12 +1089,14 @@ void MapSel::processGames(const std::vector &pliczkiTemp) for(int i=0; i> sign >> hlp; - if(hlp != version) + lf >> sign; + if(std::memcmp(sign,"VCMISVG",7)) { - tlog3 << "\t\t" << pliczkiTemp[i] << " seems to be too " << ((hlp>version) ? "new" : "old") << " and will be ommited.\n"; - ourGames[i] = NULL; + tlog1 << pliczkiTemp[i] << " is not a correct savefile!" << std::endl; continue; } ourGames[i] = new CMapInfo(); diff --git a/client/Client.cpp b/client/Client.cpp index fc7ca06c2..4b9ae3a40 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -208,7 +208,7 @@ void CClient::load( const std::string & fname ) CGI->mh = new CMapHandler(); CLoadFile lf(fname + ".vlgm1"); - lf >> sig >> ver >> dum >> *sig; + lf >> sig >> dum >> *sig; tlog0 <<"Reading save signature: "<> *VLC; diff --git a/global.h b/global.h index 4e2738b3f..1cd4c387a 100644 --- a/global.h +++ b/global.h @@ -19,7 +19,7 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte) #define THC #endif -#define NAME_VER ("VCMI 0.71c") +#define NAME_VER ("VCMI 0.72") #define CONSOLE_LOGGING_LEVEL 5 #define FILE_LOGGING_LEVEL 6 diff --git a/hch/CGeneralTextHandler.cpp b/hch/CGeneralTextHandler.cpp index 375a55093..cbb317e1a 100644 --- a/hch/CGeneralTextHandler.cpp +++ b/hch/CGeneralTextHandler.cpp @@ -47,6 +47,8 @@ void CGeneralTextHandler::load() buf1.substr(pom+1,eol-pom-1))); boost::algorithm::replace_all(zelp[zelp.size()-1].first,"\t",""); boost::algorithm::replace_all(zelp[zelp.size()-1].second,"\t",""); + if(zelp.back().second[0] == '\"' && zelp.back().second[zelp.back().second.size()-1] == '\"') + zelp.back().second = zelp.back().second.substr(1,zelp.back().second.size()-2); } itr=eol+2; } diff --git a/hch/CMusicHandler.cpp b/hch/CMusicHandler.cpp index 9d78269bc..f4fe610e1 100644 --- a/hch/CMusicHandler.cpp +++ b/hch/CMusicHandler.cpp @@ -206,6 +206,8 @@ void CSoundHandler::initCreaturesSounds(std::vector &creatures) ifs.close(); ifs.clear(); + //commented to avoid spurious warnings + /* // Find creatures without sounds for(unsigned int i=0;i &creatures) CCreature &c = creatures[i]; if (c.sounds.killed == soundBase::invalid) tlog1 << "creature " << c.idNumber << " doesn't have sounds" << std::endl; - } + }*/ } void CSoundHandler::initSpellsSounds(std::vector &spells) diff --git a/lib/Connection.cpp b/lib/Connection.cpp index 7a454b360..ca514b0e6 100644 --- a/lib/Connection.cpp +++ b/lib/Connection.cpp @@ -182,6 +182,11 @@ CSaveFile::CSaveFile( const std::string &fname ) tlog1 << "Error: cannot open to write " << fname << std::endl; sfile = NULL; } + else + { + sfile->write("VCMI",4); //write magic identifier + *this << version; //write format version + } } CSaveFile::~CSaveFile() @@ -204,6 +209,27 @@ CLoadFile::CLoadFile( const std::string &fname ) tlog1 << "Error: cannot open to read " << fname << std::endl; sfile = NULL; } + else + { + char buffer[4]; + sfile->read(buffer, 4); + + if(std::memcmp(buffer,"VCMI",4)) + { + tlog1 << "Error: wrong save format!\n"; + delete sfile; + sfile = NULL; + return; + } + + *this >> myVersion; + if(myVersion != version) + { + tlog1 << "Wrong save format!\n"; + delete sfile; + sfile = NULL; + } + } } CLoadFile::~CLoadFile() diff --git a/lib/Connection.h b/lib/Connection.h index 008ec057c..5e9b092a6 100644 --- a/lib/Connection.h +++ b/lib/Connection.h @@ -19,7 +19,7 @@ #include #include -const ui32 version = 704; +const ui32 version = 705; class CConnection; namespace mpl = boost::mpl; @@ -426,10 +426,12 @@ template class DLL_EXPORT CISer : public CLoaderBase public: bool saving; std::map loaders; // typeID => CPointerSaver + ui32 myVersion; CISer() { saving = false; + myVersion = version; } template void registerType(const T * t=NULL) @@ -489,7 +491,7 @@ public: template void loadSerializable(T &data) { - data.serialize(*this,version); + data.serialize(*this,myVersion); } template void loadArray(T &data) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 4f0d236d4..ef3f01597 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1472,7 +1472,7 @@ void CGameHandler::save( const std::string &fname ) tlog0 << "Serializing game info...\n"; CSaveFile save(std::string("Games") + PATHSEPARATOR + fname + ".vlgm1"); char hlp[8] = "VCMISVG"; - save << hlp << version << static_cast(*gs->map) << gs->scenarioOps->difficulty << *VLC << gs; + save << hlp << static_cast(*gs->map) << gs->scenarioOps->difficulty << *VLC << gs; } { diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index 08f15f81c..3ea2eca5d 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -184,7 +184,7 @@ void CVCMIServer::loadGame( CConnection *c ) CMapHeader dum; CLoadFile lf(fname + ".vlgm1"); - lf >> sig >> ver >> dum >> *sig; + lf >> sig >> dum >> *sig; tlog0 <<"Reading save signature"<> *VLC;