Skip to content

Commit

Permalink
Remove unused TEXT_DISPLAY, improve format string consistency and rem…
Browse files Browse the repository at this point in the history
…ove weird casts.
  • Loading branch information
Cyp committed Jan 17, 2011
1 parent 9a28d84 commit 46c5b8e
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 135 deletions.
18 changes: 9 additions & 9 deletions lib/ivis_common/imdload.c
Expand Up @@ -582,7 +582,7 @@ static iIMDShape *_imd_load_level(const char **ppFileData, const char *FileDataE
s->texpage = iV_TEX_INVALID;


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;
Expand All @@ -605,7 +605,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;
Expand All @@ -625,7 +625,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;
}
Expand Down Expand Up @@ -676,7 +676,7 @@ iIMDShape *iV_ProcessIMD( const char **ppFileData, const char *FileDataEnd )
Uint32 imd_flags; // FIXME UNUSED
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);
Expand All @@ -698,15 +698,15 @@ iIMDShape *iV_ProcessIMD( const char **ppFileData, const char *FileDataEnd )
}

/* Flags are ignored now. Reading them in just to pass the buffer. */
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;
}
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;
Expand All @@ -730,7 +730,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;
Expand All @@ -754,7 +754,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;
Expand All @@ -771,7 +771,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;
Expand Down
22 changes: 11 additions & 11 deletions src/droid.c
Expand Up @@ -1850,7 +1850,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
memset(pDroidDesign, 0, sizeof(DROID_TEMPLATE));

//read the data into the storage - the data is delimited using comma's
sscanf(pDroidData, "%[^','],%d,%n", componentName, &pDroidDesign->multiPlayerID, &cnt);
sscanf(pDroidData, "%255[^,'\r\n],%d,%n", componentName, &pDroidDesign->multiPlayerID, &cnt);
pDroidData += cnt;

// Store unique name in pName
Expand All @@ -1865,7 +1865,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
sstrcpy(pDroidDesign->aName, componentName);

//read in Body Name
sscanf(pDroidData, "%[^','],%n", componentName, &cnt);
sscanf(pDroidData, "%255[^,'\r\n],%n", componentName, &cnt);
pDroidData += cnt;

//get the Body stats pointer
Expand Down Expand Up @@ -1895,7 +1895,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
}

//read in Brain Name
sscanf(pDroidData, "%[^','],%n", componentName, &cnt);
sscanf(pDroidData, "%255[^,'\r\n],%n", componentName, &cnt);
pDroidData += cnt;

//get the Brain stats pointer
Expand Down Expand Up @@ -1925,7 +1925,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
}

//read in Construct Name
sscanf(pDroidData, "%[^','],%n", componentName, &cnt);
sscanf(pDroidData, "%255[^,'\r\n],%n", componentName, &cnt);
pDroidData += cnt;

//get the Construct stats pointer
Expand Down Expand Up @@ -1955,7 +1955,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
}

//read in Ecm Name
sscanf(pDroidData, "%[^','],%n", componentName, &cnt);
sscanf(pDroidData, "%255[^,'\r\n],%n", componentName, &cnt);
pDroidData += cnt;

//get the Ecm stats pointer
Expand Down Expand Up @@ -1985,7 +1985,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
}

//read in player type - decides whether or not humans can access it
sscanf(pDroidData, "%[^','],%n", playerType,&cnt);
sscanf(pDroidData, "%255[^,'\r\n],%n", playerType,&cnt);
pDroidData += cnt;

if (getTemplateFromUniqueName(pDroidDesign->pName, 0))
Expand All @@ -1995,7 +1995,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
}

//read in Propulsion Name
sscanf(pDroidData, "%[^','],%n", componentName, &cnt);
sscanf(pDroidData, "%255[^,'\r\n],%n", componentName, &cnt);
pDroidData += cnt;

//get the Propulsion stats pointer
Expand Down Expand Up @@ -2025,7 +2025,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
}

//read in Repair Name
sscanf(pDroidData, "%[^','],%n", componentName, &cnt);
sscanf(pDroidData, "%255[^,'\r\n],%n", componentName, &cnt);
pDroidData += cnt;

//get the Repair stats pointer
Expand Down Expand Up @@ -2055,7 +2055,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
}

//read in droid type - only interested if set to PERSON
sscanf(pDroidData, "%[^','],%n", componentName, &cnt);
sscanf(pDroidData, "%255[^,'\r\n],%n", componentName, &cnt);
pDroidData += cnt;

if (!strcmp(componentName, "PERSON"))
Expand Down Expand Up @@ -2089,7 +2089,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
}

//read in Sensor Name
sscanf(pDroidData, "%[^','],%n", componentName, &cnt);
sscanf(pDroidData, "%255[^,'\r\n],%n", componentName, &cnt);
pDroidData += cnt;

//get the Sensor stats pointer
Expand Down Expand Up @@ -2327,7 +2327,7 @@ BOOL loadDroidWeapons(const char *pWeaponData, UDWORD bufferSize)
TemplateName[MAX_STR_LENGTH] = {'\0'};

//read the data into the storage - the data is delimeted using comma's
sscanf(pWeaponData, "%[^','],%[^','],%[^','],%[^','],%d",
sscanf(pWeaponData, "%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%255[^,'\r\n],%d",
TemplateName, WeaponName[0], WeaponName[1], WeaponName[2], &player);

for (i = 0; i < MAX_PLAYERS + 1; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/feature.c
Expand Up @@ -157,7 +157,7 @@ BOOL loadFeatureStats(const char *pFeatureData, UDWORD bufferSize)


//read the data into the storage - the data is delimeted using comma's
sscanf(pFeatureData, "%[^','],%d,%d,%d,%d,%d,%[^','],%[^','],%d,%d,%d",
sscanf(pFeatureData, "%255[^,'\r\n],%d,%d,%d,%d,%d,%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d",
featureName, &Width, &Breadth,
&damageable, &psFeature->armourValue, &psFeature->body,
GfxFile, type, &tileDraw, &allowLOS,
Expand Down
32 changes: 16 additions & 16 deletions src/function.c
Expand Up @@ -180,7 +180,7 @@ static BOOL loadProduction(const char *pData)
functionName[0] = '\0';
//propulsionType[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
Expand Down Expand Up @@ -215,7 +215,7 @@ static BOOL loadProduction(const char *pData)
psFunction->propulsionType = propType;
#endif

if (!getBodySize(bodySize, (UBYTE*)&psFunction->capacity))
if (!getBodySize(bodySize, &psFunction->capacity))
{

ASSERT( false, "loadProduction: unknown body size for %s",psFunction->pName );
Expand Down Expand Up @@ -268,7 +268,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);


Expand Down Expand Up @@ -333,7 +333,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);
Expand Down Expand Up @@ -367,7 +367,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);
Expand Down Expand Up @@ -404,7 +404,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);
Expand Down Expand Up @@ -488,7 +488,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
Expand Down Expand Up @@ -555,7 +555,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);
Expand Down Expand Up @@ -605,7 +605,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);

Expand Down Expand Up @@ -674,7 +674,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);
Expand Down Expand Up @@ -725,7 +725,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);
Expand Down Expand Up @@ -774,7 +774,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);
Expand Down Expand Up @@ -819,7 +819,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);
Expand Down Expand Up @@ -855,7 +855,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
Expand Down Expand Up @@ -896,7 +896,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);
Expand Down Expand Up @@ -1586,7 +1586,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);

Expand Down
6 changes: 1 addition & 5 deletions src/functiondef.h
Expand Up @@ -145,13 +145,9 @@ typedef struct _production_function
//common stats
FUNCTION_STATS;

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*/
} PRODUCTION_FUNCTION;

/*To research topics available*/
Expand Down
3 changes: 0 additions & 3 deletions src/intelmap.c
Expand Up @@ -193,9 +193,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)

Expand Down
2 changes: 0 additions & 2 deletions src/intelmap.h
Expand Up @@ -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);
Expand Down

0 comments on commit 46c5b8e

Please sign in to comment.