mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Merged from revision: 6937
- Added support for language specific *.AttachmentSlots.xml files git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6938 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -27,6 +27,8 @@ struct
|
||||
}
|
||||
typedef attachmentslotParseData;
|
||||
|
||||
BOOLEAN localizedTextOnly_AttachmentSlots;
|
||||
|
||||
static void XMLCALL
|
||||
attachmentslotStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
@@ -38,7 +40,9 @@ attachmentslotStartElementHandle(void *userData, const XML_Char *name, const XML
|
||||
{
|
||||
pData->curElement = ELEMENT_LIST;
|
||||
|
||||
memset(pData->curArray,0,sizeof(AttachmentSlotStruct)*pData->maxArraySize);
|
||||
// WANNE: Only init memory, when we read the complete data, otherwise the data will be erased!
|
||||
if (!localizedTextOnly_AttachmentSlots)
|
||||
memset(pData->curArray,0,sizeof(AttachmentSlotStruct)*pData->maxArraySize);
|
||||
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
@@ -46,7 +50,9 @@ attachmentslotStartElementHandle(void *userData, const XML_Char *name, const XML
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
|
||||
memset(&pData->curAttachmentSlot,0,sizeof(AttachmentSlotStruct));
|
||||
// WANNE: Only init memory, when we read the complete data, otherwise the data will be erased!
|
||||
if (!localizedTextOnly_AttachmentSlots)
|
||||
memset(&pData->curAttachmentSlot,0,sizeof(AttachmentSlotStruct));
|
||||
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
@@ -102,12 +108,21 @@ attachmentslotEndElementHandle(void *userData, const XML_Char *name)
|
||||
pData->curElement = ELEMENT_LIST;
|
||||
|
||||
if(pData->curAttachmentSlot.uiSlotIndex < pData->maxArraySize)
|
||||
{
|
||||
pData->curArray[pData->curAttachmentSlot.uiSlotIndex] = pData->curAttachmentSlot; //write the attachmentinfo into the table
|
||||
//Save the highest known index up till now.
|
||||
if(LAST_SLOT_INDEX < pData->curAttachmentSlot.uiSlotIndex){
|
||||
LAST_SLOT_INDEX = (UINT16) pData->curAttachmentSlot.uiSlotIndex;
|
||||
{
|
||||
if (!localizedTextOnly_AttachmentSlots)
|
||||
{
|
||||
pData->curArray[pData->curAttachmentSlot.uiSlotIndex] = pData->curAttachmentSlot; //write the attachmentinfo into the table
|
||||
|
||||
//Save the highest known index up till now.
|
||||
if(LAST_SLOT_INDEX < pData->curAttachmentSlot.uiSlotIndex)
|
||||
{
|
||||
LAST_SLOT_INDEX = (UINT16) pData->curAttachmentSlot.uiSlotIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy(AttachmentSlots[pData->curAttachmentSlot.uiSlotIndex].szSlotName, pData->curAttachmentSlot.szSlotName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(strcmp(name, "uiSlotIndex") == 0)
|
||||
@@ -164,7 +179,7 @@ attachmentslotEndElementHandle(void *userData, const XML_Char *name)
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN ReadInAttachmentSlotsStats(STR fileName)
|
||||
BOOLEAN ReadInAttachmentSlotsStats(STR fileName, BOOLEAN localizedVersion)
|
||||
{
|
||||
HWFILE hFile;
|
||||
UINT32 uiBytesRead;
|
||||
@@ -174,6 +189,8 @@ BOOLEAN ReadInAttachmentSlotsStats(STR fileName)
|
||||
|
||||
attachmentslotParseData pData;
|
||||
|
||||
localizedTextOnly_AttachmentSlots = localizedVersion;
|
||||
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading AttachmentSlots.xml" );
|
||||
|
||||
// Open attachmentinfo file
|
||||
@@ -195,24 +212,21 @@ BOOLEAN ReadInAttachmentSlotsStats(STR fileName)
|
||||
|
||||
FileClose( hFile );
|
||||
|
||||
|
||||
XML_SetElementHandler(parser, attachmentslotStartElementHandle, attachmentslotEndElementHandle);
|
||||
XML_SetCharacterDataHandler(parser, attachmentslotCharacterDataHandle);
|
||||
|
||||
|
||||
// This should fix the crash in a Release Version with VS 2008
|
||||
//memset(&pData,0,sizeof(pData));
|
||||
|
||||
pData.curElement = ELEMENT_NONE;
|
||||
pData.szCharData[0] = 0;
|
||||
pData.currentDepth = 0;
|
||||
pData.maxReadDepth = 0;
|
||||
pData.curArray = AttachmentSlots;
|
||||
pData.maxArraySize = MAXITEMS;
|
||||
|
||||
|
||||
pData.curArray = AttachmentSlots;
|
||||
pData.maxArraySize = MAXITEMS;
|
||||
|
||||
XML_SetUserData(parser, &pData);
|
||||
|
||||
|
||||
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
|
||||
{
|
||||
CHAR8 errorBuf[511];
|
||||
@@ -226,9 +240,7 @@ BOOLEAN ReadInAttachmentSlotsStats(STR fileName)
|
||||
|
||||
MemFree(lpcBuffer);
|
||||
|
||||
|
||||
XML_ParserFree(parser);
|
||||
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user