mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
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:
@@ -6,7 +6,7 @@
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "explosion control.h"
|
||||
#include "explosion control.h"
|
||||
#include "TopicIDs.h"
|
||||
#include "TopicOps.h"
|
||||
#include "Debug.h"
|
||||
@@ -23,7 +23,7 @@ struct
|
||||
|
||||
CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1];
|
||||
|
||||
EXPLOSION_DATA expData;
|
||||
EXPLOSION_DATA expData;
|
||||
INT32 maxArraySize;
|
||||
INT32 curIndex;
|
||||
INT32 currentDepth;
|
||||
@@ -31,7 +31,7 @@ struct
|
||||
}
|
||||
typedef explosionDataParseData;
|
||||
|
||||
static void XMLCALL
|
||||
static void XMLCALL
|
||||
explosionDataStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
explosionDataParseData * pData = (explosionDataParseData *)userData;
|
||||
@@ -50,7 +50,7 @@ explosionDataStartElementHandle(void *userData, const XML_Char *name, const XML_
|
||||
|
||||
//DebugMsg(TOPIC_JA2, DBG_LEVEL_3,"MergeStartElementHandle: setting memory for curMerge");
|
||||
|
||||
memset(&(pData->expData),0,sizeof(EXPLOSION_DATA));
|
||||
memset(&(pData->expData),0,sizeof(EXPLOSION_DATA));
|
||||
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
pData->curIndex++;
|
||||
@@ -59,8 +59,8 @@ explosionDataStartElementHandle(void *userData, const XML_Char *name, const XML_
|
||||
(strcmp(name, "TransKeyFrame") == 0 ||
|
||||
strcmp(name, "DamageKeyFrame") == 0 ||
|
||||
strcmp(name, "ExplosionSoundID") == 0 ||
|
||||
strcmp(name, "AltExplosionSoundID") == 0 ||
|
||||
strcmp(name, "BlastFilename") == 0 ||
|
||||
strcmp(name, "AltExplosionSoundID") == 0 ||
|
||||
strcmp(name, "BlastFilename") == 0 ||
|
||||
strcmp(name, "BlastSpeed") == 0 ))
|
||||
{
|
||||
pData->curElement = ELEMENT_PROPERTY;
|
||||
@@ -80,9 +80,9 @@ explosionDataCharacterDataHandle(void *userData, const XML_Char *str, int len)
|
||||
{
|
||||
explosionDataParseData * pData = (explosionDataParseData *)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)));
|
||||
}
|
||||
}
|
||||
@@ -105,41 +105,41 @@ explosionDataEndElementHandle(void *userData, const XML_Char *name)
|
||||
|
||||
if(pData->curIndex < pData->maxArraySize)
|
||||
{
|
||||
memcpy( &(gExpAniData[pData->curIndex]), &(pData->expData), sizeof(EXPLOSION_DATA) );
|
||||
memcpy( &(gExpAniData[pData->curIndex]), &(pData->expData), sizeof(EXPLOSION_DATA) );
|
||||
}
|
||||
}
|
||||
else if(strcmp(name, "TransKeyFrame") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
pData->expData.ubTransKeyFrame = (UINT8) atol(pData->szCharData);
|
||||
pData->expData.ubTransKeyFrame = (UINT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "DamageKeyFrame") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
pData->expData.ubDamageKeyFrame = (UINT8) atol(pData->szCharData);
|
||||
pData->expData.ubDamageKeyFrame = (UINT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "ExplosionSoundID") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
pData->expData.uiExplosionSoundID = (UINT32) atol(pData->szCharData);
|
||||
pData->expData.uiExplosionSoundID = (UINT32) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "AltExplosionSoundID") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
pData->expData.uiAltExplosionSoundID = (UINT32) atol(pData->szCharData);
|
||||
pData->expData.uiAltExplosionSoundID = (UINT32) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "BlastFilename") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
// Lesh: maybe it is needed to check lenght of the pData->szCharData string
|
||||
// and warn user, otherwise game behavior is unexpected when trying to
|
||||
// play animation from clipped filename (runtime error, crash ???)
|
||||
strncpy(pData->expData.zBlastFilename, pData->szCharData, MAX_BLAST_FILENAME_LEN);
|
||||
// Lesh: maybe it is needed to check lenght of the pData->szCharData string
|
||||
// and warn user, otherwise game behavior is unexpected when trying to
|
||||
// play animation from clipped filename (runtime error, crash ???)
|
||||
strncpy(pData->expData.zBlastFilename, pData->szCharData, MAX_BLAST_FILENAME_LEN);
|
||||
}
|
||||
else if(strcmp(name, "BlastSpeed") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
pData->expData.sBlastSpeed = (UINT8) atol(pData->szCharData);
|
||||
pData->expData.sBlastSpeed = (UINT8) atol(pData->szCharData);
|
||||
}
|
||||
|
||||
pData->maxReadDepth--;
|
||||
@@ -158,7 +158,7 @@ BOOLEAN ReadInExplosionDataStats(STR fileName)
|
||||
UINT32 uiFSize;
|
||||
CHAR8 * lpcBuffer;
|
||||
XML_Parser parser = XML_ParserCreate(NULL);
|
||||
|
||||
|
||||
explosionDataParseData pData;
|
||||
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading ExplosionData.xml" );
|
||||
@@ -167,7 +167,7 @@ BOOLEAN ReadInExplosionDataStats(STR fileName)
|
||||
hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );
|
||||
if ( !hFile )
|
||||
return( FALSE );
|
||||
|
||||
|
||||
uiFSize = FileGetSize(hFile);
|
||||
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
|
||||
|
||||
@@ -182,19 +182,19 @@ BOOLEAN ReadInExplosionDataStats(STR fileName)
|
||||
|
||||
FileClose( hFile );
|
||||
|
||||
|
||||
|
||||
XML_SetElementHandler(parser, explosionDataStartElementHandle, explosionDataEndElementHandle);
|
||||
XML_SetCharacterDataHandler(parser, explosionDataCharacterDataHandle);
|
||||
|
||||
|
||||
|
||||
memset(&pData,0,sizeof(pData));
|
||||
pData.maxArraySize = NUM_EXP_TYPES;
|
||||
pData.maxArraySize = NUM_EXP_TYPES;
|
||||
pData.curIndex = -1;
|
||||
|
||||
|
||||
XML_SetUserData(parser, &pData);
|
||||
|
||||
|
||||
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
|
||||
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
|
||||
{
|
||||
CHAR8 errorBuf[511];
|
||||
|
||||
@@ -221,21 +221,21 @@ BOOLEAN WriteExplosionDataStats()
|
||||
hFile = FileOpen( "TABLEDATA\\ExplosionData out.xml", FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
|
||||
if ( !hFile )
|
||||
return( FALSE );
|
||||
|
||||
|
||||
{
|
||||
UINT32 cnt;
|
||||
|
||||
FilePrintf(hFile,"<EXPDATALIST>\r\n");
|
||||
for(cnt = 0;cnt < NUM_EXP_TYPES;cnt++)
|
||||
for(cnt = 0;cnt < NUM_EXP_TYPES;cnt++)
|
||||
{
|
||||
FilePrintf(hFile,"\t<EXPDATA>\r\n");
|
||||
|
||||
FilePrintf(hFile,"\t\t<TransKeyFrame>%d</TransKeyFrame>\r\n", gExpAniData[cnt].ubTransKeyFrame);
|
||||
FilePrintf(hFile,"\t\t<DamageKeyFrame>%d</DamageKeyFrame>\r\n", gExpAniData[cnt].ubDamageKeyFrame);
|
||||
FilePrintf(hFile,"\t\t<ExplosionSoundID>%d</ExplosionSoundID>\r\n", gExpAniData[cnt].uiExplosionSoundID);
|
||||
FilePrintf(hFile,"\t\t<AltExplosionSoundID>%d</AltExplosionSoundID>\r\n", gExpAniData[cnt].uiAltExplosionSoundID);
|
||||
FilePrintf(hFile,"\t\t<BlastFilename>%s</BlastFilename>\r\n", gExpAniData[cnt].zBlastFilename);
|
||||
FilePrintf(hFile,"\t\t<BlastSpeed>%d</BlastSpeed>\r\n", gExpAniData[cnt].sBlastSpeed);
|
||||
FilePrintf(hFile,"\t\t<TransKeyFrame>%d</TransKeyFrame>\r\n", gExpAniData[cnt].ubTransKeyFrame);
|
||||
FilePrintf(hFile,"\t\t<DamageKeyFrame>%d</DamageKeyFrame>\r\n", gExpAniData[cnt].ubDamageKeyFrame);
|
||||
FilePrintf(hFile,"\t\t<ExplosionSoundID>%d</ExplosionSoundID>\r\n", gExpAniData[cnt].uiExplosionSoundID);
|
||||
FilePrintf(hFile,"\t\t<AltExplosionSoundID>%d</AltExplosionSoundID>\r\n", gExpAniData[cnt].uiAltExplosionSoundID);
|
||||
FilePrintf(hFile,"\t\t<BlastFilename>%s</BlastFilename>\r\n", gExpAniData[cnt].zBlastFilename);
|
||||
FilePrintf(hFile,"\t\t<BlastSpeed>%d</BlastSpeed>\r\n", gExpAniData[cnt].sBlastSpeed);
|
||||
|
||||
FilePrintf(hFile,"\t</EXPDATA>\r\n");
|
||||
}
|
||||
@@ -244,4 +244,4 @@ BOOLEAN WriteExplosionDataStats()
|
||||
FileClose( hFile );
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user