Merged New Inventory Project into main branch

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1871 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
lalien
2008-03-08 15:15:25 +00:00
parent e16d166277
commit 43ca24dda8
649 changed files with 93359 additions and 82507 deletions
+20 -22
View File
@@ -3,8 +3,6 @@
#else
#include "sgp.h"
#include "overhead types.h"
#include "Sound Control.h"
#include "Soldier Control.h"
#include "overhead.h"
#include "Event Pump.h"
#include "weapons.h"
@@ -54,13 +52,13 @@ struct
WEAPON_DROPS * curArray;
UINT32 maxArraySize;
UINT32 curIndex;
UINT32 curIndex;
UINT32 currentDepth;
UINT32 maxReadDepth;
}
typedef weaponDropParseData;
static void XMLCALL
static void XMLCALL
weaponDropStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts)
{
weaponDropParseData * pData = (weaponDropParseData *)userData;
@@ -84,9 +82,9 @@ weaponDropStartElementHandle(void *userData, const XML_Char *name, const XML_Cha
pData->maxReadDepth++; //we are not skipping this element
}
else if(pData->curElement == ELEMENT &&
(strcmp(name, "uiIndex") == 0 ||
(strcmp(name, "uiIndex") == 0 ||
strcmp(name, "ubWeaponType") == 0 ||
strcmp(name, "ubEnemyDropRate") == 0 ||
strcmp(name, "ubEnemyDropRate") == 0 ||
strcmp(name, "ubMilitiaDropRate") == 0 ))
{
pData->curElement = ELEMENT_PROPERTY;
@@ -106,9 +104,9 @@ weaponDropCharacterDataHandle(void *userData, const XML_Char *str, int len)
{
weaponDropParseData * pData = (weaponDropParseData *)userData;
if( (pData->currentDepth <= pData->maxReadDepth) &&
if( (pData->currentDepth <= pData->maxReadDepth) &&
(strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH)
){
){
strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData)));
}
}
@@ -116,7 +114,7 @@ weaponDropCharacterDataHandle(void *userData, const XML_Char *str, int len)
static void XMLCALL
weaponDropEndElementHandle(void *userData, const XML_Char *name)
{
{
weaponDropParseData * pData = (weaponDropParseData *)userData;
if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading
@@ -137,22 +135,22 @@ weaponDropEndElementHandle(void *userData, const XML_Char *name)
else if(strcmp(name, "uiIndex") == 0)
{
pData->curElement = ELEMENT;
pData->curWeaponDrop.uiIndex = (UINT32) atol(pData->szCharData);
pData->curWeaponDrop.uiIndex = (UINT32) atol(pData->szCharData);
}
else if(strcmp(name, "ubWeaponType") == 0)
{
pData->curElement = ELEMENT;
pData->curWeaponDrop.ubWeaponType = (UINT8) atol(pData->szCharData);
pData->curWeaponDrop.ubWeaponType = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubEnemyDropRate") == 0)
{
pData->curElement = ELEMENT;
pData->curWeaponDrop.ubEnemyDropRate = (UINT8) atol(pData->szCharData);
pData->curWeaponDrop.ubEnemyDropRate = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubMilitiaDropRate") == 0)
{
pData->curElement = ELEMENT;
pData->curWeaponDrop.ubMilitiaDropRate = (UINT8) atol(pData->szCharData);
pData->curWeaponDrop.ubMilitiaDropRate = (UINT8) atol(pData->szCharData);
}
pData->maxReadDepth--;
@@ -171,7 +169,7 @@ BOOLEAN ReadInEnemyWeaponDropsStats(WEAPON_DROPS *pEnemyWeaponDrops, STR fileNam
UINT32 uiFSize;
CHAR8 * lpcBuffer;
XML_Parser parser = XML_ParserCreate(NULL);
weaponDropParseData pData;
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading EnemyWeaponDrops.xml" );
@@ -180,7 +178,7 @@ BOOLEAN ReadInEnemyWeaponDropsStats(WEAPON_DROPS *pEnemyWeaponDrops, STR fileNam
hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );
if ( !hFile )
return( FALSE );
uiFSize = FileGetSize(hFile);
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
@@ -195,19 +193,19 @@ BOOLEAN ReadInEnemyWeaponDropsStats(WEAPON_DROPS *pEnemyWeaponDrops, STR fileNam
FileClose( hFile );
XML_SetElementHandler(parser, weaponDropStartElementHandle, weaponDropEndElementHandle);
XML_SetCharacterDataHandler(parser, weaponDropCharacterDataHandle);
memset(&pData,0,sizeof(pData));
pData.curArray = pEnemyWeaponDrops;
pData.maxArraySize = MAX_DROP_ITEMS;
pData.maxArraySize = MAX_DROP_ITEMS;
XML_SetUserData(parser, &pData);
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
{
CHAR8 errorBuf[511];
@@ -236,7 +234,7 @@ BOOLEAN WriteEnemyWeaponDropsStats(WEAPON_DROPS *pEnemyWeaponDrops, STR fileName
hFile = FileOpen( fileName, FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
if ( !hFile )
return( FALSE );
{
UINT32 cnt;
@@ -258,4 +256,4 @@ BOOLEAN WriteEnemyWeaponDropsStats(WEAPON_DROPS *pEnemyWeaponDrops, STR fileName
FileClose( hFile );
return( TRUE );
}
}