Fix: In Release built with VS2008 the game crashes when parsing xmls.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7530 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2014-09-24 23:29:07 +00:00
parent 7558c84bc2
commit 58d9cf0925
2 changed files with 34 additions and 7 deletions
+21 -5
View File
@@ -85,6 +85,8 @@ structureconstructCharacterDataHandle(void *userData, const XML_Char *str, int l
static void XMLCALL
structureconstructEndElementHandle(void *userData, const XML_Char *name)
{
static std::vector<UINT8> staticnorthtilevector, staticsouthtilevector, staticeasttilevector, staticwesttilevector;
structureconstructParseData * pData = (structureconstructParseData *)userData;
if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading
@@ -100,7 +102,21 @@ structureconstructEndElementHandle(void *userData, const XML_Char *name)
// we do NOT want to read the first entry -> move stuff by 1
if(structureconstructcnt < pData->maxArraySize)
{
pData->curArray[structureconstructcnt] = pData->curFood; //write the data into the table
// for whatever reasons the game crashes in VS2008 Release builds when copying over the tilevector
// this seems odd, as this works just fine in VS2010 and VS2013, and also works in VS205 debug builds
// for now, copy over the content by hand
pData->curArray[structureconstructcnt].usCreationItem = pData->curFood.usCreationItem;
pData->curArray[structureconstructcnt].usItemStatusLoss= pData->curFood.usItemStatusLoss;
strncpy(pData->curArray[structureconstructcnt].szTileSetName, pData->curFood.szTileSetName, 20);
pData->curArray[structureconstructcnt].northtilevector = staticnorthtilevector;
pData->curArray[structureconstructcnt].southtilevector = staticsouthtilevector;
pData->curArray[structureconstructcnt].easttilevector = staticeasttilevector;
pData->curArray[structureconstructcnt].westtilevector = staticwesttilevector;
staticnorthtilevector.clear();
staticsouthtilevector.clear();
staticeasttilevector.clear();
staticwesttilevector.clear();
}
++structureconstructcnt;
@@ -124,22 +140,22 @@ structureconstructEndElementHandle(void *userData, const XML_Char *name)
else if(strcmp(name, "northfacingtile") == 0)
{
pData->curElement = ELEMENT;
pData->curFood.northtilevector.push_back( (UINT8) atol(pData->szCharData) );
staticnorthtilevector.push_back( (UINT8) atol(pData->szCharData) );
}
else if(strcmp(name, "southfacingtile") == 0)
{
pData->curElement = ELEMENT;
pData->curFood.southtilevector.push_back( (UINT8) atol(pData->szCharData) );
staticsouthtilevector.push_back( (UINT8) atol(pData->szCharData) );
}
else if ( strcmp( name, "eastfacingtile" ) == 0 )
{
pData->curElement = ELEMENT;
pData->curFood.easttilevector.push_back( (UINT8)atol( pData->szCharData ) );
staticeasttilevector.push_back( (UINT8)atol( pData->szCharData ) );
}
else if ( strcmp( name, "westfacingtile" ) == 0 )
{
pData->curElement = ELEMENT;
pData->curFood.westtilevector.push_back( (UINT8)atol( pData->szCharData ) );
staticwesttilevector.push_back( (UINT8)atol( pData->szCharData ) );
}
pData->maxReadDepth--;
+13 -2
View File
@@ -83,6 +83,8 @@ structuredeconstructCharacterDataHandle(void *userData, const XML_Char *str, int
static void XMLCALL
structuredeconstructEndElementHandle(void *userData, const XML_Char *name)
{
static std::vector<UINT8> statictilevector;
structuredeconstructParseData * pData = (structuredeconstructParseData *)userData;
if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading
@@ -97,7 +99,16 @@ structuredeconstructEndElementHandle(void *userData, const XML_Char *name)
if(structuredeconstructcnt < pData->maxArraySize)
{
pData->curArray[structuredeconstructcnt] = pData->curFood; //write the data into the table
// for whatever reasons the game crashes in VS2008 Release builds when copying over the tilevector
// this seems odd, as this works just fine in VS2010 and VS2013, and also works in VS205 debug builds
// for now, copy over the content by hand
pData->curArray[structuredeconstructcnt].usDeconstructItem = pData->curFood.usDeconstructItem;
pData->curArray[structuredeconstructcnt].usItemToCreate= pData->curFood.usItemToCreate;
pData->curArray[structuredeconstructcnt].usCreatedItemStatus = pData->curFood.usCreatedItemStatus;
strncpy(pData->curArray[structuredeconstructcnt].szTileSetName, pData->curFood.szTileSetName, 20);
pData->curArray[structuredeconstructcnt].tilevector = statictilevector;
statictilevector.clear();
}
++structuredeconstructcnt;
@@ -126,7 +137,7 @@ structuredeconstructEndElementHandle(void *userData, const XML_Char *name)
else if(strcmp(name, "allowedtile") == 0)
{
pData->curElement = ELEMENT;
pData->curFood.tilevector.push_back( (UINT8) atol(pData->szCharData) );
statictilevector.push_back( (UINT8) atol(pData->szCharData) );
}
pData->maxReadDepth--;