Remove unused TEXT_DISPLAY, improve format string consistency and remove weird casts.

master
Cyp 2010-12-25 14:05:19 +01:00
parent f99d9b20cc
commit 4fb9e61548
10 changed files with 121 additions and 143 deletions

View File

@ -530,7 +530,7 @@ static iIMDShape *_imd_load_level(const char **ppFileData, const char *FileDataE
// Load optional MATERIALS directive
pTmp = pFileData; // remember position
i = sscanf(pFileData, "%s %n", buffer, &cnt);
i = sscanf(pFileData, "%255s %n", buffer, &cnt);
ASSERT_OR_RETURN(NULL, i == 1, "Bad directive following LEVEL");
memset(s->material, 0, sizeof(s->material));
s->material[LIGHT_AMBIENT][3] = 1.0f;
@ -538,7 +538,7 @@ static iIMDShape *_imd_load_level(const char **ppFileData, const char *FileDataE
s->material[LIGHT_SPECULAR][3] = 1.0f;
if (strcmp(buffer, "MATERIALS") == 0)
{
i = sscanf(pFileData, "%s %f %f %f %f %f %f %f %f %f %f%n", buffer,
i = sscanf(pFileData, "%255s %f %f %f %f %f %f %f %f %f %f%n", buffer,
&s->material[LIGHT_AMBIENT][0], &s->material[LIGHT_AMBIENT][1], &s->material[LIGHT_AMBIENT][2],
&s->material[LIGHT_DIFFUSE][0], &s->material[LIGHT_DIFFUSE][1], &s->material[LIGHT_DIFFUSE][2],
&s->material[LIGHT_SPECULAR][0], &s->material[LIGHT_SPECULAR][1], &s->material[LIGHT_SPECULAR][2],
@ -562,7 +562,7 @@ static iIMDShape *_imd_load_level(const char **ppFileData, const char *FileDataE
pFileData = pTmp;
}
if (sscanf(pFileData, "%s %d%n", buffer, &s->npoints, &cnt) != 2)
if (sscanf(pFileData, "%255s %d%n", buffer, &s->npoints, &cnt) != 2)
{
debug(LOG_ERROR, "_imd_load_level(2): file corrupt");
return NULL;
@ -575,7 +575,7 @@ static iIMDShape *_imd_load_level(const char **ppFileData, const char *FileDataE
_imd_load_points( &pFileData, s );
if (sscanf(pFileData, "%s %d%n", buffer, &s->npolys, &cnt) != 2)
if (sscanf(pFileData, "%255s %d%n", buffer, &s->npolys, &cnt) != 2)
{
debug(LOG_ERROR, "_imd_load_level(3): file corrupt");
return NULL;
@ -591,7 +591,7 @@ static iIMDShape *_imd_load_level(const char **ppFileData, const char *FileDataE
while (!AtEndOfFile(pFileData, FileDataEnd)) // check for end of file (give or take white space)
{
// Scans in the line ... if we don't get 2 parameters then quit
if (sscanf(pFileData, "%s %d%n", buffer, &n, &cnt) != 2)
if (sscanf(pFileData, "%255s %d%n", buffer, &n, &cnt) != 2)
{
break;
}
@ -642,7 +642,7 @@ iIMDShape *iV_ProcessIMD( const char **ppFileData, const char *FileDataEnd )
uint32_t imd_flags;
BOOL bTextured = false;
if (sscanf(pFileData, "%s %d%n", buffer, &imd_version, &cnt) != 2)
if (sscanf(pFileData, "%255s %d%n", buffer, &imd_version, &cnt) != 2)
{
debug(LOG_ERROR, "iV_ProcessIMD %s bad version: (%s)", pFileName, buffer);
assert(false);
@ -664,7 +664,7 @@ iIMDShape *iV_ProcessIMD( const char **ppFileData, const char *FileDataEnd )
}
// Read flag
if (sscanf(pFileData, "%s %x%n", buffer, &imd_flags, &cnt) != 2)
if (sscanf(pFileData, "%255s %x%n", buffer, &imd_flags, &cnt) != 2)
{
debug(LOG_ERROR, "iV_ProcessIMD %s bad flags: %s", pFileName, buffer);
return NULL;
@ -672,7 +672,7 @@ iIMDShape *iV_ProcessIMD( const char **ppFileData, const char *FileDataEnd )
pFileData += cnt;
/* This can be either texture or levels */
if (sscanf(pFileData, "%s %d%n", buffer, &nlevels, &cnt) != 2)
if (sscanf(pFileData, "%255s %d%n", buffer, &nlevels, &cnt) != 2)
{
debug(LOG_ERROR, "iV_ProcessIMD %s expecting TEXTURE or LEVELS: %s", pFileName, buffer);
return NULL;
@ -696,7 +696,7 @@ iIMDShape *iV_ProcessIMD( const char **ppFileData, const char *FileDataEnd )
}
texfile[i] = '\0';
if (sscanf(pFileData, "%s%n", texType, &cnt) != 1)
if (sscanf(pFileData, "%255s%n", texType, &cnt) != 1)
{
debug(LOG_ERROR, "iV_ProcessIMD %s texture info corrupt: %s", pFileName, buffer);
return NULL;
@ -718,7 +718,7 @@ iIMDShape *iV_ProcessIMD( const char **ppFileData, const char *FileDataEnd )
pFileData += cnt;
/* Now read in LEVELS directive */
if (sscanf(pFileData, "%s %d%n", buffer, &nlevels, &cnt) != 2)
if (sscanf(pFileData, "%255s %d%n", buffer, &nlevels, &cnt) != 2)
{
debug(LOG_ERROR, "iV_ProcessIMD %s bad levels info: %s", pFileName, buffer);
return NULL;
@ -735,7 +735,7 @@ iIMDShape *iV_ProcessIMD( const char **ppFileData, const char *FileDataEnd )
}
/* Read first LEVEL directive */
if (sscanf(pFileData, "%s %d%n", buffer, &level, &cnt) != 2)
if (sscanf(pFileData, "%255s %d%n", buffer, &level, &cnt) != 2)
{
debug(LOG_ERROR, "(_load_level) file corrupt -J");
return NULL;

View File

@ -175,13 +175,13 @@ static BOOL loadProduction(const char *pData)
//read the data in
functionName[0] = '\0';
bodySize[0] = '\0';
sscanf(pData, "%[^','],%[^','],%d", functionName, bodySize,
sscanf(pData, "%255[^,'\r\n],%255[^,'\r\n],%d", functionName, bodySize,
&productionOutput);
//allocate storage for the name
storeName((FUNCTION *)psFunction, functionName);
if (!getBodySize(bodySize, (UBYTE*)&psFunction->capacity))
if (!getBodySize(bodySize, &psFunction->capacity))
{
ASSERT( false, "loadProduction: unknown body size for %s",psFunction->pName );
@ -233,7 +233,7 @@ static BOOL loadProductionUpgradeFunction(const char *pData)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d,%d,%d,%d", functionName, &factory,
sscanf(pData, "%255[^,'\r\n],%d,%d,%d,%d", functionName, &factory,
&cyborg, &vtol,&outputModifier);
@ -298,7 +298,7 @@ static BOOL loadResearchFunction(const char *pData)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d", functionName, &psFunction->researchPoints);
sscanf(pData, "%255[^,'\r\n],%d", functionName, &psFunction->researchPoints);
//allocate storage for the name
storeName((FUNCTION *)psFunction, functionName);
@ -332,7 +332,7 @@ static BOOL loadReArmFunction(const char *pData)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d", functionName, &psFunction->reArmPoints);
sscanf(pData, "%255[^,'\r\n],%d", functionName, &psFunction->reArmPoints);
//allocate storage for the name
storeName((FUNCTION *)psFunction, functionName);
@ -369,7 +369,7 @@ static BOOL loadUpgradeFunction(const char *pData, UBYTE type)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d", functionName, &modifier);
sscanf(pData, "%255[^,'\r\n],%d", functionName, &modifier);
//allocate storage for the name
storeName((FUNCTION *)psFunction, functionName);
@ -453,7 +453,7 @@ static BOOL loadDroidBodyUpgradeFunction(const char *pData)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d,%d,%d,%d,%d,%d", functionName, &modifier,
sscanf(pData, "%255[^,'\r\n],%d,%d,%d,%d,%d,%d", functionName, &modifier,
&body, &armourKinetic, &armourHeat, &droid, &cyborg);
//allocate storage for the name
@ -520,7 +520,7 @@ static BOOL loadDroidSensorUpgradeFunction(const char *pData)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d,%d", functionName, &modifier, &range);
sscanf(pData, "%255[^,'\r\n],%d,%d", functionName, &modifier, &range);
//allocate storage for the name
storeName((FUNCTION *)psFunction, functionName);
@ -570,7 +570,7 @@ static BOOL loadWeaponUpgradeFunction(const char *pData)
//read the data in
functionName[0] = '\0';
weaponSubClass[0] = '\0';
sscanf(pData, "%[^','],%[^','],%d,%d,%d,%d,%d,%d,%d", functionName,
sscanf(pData, "%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%d,%d,%d", functionName,
weaponSubClass, &firePause, &shortHit, &longHit, &damage, &radiusDamage,
&incenDamage, &radiusHit);
@ -639,7 +639,7 @@ static BOOL loadStructureUpgradeFunction(const char *pData)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d,%d,%d", functionName, &armour, &body, &resistance);
sscanf(pData, "%255[^,'\r\n],%d,%d,%d", functionName, &armour, &body, &resistance);
//allocate storage for the name
storeName((FUNCTION *)psFunction, functionName);
@ -690,7 +690,7 @@ static BOOL loadWallDefenceUpgradeFunction(const char *pData)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d,%d", functionName, &armour, &body);
sscanf(pData, "%255[^,'\r\n],%d,%d", functionName, &armour, &body);
//allocate storage for the name
storeName((FUNCTION *)psFunction, functionName);
@ -739,7 +739,7 @@ static BOOL loadPowerGenFunction(const char *pData)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d,%d,%d,%d,%d,%d", functionName,
sscanf(pData, "%255[^,'\r\n],%d,%d,%d,%d,%d,%d", functionName,
&psFunction->powerOutput, &psFunction->powerMultiplier,
&psFunction->criticalMassChance, &psFunction->criticalMassRadius,
&psFunction->criticalMassDamage, &psFunction->radiationDecayTime);
@ -801,7 +801,7 @@ static BOOL loadResourceFunction(const char *pData)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d", functionName, &psFunction->maxPower);
sscanf(pData, "%255[^,'\r\n],%d", functionName, &psFunction->maxPower);
//allocate storage for the name
storeName((FUNCTION *)psFunction, functionName);
@ -837,7 +837,7 @@ static BOOL loadRepairDroidFunction(const char *pData)
//read the data in
functionName[0] = '\0';
sscanf(pData, "%[^','],%d", functionName,
sscanf(pData, "%255[^,'\r\n],%d", functionName,
&psFunction->repairPoints);
//allocate storage for the name
@ -878,7 +878,7 @@ static BOOL loadWallFunction(const char *pData)
//read the data in
functionName[0] = '\0';
structureName[0] = '\0';
sscanf(pData, "%[^','],%[^','],%*d", functionName, structureName);
sscanf(pData, "%255[^,'\r\n],%255[^,'\r\n],%*d", functionName, structureName);
//allocate storage for the name
storeName((FUNCTION *)psFunction, functionName);
@ -1541,7 +1541,7 @@ BOOL loadFunctionStats(const char *pFunctionData, UDWORD bufferSize)
{
//read the data into the storage - the data is delimeted using comma's
FunctionType[0] = '\0';
sscanf(pFunctionData, "%[^',']", FunctionType);
sscanf(pFunctionData, "%255[^,'\r\n]", FunctionType);
type = functionType(FunctionType);
pFunctionData += (strlen(FunctionType)+1);

View File

@ -123,13 +123,9 @@ struct PRODUCTION_UPGRADE_FUNCTION : public FUNCTION
/*To manufacture droids designed previously*/
struct PRODUCTION_FUNCTION : public FUNCTION
{
UWORD capacity; /*The max size of body the factory
can produce*/
UBYTE capacity; // The max size of body the factory can produce
UWORD productionOutput; /*Droid Build Points Produced Per
Build Cycle*/
//struct _propulsion_types* propulsionType;
//UBYTE propulsionType; /*The type of propulsion the facility
// can produce*/
};
/*To research topics available*/

View File

@ -195,9 +195,6 @@ static BOOL intDisplaySeqTextViewPage(VIEW_REPLAY *psViewReplay,
// The current message being displayed
MESSAGE *psCurrentMsg = NULL;
// The display stats for the current messages' text
TEXT_DISPLAY currentTextDisplay;
#define PAUSE_DISPLAY_CONDITION (!bMultiPlayer)
#define PAUSEMESSAGE_YOFFSET (0)

View File

@ -40,8 +40,6 @@
// The current message being displayed
extern MESSAGE *psCurrentMsg;
// The display stats for the current messages' text
extern TEXT_DISPLAY currentTextDisplay;
/* Add the Intelligence Map widgets to the widget screen */
//extern BOOL intAddIntelMap(BOOL playCurrent);

View File

@ -224,7 +224,7 @@ BOOL mapNew(UDWORD width, UDWORD height)
static void init_tileNames(int type)
{
char *pFileData = NULL;
char name[100] = {'\0'};
char name[MAX_STR_LENGTH] = {'\0'};
int numlines = 0, i = 0, cnt = 0;
uint32_t fileSize = 0;
@ -240,7 +240,7 @@ static void init_tileNames(int type)
abort();
}
sscanf(pFileData, "%[^','],%d%n", name, &numlines, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%d%n", name, &numlines, &cnt);
pFileData += cnt;
if (strcmp("arizona_enum", name))
@ -258,7 +258,7 @@ static void init_tileNames(int type)
abort();
}
sscanf(pFileData, "%[^','],%d%n", name, &numlines, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%d%n", name, &numlines, &cnt);
pFileData += cnt;
if (strcmp("urban_enum", name))
@ -276,7 +276,7 @@ static void init_tileNames(int type)
abort();
}
sscanf(pFileData, "%[^','],%d%n", name, &numlines, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%d%n", name, &numlines, &cnt);
pFileData += cnt;
if (strcmp("rockie_enum", name))
@ -302,12 +302,12 @@ static void init_tileNames(int type)
//increment the pointer to the start of the next record
pFileData = strchr(pFileData,'\n') + 1;
Tile_names = (char *)malloc(numlines * sizeof(char[40]) );
memset(Tile_names, 0x0, (numlines * sizeof(char[40])));
Tile_names = (char *)malloc(numlines * sizeof(char[MAX_STR_LENGTH]) );
memset(Tile_names, 0x0, (numlines * sizeof(char[MAX_STR_LENGTH])));
for (i=0; i < numlines; i++)
{
sscanf(pFileData, "%s%n", &Tile_names[i*40], &cnt);
sscanf(pFileData, "%255[^,'\r\n]%n", &Tile_names[i*MAX_STR_LENGTH], &cnt);
pFileData += cnt;
//increment the pointer to the start of the next record
pFileData = strchr(pFileData,'\n') + 1;
@ -320,9 +320,9 @@ static void init_tileNames(int type)
static BOOL mapLoadGroundTypes(void)
{
char *pFileData = NULL;
char tilename[255] = {'\0'};
char textureName[255] = {'\0'};
char textureType[255] = {'\0'};
char tilename[MAX_STR_LENGTH] = {'\0'};
char textureName[MAX_STR_LENGTH] = {'\0'};
char textureType[MAX_STR_LENGTH] = {'\0'};
double textureSize = 0.f;
int numlines = 0;
int cnt = 0, i = 0;
@ -342,7 +342,7 @@ fallback:
abort();
}
sscanf(pFileData, "%[^','],%d%n", tilename, &numlines, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%d%n", tilename, &numlines, &cnt);
pFileData += cnt;
if (strcmp(tilename, "tertilesc1hw"))
@ -359,7 +359,7 @@ fallback:
for (i=0; i < numlines; i++)
{
sscanf(pFileData, "%[^','],%[^','],%lf%n", textureType, textureName, &textureSize, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%255[^,'\r\n],%lf%n", textureType, textureName, &textureSize, &cnt);
pFileData += cnt;
//increment the pointer to the start of the next record
pFileData = strchr(pFileData,'\n') + 1;
@ -384,7 +384,7 @@ fallback:
goto fallback;
}
sscanf(pFileData, "%[^','],%d%n", tilename, &numlines, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%d%n", tilename, &numlines, &cnt);
pFileData += cnt;
if (strcmp(tilename, "tertilesc2hw"))
@ -401,7 +401,7 @@ fallback:
for (i=0; i < numlines; i++)
{
sscanf(pFileData, "%[^','],%[^','],%lf%n", textureType, textureName, &textureSize, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%255[^,'\r\n],%lf%n", textureType, textureName, &textureSize, &cnt);
pFileData += cnt;
//increment the pointer to the start of the next record
pFileData = strchr(pFileData,'\n') + 1;
@ -426,7 +426,7 @@ fallback:
goto fallback;
}
sscanf(pFileData, "%[^','],%d%n", tilename, &numlines, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%d%n", tilename, &numlines, &cnt);
pFileData += cnt;
if (strcmp(tilename, "tertilesc3hw"))
@ -443,7 +443,7 @@ fallback:
for (i=0; i < numlines; i++)
{
sscanf(pFileData, "%[^','],%[^','],%lf%n", textureType, textureName, &textureSize, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%255[^,'\r\n],%lf%n", textureType, textureName, &textureSize, &cnt);
pFileData += cnt;
//increment the pointer to the start of the next record
pFileData = strchr(pFileData,'\n') + 1;
@ -473,8 +473,8 @@ fallback:
static void SetGroundForTile(const char *filename, const char *nametype)
{
char *pFileData = NULL;
char tilename[255] = {'\0'};
char val1[25], val2[25], val3[25], val4[25];
char tilename[MAX_STR_LENGTH] = {'\0'};
char val1[MAX_STR_LENGTH], val2[MAX_STR_LENGTH], val3[MAX_STR_LENGTH], val4[MAX_STR_LENGTH];
int numlines = 0;
int cnt = 0, i = 0;
uint32_t fileSize = 0;
@ -486,7 +486,7 @@ static void SetGroundForTile(const char *filename, const char *nametype)
abort();
}
sscanf(pFileData, "%[^','],%d%n", tilename, &numlines, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%d%n", tilename, &numlines, &cnt);
pFileData += cnt;
if (strcmp(tilename, nametype))
@ -503,7 +503,7 @@ static void SetGroundForTile(const char *filename, const char *nametype)
for (i=0; i < numlines; i++)
{
sscanf(pFileData, "%[^','],%[^','],%[^','],%s%n", val1, val2, val3, val4, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n]%n", val1, val2, val3, val4, &cnt);
pFileData += cnt;
//increment the pointer to the start of the next record
pFileData = strchr(pFileData,'\n') + 1;
@ -525,7 +525,7 @@ static int getTextureType(const char *textureType)
int i = 0;
for (i=0; i < numTile_names; i++)
{
if (!strcmp(textureType, &Tile_names[i*40]))
if (!strcmp(textureType, &Tile_names[i*MAX_STR_LENGTH]))
{
return i;
}
@ -674,7 +674,7 @@ static int determineGroundType(int x, int y, const char *tileset)
// reads in the decal array for the requested tileset.
static void SetDecals(const char *filename, const char *decal_type)
{
char decalname[50], *pFileData;
char decalname[MAX_STR_LENGTH], *pFileData;
int numlines, cnt, i, tiledecal;
uint32_t fileSize;
@ -686,7 +686,7 @@ static void SetDecals(const char *filename, const char *decal_type)
abort();
}
sscanf(pFileData, "%[^','],%d%n", decalname, &numlines, &cnt);
sscanf(pFileData, "%255[^,'\r\n],%d%n", decalname, &numlines, &cnt);
pFileData += cnt;
if (strcmp(decalname, decal_type))

View File

@ -509,7 +509,7 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize)
name[0] = '\0';
//read the data into the storage - the data is delimeted using comma's
sscanf(pViewMsgData,"%[^','],%d%n",name, &numText,&cnt);
sscanf(pViewMsgData,"%255[^,'\r\n],%d%n",name, &numText,&cnt);
pViewMsgData += cnt;
//check not loading up too many text strings
@ -539,7 +539,7 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize)
for (dataInc = 0; dataInc < psViewData->numText; dataInc++)
{
name[0] = '\0';
sscanf(pViewMsgData,",%[^',']%n",name,&cnt);
sscanf(pViewMsgData,",%255[^,'\r\n]%n",name,&cnt);
pViewMsgData += cnt;
// Get the string from the ID string
@ -569,7 +569,7 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize)
imdName2[0] = '\0';
string[0] = '\0';
audioName[0] = '\0';
sscanf(pViewMsgData,",%[^','],%[^','],%[^','],%[^','],%d%n",
sscanf(pViewMsgData,",%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%d%n",
imdName, imdName2, string, audioName, &dummy, &cnt);
pViewMsgData += cnt;
psViewRes = (VIEW_RESEARCH *)psViewData->pData;
@ -645,7 +645,7 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize)
//load extradat for extended type only
if (psViewData->type == VIEW_RPL)
{
sscanf(pViewMsgData, ",%[^','],%d%n", name, &count,&cnt);
sscanf(pViewMsgData, ",%255[^,'\r\n],%d%n", name, &count,&cnt);
pViewMsgData += cnt;
if (count > MAX_DATA)
{
@ -658,7 +658,7 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize)
}
else //extended type
{
sscanf(pViewMsgData, ",%[^','],%d,%d%n", name, &count, &count2,&cnt);
sscanf(pViewMsgData, ",%255[^,'\r\n],%d,%d%n", name, &count, &count2,&cnt);
pViewMsgData += cnt;
if (count > MAX_DATA)
{
@ -688,7 +688,7 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize)
seqInc++)
{
name[0] = '\0';
sscanf(pViewMsgData,",%[^',']%n", name,&cnt);
sscanf(pViewMsgData,",%255[^,'\r\n]%n", name,&cnt);
pViewMsgData += cnt;
// Get the string from the ID string
@ -700,7 +700,7 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize)
}
}
//get the audio text string
sscanf(pViewMsgData,",%[^','],%d%n", audioName, &dummy, &cnt);
sscanf(pViewMsgData,",%255[^,'\r\n],%d%n", audioName, &dummy, &cnt);
pViewMsgData += cnt;
if (strcmp(audioName, "0"))
@ -733,7 +733,7 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize)
int tmp;
audioName[0] = '\0';
sscanf( pViewMsgData, ", %d,%d,%d,%[^','],%d%n", &LocX, &LocY, &LocZ,
sscanf( pViewMsgData, ", %d,%d,%d,%255[^,'\r\n],%d%n", &LocX, &LocY, &LocZ,
audioName, &tmp, &cnt);
proxType = (PROX_TYPE)tmp;
}

View File

@ -86,9 +86,6 @@ typedef struct _view_replay
{
UBYTE numSeq;
SEQ_DISPLAY *pSeqList;
//char **ppSeqName;
//UBYTE numText; //the number of textmessages associated with this sequence
//char **ppTextMsg; //Pointer to text messages - if any
} VIEW_REPLAY;
// info required to view a proximity message
@ -145,16 +142,6 @@ struct PROXIMITY_DISPLAY : public OBJECT_POSITION
PROXIMITY_DISPLAY * psNext; //pointer to the next in the list
};
//used to display the text messages in 3D view of the Intel display
typedef struct _text_display
{
UDWORD totalFrames; //number of frames for whole message to be displayed
UDWORD startTime; //time started text display
UDWORD font; //id of which font to use
UWORD fontColour; //colour number
char text[MAX_STR_LENGTH-1]; //storage to hold the currently displayed text
} TEXT_DISPLAY;
typedef struct _viewData_list
{
VIEWDATA *psViewData; //array of data

View File

@ -276,7 +276,7 @@ BOOL loadResearch(const char *pResearchData, UDWORD bufferSize)
//read the data into the storage - the data is delimeted using comma's
ResearchName[0] = '\0';
sscanf(pResearchData,"%[^','],", ResearchName);
sscanf(pResearchData,"%255[^,'\r\n],", ResearchName);
//allocate storage for the name
pResearch->pName = allocateName(ResearchName);
@ -290,11 +290,11 @@ BOOL loadResearch(const char *pResearchData, UDWORD bufferSize)
//determine the tech level (unused, so we don't use the resulting string)
ResearchName[0] = '\0';
sscanf(pResearchData,"%[^','],", ResearchName);
sscanf(pResearchData,"%255[^,'\r\n],", ResearchName);
pResearchData += (strlen(ResearchName)+1);
ResearchName[0] = '\0';
sscanf(pResearchData,"%[^','],", ResearchName);
sscanf(pResearchData,"%255[^,'\r\n],", ResearchName);
if (strcmp(ResearchName, "0"))
{
@ -324,8 +324,8 @@ BOOL loadResearch(const char *pResearchData, UDWORD bufferSize)
UDWORD numRedArtefacts;
UDWORD numArteResults;
sscanf(pResearchData,"%d,%[^','],%[^','],%[^','],%[^','],%[^','], \
%[^','],%[^','],%d,%d,%d,%d,%d,%d,%d,%d,%d",
sscanf(pResearchData,"%d,%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n], \
%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%d,%d,%d,%d,%d",
&techCode, iconID, imdName, imdName2, msgName,
structName, compName, compType,
&resPoints, &keyTopic, &numPRRequired,
@ -560,7 +560,7 @@ BOOL loadResearchPR(const char *pPRData, UDWORD bufferSize)
//read the data into the storage - the data is delimited using commas
ResearchName[0] = '\0';
PRName[0] = '\0';
sscanf(pPRData,"%[^','],%[^','],%*d", ResearchName, PRName);
sscanf(pPRData,"%255[^,'\r\n],%255[^,'\r\n],%*d", ResearchName, PRName);
//loop through each Research to compare the name
for (incR=0; incR < numResearch; incR++)
@ -664,7 +664,7 @@ BOOL loadResearchArtefacts(const char *pArteData, UDWORD bufferSize, UDWORD list
ResearchName[0] = '\0';
ArteName[0] = '\0';
TypeName[0] = '\0';
sscanf(pArteData,"%[^','],%[^','],%[^',']", ResearchName, ArteName, TypeName);
sscanf(pArteData,"%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n]", ResearchName, ArteName, TypeName);
//increment the data pointer
pArteData += (strlen(ResearchName)+1+strlen(ArteName)+1+strlen(TypeName)+1);
@ -713,7 +713,7 @@ BOOL loadResearchArtefacts(const char *pArteData, UDWORD bufferSize, UDWORD list
case RES_LIST:
ArteName[0] = '\0';
TypeName[0] = '\0';
sscanf(pArteData, "%[^','],%[^','],%*d", ArteName, TypeName);
sscanf(pArteData, "%255[^,'\r\n],%255[^,'\r\n],%*d", ArteName, TypeName);
if (!strcmp(ArteName, "0"))
{
pResearch->pReplacedArtefacts[pResearch->storeCount] = NULL;
@ -812,7 +812,7 @@ BOOL loadResearchStructures(const char *pStructData, UDWORD bufferSize,UDWORD li
//read the data into the storage - the data is delimited using comma's
ResearchName[0] = '\0';
StructureName[0] = '\0';
sscanf(pStructData,"%[^','],%[^','],%*d,%*d", ResearchName, StructureName);
sscanf(pStructData,"%255[^,'\r\n],%255[^,'\r\n],%*d,%*d", ResearchName, StructureName);
//loop through each Research to compare the name
for (incR = 0; incR < numResearch; incR++)
@ -931,7 +931,7 @@ BOOL loadResearchFunctions(const char *pFunctionData, UDWORD bufferSize)
//read the data into the storage - the data is delimited using comma's
ResearchName[0] = '\0';
FunctionName[0] = '\0';
sscanf(pFunctionData,"%[^','],%[^','],%*d", ResearchName, FunctionName);
sscanf(pFunctionData,"%255[^,'\r\n],%255[^,'\r\n],%*d", ResearchName, FunctionName);
//loop through each Research to compare the name
for (incR=0; incR < numResearch; incR++)

View File

@ -557,9 +557,9 @@ BOOL loadWeaponStats(const char *pWeaponData, UDWORD bufferSize)
hitGfx[MAX_STR_LENGTH], missGfx[MAX_STR_LENGTH],
waterGfx[MAX_STR_LENGTH], muzzleGfx[MAX_STR_LENGTH],
trailGfx[MAX_STR_LENGTH], dummy[MAX_STR_LENGTH];
char fireOnMove[10], weaponClass[15], weaponSubClass[15],
weaponEffect[16], movement[15], facePlayer[5], //weaponEffect[15] caused stack corruption. --Qamly
faceInFlight[5],lightWorld[5];
char fireOnMove[MAX_STR_LENGTH], weaponClass[MAX_STR_LENGTH], weaponSubClass[MAX_STR_LENGTH],
weaponEffect[MAX_STR_LENGTH], movement[MAX_STR_LENGTH], facePlayer[MAX_STR_LENGTH], //weaponEffect[15] caused stack corruption. --Qamly
faceInFlight[MAX_STR_LENGTH],lightWorld[MAX_STR_LENGTH];
UDWORD longRange, effectSize, numAttackRuns, designable;
UDWORD numRounds;
@ -602,24 +602,24 @@ BOOL loadWeaponStats(const char *pWeaponData, UDWORD bufferSize)
//read the data into the storage - the data is delimeted using comma's
sscanf(pWeaponData,"%[^','],%[^','],%d,%d,%d,%d,%d,%d,%[^','],\
%[^','],%[^','],%[^','],%[^','],%[^','],%[^','],%[^','],%d,\
%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%[^','],\
%[^','],%[^','],%[^','],%[^','],%d,%d,%d,%[^','],%[^','],%d,%d,\
%[^','],%d,%d,%d,%d,%d",
(char *)&WeaponName, (char *)&dummy, &psStats->buildPower,&psStats->buildPoints,
sscanf(pWeaponData,"%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%d,%d,%255[^,'\r\n],\
%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%d,\
%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%255[^,'\r\n],\
%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%255[^,'\r\n],%255[^,'\r\n],%d,%d,\
%255[^,'\r\n],%d,%d,%d,%d,%d",
WeaponName, dummy, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &dummyVal, &dummyVal,
&psStats->body, (char *)&GfxFile, (char *)&mountGfx, (char *)&muzzleGfx, (char *)&flightGfx,
(char *)&hitGfx, (char *)&missGfx, (char *)&waterGfx, (char *)&trailGfx, &psStats->shortRange,
&psStats->body, GfxFile, mountGfx, muzzleGfx, flightGfx,
hitGfx, missGfx, waterGfx, trailGfx, &psStats->shortRange,
&psStats->longRange,&psStats->shortHit, &psStats->longHit,
&psStats->firePause, &psStats->numExplosions, &numRounds,
&psStats->reloadTime, &psStats->damage, &psStats->radius,
&psStats->radiusHit, &psStats->radiusDamage, &psStats->incenTime,
&psStats->incenDamage, &psStats->incenRadius, &psStats->directLife,
&psStats->radiusLife, &psStats->flightSpeed, &dummyVal,
(char *)&fireOnMove, (char *)&weaponClass, (char *)&weaponSubClass, (char *)&movement, (char *)&weaponEffect,
&rotate, &maxElevation, &minElevation, (char *)&facePlayer, (char *)&faceInFlight,
&psStats->recoilValue, &psStats->minRange, (char *)&lightWorld,
fireOnMove, weaponClass, weaponSubClass, movement, weaponEffect,
&rotate, &maxElevation, &minElevation, facePlayer, faceInFlight,
&psStats->recoilValue, &psStats->minRange, lightWorld,
&effectSize, &surfaceToAir, &numAttackRuns, &designable, &penetrate);
psStats->numRounds = (UBYTE)numRounds;
@ -999,11 +999,11 @@ BOOL loadBodyStats(const char *pBodyData, UDWORD bufferSize)
//Watermelon:added 10 %d to store FRONT,REAR,LEFT,RIGHT,TOP,BOTTOM armour values
//read the data into the storage - the data is delimeted using comma's
sscanf(pBodyData,"%[^','],%[^','],%[^','],%d,%d,%d,%d,%[^','],\
sscanf(pBodyData,"%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%255[^,'\r\n],\
%d,%d,%d, \
%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%[^','],%d",
(char*)&BodyName, (char*)&dummy, (char*)&size, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &psStats->body, (char*)&GfxFile, &dummyVal,
%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%255[^,'\r\n],%d",
BodyName, dummy, size, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &psStats->body, GfxFile, &dummyVal,
&psStats->weaponSlots, &psStats->powerOutput,
(int*)&psStats->armourValue[HIT_SIDE_FRONT][WC_KINETIC], (int*)&psStats->armourValue[HIT_SIDE_FRONT][WC_HEAT],
(int*)&psStats->armourValue[HIT_SIDE_REAR][WC_KINETIC], (int*)&psStats->armourValue[HIT_SIDE_REAR][WC_HEAT],
@ -1011,7 +1011,7 @@ BOOL loadBodyStats(const char *pBodyData, UDWORD bufferSize)
(int*)&psStats->armourValue[HIT_SIDE_RIGHT][WC_KINETIC], (int*)&psStats->armourValue[HIT_SIDE_RIGHT][WC_HEAT],
(int*)&psStats->armourValue[HIT_SIDE_TOP][WC_KINETIC], (int*)&psStats->armourValue[HIT_SIDE_TOP][WC_HEAT],
(int*)&psStats->armourValue[HIT_SIDE_BOTTOM][WC_KINETIC],(int*)&psStats->armourValue[HIT_SIDE_BOTTOM][WC_HEAT],
(char*)&flameIMD, &designable);//, &psStats->armourValue[WC_EXPLOSIVE],
flameIMD, &designable);//, &psStats->armourValue[WC_EXPLOSIVE],
//&psStats->armourValue[WC_MISC]);
//allocate storage for the name
@ -1107,10 +1107,10 @@ BOOL loadBrainStats(const char *pBrainData, UDWORD bufferSize)
BrainName[0] = '\0';
weaponName[0] = '\0';
//read the data into the storage - the data is delimeted using comma's
sscanf(pBrainData,"%[^','],%[^','],%d,%d,%d,%d,%d,%[^','],%d",
(char*)&BrainName, (char*)&dummy, &psStats->buildPower,&psStats->buildPoints,
sscanf(pBrainData,"%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%d,%255[^,'\r\n],%d",
BrainName, dummy, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &dummyVal, &dummyVal,
(char*)&weaponName, &psStats->progCap); //, &psStats->AICap, &psStats->AISpeed);
weaponName, &psStats->progCap);
if (!allocateStatName((BASE_STATS *)psStats, BrainName))
{
@ -1233,11 +1233,11 @@ BOOL loadPropulsionStats(const char *pPropulsionData, UDWORD bufferSize)
imdName[0] = '\0';
//read the data into the storage - the data is delimeted using comma's
sscanf(pPropulsionData,"%[^','],%[^','],%d,%d,%d,%d,%d,%d,%[^','],\
%[^','],%d,%d",
(char*)&PropulsionName, (char*)&dummy, &psStats->buildPower,&psStats->buildPoints,
sscanf(pPropulsionData,"%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%d,%d,%255[^,'\r\n],\
%255[^,'\r\n],%d,%d",
PropulsionName, dummy, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &dummyVal, &dummyVal,
&psStats->body, (char*)&imdName, (char*)&type, &psStats->maxSpeed, &designable);
&psStats->body, imdName, type, &psStats->maxSpeed, &designable);
if (!allocateStatName((BASE_STATS *)psStats, PropulsionName))
{
@ -1348,12 +1348,12 @@ BOOL loadSensorStats(const char *pSensorData, UDWORD bufferSize)
location[0] = '\0';
type[0] = '\0';
//read the data into the storage - the data is delimeted using comma's
sscanf(pSensorData,"%[^','],%[^','],%d,%d,%d,%d,%d,%d,%[^','],\
%[^','],%d,%[^','],%[^','],%d,%d,%d",
(char*)&SensorName, (char*)&dummy, &psStats->buildPower,&psStats->buildPoints,
sscanf(pSensorData,"%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%d,%d,%255[^,'\r\n],\
%255[^,'\r\n],%d,%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d",
SensorName, dummy, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &dummyVal, &dummyVal,
&psStats->body, (char*)&GfxFile,(char*)&mountGfx,
&psStats->range, (char*)&location, (char*)&type, &psStats->time, &psStats->power, &designable);
&psStats->body, GfxFile, mountGfx,
&psStats->range, location, type, &psStats->time, &psStats->power, &designable);
if (!allocateStatName((BASE_STATS *)psStats, SensorName))
{
@ -1482,11 +1482,11 @@ BOOL loadECMStats(const char *pECMData, UDWORD bufferSize)
mountGfx[0] = '\0';
location[0] = '\0';
//read the data into the storage - the data is delimeted using comma's
sscanf(pECMData,"%[^','],%[^','],%d,%d,%d,%d,%d,%d,%[^','],%[^','],\
%[^','],%d,%d,%d",
(char*)&ECMName, (char*)&dummy, &psStats->buildPower,&psStats->buildPoints,
sscanf(pECMData,"%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%d,%d,%255[^,'\r\n],%255[^,'\r\n],\
%255[^,'\r\n],%d,%d,%d",
ECMName, dummy, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &dummyVal, &dummyVal,
&psStats->body, (char*)&GfxFile, (char*)&mountGfx, (char*)&location, &psStats->power,
&psStats->body, GfxFile, mountGfx, location, &psStats->power,
&psStats->range, &designable);
if (!allocateStatName((BASE_STATS *)psStats, ECMName))
@ -1587,11 +1587,11 @@ BOOL loadRepairStats(const char *pRepairData, UDWORD bufferSize)
location[0] = '\0';
//read the data into the storage - the data is delimeted using comma's
sscanf(pRepairData,"%[^','],%[^','],%d,%d,%d,%d,%d,%d,%[^','],\
%[^','],%[^','],%d,%d,%d",
(char*)&RepairName, (char*)&dummy, &psStats->buildPower,&psStats->buildPoints,
sscanf(pRepairData,"%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%d,%d,%255[^,'\r\n],\
%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d",
RepairName, dummy, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &dummyVal, &dummyVal,
&repairArmour, (char*)&location, (char*)&GfxFile, (char*)&mountGfx,
&repairArmour, location, GfxFile, mountGfx,
&psStats->repairPoints, &psStats->time,&designable);
if (!allocateStatName((BASE_STATS *)psStats, RepairName))
@ -1705,11 +1705,11 @@ BOOL loadConstructStats(const char *pConstructData, UDWORD bufferSize)
GfxFile[0] = '\0';
mountGfx[0] = '\0';
//read the data into the storage - the data is delimeted using comma's
sscanf(pConstructData,"%[^','],%[^','],%d,%d,%d,%d,%d,%d,%[^','],\
%[^','],%d,%d",
(char*)&ConstructName, (char*)&dummy, &psStats->buildPower,&psStats->buildPoints,
sscanf(pConstructData,"%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%d,%d,%255[^,'\r\n],\
%255[^,'\r\n],%d,%d",
ConstructName, dummy, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &dummyVal, &dummyVal,
&psStats->body, (char*)&GfxFile, (char*)&mountGfx,
&psStats->body, GfxFile, mountGfx,
&psStats->constructPoints,&designable);
if (!allocateStatName((BASE_STATS *)psStats, ConstructName))
@ -1802,8 +1802,8 @@ BOOL loadPropulsionTypes(const char *pPropTypeData, UDWORD bufferSize)
for (i=0; i < NumTypes; i++)
{
//read the data into the storage - the data is delimeted using comma's
sscanf(pPropTypeData,"%[^','],%[^','],%d",
(char*)&PropulsionName, (char*)&flightName, &multiplier);
sscanf(pPropTypeData,"%255[^,'\r\n],%255[^,'\r\n],%d",
PropulsionName, flightName, &multiplier);
//set the pointer for this record based on the name
if (!getPropulsionType(PropulsionName, &type))
@ -1941,7 +1941,7 @@ BOOL loadSpecialAbility(const char *pSAbilityData, UDWORD bufferSize)
for (i=0; i < NumTypes; i++)
{
//read the data into the storage - the data is delimeted using comma's
sscanf(pSAbilityData,"%[^','],%d",(char*)&SAbilityName, &accessID);
sscanf(pSAbilityData,"%255[^,'\r\n],%d", SAbilityName, &accessID);
//check that the data is ordered in the way it will be stored
if (accessID != i)
{
@ -2012,8 +2012,8 @@ BOOL loadBodyPropulsionIMDs(const char *pData, UDWORD bufferSize)
/*read the data into the storage - the data is delimited using comma's
not interested in the last number - needed for sscanf*/
sscanf(pData,"%[^','],%[^','],%[^','],%[^','],%*d",(char*)&bodyName,
(char*)&propulsionName, (char*)&leftIMD, (char*)&rightIMD);
sscanf(pData,"%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%*d", bodyName,
propulsionName, leftIMD, rightIMD);
//get the body stats
found = false;
@ -2146,7 +2146,7 @@ BOOL loadWeaponSounds(const char *pSoundData, UDWORD bufferSize)
szWeaponWav[0] = '\0';
szExplosionWav[0] = '\0';
//read the data into the storage - the data is delimeted using comma's
sscanf(pSoundData,"%[^','],%[^','],%[^','],%d",
sscanf(pSoundData,"%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%d",
WeaponName, szWeaponWav, szExplosionWav, &iDum);
if ( statsGetAudioIDFromString( WeaponName, szWeaponWav, &weaponSoundID ) == false )
@ -2198,8 +2198,8 @@ BOOL loadWeaponModifiers(const char *pWeapModData, UDWORD bufferSize)
for (i=0; i < NumRecords; i++)
{
//read the data into the storage - the data is delimeted using comma's
sscanf(pWeapModData,"%[^','],%[^','],%d",
(char*)&weaponEffectName, (char*)&propulsionName, &modifier);
sscanf(pWeapModData,"%255[^,'\r\n],%255[^,'\r\n],%d",
weaponEffectName, propulsionName, &modifier);
//get the weapon effect inc
if (!getWeaponEffect(weaponEffectName, &effectInc))
@ -2254,7 +2254,7 @@ BOOL loadPropulsionSounds(const char *pPropSoundData, UDWORD bufferSize)
propulsionName[0] = '\0';
//read the data into the storage - the data is delimeted using comma's
sscanf(pPropSoundData,"%[^','],%[^','],%[^','],%[^','],%[^','],%[^','],%[^','],%d",
sscanf(pPropSoundData,"%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%d",
propulsionName, szStart, szIdle, szMoveOff, szMove, szHiss, szShutDown, &iDum);
if ( statsGetAudioIDFromString( propulsionName, szStart, &startID ) == false )