1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Fixed crash on sieges.

This commit is contained in:
Michał W. Urbańczyk 2010-08-01 18:12:53 +00:00
parent 4140711b6d
commit 5665ec1a0d
4 changed files with 21 additions and 18 deletions

View File

@ -7,7 +7,7 @@ GENERAL:
- vcmimelkor - player loses - vcmimelkor - player loses
ADVENTURE MAP: ADVENTURE MAP:
* Neutral armies growth implemented (%10 weekly) * Neutral armies growth implemented (10% weekly)
* Power rating of neutral stacks * Power rating of neutral stacks
* Favourable Winds reduce sailing cost * Favourable Winds reduce sailing cost

View File

@ -32,7 +32,24 @@ CGDefInfo::CGDefInfo()
{ {
handler = NULL; handler = NULL;
visitDir = (8|16|32|64|128); //4,5,6,7,8 - any not-from-up direction 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() void CDefObjInfoHandler::load()
{ {
VLC->dobjinfo = this; VLC->dobjinfo = this;
@ -102,13 +119,7 @@ void CDefObjInfoHandler::load()
inp >> nobj->printPriority; inp >> nobj->printPriority;
//coverageMap calculating //coverageMap calculating
std::string nameCopy = nobj->name; nobj->fetchInfoFromMSK();
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];
}
gobjs[nobj->id][nobj->subid] = nobj; gobjs[nobj->id][nobj->subid] = nobj;

View File

@ -46,6 +46,7 @@ public:
& terrainMenu & width & height & type & printPriority & coverageMap & shadowCoverage; & terrainMenu & width & height & type & printPriority & coverageMap & shadowCoverage;
} }
CGDefInfo(); CGDefInfo();
void fetchInfoFromMSK();
}; };
class DLL_EXPORT CDefObjInfoHandler class DLL_EXPORT CDefObjInfoHandler
{ {

View File

@ -1325,16 +1325,7 @@ void Mapa::readDefInfo( const unsigned char * bufor, int &i)
std::memset(vinya->blockMap,255,6); std::memset(vinya->blockMap,255,6);
//calculating coverageMap //calculating coverageMap
std::string nameCopy = vinya->name; vinya->fetchInfoFromMSK();
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];
}
defy.push_back(vinya); // add this def to the vector defy.push_back(vinya); // add this def to the vector
} }