X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=5670dc3bc5eb12430461b8e4ef8c86b13adcfb0a;hb=f4685cb5e78e8e8056448d1de1bb75edb9a4fb1b;hp=62ecfc2491ea16bbbe35e54971af5264e1ba18cb;hpb=8265984dce72d262e3865ebad4668d98b5b26d4a;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 62ecfc2..5670dc3 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "openal_wrapper.h" #include "Settings.h" #include "Input.h" +#include "Animation.h" using namespace std; @@ -47,9 +48,7 @@ extern XYZ viewer; extern int environment; extern float texscale; extern Terrain terrain; -extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; -//extern Sprites sprites; extern int kTextureSize; extern float screenwidth,screenheight; extern float gravity; @@ -60,7 +59,6 @@ extern int slomo; extern float slomodelay; extern bool floatjump; extern float volume; -extern Animation animation[animation_count]; extern Light light; extern float texdetail; extern GLubyte bloodText[512*512*3]; @@ -243,7 +241,6 @@ static bool stripfx(const char *str, const char *pfx) return !strncasecmp(str, pfx, strlen(pfx)); } -extern OPENAL_STREAM * strm[20]; extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); @@ -1160,7 +1157,7 @@ static void cmd_dispatch(Game *game, const char *cmd) } /********************> Tick() <*****/ -extern void ScreenShot(const char * fname); +extern bool save_image(const char * fname); void Screenshot (void) { char temp[1024]; @@ -1173,8 +1170,8 @@ void Screenshot (void) #else mkdir("Screenshots", S_IRWXU); #endif - - ScreenShot(temp); + + save_image(temp); } @@ -1390,7 +1387,7 @@ void Game::Setenvironment(int which) windvector.z=3; if(ambientsound){ //PlaySoundEx( wind, samp[wind], NULL, true); - PlayStreamEx(stream_wind, strm[stream_wind], 0, true); + PlayStreamEx(stream_wind, samp[stream_wind], 0, true); OPENAL_SetPaused(channels[stream_wind], false); OPENAL_SetVolume(channels[stream_wind], 256); } @@ -1400,18 +1397,10 @@ void Game::Setenvironment(int which) LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0); LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0); - OPENAL_Sample_Free(samp[footstepsound]); - OPENAL_Sample_Free(samp[footstepsound2]); - OPENAL_Sample_Free(samp[footstepsound3]); - OPENAL_Sample_Free(samp[footstepsound4]); - samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f); + footstepsound = footstepsn1; + footstepsound2 = footstepsn2; + footstepsound3 = footstepst1; + footstepsound4 = footstepst2; LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0); @@ -1449,23 +1438,15 @@ void Game::Setenvironment(int which) if(ambientsound){ //PlaySoundEx( desertambient, samp[desertambient], NULL, true); - PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true); + PlayStreamEx( stream_desertambient, samp[stream_desertambient], NULL, true); OPENAL_SetPaused(channels[stream_desertambient], false); OPENAL_SetVolume(channels[stream_desertambient], 256); } - OPENAL_Sample_Free(samp[footstepsound]); - OPENAL_Sample_Free(samp[footstepsound2]); - OPENAL_Sample_Free(samp[footstepsound3]); - OPENAL_Sample_Free(samp[footstepsound4]); - samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f); + footstepsound = footstepsn1; + footstepsound2 = footstepsn2; + footstepsound3 = footstepsn1; + footstepsound4 = footstepsn2; LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0); @@ -1500,23 +1481,15 @@ void Game::Setenvironment(int which) LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0); if(ambientsound){ - PlayStreamEx( stream_wind, strm[stream_wind], NULL, true); + PlayStreamEx( stream_wind, samp[stream_wind], NULL, true); OPENAL_SetPaused(channels[stream_wind], false); OPENAL_SetVolume(channels[stream_wind], 100); } - OPENAL_Sample_Free(samp[footstepsound]); - OPENAL_Sample_Free(samp[footstepsound2]); - OPENAL_Sample_Free(samp[footstepsound3]); - OPENAL_Sample_Free(samp[footstepsound4]); - samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass2.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f); + footstepsound = footstepgr1; + footstepsound2 = footstepgr2; + footstepsound3 = footstepst1; + footstepsound4 = footstepst2; LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0); @@ -1574,26 +1547,6 @@ void Game::Loadlevel(int which){ whichlevel=which; } -/*char * Game::MD5_string (unsigned char *string){ -char temp[50]; -char temp2[100]; - -strcpy(temp2,(const char *)string); -strcat((char *)temp2,(const char *)"Lugaru"); -sprintf (temp, "%d",strlen((char *)temp2)); -strcat((char *)temp2,temp); - -MD5 context; -unsigned int len = strlen ( (char *)temp2); - -context.update ((unsigned char *)temp2, len); -context.finalize (); - -return context.hex_digest(); -}*/ - - - void Game::Loadlevel(char *name){ int i,j,k,l,m; static int oldlevel; @@ -1650,7 +1603,7 @@ void Game::Loadlevel(char *name){ won=0; //campaign=0; - animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral); + animation[bounceidleanim].Load((char *)"Idle",middleheight,neutral); numdialogues=0; @@ -2216,7 +2169,7 @@ void Game::Loadlevel(char *name){ player[i].proportionlegs.z=0; } - player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0); + player[i].tempanimation.Load((char *)"Tempanim",0,0); player[i].headmorphness=0; player[i].targetheadmorphness=1; @@ -2317,7 +2270,7 @@ void Game::Loadlevel(char *name){ { if(ambientsound) { - PlayStreamEx(stream_wind, strm[stream_wind], NULL, true); + PlayStreamEx(stream_wind, samp[stream_wind], NULL, true); OPENAL_SetPaused(channels[stream_wind], false); OPENAL_SetVolume(channels[stream_wind], 256); } @@ -2329,7 +2282,7 @@ void Game::Loadlevel(char *name){ //PlaySoundEx(desertambient, // samp[desertambient], NULL, true); PlayStreamEx(stream_desertambient, - strm[stream_desertambient], NULL, true); + samp[stream_desertambient], NULL, true); OPENAL_SetPaused(channels[stream_desertambient], false); OPENAL_SetVolume(channels[stream_desertambient], 256); } @@ -2339,7 +2292,7 @@ void Game::Loadlevel(char *name){ if(ambientsound) { //PlaySoundEx(wind, samp[wind], NULL, true); - PlayStreamEx(stream_wind, strm[stream_wind], NULL, true); + PlayStreamEx(stream_wind, samp[stream_wind], NULL, true); OPENAL_SetPaused(channels[stream_wind], false); OPENAL_SetVolume(channels[stream_wind], 100); } @@ -2424,7 +2377,7 @@ void Game::Tick() if(mainmenu&&endgame==1)mainmenu=10; if( (Input::isKeyDown(SDLK_ESCAPE)||(mainmenu==0&&((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze)) && !mainmenutogglekeydown - && (!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==10) + && (!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==10) ) { // go back selected=-1; if(mainmenu==1||mainmenu==2||mainmenu==0){ @@ -2437,7 +2390,7 @@ void Game::Tick() if(mainmenu&&musictoggle){ if(mainmenu==1||mainmenu==2||mainmenu==100){ OPENAL_SetFrequency(OPENAL_ALL, 0.001); - PlayStreamEx( stream_music3, strm[stream_music3], NULL, true); + PlayStreamEx( stream_music3, samp[stream_music3], NULL, true); OPENAL_SetPaused(channels[stream_music3], false); OPENAL_SetVolume(channels[stream_music3], 256); OPENAL_SetPaused(channels[music1], true); @@ -2460,7 +2413,7 @@ void Game::Tick() SaveSettings(*this); } - if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){ + if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==10||mainmenu==100){ fireSound(); flash(); @@ -2473,8 +2426,6 @@ void Game::Tick() if(mainmenu==6)mainmenu=5; if(mainmenu==7)mainmenu=1; if(mainmenu==9)mainmenu=5; - if(mainmenu==11)mainmenu=5; - if(mainmenu==13)mainmenu=12; if(mainmenu==10)mainmenu=5; if(mainmenu==100){ mainmenu=5; @@ -2488,16 +2439,6 @@ void Game::Tick() } } - /*static bool minimaptogglekeydown; - if(Input::isKeyDown(SDLK_TAB)&&!minimaptogglekeydown){ - minimap=1-minimap; - minimaptogglekeydown=1; - } - if(!Input::isKeyDown(SDLK_TAB)){ - minimaptogglekeydown=0; - } - */ - static bool minimaptogglekeydown; if(Input::isKeyDown(SDLK_TAB)&&!minimaptogglekeydown&&tutoriallevel){ if(tutorialstage!=51) @@ -2656,7 +2597,7 @@ void Game::Tick() } if(musictoggle){ - PlayStreamEx( stream_music3, strm[stream_music3], NULL, true); + PlayStreamEx( stream_music3, samp[stream_music3], NULL, true); OPENAL_SetPaused(channels[stream_music3], false); OPENAL_SetVolume(channels[stream_music3], 256); } @@ -2759,7 +2700,7 @@ void Game::Tick() gameon=1; OPENAL_SetPaused(channels[stream_music3], true); } - if(Input::Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){//selected>=7&&(selected-7<=campaignnumchoices)){ + if(Input::Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){ fireSound(); flash(); @@ -2856,36 +2797,6 @@ void Game::Tick() mainmenu=5; } } - if(mainmenu==11){ - if(Input::Button()&&!oldbutton&&selected=0&&selected<=accountactive->getProgress()){ - fireSound(); - - flash(); - - startbonustotal=0; - - loading=2; - loadtime=0; - targetlevel=selected; - if(firstload) { - TickOnceAfter(); - Loadlevel(selected); - } else - LoadStuff(); - campaign=0; - - mainmenu=0; - gameon=1; - OPENAL_SetPaused(channels[stream_music3], true); - } - if(Input::Button()&&!oldbutton&&selected==numchallengelevels){ - fireSound(); - - flash(); - - mainmenu=5; - } - } if(mainmenu==10){ endgame=2; if(Input::Button()&&!oldbutton&&selected==3){ @@ -5164,7 +5075,7 @@ void Game::Tick() player[numplayers].proportionlegs.z=0; } - player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0); + player[numplayers].tempanimation.Load((char *)"Tempanim",0,0); player[numplayers].damagetolerance=200; @@ -6740,21 +6651,6 @@ void Game::Tick() else player[i].targetrotation-=90; } } - /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){ - if(abs(Random()%6)){ - player[i].crouchkeydown=1; - if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){ - if(player[i].isRun()){ - player[i].targetframe=0; - player[i].target=0; - player[i].targetanimation=sneakanim; - } - } - else player[i].forwardkeydown=0; - } - else player[i].crouchkeydown=0; - } - else player[i].crouchkeydown=0;*/ } player[i].leftkeydown=0; @@ -7737,65 +7633,76 @@ void Game::Tick() objects.DoStuff(); - if(numenvsounds!=0) - for(j=numenvsounds-1;j>=0;j--){ - envsoundlife[j]-=multiplier; - if(envsoundlife[j]<0){ - numenvsounds--; - envsoundlife[j]=envsoundlife[numenvsounds]; - envsound[j]=envsound[numenvsounds]; - } + for(j=numenvsounds-1;j>=0;j--){ + envsoundlife[j]-=multiplier; + if(envsoundlife[j]<0){ + numenvsounds--; + envsoundlife[j]=envsoundlife[numenvsounds]; + envsound[j]=envsound[numenvsounds]; } - if(!slomo)OPENAL_SetFrequency(OPENAL_ALL, 22050); - if(slomo)OPENAL_SetFrequency(OPENAL_ALL, slomofreq); - - if(tutoriallevel==1){ - XYZ temp; - XYZ temp2; - XYZ temp3; - XYZ oldtemp; - XYZ oldtemp2; - temp.x=1011; - temp.y=84; - temp.z=491; - temp2.x=1025; - temp2.y=75; - temp2.z=447; - temp3.x=1038; - temp3.y=76; - temp3.z=453; - oldtemp=temp; - oldtemp2=temp2; - if(tutorialstage>=51) + } + if(slomo) OPENAL_SetFrequency(OPENAL_ALL, slomofreq); + else OPENAL_SetFrequency(OPENAL_ALL, 22050); + + if(tutoriallevel==1){ + XYZ temp; + XYZ temp2; + XYZ temp3; + XYZ oldtemp; + XYZ oldtemp2; + temp.x=1011; + temp.y=84; + temp.z=491; + temp2.x=1025; + temp2.y=75; + temp2.z=447; + temp3.x=1038; + temp3.y=76; + temp3.z=453; + oldtemp=temp; + oldtemp2=temp2; + if(tutorialstage>=51) + if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){ + OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu... + OPENAL_SetFrequency(OPENAL_ALL, 0.001); + + PlayStreamEx( stream_music3, samp[stream_music3], NULL, true); + OPENAL_SetPaused(channels[stream_music3], false); + OPENAL_SetVolume(channels[stream_music3], 256); + + gameon=0; + mainmenu=5; + + fireSound(); + + flash(); + } + if(tutorialstage<51) if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){ - OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu... - OPENAL_SetFrequency(OPENAL_ALL, 0.001); - - PlayStreamEx( stream_music3, strm[stream_music3], NULL, true); - OPENAL_SetPaused(channels[stream_music3], false); - OPENAL_SetVolume(channels[stream_music3], 256); - - gameon=0; - mainmenu=5; - - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); + float gLoc[3]; + float vel[3]; + gLoc[0]=player[0].coords.x; + gLoc[1]=player[0].coords.y; + gLoc[2]=player[0].coords.z; + vel[0]=0; + vel[1]=0; + vel[2]=0; PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); OPENAL_SetVolume(channels[fireendsound], 256); OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); + + player[0].coords=(oldtemp+oldtemp2)/2; flash(); } - if(tutorialstage<51) - if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){ + if(tutorialstage>=14&&tutorialstage<50) + if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){ float gLoc[3]; float vel[3]; - gLoc[0]=player[0].coords.x; - gLoc[1]=player[0].coords.y; - gLoc[2]=player[0].coords.z; + gLoc[0]=player[1].coords.x; + gLoc[1]=player[1].coords.y; + gLoc[2]=player[1].coords.z; vel[0]=0; vel[1]=0; vel[2]=0; @@ -7804,87 +7711,68 @@ void Game::Tick() OPENAL_SetVolume(channels[fireendsound], 256); OPENAL_SetPaused(channels[fireendsound], false); - player[0].coords=(oldtemp+oldtemp2)/2; - - flash(); - } - if(tutorialstage>=14&&tutorialstage<50) - if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){ - float gLoc[3]; - float vel[3]; - gLoc[0]=player[1].coords.x; - gLoc[1]=player[1].coords.y; - gLoc[2]=player[1].coords.z; - vel[0]=0; - vel[1]=0; - vel[2]=0; - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - - for(int i=0;i90)rotation2=90; if(rotation2<-70)rotation2=-70; } - if(mainmenu)rotation+=multiplier*5; } void Game::TickOnceAfter(){ @@ -7991,31 +7880,17 @@ void Game::TickOnceAfter(){ if(musictoggle){ if(musicvolume[0]>0&&oldmusicvolume[0]<=0){ - PlayStreamEx( music1, strm[music1], NULL, true); + PlayStreamEx( music1, samp[music1], NULL, true); OPENAL_SetPaused(channels[music1], false); } if(musicvolume[1]>0&&oldmusicvolume[1]<=0){ - PlayStreamEx( stream_music2, strm[stream_music2], NULL, true); + PlayStreamEx( stream_music2, samp[stream_music2], NULL, true); OPENAL_SetPaused(channels[stream_music2], false); } if(musicvolume[2]>0&&oldmusicvolume[2]<=0){ - PlayStreamEx( stream_music3, strm[stream_music3], NULL, true); + PlayStreamEx( stream_music3, samp[stream_music3], NULL, true); OPENAL_SetPaused(channels[stream_music3], false); } - } - - if(!musictoggle){ - OPENAL_SetPaused(channels[music1], true); - OPENAL_SetPaused(channels[stream_music2], true); - OPENAL_SetPaused(channels[stream_music3], true); - - for(i=0;i<4;i++){ - oldmusicvolume[i]=0; - musicvolume[i]=0; - } - } - - if(musictoggle){ if(musicvolume[0]<=0&&oldmusicvolume[0]>0){ OPENAL_SetPaused(channels[music1], true); } @@ -8039,283 +7914,276 @@ void Game::TickOnceAfter(){ for(i=0;i<3;i++){ oldmusicvolume[i]=musicvolume[i]; } + } else { + OPENAL_SetPaused(channels[music1], true); + OPENAL_SetPaused(channels[stream_music2], true); + OPENAL_SetPaused(channels[stream_music3], true); + + for(i=0;i<4;i++){ + oldmusicvolume[i]=0; + musicvolume[i]=0; + } } killhotspot=2; - if(numhotspots) - for(i=0;i10&&hotspottype[i]<20){ - if(player[hotspottype[i]-10].dead==0){ - killhotspot=0; - } - else if(killhotspot==2) - killhotspot=1; + for(i=0;i10&&hotspottype[i]<20){ + if(player[hotspottype[i]-10].dead==0){ + killhotspot=0; } + else if(killhotspot==2) + killhotspot=1; } - if(killhotspot==2)killhotspot=0; + } + if(killhotspot==2)killhotspot=0; - winhotspot=0; - if(numhotspots) - for(i=0;i1) - for(i=1;imaxalarmed)maxalarmed=numalarmed; + int numalarmed=0; + for(i=1;imaxalarmed)maxalarmed=numalarmed; - if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){ - if(player[0].dead&&changedelay<=0){ - changedelay=1; - targetlevel=whichlevel; - } - alldead=1; - if(numplayers>1) - for(i=1;inumchallengelevels-1)targetlevel=0; - } - if(winhotspot||windialogue){ - changedelay=0.1; - targetlevel=whichlevel+1; - if(targetlevel>numchallengelevels-1)targetlevel=0; - } + if(alldead&&!player[0].dead&&maptype==mapkilleveryone){ + changedelay=1; + targetlevel=whichlevel+1; + if(targetlevel>numchallengelevels-1)targetlevel=0; + } + if(winhotspot||windialogue){ + changedelay=0.1; + targetlevel=whichlevel+1; + if(targetlevel>numchallengelevels-1)targetlevel=0; + } - if(killhotspot){ - changedelay=1; - targetlevel=whichlevel+1; - if(targetlevel>numchallengelevels-1)targetlevel=0; - } + if(killhotspot){ + changedelay=1; + targetlevel=whichlevel+1; + if(targetlevel>numchallengelevels-1)targetlevel=0; + } - if(changedelay>0&&!player[0].dead&&!won){ - //high scores, awards, win - if(campaign){ - won=1; - accountactive->winCampaignLevel(whichchoice, bonustotal, leveltime); - /*accountcampaignchoices[accountactive][accountactive->getCampaignChoicesMade()]=whichchoice; - accountactive->getCampaignChoicesMade()++; - accountcampaignscore[accountactive]+=bonustotal; - accountcampaigntime[accountactive]+=leveltime; - if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive]) - accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];*/ - scoreadded=1; - } - else - { - won=1; - accountactive->winLevel(whichlevel,bonustotal-startbonustotal,leveltime); - } - } - } + if(changedelay>0&&!player[0].dead&&!won){ + //high scores, awards, win + if(campaign){ + accountactive->winCampaignLevel(whichchoice, bonustotal, leveltime); + scoreadded=1; + } + else + { + accountactive->winLevel(whichlevel,bonustotal-startbonustotal,leveltime); + } + won=1; + } + } - if(!winfreeze){ + if(!winfreeze){ - if(leveltime<1){ - loading=0; - changedelay=.1; - alldead=0; - winhotspot=0; - killhotspot=0; - } + if(leveltime<1){ + loading=0; + changedelay=.1; + alldead=0; + winhotspot=0; + killhotspot=0; + } - if(!editorenabled&&gameon&&!mainmenu){ - if(changedelay!=-999)changedelay-=multiplier/7; - if(player[0].dead)targetlevel=whichlevel; - if(loading==2&&!campaign){ - flash(); + if(!editorenabled&&gameon&&!mainmenu){ + if(changedelay!=-999)changedelay-=multiplier/7; + if(player[0].dead)targetlevel=whichlevel; + if(loading==2&&!campaign){ + flash(); - fireSound(firestartsound); + fireSound(firestartsound); - if(!player[0].dead&&targetlevel!=whichlevel){ - startbonustotal=bonustotal; - } - if(!player[0].dead)Loadlevel(targetlevel); - if(player[0].dead)Loadlevel(whichlevel); + if(!player[0].dead&&targetlevel!=whichlevel){ + startbonustotal=bonustotal; + } + if(player[0].dead) Loadlevel(whichlevel); + else Loadlevel(targetlevel); - fireSound(); + fireSound(); - loading=3; - } - if(loading==2&&targetlevel==whichlevel){ - flash(); - loadtime=0; + loading=3; + } + if(loading==2&&targetlevel==whichlevel){ + flash(); + loadtime=0; - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - fireSound(firestartsound); + fireSound(firestartsound); - for(i=0;i<255;i++){ - mapname[i]='\0'; - } - mapname[0]=':'; - mapname[1]='D'; - mapname[2]='a'; - mapname[3]='t'; - mapname[4]='a'; - mapname[5]=':'; - mapname[6]='M'; - mapname[7]='a'; - mapname[8]='p'; - mapname[9]='s'; - mapname[10]=':'; - strcat(mapname,campaignmapname[levelorder[accountactive->getCampaignChoicesMade()]]);//[campaignchoicewhich[whichchoice]]); - Loadlevel(mapname); - - fireSound(); - - loading=3; - } - if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1; - if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){ - { - if(whichlevel!=-2&&!loading&&!player[0].dead){ - winfreeze=1; - changedelay=-999; - } - if(player[0].dead)loading=1; - } - } - } + for(i=0;i<255;i++){ + mapname[i]='\0'; + } + mapname[0]=':'; + mapname[1]='D'; + mapname[2]='a'; + mapname[3]='t'; + mapname[4]='a'; + mapname[5]=':'; + mapname[6]='M'; + mapname[7]='a'; + mapname[8]='p'; + mapname[9]='s'; + mapname[10]=':'; + strcat(mapname,campaignmapname[levelorder[accountactive->getCampaignChoicesMade()]]);//[campaignchoicewhich[whichchoice]]); + Loadlevel(mapname); - if(campaign) - if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){ - if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){ - endgame=1; - } - } - else if(mainmenu==0&&winfreeze){ - if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2) - stealthloading=1; - else stealthloading=0; + fireSound(); - if(!stealthloading){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - fireSound(firestartsound); + loading=3; + } + if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1; + if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){ + { + if(whichlevel!=-2&&!loading&&!player[0].dead){ + winfreeze=1; + changedelay=-999; + } + if(player[0].dead)loading=1; + } + } + } - flash(); - } + if(campaign) + if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){ + if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){ + endgame=1; + } + } + else if(mainmenu==0&&winfreeze){ + if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2) + stealthloading=1; + else stealthloading=0; - startbonustotal=0; - - ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt")); - ipstream.ignore(256,':'); - ipstream >> campaignnumlevels; - for(i=0;i> campaignmapname[i]; - ipstream.ignore(256,':'); - ipstream >> campaigndescription[i]; - for(j=0;j<256;j++){ - if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' '; - } - ipstream.ignore(256,':'); - ipstream >> campaignchoosenext[i]; - ipstream.ignore(256,':'); - ipstream >> campaignnumnext[i]; - if(campaignnumnext[i]) - for(j=0;j> campaignnextlevel[i][j]; - campaignnextlevel[i][j]-=1; - } - ipstream.ignore(256,':'); - ipstream >> campaignlocationx[i]; - ipstream.ignore(256,':'); - ipstream >> campaignlocationy[i]; - } - ipstream.close(); + if(!stealthloading){ + float gLoc[3]={0,0,0}; + float vel[3]={0,0,0}; + fireSound(firestartsound); - for(i=0;i> campaignnumlevels; + for(i=0;i> campaignmapname[i]; + ipstream.ignore(256,':'); + ipstream >> campaigndescription[i]; + for(j=0;j<256;j++){ + if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' '; + } + ipstream.ignore(256,':'); + ipstream >> campaignchoosenext[i]; + ipstream.ignore(256,':'); + ipstream >> campaignnumnext[i]; + for(j=0;j> campaignnextlevel[i][j]; + campaignnextlevel[i][j]-=1; + } + ipstream.ignore(256,':'); + ipstream >> campaignlocationx[i]; + ipstream.ignore(256,':'); + ipstream >> campaignlocationy[i]; + } + ipstream.close(); - for(i=0;igetCampaignChoicesMade()) - for(i=0;igetCampaignChoicesMade();i++){ - levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)]; - levelvisible[levelorder[i+1]]=1; - } - int whichlevelstart; - whichlevelstart=accountactive->getCampaignChoicesMade()-1; - if(whichlevelstart<0){ - campaignchoicenum=1; - campaignchoicewhich[0]=0; - } - else - { - campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]]; - if(campaignchoicenum) - for(i=0;igetCampaignChoicesMade();i++){ + levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)]; + levelvisible[levelorder[i+1]]=1; + } + int whichlevelstart; + whichlevelstart=accountactive->getCampaignChoicesMade()-1; + if(whichlevelstart<0){ + campaignchoicenum=1; + campaignchoicewhich[0]=0; + } + else + { + campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]]; + for(i=0;i