mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +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:
@@ -470,7 +470,16 @@ BOOLEAN LoadExternalGameplayData(STR directoryName)
|
|||||||
//WarmSteel - Attachment slots related xml's
|
//WarmSteel - Attachment slots related xml's
|
||||||
strcpy(fileName, directoryName);
|
strcpy(fileName, directoryName);
|
||||||
strcat(fileName, ATTACHMENTSLOTSFILENAME);
|
strcat(fileName, ATTACHMENTSLOTSFILENAME);
|
||||||
SGP_THROW_IFFALSE(ReadInAttachmentSlotsStats(fileName),ATTACHMENTSLOTSFILENAME);
|
SGP_THROW_IFFALSE(ReadInAttachmentSlotsStats(fileName, FALSE),ATTACHMENTSLOTSFILENAME);
|
||||||
|
|
||||||
|
#ifndef ENGLISH
|
||||||
|
AddLanguagePrefix(fileName);
|
||||||
|
if ( FileExists(fileName) )
|
||||||
|
{
|
||||||
|
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||||
|
SGP_THROW_IFFALSE(ReadInAttachmentSlotsStats(fileName,TRUE), fileName);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Flugente: created separate gun and item choices for different soldier classes - read in different xmls
|
// Flugente: created separate gun and item choices for different soldier classes - read in different xmls
|
||||||
strcpy(fileName, directoryName);
|
strcpy(fileName, directoryName);
|
||||||
|
|||||||
+1
-1
@@ -337,7 +337,7 @@ extern BOOLEAN WriteIncompatibleAttachmentStats();
|
|||||||
extern BOOLEAN ReadInIncompatibleAttachmentStats(STR fileName);
|
extern BOOLEAN ReadInIncompatibleAttachmentStats(STR fileName);
|
||||||
//WarmSteel - for New Attachment System
|
//WarmSteel - for New Attachment System
|
||||||
extern BOOLEAN WriteAttachmentSlotsStats();
|
extern BOOLEAN WriteAttachmentSlotsStats();
|
||||||
extern BOOLEAN ReadInAttachmentSlotsStats(STR fileName);
|
extern BOOLEAN ReadInAttachmentSlotsStats(STR fileName, BOOLEAN localizedVersion);
|
||||||
|
|
||||||
extern BOOLEAN WriteExtendedArmyGunChoicesStats();
|
extern BOOLEAN WriteExtendedArmyGunChoicesStats();
|
||||||
extern BOOLEAN ReadInExtendedArmyGunChoicesStats(ARMY_GUN_CHOICE_TYPE* pGunChoice, STR fileName);
|
extern BOOLEAN ReadInExtendedArmyGunChoicesStats(ARMY_GUN_CHOICE_TYPE* pGunChoice, STR fileName);
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ struct
|
|||||||
}
|
}
|
||||||
typedef attachmentslotParseData;
|
typedef attachmentslotParseData;
|
||||||
|
|
||||||
|
BOOLEAN localizedTextOnly_AttachmentSlots;
|
||||||
|
|
||||||
static void XMLCALL
|
static void XMLCALL
|
||||||
attachmentslotStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts)
|
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;
|
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
|
pData->maxReadDepth++; //we are not skipping this element
|
||||||
}
|
}
|
||||||
@@ -46,7 +50,9 @@ attachmentslotStartElementHandle(void *userData, const XML_Char *name, const XML
|
|||||||
{
|
{
|
||||||
pData->curElement = ELEMENT;
|
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
|
pData->maxReadDepth++; //we are not skipping this element
|
||||||
}
|
}
|
||||||
@@ -102,12 +108,21 @@ attachmentslotEndElementHandle(void *userData, const XML_Char *name)
|
|||||||
pData->curElement = ELEMENT_LIST;
|
pData->curElement = ELEMENT_LIST;
|
||||||
|
|
||||||
if(pData->curAttachmentSlot.uiSlotIndex < pData->maxArraySize)
|
if(pData->curAttachmentSlot.uiSlotIndex < pData->maxArraySize)
|
||||||
{
|
{
|
||||||
pData->curArray[pData->curAttachmentSlot.uiSlotIndex] = pData->curAttachmentSlot; //write the attachmentinfo into the table
|
if (!localizedTextOnly_AttachmentSlots)
|
||||||
//Save the highest known index up till now.
|
{
|
||||||
if(LAST_SLOT_INDEX < pData->curAttachmentSlot.uiSlotIndex){
|
pData->curArray[pData->curAttachmentSlot.uiSlotIndex] = pData->curAttachmentSlot; //write the attachmentinfo into the table
|
||||||
LAST_SLOT_INDEX = (UINT16) pData->curAttachmentSlot.uiSlotIndex;
|
|
||||||
|
//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)
|
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;
|
HWFILE hFile;
|
||||||
UINT32 uiBytesRead;
|
UINT32 uiBytesRead;
|
||||||
@@ -174,6 +189,8 @@ BOOLEAN ReadInAttachmentSlotsStats(STR fileName)
|
|||||||
|
|
||||||
attachmentslotParseData pData;
|
attachmentslotParseData pData;
|
||||||
|
|
||||||
|
localizedTextOnly_AttachmentSlots = localizedVersion;
|
||||||
|
|
||||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading AttachmentSlots.xml" );
|
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading AttachmentSlots.xml" );
|
||||||
|
|
||||||
// Open attachmentinfo file
|
// Open attachmentinfo file
|
||||||
@@ -195,24 +212,21 @@ BOOLEAN ReadInAttachmentSlotsStats(STR fileName)
|
|||||||
|
|
||||||
FileClose( hFile );
|
FileClose( hFile );
|
||||||
|
|
||||||
|
|
||||||
XML_SetElementHandler(parser, attachmentslotStartElementHandle, attachmentslotEndElementHandle);
|
XML_SetElementHandler(parser, attachmentslotStartElementHandle, attachmentslotEndElementHandle);
|
||||||
XML_SetCharacterDataHandler(parser, attachmentslotCharacterDataHandle);
|
XML_SetCharacterDataHandler(parser, attachmentslotCharacterDataHandle);
|
||||||
|
|
||||||
|
|
||||||
// This should fix the crash in a Release Version with VS 2008
|
// This should fix the crash in a Release Version with VS 2008
|
||||||
//memset(&pData,0,sizeof(pData));
|
//memset(&pData,0,sizeof(pData));
|
||||||
|
|
||||||
pData.curElement = ELEMENT_NONE;
|
pData.curElement = ELEMENT_NONE;
|
||||||
pData.szCharData[0] = 0;
|
pData.szCharData[0] = 0;
|
||||||
pData.currentDepth = 0;
|
pData.currentDepth = 0;
|
||||||
pData.maxReadDepth = 0;
|
pData.maxReadDepth = 0;
|
||||||
pData.curArray = AttachmentSlots;
|
pData.curArray = AttachmentSlots;
|
||||||
pData.maxArraySize = MAXITEMS;
|
pData.maxArraySize = MAXITEMS;
|
||||||
|
|
||||||
|
|
||||||
XML_SetUserData(parser, &pData);
|
XML_SetUserData(parser, &pData);
|
||||||
|
|
||||||
|
|
||||||
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
|
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
|
||||||
{
|
{
|
||||||
CHAR8 errorBuf[511];
|
CHAR8 errorBuf[511];
|
||||||
@@ -226,9 +240,7 @@ BOOLEAN ReadInAttachmentSlotsStats(STR fileName)
|
|||||||
|
|
||||||
MemFree(lpcBuffer);
|
MemFree(lpcBuffer);
|
||||||
|
|
||||||
|
|
||||||
XML_ParserFree(parser);
|
XML_ParserFree(parser);
|
||||||
|
|
||||||
|
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user