From eecffd77acac5500bad32cde2c56e18ee00f6cf7 Mon Sep 17 00:00:00 2001 From: Alexander Monakov Date: Sun, 16 May 2010 01:29:18 +0400 Subject: [PATCH] Remove Compare --- Source/GameTick.cpp | 172 +++++++++++++++++++++++--------------------- Source/WinInput.cpp | 9 --- Source/WinInput.h | 1 - 3 files changed, 89 insertions(+), 93 deletions(-) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 2e42476..19876ad 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -247,6 +247,12 @@ STATIC_ASSERT (rabbittype == 0 && wolftype == 1) static const char **creatureskin[] = {rabbitskin, wolfskin}; +/* Return true if PFX is a prefix of STR (case-insensitive). */ +static bool stripfx(const char *str, const char *pfx) +{ + return !strncasecmp(str, pfx, strlen(pfx)); +} + /********************> Tick() <*****/ extern OPENAL_STREAM * strm[20]; extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); @@ -3244,14 +3250,14 @@ void Game::Tick() if(i==MAC_RETURN_KEY){ archiveselected=0; donesomething=0; - if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){ + if(stripfx(consoletext[0], "quit ")||stripfx(consoletext[0], "exit ")){ PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true); OPENAL_SetVolume(channels[consolesuccesssound], 256); OPENAL_SetPaused(channels[consolesuccesssound], false); donesomething=1; tryquit=1; } - /*if(Compare(consoletext[0],"send ",0,4)){ + /*if(stripfx(consoletext[0], "send ")){ for(j=5;j32)numchars=32; @@ -3274,7 +3280,7 @@ void Game::Tick() //NetworkSendName(playerName); donesomething=1; }*/ - if(Compare(consoletext[0],"map ",0,3)){ + if(stripfx(consoletext[0], "map ")){ mapname[0]=':'; mapname[1]='D'; mapname[2]='a'; @@ -3295,7 +3301,7 @@ void Game::Tick() campaign=0; donesomething=1; } - /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){ + /*if(stripfx(consoletext[0], "connect ")&&!ishost){ int v; unsigned char playerNameStr[32]; char theIPAddress[256]; @@ -3356,7 +3362,7 @@ void Game::Tick() } } - if(Compare(consoletext[0],"host ",0,4)){ + if(stripfx(consoletext[0], "host ")){ unsigned char gameNameStr[32], playerNameStr[32]; char gameName[32];//, playerName[32]; NMUInt32 port; @@ -3415,7 +3421,7 @@ void Game::Tick() } } */ - if(Compare(consoletext[0],"save ",0,4)){ + if(stripfx(consoletext[0], "save ")){ mapname[0]=':'; mapname[1]='D'; mapname[2]='a'; @@ -3739,7 +3745,7 @@ void Game::Tick() donesomething=1;*/ } /* - if(Compare(consoletext[0],"save ",0,4)){ + if(stripfx(consoletext[0], "save ")){ mapname[0]=':'; mapname[1]='D'; mapname[2]='a'; @@ -3813,17 +3819,17 @@ void Game::Tick() fclose(tfile); donesomething=1; }*/ - if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){ + if(stripfx(consoletext[0], "cellar door ")||stripfx(consoletext[0], "cellardoor ")){ LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); donesomething=1; } - /*if(Compare(consoletext[0],"Pants ",0,5)){ + /*if(stripfx(consoletext[0], "Pants ")){ AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize); player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize); donesomething=1; }*/ - if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){ + if(stripfx(consoletext[0], "tintr ")||stripfx(consoletext[0], "Tintr ")){ for(j=6;j0)player[i].immobile=1; } @@ -4592,7 +4598,7 @@ void Game::Tick() } - if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){ + if(stripfx(consoletext[0], "default ")||stripfx(consoletext[0], "Default ")){ player[0].armorhead=1; player[0].armorhigh=1; player[0].armorlow=1; @@ -4633,7 +4639,7 @@ void Game::Tick() donesomething=1; } - if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){ + if(stripfx(consoletext[0], "tint ")||stripfx(consoletext[0], "Tint ")){ int startpoint; int alldone; alldone=0; @@ -4673,7 +4679,7 @@ void Game::Tick() donesomething=1; } - if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){ + if(stripfx(consoletext[0], "sky tint ")||stripfx(consoletext[0], "Sky Tint ")){ int startpoint; int alldone; alldone=0; @@ -4725,7 +4731,7 @@ void Game::Tick() donesomething=1; } - if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){ + if(stripfx(consoletext[0], "sky light ")||stripfx(consoletext[0], "Sky Light ")){ int startpoint; int alldone; alldone=0; @@ -4773,7 +4779,7 @@ void Game::Tick() donesomething=1; } - if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){ + if(stripfx(consoletext[0], "skybox ")||stripfx(consoletext[0], "Skybox ")){ skyboxtexture=1-skyboxtexture; SetUpLighting(); @@ -4786,7 +4792,7 @@ void Game::Tick() donesomething=1; } - if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){ + if(stripfx(consoletext[0], "protection ")||stripfx(consoletext[0], "Protection ")){ int startpoint; int alldone; alldone=0; @@ -4826,7 +4832,7 @@ void Game::Tick() donesomething=1; } - if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){ + if(stripfx(consoletext[0], "armor ")||stripfx(consoletext[0], "Armor ")){ int startpoint; int alldone; alldone=0; @@ -4866,7 +4872,7 @@ void Game::Tick() donesomething=1; } - if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){ + if(stripfx(consoletext[0], "protectionreset ")||stripfx(consoletext[0], "Protectionreset ")){ for(i=0;i