X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=05bb4ce08dd6c9f5430d30e2b019d5c6fcb7700d;hb=bbf8873b80baf3cb468ac12b3f62b0938320fef1;hp=ee3ddea78f1d5bd032e38034d633747b971b29a2;hpb=f7f3989db89536a13751c11625168948a08e03e0;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index ee3ddea..05bb4ce 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif +#include #include #include "Game.h" #include "openal_wrapper.h" @@ -495,7 +496,7 @@ static void ch_size(Game *game, const char *args) static int find_closest() { int closest = 0; - float closestdist = 1.0/0.0; + float closestdist = std::numeric_limits::max(); for (int i = 1; i < numplayers; i++) { float distance; @@ -2176,8 +2177,7 @@ void Game::MenuTick(){ mainmenu=1; } } - } - if(mainmenu==3){ + }else if(mainmenu==3){ if(Input::MouseClicked()){ if(selected!=-1) @@ -2296,8 +2296,7 @@ void Game::MenuTick(){ break; } } - } - if(mainmenu==4){ + }else if(mainmenu==4){ if(Input::MouseClicked()&&selected!=-1&&!waiting){ fireSound(); if(selected<9&&keyselect==-1) @@ -2317,9 +2316,7 @@ void Game::MenuTick(){ if(newscreenheight<0)newscreenheight=screenheight; } } - } - - if(mainmenu==5){ + }else if(mainmenu==5){ if(endgame==2){ accountactive->endGame(); @@ -2383,8 +2380,7 @@ void Game::MenuTick(){ break; } } - } - else if(mainmenu==9){ + }else if(mainmenu==9){ if(Input::MouseClicked()&&selected=0&&selected<=accountactive->getProgress()){ fireSound(); flash(); @@ -2410,17 +2406,14 @@ void Game::MenuTick(){ flash(); mainmenu=5; } - } - if(mainmenu==10){ + }else if(mainmenu==10){ endgame=2; if(Input::MouseClicked()&&selected==3){ fireSound(); flash(); mainmenu=5; } - } - - if(mainmenu==6){ + }else if(mainmenu==6){ if(Input::MouseClicked()) { if(selected>-1){ fireSound(); @@ -2434,8 +2427,7 @@ void Game::MenuTick(){ } } } - } - if(mainmenu==7){ + }else if(mainmenu==7){ if(Input::MouseClicked()) { if(selected!=-1){ fireSound(); @@ -2451,7 +2443,7 @@ void Game::MenuTick(){ mainmenu=1; for(int j=0;j<255;j++){ - displaytext[0][j]=' '; + displaytext[0][j]=0; } displaychars[0]=0; displayselected=0; @@ -2459,8 +2451,7 @@ void Game::MenuTick(){ } } } - } - if(mainmenu==8){ + }else if(mainmenu==8){ if(Input::MouseClicked()&&selected>-1){ fireSound(); flash(); @@ -2468,8 +2459,7 @@ void Game::MenuTick(){ accountactive->setDifficulty(selected); mainmenu=5; } - } - if (mainmenu==18) { + }else if(mainmenu==18){ if(Input::MouseClicked()&&selected==0) { newstereomode = (StereoMode)(newstereomode + 1); while(!CanInitStereo(newstereomode)) { @@ -2536,7 +2526,7 @@ void Game::MenuTick(){ fireSound(firestartsound); for(int i=0;i<255;i++){ - displaytext[0][i]=' '; + displaytext[0][i]=0; } displaychars[0]=0; @@ -2953,55 +2943,6 @@ void Game::doTutorial(){ void Game::doDebugKeys(){ float headprop,bodyprop,armprop,legprop; if(debugmode){ - if(Input::isKeyPressed(SDLK_v)){ - freeze=1-freeze; - if(freeze){ - OPENAL_SetFrequency(OPENAL_ALL, 0.001); - } - } - - if(Input::isKeyPressed(SDLK_BACKQUOTE)){ - console=1-console; - if(console){ - OPENAL_SetFrequency(OPENAL_ALL, 0.001); - } else { - freeze=0; - waiting=false; - } - } - - if(console) - freeze=1; - if(console&&!Input::isKeyDown(SDLK_LMETA)){ - inputText(consoletext[0],&consoleselected,&consolechars[0]); - if(!waiting) { - archiveselected=0; - cmd_dispatch(this, consoletext[0]); - if(consolechars[0]>0){ - - for(int k=14;k>=1;k--){ - for(int j=0;j<255;j++){ - consoletext[k][j]=consoletext[k-1][j]; - } - consolechars[k]=consolechars[k-1]; - } - for(int j=0;j<255;j++){ - consoletext[0][j]=' '; - } - consolechars[0]=0; - consoleselected=0; - } - } - - consoleblinkdelay-=multiplier; - if(consoleblinkdelay<=0){ - consoleblinkdelay=.3; - consoleblink=1-consoleblink; - } - } - - - if(Input::isKeyPressed(SDLK_h)){ player[0].damagetolerance=200000; player[0].damage=0; @@ -6096,11 +6037,11 @@ void Game::Tick(){ if(!winfreeze)leveltime+=multiplier; //keys - if(Input::isKeyDown(SDLK_ESCAPE)){ - chatting=0; - console=0; - freeze=0; - displaychars[0]=0; + if(Input::isKeyPressed(SDLK_v)&&debugmode){ + freeze=1-freeze; + if(freeze){ + OPENAL_SetFrequency(OPENAL_ALL, 0.001); + } } if(Input::isKeyPressed(chatkey)&&!console&&!chatting&&debugmode) @@ -6110,9 +6051,8 @@ void Game::Tick(){ inputText(displaytext[0],&displayselected,&displaychars[0]); if(!waiting) { if(displaychars[0]){ - for(int j=0;j<255;j++){ - displaytext[0][j]=' '; - } + for(int j=0;j<255;j++) + displaytext[0][j]=0; displaychars[0]=0; displayselected=0; } @@ -6128,6 +6068,46 @@ void Game::Tick(){ if(chatting) keyboardfrozen=1; + if(Input::isKeyPressed(SDLK_BACKQUOTE)&&debugmode){ + console=1-console; + if(console){ + OPENAL_SetFrequency(OPENAL_ALL, 0.001); + } else { + freeze=0; + waiting=false; + } + } + + if(console) + freeze=1; + if(console&&!Input::isKeyDown(SDLK_LMETA)){ + inputText(consoletext[0],&consoleselected,&consolechars[0]); + if(!waiting) { + archiveselected=0; + if(consolechars[0]>0){ + consoletext[0][consolechars[0]]=' '; + cmd_dispatch(this, consoletext[0]); + for(int k=14;k>=1;k--){ + for(int j=0;j<255;j++) + consoletext[k][j]=consoletext[k-1][j]; + consolechars[k]=consolechars[k-1]; + } + for(int j=0;j<255;j++) + consoletext[0][j]=0; + consolechars[0]=0; + consoleselected=0; + } + } + + consoleblinkdelay-=multiplier; + if(consoleblinkdelay<=0){ + consoleblinkdelay=.3; + consoleblink=1-consoleblink; + } + } + + + if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){ tryquit=1; if(mainmenu==3){ @@ -6153,11 +6133,16 @@ void Game::Tick(){ if((Input::isKeyPressed(jumpkey)||Input::isKeyPressed(SDLK_SPACE))&&!campaign) if(winfreeze) winfreeze=0; - if((Input::isKeyDown(SDLK_ESCAPE))&&!campaign&&gameon) - if(winfreeze){ + if((Input::isKeyDown(SDLK_ESCAPE))&&!campaign&&gameon){ + if(console){ + console=0; + freeze=0; + }else if(winfreeze){ mainmenu=9; gameon=0; } + } + //TODO: what is this test?