From 912cf2c8e2f3d6cdf53da32cee9d1866123b4a9f Mon Sep 17 00:00:00 2001 From: Dennis Schridde Date: Sat, 23 Sep 2006 14:56:18 +0000 Subject: [PATCH] Partially revert r739. SDL < 1.2.10 doesn't define the string function wrappers. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@747 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/framework/debug.c | 2 +- lib/framework/win32fixes.h | 2 + lib/gamelib/anim.c | 3 +- lib/ivis_common/bitimage.c | 6 +-- lib/ivis_common/imdload.c | 2 +- lib/ivis_opengl/tex.c | 6 +-- lib/sound/cdaudio.c | 4 +- src/audio_id.c | 2 +- src/clparse.c | 78 +++++++++++++++++++------------------- src/init.c | 4 +- src/research.c | 2 +- src/scriptfuncs.c | 58 ++++++++++++++-------------- 12 files changed, 85 insertions(+), 84 deletions(-) diff --git a/lib/framework/debug.c b/lib/framework/debug.c index 659307e24..085b67954 100644 --- a/lib/framework/debug.c +++ b/lib/framework/debug.c @@ -68,7 +68,7 @@ static int code_part_from_str(const char *str) int i; for (i = 0; i < LOG_LAST; i++) { - if (SDL_strcasecmp(code_part_names[i], str) == 0) { + if (strcasecmp(code_part_names[i], str) == 0) { return i; } } diff --git a/lib/framework/win32fixes.h b/lib/framework/win32fixes.h index c49a1e0f5..8d1e5e963 100644 --- a/lib/framework/win32fixes.h +++ b/lib/framework/win32fixes.h @@ -1,3 +1,5 @@ +#define strcasecmp _stricmp +#define strncasecmp _strnicmp #define vsnprintf _vsnprintf #define snprintf _snprintf diff --git a/lib/gamelib/anim.c b/lib/gamelib/anim.c index b86620852..6bf3f61ca 100644 --- a/lib/gamelib/anim.c +++ b/lib/gamelib/anim.c @@ -342,8 +342,7 @@ anim_GetAnimID( char *szName ) /* find matching anim string in list */ psAnim = g_animGlobals.psAnimList; - while( psAnim != NULL && - SDL_strcasecmp( psAnim->szFileName, szName ) != 0 ) + while( psAnim != NULL && strcasecmp( psAnim->szFileName, szName ) != 0 ) { psAnim = psAnim->psNext; } diff --git a/lib/ivis_common/bitimage.c b/lib/ivis_common/bitimage.c index 925f03dcd..d22cb0d7d 100644 --- a/lib/ivis_common/bitimage.c +++ b/lib/ivis_common/bitimage.c @@ -144,7 +144,7 @@ void iV_FreeImageFile(IMAGEFILE *ImageFile) // for(i=0; iHeader.NumTPages; i++) { // FREE(ImageFile->TexturePages[i].bmp); // } - + FREE(ImageFile->TexturePages); FREE(ImageFile->ImageDefs); FREE(ImageFile); @@ -170,7 +170,7 @@ static BOOL LoadTextureFile(STRING *FileName, iSprite *pSprite, int *texPageID) return FALSE; } else { *pSprite = *(iSprite*)resGetData("IMGPAGE", real_filename); - debug(LOG_TEXTURE, "Load texture from resource cache: %s (%d, %d)", + debug(LOG_TEXTURE, "Load texture from resource cache: %s (%d, %d)", real_filename, pSprite->width, pSprite->height); } @@ -179,7 +179,7 @@ static BOOL LoadTextureFile(STRING *FileName, iSprite *pSprite, int *texPageID) /* We have already loaded this one? */ while (i < _TEX_INDEX) { - if (SDL_strcasecmp(real_filename, _TEX_PAGE[i].name) == 0) { + if (strcasecmp(real_filename, _TEX_PAGE[i].name) == 0) { *texPageID = (_TEX_PAGE[i].textPage3dfx); debug(LOG_TEXTURE, "LoadTextureFile: already loaded"); return TRUE; diff --git a/lib/ivis_common/imdload.c b/lib/ivis_common/imdload.c index 0200478a1..f325737c7 100644 --- a/lib/ivis_common/imdload.c +++ b/lib/ivis_common/imdload.c @@ -276,7 +276,7 @@ iIMDShape *iV_ProcessIMD(STRING **ppFileData, STRING *FileDataEnd, STRING *IMDpa if (bTextured) { //resToLower(texfile); // printf("texfile cmp in imdload.c :%s\n", texfile); - if (SDL_strncasecmp(texfile, "page-", 5) == 0) { + if (strncasecmp(texfile, "page-", 5) == 0) { for(i = 5; i < (SDWORD)strlen(texfile); i++) { if (!isdigit(texfile[i])) { break; diff --git a/lib/ivis_opengl/tex.c b/lib/ivis_opengl/tex.c index 8480c9d53..cd9ccf72b 100644 --- a/lib/ivis_opengl/tex.c +++ b/lib/ivis_opengl/tex.c @@ -65,7 +65,7 @@ int pie_AddBMPtoTexPages(iSprite* s, STRING* filename, int type, iBool bColourKe /* Have we already loaded this one? (Should generally not happen here.) */ while (i < _TEX_INDEX) { - if (SDL_strcasecmp(filename, _TEX_PAGE[i].name) == 0) { + if (strcasecmp(filename, _TEX_PAGE[i].name) == 0) { // this happens with terrain for some reason, which is necessary debug(LOG_TEXTURE, "pie_AddBMPtoTexPages: %s loaded again", filename); } @@ -152,7 +152,7 @@ int iV_GetTexture(char *filename) /* Have we already loaded this one then? (Yes. Always.) */ while (i < _TEX_INDEX) { - if (SDL_strcasecmp(filename, _TEX_PAGE[i].name) == 0) { + if (strcasecmp(filename, _TEX_PAGE[i].name) == 0) { return i; } i++; @@ -182,7 +182,7 @@ int pie_ReloadTexPage(STRING *filename, char *pBuffer) debug( LOG_NEVER, "pie_ReloadTexPage called" ); /* Have we already loaded this one then? */ - while (SDL_strcasecmp(filename,_TEX_PAGE[i].name) != 0) { + while (strcasecmp(filename,_TEX_PAGE[i].name) != 0) { i++; if (i >= _TEX_INDEX) { debug(LOG_TEXTURE, "Texture %s not in resources", filename); diff --git a/lib/sound/cdaudio.c b/lib/sound/cdaudio.c index e3bd91973..8ccfa70c5 100644 --- a/lib/sound/cdaudio.c +++ b/lib/sound/cdaudio.c @@ -281,7 +281,7 @@ static BOOL cdAudio_OpenTrack(char* filename) { music_file_format = WZ_NONE; #ifndef WZ_NOMP3 - if (SDL_strncasecmp(filename+strlen(filename)-4, ".mp3", 4) == 0) + if (strncasecmp(filename+strlen(filename)-4, ".mp3", 4) == 0) { music_file = PHYSFS_openRead(filename); @@ -323,7 +323,7 @@ static BOOL cdAudio_OpenTrack(char* filename) { #endif #ifndef WZ_NOOGG - if (SDL_strncasecmp(filename+strlen(filename)-4, ".ogg", 4) == 0) + if (strncasecmp(filename+strlen(filename)-4, ".ogg", 4) == 0) { music_file = PHYSFS_openRead(filename); diff --git a/src/audio_id.c b/src/audio_id.c index 4bea6be64..0ac94b6bf 100644 --- a/src/audio_id.c +++ b/src/audio_id.c @@ -487,7 +487,7 @@ audioID_GetIDFromStr( const STRING *pWavStr, SDWORD *piID ) for ( i=0; i 10 // Do not add addon.lev again - && !SDL_strcasecmp( *file+(len-10), ".addon.lev") ) { + && !strcasecmp( *file+(len-10), ".addon.lev") ) { debug( LOG_WZ, "Loading lev file: %s\n", *file ); loadLevFile( *file, MOD_MULTIPLAY ); } @@ -1025,7 +1025,7 @@ BOOL systemInitialise(void) } if ( war_getSoundEnabled() ) - { + { if( !audio_Init(droidAudioTrackStopped) ) debug( LOG_SOUND, "Couldn't initialise audio system: continuing without audio\n" ); } diff --git a/src/research.c b/src/research.c index 66739b7c5..f0efcfd0a 100644 --- a/src/research.c +++ b/src/research.c @@ -2801,7 +2801,7 @@ RESEARCH * getResearch(STRING *pName, BOOL resName) #ifdef HASH_NAMES if (asResearch[inc].NameHash==HashedName) #else - if (!SDL_strcasecmp(asResearch[inc].pName, pName)) + if (!strcasecmp(asResearch[inc].pName, pName)) #endif { return &asResearch[inc]; diff --git a/src/scriptfuncs.c b/src/scriptfuncs.c index 3b9bc60b8..1de2d2972 100644 --- a/src/scriptfuncs.c +++ b/src/scriptfuncs.c @@ -9535,7 +9535,7 @@ BOOL addHelpBlip(SDWORD locX, SDWORD locY, SDWORD forPlayer, SDWORD sender, STRI psMessage->pViewData = (MSG_VIEWDATA *)pTempData; //check the z value is at least the height of the terrain - height = map_Height(((VIEW_PROXIMITY *)pTempData->pData)->x, + height = map_Height(((VIEW_PROXIMITY *)pTempData->pData)->x, ((VIEW_PROXIMITY *)pTempData->pData)->y); //if (((VIEW_PROXIMITY *)pTempData->pData)->z < height) @@ -9561,7 +9561,7 @@ BOOL addHelpBlip(SDWORD locX, SDWORD locY, SDWORD forPlayer, SDWORD sender, STRI return FALSE; } } - + return TRUE; } @@ -9613,7 +9613,7 @@ VIEWDATA *HelpViewData(SDWORD sender, STRING *textMsg, UDWORD LocX, UDWORD LocY) { debug(LOG_ERROR,"prepairHelpViewData() - ViewData Name - Out of memory"); return NULL; - } + } strcpy(psViewData->pName,name); @@ -9634,7 +9634,7 @@ VIEWDATA *HelpViewData(SDWORD sender, STRING *textMsg, UDWORD LocX, UDWORD LocY) debug(LOG_ERROR,"prepairHelpViewData() - Unable to allocate memory"); return NULL; } - + //store audio audioID = NO_SOUND; @@ -9646,7 +9646,7 @@ VIEWDATA *HelpViewData(SDWORD sender, STRING *textMsg, UDWORD LocX, UDWORD LocY) debug(LOG_ERROR,"prepairHelpViewData() - Negative X coord for prox message"); return NULL; } - + if (LocY < 0) { debug(LOG_ERROR,"prepairHelpViewData() - Negative X coord for prox message"); @@ -9752,7 +9752,7 @@ BOOL scrRemoveHelpMessage(void) } //else //{ - // ASSERT((FALSE, "scrRemoveMessage:cannot find message - %s", + // ASSERT((FALSE, "scrRemoveMessage:cannot find message - %s", // psViewData->pName)); // return FALSE; //} @@ -9825,7 +9825,7 @@ SDWORD getNumRepairedBy(DROID *psDroidToCheck, SDWORD player) BOOL scrMsgBox(void) { STRING *ssval=NULL; - + if (!stackPopParams(1, VAL_STRING, &ssval)) { debug(LOG_ERROR, "scrMsgBox(): stack failed"); @@ -9835,7 +9835,7 @@ BOOL scrMsgBox(void) //dbg_console("DEBUG: %s", ssval); printf_console("DEBUG: %s",ssval); - + return TRUE; } @@ -9871,7 +9871,7 @@ BOOL scrStructInRangeVis(void) // check for a base object being in range of a point BOOL objectInRangeVis(BASE_OBJECT *psList, SDWORD x, SDWORD y, SDWORD range, SDWORD lookingPlayer) { - BASE_OBJECT *psCurr; + BASE_OBJECT *psCurr; SDWORD xdiff, ydiff, rangeSq; // See if there is a droid in range @@ -9932,7 +9932,7 @@ BOOL scrPursueResearch(void) STRING sTemp[128]; STRUCTURE *psBuilding; RESEARCH_FACILITY *psResFacilty; - + RESEARCH *pResearch; if (!stackPopParams(3,ST_STRUCTURE, &structure, VAL_INT, &player, ST_RESEARCH, &psResearch )) @@ -9942,7 +9942,7 @@ BOOL scrPursueResearch(void) } if(psResearch == NULL) - { + { ASSERT(FALSE, ": no such research topic"); return FALSE; } @@ -10020,14 +10020,14 @@ BOOL scrPursueResearch(void) } index = Stack[top + 2]; //if index = -1, then exit cur = Stack[top + 1]; //go to next PR of the last node, since this one didn't work - + } else //end of nodes not reached { tempIndex = asResearch[index].pPRList[cur]; //get cur node's index //DbgMsg("evaluating node: %d, (cur = %d), %s", tempIndex, cur, asResearch[tempIndex].pName); - if(skTopicAvail(tempIndex,player) && (!beingResearchedByAlly(tempIndex, player))) // - ally check added + if(skTopicAvail(tempIndex,player) && (!beingResearchedByAlly(tempIndex, player))) // - ally check added { //DbgMsg("avail: %d (cur=%d), %s", tempIndex, cur, asResearch[tempIndex].pName); found = TRUE; @@ -10078,9 +10078,9 @@ BOOL scrPursueResearch(void) pResearch = (asResearch + foundIndex); pPlayerRes = asPlayerResList[player]+ foundIndex; psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up - + if (IsResearchCancelled(pPlayerRes)) - { + { psResFacilty->powerAccrued = pResearch->researchPower;//set up as if all power available for cancelled topics } else @@ -10176,7 +10176,7 @@ SDWORD guessPlayerFromMessage(STRING **str) while( sscanf(*str, "%[^,:;?! ]%*[,;?! ]%n", playerName, &count) //didn't reach the end //first field: what to stop on; second field: what to read (skip) afterwards && player >= 0 //last string was a player name - //&& *str < copyStr + strlen(copyStr) + //&& *str < copyStr + strlen(copyStr) ) { if(count==0) /* nothing read ? */ @@ -10218,7 +10218,7 @@ SDWORD getPlayerFromString(STRING *playerName) { /* check name */ debug(LOG_SCRIPT, "checking (%s,%s)",getPlayerName(playerIndex), playerName); - if(SDL_strncasecmp(getPlayerName(playerIndex),playerName, 255) == 0) + if (strncasecmp(getPlayerName(playerIndex),playerName, 255) == 0) { debug(LOG_SCRIPT, "matched, returning %d", playerIndex); return playerIndex; @@ -10226,7 +10226,7 @@ SDWORD getPlayerFromString(STRING *playerName) /* check color */ debug(LOG_SCRIPT, "checking (%s,%s)",getPlayerColorName(playerIndex), playerName); - if(SDL_strncasecmp(getPlayerColorName(playerIndex),playerName, 255) == 0) + if (strncasecmp(getPlayerColorName(playerIndex),playerName, 255) == 0) { debug(LOG_SCRIPT, "matched, returning %d", playerIndex); return playerIndex; @@ -10235,12 +10235,12 @@ SDWORD getPlayerFromString(STRING *playerName) /* check player number */ sprintf(sPlayerNumber,"%d",playerIndex); debug(LOG_SCRIPT, "checking (%s,%s)",sPlayerNumber, playerName); - if(SDL_strncasecmp(sPlayerNumber,playerName, 255) == 0) + if (strncasecmp(sPlayerNumber,playerName, 255) == 0) { debug(LOG_SCRIPT, "matched, returning %d", playerIndex); return playerIndex; } - + } return -1; @@ -10279,7 +10279,7 @@ BOOL scrGetTargetPlayers(void) strcpy(*ssval, myMsg); debug(LOG_SCRIPT, "scrGetTargetPlayers: ssval='%s'", *ssval); - + if (!stackPushResult(VAL_INT, players)) { debug(LOG_ERROR, "scrGetTargetPlayers(): failed to push result"); @@ -10346,7 +10346,7 @@ BOOL scrMatch(void) debug(LOG_SCRIPT, "wordNeed '%s'", wordNeed); /* failed if *one* of the strings ended */ - if((fieldAssignedParse > 0 && fieldAssignedMatch <= 0) + if((fieldAssignedParse > 0 && fieldAssignedMatch <= 0) || (fieldAssignedMatch > 0 && fieldAssignedParse <= 0)) { debug(LOG_SCRIPT, "exit condition FAILED"); @@ -10361,14 +10361,14 @@ BOOL scrMatch(void) } /* - * now compare both words + * now compare both words */ - - if(SDL_strncasecmp(wordNeed,"", 255) == 0) /* if we are looking for player */ + + if (strncasecmp(wordNeed,"", 255) == 0) /* if we are looking for player */ { debug(LOG_SCRIPT, "matching "); *nResult = getPlayerFromString(wordFound); - + if(*nResult == -1) /* failed to match player, stop */ { debug(LOG_SCRIPT, "failed to match "); @@ -10379,7 +10379,7 @@ BOOL scrMatch(void) debug(LOG_SCRIPT, "matched "); } } - else if(SDL_strncasecmp(wordNeed,wordFound,255) != 0) /* just compare words to se if they match */ + else if (strncasecmp(wordNeed,wordFound,255) != 0) /* just compare words to se if they match */ { debug(LOG_SCRIPT, "words did not match"); ok = FALSE; @@ -10392,7 +10392,7 @@ BOOL scrMatch(void) FREE(wordFound); FREE(wordNeed); - + if (!stackPushResult(VAL_BOOL, ok)) { debug(LOG_ERROR, "scrGetTargetPlayers(): failed to push result"); @@ -10418,5 +10418,5 @@ SDWORD getFirstWord(STRING *sText, STRING **sWord, SDWORD *readCount) *readCount = count; - return fieldsAssigned; + return fieldsAssigned; }