From 5665ec1a0d34a78ff3bfd2dcb50e829c7d63867d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sun, 1 Aug 2010 18:12:53 +0000 Subject: [PATCH] Fixed crash on sieges. --- ChangeLog | 2 +- hch/CDefObjInfoHandler.cpp | 25 ++++++++++++++++++------- hch/CDefObjInfoHandler.h | 1 + lib/map.cpp | 11 +---------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa9d6763f..c54a379c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ GENERAL: - vcmimelkor - player loses ADVENTURE MAP: -* Neutral armies growth implemented (%10 weekly) +* Neutral armies growth implemented (10% weekly) * Power rating of neutral stacks * Favourable Winds reduce sailing cost diff --git a/hch/CDefObjInfoHandler.cpp b/hch/CDefObjInfoHandler.cpp index 0c0e02d6a..b13b6eaa7 100644 --- a/hch/CDefObjInfoHandler.cpp +++ b/hch/CDefObjInfoHandler.cpp @@ -32,7 +32,24 @@ CGDefInfo::CGDefInfo() { handler = NULL; visitDir = (8|16|32|64|128); //4,5,6,7,8 - any not-from-up direction + + width = height = -1; } + +void CGDefInfo::fetchInfoFromMSK() +{ + std::string nameCopy = name; + std::string msk = spriteh->getTextFile(nameCopy.replace( nameCopy.size()-4, 4, ".MSK" )); + + width = msk[0]; + height = msk[1]; + for(int i=0; i<6; ++i) + { + coverageMap[i] = msk[i+2]; + shadowCoverage[i] = msk[i+8]; + } +} + void CDefObjInfoHandler::load() { VLC->dobjinfo = this; @@ -102,13 +119,7 @@ void CDefObjInfoHandler::load() inp >> nobj->printPriority; //coverageMap calculating - std::string nameCopy = nobj->name; - std::string msk = spriteh->getTextFile(nameCopy.replace( nameCopy.size()-4, 4, ".MSK" )); - for(int i=0; i<6; ++i) - { - nobj->coverageMap[i] = msk[i+2]; - nobj->shadowCoverage[i] = msk[i+8]; - } + nobj->fetchInfoFromMSK(); gobjs[nobj->id][nobj->subid] = nobj; diff --git a/hch/CDefObjInfoHandler.h b/hch/CDefObjInfoHandler.h index 750f5bfb3..e8a8fd8e4 100644 --- a/hch/CDefObjInfoHandler.h +++ b/hch/CDefObjInfoHandler.h @@ -46,6 +46,7 @@ public: & terrainMenu & width & height & type & printPriority & coverageMap & shadowCoverage; } CGDefInfo(); +void fetchInfoFromMSK(); }; class DLL_EXPORT CDefObjInfoHandler { diff --git a/lib/map.cpp b/lib/map.cpp index 1e4e4ab5d..2b3b189e0 100644 --- a/lib/map.cpp +++ b/lib/map.cpp @@ -1325,16 +1325,7 @@ void Mapa::readDefInfo( const unsigned char * bufor, int &i) std::memset(vinya->blockMap,255,6); //calculating coverageMap - std::string nameCopy = vinya->name; - std::string msk = spriteh->getTextFile(nameCopy.replace( nameCopy.size()-4, 4, ".MSK" )); - - vinya->width = msk[0]; - vinya->height = msk[1]; - for(int i=0; i<6; ++i) - { - vinya->coverageMap[i] = msk[i+2]; - vinya->shadowCoverage[i] = msk[i+8]; - } + vinya->fetchInfoFromMSK(); defy.push_back(vinya); // add this def to the vector }