Consistent insensitive string comparisons.

This seems to reduce the need for a #define,
but I need someone on the Windows side to check.
This commit is contained in:
Jason Felds
2011-05-11 16:48:51 -04:00
parent 52f3bdf7a6
commit 750b688de4
17 changed files with 72 additions and 79 deletions
+2 -2
View File
@@ -37,7 +37,7 @@ void AnnouncerManager::GetAnnouncerNames( vector<RString>& AddTo )
// strip out the empty announcer folder
for( int i=AddTo.size()-1; i>=0; i-- )
if( !stricmp( AddTo[i], EMPTY_ANNOUNCER_NAME ) )
if( !AddTo[i].EqualsNoCase( EMPTY_ANNOUNCER_NAME ) )
AddTo.erase(AddTo.begin()+i, AddTo.begin()+i+1 );
}
@@ -49,7 +49,7 @@ bool AnnouncerManager::DoesAnnouncerExist( RString sAnnouncerName )
vector<RString> asAnnouncerNames;
GetAnnouncerNames( asAnnouncerNames );
for( unsigned i=0; i<asAnnouncerNames.size(); i++ )
if( 0==stricmp(sAnnouncerName, asAnnouncerNames[i]) )
if( sAnnouncerName.EqualsNoCase(asAnnouncerNames[i]) )
return true;
return false;
}
+3 -3
View File
@@ -390,15 +390,15 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
// Check for string match first, then do integer match.
// "if(StringType(type)==0)" was matching against all string matches.
// -Chris
if( stricmp(type,"sprite")==0 )
if( type.EqualsNoCase("sprite") )
{
m_Type = TYPE_SPRITE;
}
else if( stricmp(type,"particles")==0 )
else if( type.EqualsNoCase("particles") )
{
m_Type = TYPE_PARTICLES;
}
else if( stricmp(type,"tiles")==0 )
else if( type.EqualsNoCase("tiles") )
{
m_Type = TYPE_TILES;
}
+15 -15
View File
@@ -61,13 +61,13 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
const MsdFile::value_t &sParams = msd.GetValue(i);
// handle the data
if( 0 == stricmp(sValueName, "COURSE") )
if( sValueName.EqualsNoCase("COURSE") )
out.m_sMainTitle = sParams[1];
else if( 0 == stricmp(sValueName, "COURSETRANSLIT") )
else if( sValueName.EqualsNoCase("COURSETRANSLIT") )
out.m_sMainTitleTranslit = sParams[1];
else if( 0 == stricmp(sValueName, "SCRIPTER") )
else if( sValueName.EqualsNoCase("SCRIPTER") )
out.m_sScripter = sParams[1];
else if( 0 == stricmp(sValueName, "REPEAT") )
else if( sValueName.EqualsNoCase("REPEAT") )
{
RString str = sParams[1];
str.MakeLower();
@@ -75,23 +75,23 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
out.m_bRepeat = true;
}
else if( 0 == stricmp(sValueName, "BANNER") )
else if( sValueName.EqualsNoCase("BANNER") )
{
out.m_sBannerPath = sParams[1];
}
else if( 0 == stricmp(sValueName, "BACKGROUND") )
else if( sValueName.EqualsNoCase("BACKGROUND") )
{
out.m_sBackgroundPath = sParams[1];
}
else if( 0 == stricmp(sValueName, "LIVES") )
else if( sValueName.EqualsNoCase("LIVES") )
{
out.m_iLives = max( StringToInt(sParams[1]), 0 );
}
else if( 0 == stricmp(sValueName, "GAINSECONDS") )
else if( sValueName.EqualsNoCase("GAINSECONDS") )
{
fGainSeconds = StringToFloat( sParams[1] );
}
else if( 0 == stricmp(sValueName, "METER") )
else if( sValueName.EqualsNoCase("METER") )
{
if( sParams.params.size() == 2 )
{
@@ -110,7 +110,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
}
// todo: add COMBO and COMBOMODE from DWI CRS files? -aj
else if( 0 == stricmp(sValueName, "MODS") )
else if( sValueName.EqualsNoCase("MODS") )
{
Attack attack;
float end = -9999;
@@ -156,7 +156,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
}
}
else if( 0 == stricmp(sValueName, "SONG") )
else if( sValueName.EqualsNoCase("SONG") )
{
CourseEntry new_entry;
@@ -298,13 +298,13 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
out.m_vEntries.push_back( new_entry );
}
else if( !stricmp(sValueName, "DISPLAYCOURSE") || !stricmp(sValueName, "COMBO") ||
!stricmp(sValueName, "COMBOMODE") )
else if( !sValueName.EqualsNoCase("DISPLAYCOURSE") || !sValueName.EqualsNoCase("COMBO") ||
!sValueName.EqualsNoCase("COMBOMODE") )
{
// Ignore
}
else if( bFromCache && !stricmp(sValueName, "RADAR") )
else if( bFromCache && !sValueName.EqualsNoCase("RADAR") )
{
StepsType st = (StepsType) StringToInt(sParams[1]);
CourseDifficulty cd = (CourseDifficulty) StringToInt( sParams[2] );
@@ -313,7 +313,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
rv.FromString( sParams[3] );
out.m_RadarCache[Course::CacheEntry(st, cd)] = rv;
}
else if( 0 == stricmp(sValueName, "STYLE") )
else if( sValueName.EqualsNoCase("STYLE") )
{
RString sStyles = sParams[1];
vector<RString> asStyles;
+1 -1
View File
@@ -948,7 +948,7 @@ MultiPlayer InputMapper::InputDeviceToMultiPlayer( InputDevice id )
GameButton InputScheme::ButtonNameToIndex( const RString &sButtonName ) const
{
for( GameButton gb=(GameButton) 0; gb<m_iButtonsPerController; gb=(GameButton)(gb+1) )
if( stricmp(GetGameButtonName(gb), sButtonName) == 0 )
if( sButtonName.EqualsNoCase(GetGameButtonName(gb)) )
return gb;
return GameButton_Invalid;
+1 -1
View File
@@ -63,7 +63,7 @@ bool LyricsLoader::LoadFromLRCFile(const RString& sPath, Song& out)
StripCrnl(sValueData);
// handle the data
if( 0==stricmp(sValueName,"COLOUR") || 0==stricmp(sValueName,"COLOR") )
if( sValueName.EqualsNoCase("COLOUR") || sValueName.EqualsNoCase("COLOR") )
{
// set color var here for this segment
int r, g, b;
+1 -1
View File
@@ -63,7 +63,7 @@ void ModIcon::Set( const RString &_sText )
};
for( unsigned i=0; i<ARRAYLEN(sStopWords); i++ )
if( 0==stricmp(sText,sStopWords[i]) )
if( sText.EqualsNoCase(sStopWords[i]) )
sText = "";
sText.Replace( " ", "\n" );
+1 -1
View File
@@ -199,7 +199,7 @@ bool NoteSkinManager::DoesNoteSkinExist( const RString &sSkinName )
vector<RString> asSkinNames;
GetAllNoteSkinNamesForGame( GAMESTATE->m_pCurGame, asSkinNames );
for( unsigned i=0; i<asSkinNames.size(); i++ )
if( 0==stricmp(sSkinName, asSkinNames[i]) )
if( sSkinName.EqualsNoCase(asSkinNames[i]) )
return true;
return false;
}
+18 -18
View File
@@ -447,10 +447,10 @@ bool DWILoader::LoadFromDir( const RString &sPath_, Song &out, set<RString> &Bla
}
// handle the data
if( 0==stricmp(sValueName,"FILE") )
if( sValueName.EqualsNoCase("FILE") )
out.m_sMusicFile = sParams[1];
else if( 0==stricmp(sValueName,"TITLE") )
else if( sValueName.EqualsNoCase("TITLE") )
{
NotesLoader::GetMainAndSubTitlesFromFullTitle( sParams[1], out.m_sMainTitle, out.m_sSubTitle );
@@ -460,22 +460,22 @@ bool DWILoader::LoadFromDir( const RString &sPath_, Song &out, set<RString> &Bla
ConvertString( out.m_sSubTitle, "utf-8,english" );
}
else if( 0==stricmp(sValueName,"ARTIST") )
else if( sValueName.EqualsNoCase("ARTIST") )
{
out.m_sArtist = sParams[1];
ConvertString( out.m_sArtist, "utf-8,english" );
}
else if( 0==stricmp(sValueName,"GENRE") )
else if( sValueName.EqualsNoCase("GENRE") )
{
out.m_sGenre = sParams[1];
ConvertString( out.m_sGenre, "utf-8,english" );
}
else if( 0==stricmp(sValueName,"CDTITLE") )
else if( sValueName.EqualsNoCase("CDTITLE") )
out.m_sCDTitleFile = sParams[1];
else if( 0==stricmp(sValueName,"BPM") )
else if( sValueName.EqualsNoCase("BPM") )
{
const float fBPM = StringToFloat( sParams[1] );
@@ -491,7 +491,7 @@ bool DWILoader::LoadFromDir( const RString &sPath_, Song &out, set<RString> &Bla
NoteRowToBeat(0), fBPM );
}
}
else if( 0==stricmp(sValueName,"DISPLAYBPM") )
else if( sValueName.EqualsNoCase("DISPLAYBPM") )
{
// #DISPLAYBPM:[xxx..xxx]|[xxx]|[*];
int iMin, iMax;
@@ -515,17 +515,17 @@ bool DWILoader::LoadFromDir( const RString &sPath_, Song &out, set<RString> &Bla
}
}
else if( 0==stricmp(sValueName,"GAP") )
else if( sValueName.EqualsNoCase("GAP") )
// the units of GAP is 1/1000 second
out.m_Timing.m_fBeat0OffsetInSeconds = -StringToInt( sParams[1] ) / 1000.0f;
else if( 0==stricmp(sValueName,"SAMPLESTART") )
else if( sValueName.EqualsNoCase("SAMPLESTART") )
out.m_fMusicSampleStartSeconds = ParseBrokenDWITimestamp(sParams[1], sParams[2], sParams[3]);
else if( 0==stricmp(sValueName,"SAMPLELENGTH") )
else if( sValueName.EqualsNoCase("SAMPLELENGTH") )
out.m_fMusicSampleLengthSeconds = ParseBrokenDWITimestamp(sParams[1], sParams[2], sParams[3]);
else if( 0==stricmp(sValueName,"FREEZE") )
else if( sValueName.EqualsNoCase("FREEZE") )
{
vector<RString> arrayFreezeExpressions;
split( sParams[1], ",", arrayFreezeExpressions );
@@ -547,7 +547,7 @@ bool DWILoader::LoadFromDir( const RString &sPath_, Song &out, set<RString> &Bla
}
}
else if( 0==stricmp(sValueName,"CHANGEBPM") || 0==stricmp(sValueName,"BPMCHANGE") )
else if( sValueName.EqualsNoCase("CHANGEBPM") || sValueName.EqualsNoCase("BPMCHANGE") )
{
vector<RString> arrayBPMChangeExpressions;
split( sParams[1], ",", arrayBPMChangeExpressions );
@@ -577,10 +577,10 @@ bool DWILoader::LoadFromDir( const RString &sPath_, Song &out, set<RString> &Bla
}
}
else if( 0==stricmp(sValueName,"SINGLE") ||
0==stricmp(sValueName,"DOUBLE") ||
0==stricmp(sValueName,"COUPLE") ||
0==stricmp(sValueName,"SOLO") )
else if( sValueName.EqualsNoCase("SINGLE") ||
sValueName.EqualsNoCase("DOUBLE") ||
sValueName.EqualsNoCase("COUPLE") ||
sValueName.EqualsNoCase("SOLO") )
{
Steps* pNewNotes = new Steps;
LoadFromDWITokens(
@@ -597,8 +597,8 @@ bool DWILoader::LoadFromDir( const RString &sPath_, Song &out, set<RString> &Bla
else
delete pNewNotes;
}
else if( 0==stricmp(sValueName,"DISPLAYTITLE") ||
0==stricmp(sValueName,"DISPLAYARTIST") )
else if( sValueName.EqualsNoCase("DISPLAYTITLE") ||
sValueName.EqualsNoCase("DISPLAYARTIST") )
{
/* We don't want to support these tags. However, we don't want
* to pick up images used here as song images (eg. banners). */
+2 -2
View File
@@ -143,9 +143,9 @@ static void Deserialize( Song &out, const Json::Value &root )
out.m_fMusicSampleStartSeconds = (float)root["SampleStart"].asDouble();
out.m_fMusicSampleLengthSeconds = (float)root["SampleLength"].asDouble();
RString sSelectable = root["Selectable"].asString();
if( !stricmp(sSelectable,"YES") )
if( sSelectable.EqualsNoCase("YES") )
out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if(!stricmp(sSelectable,"NO"))
else if( sSelectable.EqualsNoCase("NO") )
out.m_SelectionDisplay = out.SHOW_NEVER;
out.m_fFirstBeat = (float)root["FirstBeat"].asDouble();
+6 -6
View File
@@ -286,12 +286,12 @@ static void LoadTags( const RString &str, Song &out )
split( str, " - ", asBits, false );
// Ignore the difficulty, since we get that elsewhere.
if( asBits.size() == 3 && (
!stricmp(asBits[2], "double") ||
!stricmp(asBits[2], "easy") ||
!stricmp(asBits[2], "normal") ||
!stricmp(asBits[2], "hard") ||
!stricmp(asBits[2], "crazy") ||
!stricmp(asBits[2], "nightmare"))
asBits[2].EqualsNoCase("double") ||
asBits[2].EqualsNoCase("easy") ||
asBits[2].EqualsNoCase("normal") ||
asBits[2].EqualsNoCase("hard") ||
asBits[2].EqualsNoCase("crazy") ||
asBits[2].EqualsNoCase("nightmare"))
)
{
asBits.erase( asBits.begin()+2, asBits.begin()+3 );
+4 -4
View File
@@ -596,18 +596,18 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache
else if( sValueName=="SELECTABLE" )
{
if(!stricmp(sParams[1],"YES"))
if(sParams[1].EqualsNoCase("YES"))
out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if(!stricmp(sParams[1],"NO"))
else if(sParams[1].EqualsNoCase("NO"))
out.m_SelectionDisplay = out.SHOW_NEVER;
// ROULETTE from 3.9. It was removed since UnlockManager can serve
// the same purpose somehow. This, of course, assumes you're using
// unlocks. -aj
else if(!stricmp(sParams[1],"ROULETTE"))
else if(sParams[1].EqualsNoCase("ROULETTE"))
out.m_SelectionDisplay = out.SHOW_ALWAYS;
/* The following two cases are just fixes to make sure simfiles that
* used 3.9+ features are not excluded here */
else if(!stricmp(sParams[1],"ES") || !stricmp(sParams[1],"OMES"))
else if(sParams[1].EqualsNoCase("ES") || sParams[1].EqualsNoCase("OMES"))
out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if( StringToInt(sParams[1]) > 0 )
out.m_SelectionDisplay = out.SHOW_ALWAYS;
+4 -4
View File
@@ -244,18 +244,18 @@ bool SMALoader::LoadFromSMAFile( const RString &sPath, Song &out )
else if( sValueName=="SELECTABLE" )
{
if(!stricmp(sParams[1],"YES"))
if(sParams[1].EqualsNoCase("YES"))
out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if(!stricmp(sParams[1],"NO"))
else if(sParams[1].EqualsNoCase("NO"))
out.m_SelectionDisplay = out.SHOW_NEVER;
// ROULETTE from 3.9. It was removed since UnlockManager can serve
// the same purpose somehow. This, of course, assumes you're using
// unlocks. -aj
else if(!stricmp(sParams[1],"ROULETTE"))
else if(sParams[1].EqualsNoCase("ROULETTE"))
out.m_SelectionDisplay = out.SHOW_ALWAYS;
/* The following two cases are just fixes to make sure simfiles that
* used 3.9+ features are not excluded here */
else if(!stricmp(sParams[1],"ES") || !stricmp(sParams[1],"OMES"))
else if(sParams[1].EqualsNoCase("ES") || sParams[1].EqualsNoCase("OMES"))
out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if( StringToInt(sParams[1]) > 0 )
out.m_SelectionDisplay = out.SHOW_ALWAYS;
+4 -4
View File
@@ -276,16 +276,16 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach
else if( sValueName=="SELECTABLE" )
{
if(!stricmp(sParams[1],"YES"))
if(sParams[1].EqualsNoCase("YES"))
out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if(!stricmp(sParams[1],"NO"))
else if(sParams[1].EqualsNoCase("NO"))
out.m_SelectionDisplay = out.SHOW_NEVER;
// ROULETTE from 3.9 is no longer in use.
else if(!stricmp(sParams[1],"ROULETTE"))
else if(sParams[1].EqualsNoCase("ROULETTE"))
out.m_SelectionDisplay = out.SHOW_ALWAYS;
/* The following two cases are just fixes to make sure simfiles that
* used 3.9+ features are not excluded here */
else if(!stricmp(sParams[1],"ES") || !stricmp(sParams[1],"OMES"))
else if(sParams[1].EqualsNoCase("ES") || sParams[1].EqualsNoCase("OMES"))
out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if( StringToInt(sParams[1]) > 0 )
out.m_SelectionDisplay = out.SHOW_ALWAYS;
+6 -6
View File
@@ -181,7 +181,7 @@ static void GameSel( int &sel, bool ToSel, const ConfOption *pConfOption )
sel = 0;
for(unsigned i = 0; i < choices.size(); ++i)
if( !stricmp(choices[i], sCurGameName) )
if( !choices[i].EqualsNoCase(sCurGameName) )
sel = i;
} else {
vector<const Game*> aGames;
@@ -222,12 +222,12 @@ static void Language( int &sel, bool ToSel, const ConfOption *pConfOption )
{
sel = -1;
for( unsigned i=0; sel == -1 && i < vs.size(); ++i )
if( !stricmp(vs[i], THEME->GetCurLanguage()) )
if( !vs[i].EqualsNoCase(THEME->GetCurLanguage()) )
sel = i;
// If the current language doesn't exist, we'll show BASE_LANGUAGE, so select that.
for( unsigned i=0; sel == -1 && i < vs.size(); ++i )
if( !stricmp(vs[i], SpecialFiles::BASE_LANGUAGE) )
if( !vs[i].EqualsNoCase(SpecialFiles::BASE_LANGUAGE) )
sel = i;
if( sel == -1 )
@@ -276,7 +276,7 @@ static void RequestedTheme( int &sel, bool ToSel, const ConfOption *pConfOption
{
sel = 0;
for( unsigned i=1; i<vsThemeNames.size(); i++ )
if( !stricmp(vsThemeNames[i], PREFSMAN->m_sTheme.Get()) )
if( !vsThemeNames[i].EqualsNoCase(PREFSMAN->m_sTheme.Get()) )
sel = i;
}
else
@@ -302,7 +302,7 @@ static void Announcer( int &sel, bool ToSel, const ConfOption *pConfOption )
{
sel = 0;
for( unsigned i=1; i<choices.size(); i++ )
if( !stricmp(choices[i], ANNOUNCER->GetCurAnnouncerName()) )
if( !choices[i].EqualsNoCase(ANNOUNCER->GetCurAnnouncerName()) )
sel = i;
}
else
@@ -329,7 +329,7 @@ static void DefaultNoteSkin( int &sel, bool ToSel, const ConfOption *pConfOption
po.FromString( PREFSMAN->m_sDefaultModifiers );
sel = 0;
for( unsigned i=0; i < choices.size(); i++ )
if( !stricmp(choices[i], po.m_sNoteSkin) )
if( !choices[i].EqualsNoCase(po.m_sNoteSkin) )
sel = i;
}
else
+3 -3
View File
@@ -611,13 +611,13 @@ void Song::TidyUpData()
// Skip any image that we've already classified
if( HasBanner() && stricmp(m_sBannerFile, arrayImages[i])==0 )
if( HasBanner() && m_sBannerFile.EqualsNoCase(arrayImages[i]) )
continue; // skip
if( HasBackground() && stricmp(m_sBackgroundFile, arrayImages[i])==0 )
if( HasBackground() && m_sBackgroundFile.EqualsNoCase(arrayImages[i]) )
continue; // skip
if( HasCDTitle() && stricmp(m_sCDTitleFile, arrayImages[i])==0 )
if( HasCDTitle() && m_sCDTitleFile.EqualsNoCase(arrayImages[i]) )
continue; // skip
// todo: add checks for Jacket, Disc, and CDImage -aj
+1 -1
View File
@@ -879,7 +879,7 @@ void SongManager::InitRandomAttacks()
continue;
}
if( stricmp(sType,"ATTACK") != 0 )
if( !sType.EqualsNoCase("ATTACK") )
{
LOG->Warn( "Got \"%s:%s\" tag with wrong declaration", sType.c_str(), sAttack.c_str() );
continue;
-7
View File
@@ -192,13 +192,6 @@ typedef StdString::CStdString RString;
#include "RageException.h"
#if !defined(WIN32)
/** @brief Define stricmp to be strcasecmp. */
#define stricmp strcasecmp
/** @brief Define strnicmp to be strncasecmp. */
#define strnicmp strncasecmp
#endif
/* Define a few functions if necessary */
#include <cmath>