X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=7e231e0a03f508604dec7a56b2936c002da850e2;hb=0b7253f3d99e4382008aff8b8e221e88ff40d3e9;hp=e5e619a6e95a1a3ca4a223ddbb978d8f7f233231;hpb=5e808c58a6397c2cb1ae08293d2ba1fc91b15a0a;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index e5e619a..7e231e0 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -32,17 +32,23 @@ 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" +#include "Awards.h" using namespace std; +// Added more evilness needed for MSVC +#ifdef _MSC_VER + #define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n) + #define snprintf(buf, size, format, ...) _sprintf_p(buf, size, format) +#endif + + extern float multiplier; 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; @@ -53,21 +59,16 @@ 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]; extern GLubyte wolfbloodText[512*512*3]; -extern float terraindetail; extern float camerashake; extern float woozy; extern float blackout; extern bool cellophane; extern bool musictoggle; extern int difficulty; -extern Weapons weapons; -extern Person player[maxplayers]; -extern int numplayers; extern int bloodtoggle; extern bool invertmouse; extern float windvar; @@ -81,7 +82,6 @@ extern bool autoslomo; extern bool keyboardfrozen; extern int netdatanew; extern bool loadingstuff; -extern char mapname[256]; extern XYZ windvector; extern bool debugmode; static int music1; @@ -109,14 +109,7 @@ extern bool decals; extern bool vblsync; extern bool immediate; extern bool velocityblur; -extern int bonus; -extern int oldbonus; -extern float bonusvalue; -extern float bonustotal; -extern float bonustime; -extern float startbonustotal; extern float tintr,tintg,tintb; -extern float bonusnum[100]; extern bool skyboxtexture; extern float skyboxr; extern float skyboxg; @@ -138,7 +131,6 @@ extern bool reversaltrain; extern bool canattack; extern bool cananger; extern float damagedealt; -extern float damagetaken; extern int maptype; extern int editoractive; extern int editorpathtype; @@ -163,57 +155,10 @@ extern int hostile; extern bool stillloading; extern bool winfreeze; -extern int numfalls; -extern int numflipfail; -extern int numseen; -extern int numstaffattack; -extern int numswordattack; -extern int numknifeattack; -extern int numunarmedattack; -extern int numescaped; -extern int numflipped; -extern int numwallflipped; -extern int numthrowkill; -extern int numafterkill; -extern int numreversals; -extern int numattacks; -extern int maxalarmed; -extern int numresponded; - -extern int numdialogues; -extern int numdialogueboxes[max_dialogues]; -extern int dialoguetype[max_dialogues]; -extern int dialogueboxlocation[max_dialogues][max_dialoguelength]; -extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3]; -extern int dialogueboxsound[max_dialogues][max_dialoguelength]; -extern char dialoguetext[max_dialogues][max_dialoguelength][128]; -extern char dialoguename[max_dialogues][max_dialoguelength][64]; -extern XYZ dialoguecamera[max_dialogues][max_dialoguelength]; -extern XYZ participantlocation[max_dialogues][10]; -extern int participantfocus[max_dialogues][max_dialoguelength]; -extern int participantaction[max_dialogues][max_dialoguelength]; -extern float participantrotation[max_dialogues][10]; -extern XYZ participantfacing[max_dialogues][max_dialoguelength][10]; -extern float dialoguecamerarotation[max_dialogues][max_dialoguelength]; -extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength]; -extern int indialogue; -extern int whichdialogue; -extern int directing; -extern float dialoguetime; -extern int dialoguegonethrough[20]; - extern bool campaign; extern float oldgamespeed; -extern float accountcampaignhighscore[10]; -extern float accountcampaignfasttime[10]; -extern float accountcampaignscore[10]; -extern float accountcampaigntime[10]; - -extern int accountcampaignchoicesmade[10]; -extern int accountcampaignchoices[10][5000]; - static const char *rabbitskin[] = { ":Data:Textures:Fur3.jpg", ":Data:Textures:Fur.jpg", @@ -244,11 +189,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); - - static const char *cmd_names[] = { #define DECLARE_COMMAND(cmd) #cmd " ", #include "ConsoleCmds.h" @@ -274,9 +214,7 @@ static void ch_quit(Game *game, const char *args) static void ch_map(Game *game, const char *args) { - char buf[64]; - snprintf(buf, 63, ":Data:Maps:%s", args); - game->Loadlevel(buf); + game->Loadlevel(args); game->whichlevel = -2; campaign = 0; } @@ -315,142 +253,131 @@ static void ch_save(Game *game, const char *args) fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature); fpackf(tfile, "Bi", numdialogues); - if(numdialogues) - for(k=0;k1&&numplayers0&&player[j].num_weapons<5) - for(k=0;knumpathpoints); - if(game->numpathpoints) - for(j=0;jnumpathpoints;j++){ - fpackf(tfile, "Bf Bf Bf Bi", game->pathpoint[j].x, game->pathpoint[j].y, game->pathpoint[j].z, game->numpathpointconnect[j]); - for(k=0;knumpathpointconnect[j];k++){ - fpackf(tfile, "Bi", game->pathpointconnect[j][k]); - } - } + for(j=0;jnumpathpoints;j++){ + fpackf(tfile, "Bf Bf Bf Bi", game->pathpoint[j].x, game->pathpoint[j].y, game->pathpoint[j].z, game->numpathpointconnect[j]); + for(k=0;knumpathpointconnect[j];k++){ + fpackf(tfile, "Bi", game->pathpointconnect[j][k]); + } + } fpackf(tfile, "Bf Bf Bf Bf", game->mapcenter.x, game->mapcenter.y, game->mapcenter.z, game->mapradius); @@ -537,9 +464,7 @@ static void set_proportion(int pnum, const char *args) player[pnum].proportionbody=1.1*bodyprop; player[pnum].proportionarms=1.1*armprop; player[pnum].proportionlegs=1.1*legprop; - } - - if(player[pnum].creature==rabbittype){ + } else if(player[pnum].creature==rabbittype){ player[pnum].proportionhead=1.2*headprop; player[pnum].proportionbody=1.05*bodyprop; player[pnum].proportionarms=1.00*armprop; @@ -654,7 +579,7 @@ static void set_clothes(int pnum, Game *game, const char *args) if (!game->AddClothes(buf,0,1,&player[pnum].skeleton.skinText[pnum],&player[pnum].skeleton.skinsize)) return; - player[pnum].DoMipmaps(5,0,0,player[pnum].skeleton.skinsize,player[pnum].skeleton.skinsize); + player[pnum].DoMipmaps(); strcpy(player[pnum].clothes[player[pnum].numclothes],buf); player[pnum].clothestintr[player[pnum].numclothes]=tintr; player[pnum].clothestintg[player[pnum].numclothes]=tintg; @@ -811,23 +736,21 @@ static void ch_notindemo(Game *game, const char *args) static void ch_type(Game *game, const char *args) { int i, n = sizeof(editortypenames) / sizeof(editortypenames[0]); - for (i = 0; i < n; i++) - if (stripfx(args, editortypenames[i])) - { - editoractive = i; - break; - } + for (i = 0; i < n; i++) + if (stripfx(args, editortypenames[i])) { + editoractive = i; + break; + } } static void ch_path(Game *game, const char *args) { int i, n = sizeof(pathtypenames) / sizeof(pathtypenames[0]); for (i = 0; i < n; i++) - if (stripfx(args, pathtypenames[i])) - { - editorpathtype = i; - break; - } + if (stripfx(args, pathtypenames[i])) { + editorpathtype = i; + break; + } } static void ch_hs(Game *game, const char *args) @@ -996,9 +919,7 @@ static void ch_default(Game *game, const char *args) player[0].proportionbody=1.1; player[0].proportionarms=1.1; player[0].proportionlegs=1.1; - } - - if(player[0].creature==rabbittype){ + } else if(player[0].creature==rabbittype){ player[0].proportionhead=1.2; player[0].proportionbody=1.05; player[0].proportionarms=1.00; @@ -1036,20 +957,12 @@ static void ch_play(Game *game, const char *args) directing=0; indialogue=0; - float gLoc[3]; - float vel[3]; XYZ temppos; temppos=player[participantfocus[whichdialogue][indialogue]].coords; temppos=temppos-viewer; Normalise(&temppos); temppos+=viewer; - gLoc[0]=temppos.x; - gLoc[1]=temppos.y; - gLoc[2]=temppos.z; - vel[0]=0; - vel[1]=0; - vel[2]=0; int whichsoundplay; whichsoundplay=rabbitchitter; if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2; @@ -1071,10 +984,7 @@ static void ch_play(Game *game, const char *args) if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound; if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound; if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound; - PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true); - OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel); - OPENAL_SetVolume(channels[whichsoundplay], 256); - OPENAL_SetPaused(channels[whichsoundplay], false); + emit_sound_at(whichsoundplay, temppos); } static void ch_mapkilleveryone(Game *game, const char *args) @@ -1163,22 +1073,11 @@ static void cmd_dispatch(Game *game, const char *cmd) cmd_handlers[i](game, cmd + strlen(cmd_names[i])); break; } - if (i < n_cmds) - { - PlaySoundEx(consolesuccesssound, samp[consolesuccesssound], NULL, true); - OPENAL_SetVolume(channels[consolesuccesssound], 256); - OPENAL_SetPaused(channels[consolesuccesssound], false); - } - else - { - PlaySoundEx(consolefailsound, samp[consolefailsound], NULL, true); - OPENAL_SetVolume(channels[consolefailsound], 256); - OPENAL_SetPaused(channels[consolefailsound], false); - } + emit_sound_np(i < n_cmds ? consolesuccesssound : consolefailsound); } /********************> Tick() <*****/ -extern void ScreenShot(const char * fname); +extern bool save_image(const char * fname); void Screenshot (void) { char temp[1024]; @@ -1191,8 +1090,8 @@ void Screenshot (void) #else mkdir("Screenshots", S_IRWXU); #endif - - ScreenShot(temp); + + save_image(temp); } @@ -1389,47 +1288,29 @@ void Game::Setenvironment(int which) float temptexdetail; environment=which; -/* - OPENAL_SetPaused(channels[music1snow], true); - OPENAL_SetPaused(channels[music1grass], true); - OPENAL_SetPaused(channels[music1desert], true); - OPENAL_SetPaused(channels[wind], true); - OPENAL_SetPaused(channels[desertambient], true); -*/ - OPENAL_SetPaused(channels[stream_music1snow], true); - OPENAL_SetPaused(channels[stream_music1grass], true); - OPENAL_SetPaused(channels[stream_music1desert], true); - OPENAL_SetPaused(channels[stream_wind], true); - OPENAL_SetPaused(channels[stream_desertambient], true); + + pause_sound(stream_music1snow); + pause_sound(stream_music1grass); + pause_sound(stream_music1desert); + pause_sound(stream_wind); + pause_sound(stream_desertambient); if(environment==snowyenvironment){ windvector=0; windvector.z=3; - if(ambientsound){ - //PlaySoundEx( wind, samp[wind], NULL, true); - PlayStreamEx(stream_wind, strm[stream_wind], 0, true); - OPENAL_SetPaused(channels[stream_wind], false); - OPENAL_SetVolume(channels[stream_wind], 256); - } + if(ambientsound) + emit_stream_np(stream_wind); LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1); LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1); 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); @@ -1447,9 +1328,7 @@ void Game::Setenvironment(int which) ":Data:Textures:Skybox(snow):Back.jpg", ":Data:Textures:Skybox(snow):Right.jpg", ":Data:Textures:Skybox(snow):Up.jpg", - ":Data:Textures:Skybox(snow):Down.jpg", - ":Data:Textures:Skybox(snow):Cloud.jpg", - ":Data:Textures:Skybox(snow):Reflect.jpg"); + ":Data:Textures:Skybox(snow):Down.jpg"); @@ -1465,25 +1344,13 @@ void Game::Setenvironment(int which) LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0); - if(ambientsound){ - //PlaySoundEx( desertambient, samp[desertambient], NULL, true); - PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true); - OPENAL_SetPaused(channels[stream_desertambient], false); - OPENAL_SetVolume(channels[stream_desertambient], 256); - } + if(ambientsound) + emit_stream_np(stream_desertambient); - 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,9 +1367,7 @@ void Game::Setenvironment(int which) ":Data:Textures:Skybox(sand):Back.jpg", ":Data:Textures:Skybox(sand):Right.jpg", ":Data:Textures:Skybox(sand):Up.jpg", - ":Data:Textures:Skybox(sand):Down.jpg", - ":Data:Textures:Skybox(sand):Cloud.jpg", - ":Data:Textures:Skybox(sand):Reflect.jpg"); + ":Data:Textures:Skybox(sand):Down.jpg"); @@ -1517,24 +1382,13 @@ void Game::Setenvironment(int which) LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0); LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0); - if(ambientsound){ - PlayStreamEx( stream_wind, strm[stream_wind], NULL, true); - OPENAL_SetPaused(channels[stream_wind], false); - OPENAL_SetVolume(channels[stream_wind], 100); - } + if(ambientsound) + emit_stream_np(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); @@ -1551,9 +1405,7 @@ void Game::Setenvironment(int which) ":Data:Textures:Skybox(grass):Back.jpg", ":Data:Textures:Skybox(grass):Right.jpg", ":Data:Textures:Skybox(grass):Up.jpg", - ":Data:Textures:Skybox(grass):Down.jpg", - ":Data:Textures:Skybox(grass):Cloud.jpg", - ":Data:Textures:Skybox(grass):Reflect.jpg"); + ":Data:Textures:Skybox(grass):Down.jpg"); @@ -1569,55 +1421,31 @@ void Game::Setenvironment(int which) void Game::Loadlevel(int which){ stealthloading=0; - - if(which==0)Loadlevel((char *)":Data:Maps:map1"); - else if(which==1)Loadlevel((char *)":Data:Maps:map2"); - else if(which==2)Loadlevel((char *)":Data:Maps:map3"); - else if(which==3)Loadlevel((char *)":Data:Maps:map4"); - else if(which==4)Loadlevel((char *)":Data:Maps:map5"); - else if(which==5)Loadlevel((char *)":Data:Maps:map6"); - else if(which==6)Loadlevel((char *)":Data:Maps:map7"); - else if(which==7)Loadlevel((char *)":Data:Maps:map8"); - else if(which==8)Loadlevel((char *)":Data:Maps:map9"); - else if(which==9)Loadlevel((char *)":Data:Maps:map10"); - else if(which==10)Loadlevel((char *)":Data:Maps:map11"); - else if(which==11)Loadlevel((char *)":Data:Maps:map12"); - else if(which==12)Loadlevel((char *)":Data:Maps:map13"); - else if(which==13)Loadlevel((char *)":Data:Maps:map14"); - else if(which==14)Loadlevel((char *)":Data:Maps:map15"); - else if(which==15)Loadlevel((char *)":Data:Maps:map16"); - else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");} - else Loadlevel((char *)":Data:Maps:mapsave"); - 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(); -}*/ - + if (which == -1) + { + tutoriallevel = -1; + Loadlevel("tutorial"); + } + else if (which >= 0 && which <= 15) + { + char buf[32]; + snprintf(buf, 32, "map%d", which + 1); + Loadlevel(buf); + } + else + Loadlevel("mapsave"); +} -void Game::Loadlevel(char *name){ +void Game::Loadlevel(const char *name){ int i,j,k,l,m; static int oldlevel; int templength; float lamefloat; int lameint; + static const char *pfx = ":Data:Maps:"; + char *buf; float headprop,legprop,armprop,bodyprop; @@ -1646,18 +1474,20 @@ void Game::Loadlevel(char *name){ if(!firstload){ oldlevel=50; } - OPENAL_SetPaused(channels[whooshsound], true); - OPENAL_SetPaused(channels[stream_firesound], true); + pause_sound(whooshsound); + pause_sound(stream_firesound); // Change the map filename into something that is os specific - char *FixedFN = ConvertFileName(name); + buf = (char*) alloca(strlen(pfx) + strlen(name) + 1); + sprintf(buf, "%s%s", pfx, name); + const char *FixedFN = ConvertFileName(buf); int mapvers; FILE *tfile; tfile=fopen( FixedFN, "rb" ); if(tfile) { - OPENAL_SetPaused(channels[stream_firesound], true); + pause_sound(stream_firesound); scoreadded=0; @@ -1668,7 +1498,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; @@ -1728,9 +1558,7 @@ void Game::Loadlevel(char *name){ changedelay=0; if(console) { - PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true); - OPENAL_SetVolume(channels[consolesuccesssound], 256); - OPENAL_SetPaused(channels[consolesuccesssound], false); + emit_sound_np(consolesuccesssound); freeze=0; console=0; } @@ -1738,7 +1566,7 @@ void Game::Loadlevel(char *name){ if(!stealthloading) { terrain.numdecals=0; - sprites.numsprites=0; + Sprite::deleteSprites(); for(i=0;i64||templength<=0)templength=64; @@ -1884,6 +1698,7 @@ void Game::Loadlevel(char *name){ break; } } + dialoguename[k][l][m] = 0; funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z); funpackf(tfile, "Bi", &participantfocus[k][l]); funpackf(tfile, "Bi", &participantaction[k][l]); @@ -2163,7 +1978,7 @@ void Game::Loadlevel(char *name){ tintb=player[i].clothestintb[j]; AddClothes((char *)player[i].clothes[j],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); + player[i].DoMipmaps(); } player[i].currentanimation=bounceidleanim; @@ -2234,7 +2049,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; @@ -2334,33 +2149,17 @@ void Game::Loadlevel(char *name){ if(environment==snowyenvironment) { if(ambientsound) - { - PlayStreamEx(stream_wind, strm[stream_wind], NULL, true); - OPENAL_SetPaused(channels[stream_wind], false); - OPENAL_SetVolume(channels[stream_wind], 256); - } + emit_stream_np(stream_wind); } else if(environment==desertenvironment) { if(ambientsound) - { - //PlaySoundEx(desertambient, - // samp[desertambient], NULL, true); - PlayStreamEx(stream_desertambient, - strm[stream_desertambient], NULL, true); - OPENAL_SetPaused(channels[stream_desertambient], false); - OPENAL_SetVolume(channels[stream_desertambient], 256); - } + emit_stream_np(stream_desertambient); } else if(environment==grassyenvironment) { if(ambientsound) - { - //PlaySoundEx(wind, samp[wind], NULL, true); - PlayStreamEx(stream_wind, strm[stream_wind], NULL, true); - OPENAL_SetPaused(channels[stream_wind], false); - OPENAL_SetVolume(channels[stream_wind], 100); - } + emit_stream_np(stream_wind, 100.); } oldmusicvolume[0]=0; oldmusicvolume[1]=0; @@ -2442,7 +2241,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){ @@ -2455,15 +2254,13 @@ 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); - OPENAL_SetPaused(channels[stream_music3], false); - OPENAL_SetVolume(channels[stream_music3], 256); - OPENAL_SetPaused(channels[music1], true); + emit_stream_np(stream_music3); + pause_sound(music1); } } if(!mainmenu){ - OPENAL_SetPaused(channels[stream_music3], true); - OPENAL_SetPaused(channels[music1], false); + pause_sound(stream_music3); + resume_stream(music1); } } if(mainmenu==3){ @@ -2478,7 +2275,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(); @@ -2491,8 +2288,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; @@ -2506,23 +2301,11 @@ 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) tutorialstagetime=tutorialmaxtime; - PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true); - OPENAL_SetVolume(channels[consolefailsound], 128); - OPENAL_SetPaused(channels[consolefailsound], false); + emit_sound_np(consolefailsound, 128.); minimaptogglekeydown=1; } if(!Input::isKeyDown(SDLK_TAB)){ @@ -2532,7 +2315,7 @@ void Game::Tick() if(mainmenu){ //menu buttons if(mainmenu==1||mainmenu==2){ - if(Button()&&!oldbutton&&selected==1){ + if(Input::Button()&&!oldbutton&&selected==1){ if(!gameon){ fireSound(firestartsound); @@ -2550,12 +2333,12 @@ void Game::Tick() { //resume mainmenu=0; - OPENAL_SetPaused(channels[stream_music3], true); - OPENAL_SetPaused(channels[music1], false); + pause_sound(stream_music3); + resume_stream(music1); } } - if(Button()&&!oldbutton&&selected==2){ + if(Input::Button()&&!oldbutton&&selected==2){ fireSound(); flash(); @@ -2572,7 +2355,7 @@ void Game::Tick() if(newscreenheight<0)newscreenheight=screenheight; } - if(Button()&&!oldbutton&&selected==3){ + if(Input::Button()&&!oldbutton&&selected==3){ fireSound(); flash(); @@ -2580,7 +2363,7 @@ void Game::Tick() if(!gameon){ //quit tryquit=1; - OPENAL_SetPaused(channels[stream_music3], true); + pause_sound(stream_music3); } else{ //end game @@ -2590,10 +2373,10 @@ void Game::Tick() } } if(mainmenu==3){ - if(Button()&&!oldbutton&&selected!=-1){ + if(Input::Button()&&!oldbutton&&selected!=-1){ fireSound(); } - if(Button()&&!oldbutton&&selected==0){ + if(Input::Button()&&!oldbutton&&selected==0){ extern SDL_Rect **resolutions; bool isCustomResolution = true; @@ -2641,31 +2424,31 @@ void Game::Tick() } - if(Button()&&!oldbutton&&selected==1){ + if(Input::Button()&&!oldbutton&&selected==1){ newdetail++; if(newdetail>2)newdetail=0; } - if(Button()&&!oldbutton&&selected==2){ + if(Input::Button()&&!oldbutton&&selected==2){ bloodtoggle++; if(bloodtoggle>2)bloodtoggle=0; } - if(Button()&&!oldbutton&&selected==3){ + if(Input::Button()&&!oldbutton&&selected==3){ difficulty++; if(difficulty>2)difficulty=0; } - if(Button()&&!oldbutton&&selected==4){ + if(Input::Button()&&!oldbutton&&selected==4){ ismotionblur=1-ismotionblur; } - if(Button()&&!oldbutton&&selected==5){ + if(Input::Button()&&!oldbutton&&selected==5){ decals=1-decals; } - if(Button()&&!oldbutton&&selected==6){ + if(Input::Button()&&!oldbutton&&selected==6){ musictoggle=1-musictoggle; if(!musictoggle){ - OPENAL_SetPaused(channels[music1], true); - OPENAL_SetPaused(channels[stream_music2], true); - OPENAL_SetPaused(channels[stream_music3], true); + pause_sound(music1); + pause_sound(stream_music2); + pause_sound(stream_music3); for(i=0;i<4;i++){ oldmusicvolume[i]=0; @@ -2673,25 +2456,22 @@ void Game::Tick() } } - if(musictoggle){ - PlayStreamEx( stream_music3, strm[stream_music3], NULL, true); - OPENAL_SetPaused(channels[stream_music3], false); - OPENAL_SetVolume(channels[stream_music3], 256); - } + if(musictoggle) + emit_stream_np(stream_music3); } - if(Button()&&!oldbutton&&selected==9){ + if(Input::Button()&&!oldbutton&&selected==9){ invertmouse=1-invertmouse; } - if(Button()&&!oldbutton&&selected==10){ + if(Input::Button()&&!oldbutton&&selected==10){ usermousesensitivity+=.2; if(usermousesensitivity>2)usermousesensitivity=.2; } - if(Button()&&!oldbutton&&selected==11){ + if(Input::Button()&&!oldbutton&&selected==11){ volume+=.1f; if(volume>1.0001f)volume=0; OPENAL_SetSFXMasterVolume((int)(volume*255)); } - if(Button()&&!oldbutton&&selected==7){ + if(Input::Button()&&!oldbutton&&selected==7){ /*fireSound(); */ flash(); @@ -2702,17 +2482,17 @@ void Game::Tick() selected=-1; keyselect=-1; } - if(Button() && !oldbutton && selected == 12) { + if(Input::Button() && !oldbutton && selected == 12) { flash(); newstereomode = stereomode; mainmenu=18; keyselect=-1; } - if(Button() && !oldbutton && selected == 13) { + if(Input::Button() && !oldbutton && selected == 13) { showdamagebar=!showdamagebar; } - if(Button()&&!oldbutton&&selected==8){ + if(Input::Button()&&!oldbutton&&selected==8){ fireSound(); flash(); @@ -2729,7 +2509,7 @@ void Game::Tick() } } if(mainmenu==4){ - if(Button()&&!oldbutton&&selected!=-1&&!waiting){ + if(Input::Button()&&!oldbutton&&selected!=-1&&!waiting){ fireSound(); if(selected<9&&keyselect==-1) keyselect=selected; @@ -2757,7 +2537,7 @@ void Game::Tick() endgame=0; } - if(Button()&&!oldbutton&&selected==1){ + if(Input::Button()&&!oldbutton&&selected==1){ fireSound(); flash(); @@ -2775,9 +2555,9 @@ void Game::Tick() mainmenu=0; gameon=1; - OPENAL_SetPaused(channels[stream_music3], true); + pause_sound(stream_music3); } - if(Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){//selected>=7&&(selected-7<=campaignnumchoices)){ + if(Input::Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){ fireSound(); flash(); @@ -2789,32 +2569,17 @@ void Game::Tick() targetlevel=7; if(firstload) TickOnceAfter(); else LoadStuff(); - 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[campaignchoicewhich[selected-7-accountactive->getCampaignChoicesMade()]]); whichchoice=selected-7-accountactive->getCampaignChoicesMade(); visibleloading=1; stillloading=1; - Loadlevel(mapname); + Loadlevel(campaignmapname[campaignchoicewhich[selected-7-accountactive->getCampaignChoicesMade()]]); //Loadlevel(campaignmapname[levelorder[selected-7]]); campaign=1; mainmenu=0; gameon=1; - OPENAL_SetPaused(channels[stream_music3], true); + pause_sound(stream_music3); } - if(Button()&&!oldbutton&&selected==4){ + if(Input::Button()&&!oldbutton&&selected==4){ fireSound(); flash(); @@ -2822,21 +2587,21 @@ void Game::Tick() if(mainmenu==5&&gameon)mainmenu=2; if(mainmenu==5&&!gameon)mainmenu=1; } - if(Button()&&!oldbutton&&selected==5){ + if(Input::Button()&&!oldbutton&&selected==5){ fireSound(); flash(); mainmenu=7; } - if(Button()&&!oldbutton&&selected==3){ + if(Input::Button()&&!oldbutton&&selected==3){ fireSound(); flash(); mainmenu=6; } - if(Button()&&!oldbutton&&selected==2){ + if(Input::Button()&&!oldbutton&&selected==2){ fireSound(); flash(); @@ -2844,8 +2609,8 @@ void Game::Tick() mainmenu=9; } } - if(mainmenu==9){ - if(Button()&&!oldbutton&&selected=0&&selected<=accountactive->getProgress()){ + else if(mainmenu==9){ + if(Input::Button()&&!oldbutton&&selected=0&&selected<=accountactive->getProgress()){ fireSound(); flash(); @@ -2864,39 +2629,9 @@ void Game::Tick() mainmenu=0; gameon=1; - OPENAL_SetPaused(channels[stream_music3], true); + pause_sound(stream_music3); } - if(Button()&&!oldbutton&&selected==numchallengelevels){ - fireSound(); - - flash(); - - mainmenu=5; - } - } - if(mainmenu==11){ - if(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(Button()&&!oldbutton&&selected==numchallengelevels){ + if(Input::Button()&&!oldbutton&&selected==numchallengelevels){ fireSound(); flash(); @@ -2906,7 +2641,7 @@ void Game::Tick() } if(mainmenu==10){ endgame=2; - if(Button()&&!oldbutton&&selected==3){ + if(Input::Button()&&!oldbutton&&selected==3){ fireSound(); flash(); @@ -2916,7 +2651,7 @@ void Game::Tick() } if(mainmenu==6){ - if(Button()&&!oldbutton) { + if(Input::Button()&&!oldbutton) { if(selected>-1){ fireSound(); if(selected==1) { @@ -2931,7 +2666,7 @@ void Game::Tick() } } if(mainmenu==7){ - if(Button()&&!oldbutton) { + if(Input::Button()&&!oldbutton) { if(selected!=-1){ fireSound(); if(selected==0&&Account::getNbAccounts()<8){ @@ -2956,7 +2691,7 @@ void Game::Tick() } } if(mainmenu==8){ - if(Button()&&!oldbutton&&selected>-1){ + if(Input::Button()&&!oldbutton&&selected>-1){ fireSound(); if(selected<=2) @@ -2969,7 +2704,7 @@ void Game::Tick() } } if (mainmenu==18) { - if(Button()&&!oldbutton&&selected==0) { + if(Input::Button()&&!oldbutton&&selected==0) { newstereomode = (StereoMode)(newstereomode + 1); while(!CanInitStereo(newstereomode)) { printf("Failed to initialize mode %s (%i)\n", StereoModeName(newstereomode), newstereomode); @@ -2987,11 +2722,11 @@ void Game::Tick() stereoseparation-=0.001; } - if(Button()&&!oldbutton&&selected==2) { + if(Input::Button()&&!oldbutton&&selected==2) { stereoreverse =! stereoreverse; } - if(Button()&&!oldbutton&&selected==3) { + if(Input::Button()&&!oldbutton&&selected==3) { flash(); stereomode = newstereomode; @@ -3002,7 +2737,7 @@ void Game::Tick() } - if(Button()||Input::isKeyDown(MOUSEBUTTON2))oldbutton=1; + if(Input::Button()||Input::isKeyDown(MOUSEBUTTON2))oldbutton=1; else oldbutton=0; if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){ @@ -3029,7 +2764,28 @@ void Game::Tick() OPENAL_SetFrequency(channels[stream_music3], 22050); if(entername) { - if(!waiting) inputText(); + inputText(displaytext[0],&displayselected,&displaychars[0]); + if(!waiting) { // the input as finished + if(displaychars[0]){ // with enter + accountactive = Account::add(string(displaytext[0])); + + mainmenu=8; + + flash(); + + fireSound(firestartsound); + + for(i=0;i<255;i++){ + displaytext[0][i]=' '; + } + displaychars[0]=0; + + displayselected=0; + } else { // with escape or empty + mainmenutogglekeydown=1; + } + entername=0; + } displayblinkdelay-=multiplier; if(displayblinkdelay<=0){ @@ -3053,8 +2809,6 @@ void Game::Tick() if(Input::isKeyDown(chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){ chatting=1; chattogglekeydown=1; - togglekey[chatkey]=1; - togglekeydelay[chatkey]=-20; } if(!Input::isKeyDown(chatkey)){ @@ -3062,61 +2816,16 @@ void Game::Tick() } if(chatting){ - for(i=0;i<140;i++){ - if(Input::isKeyDown(i)){ - togglekeydelay[i]+=multiplier; - if(togglekeydelay[i]>.4){ - togglekey[i]=0; - togglekeydelay[i]=.36; + inputText(displaytext[0],&displayselected,&displaychars[0]); + if(!waiting) { + if(displaychars[0]){ + for(int j=0;j<255;j++){ + displaytext[0][j]=' '; } - if(!togglekey[i]){ - if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){ - for(j=255;j>=displayselected+1;j--){ - displaytext[0][j]=displaytext[0][j-1]; - } - displaytext[0][displayselected]=KeyToSingleChar(i); - if(Input::isKeyDown(SDLK_LSHIFT))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]); - displayselected++; - displaychars[0]++; - } - if(i==SDLK_DELETE&&displayselected!=0){ - for(j=displayselected-1;j<255;j++){ - displaytext[0][j]=displaytext[0][j+1]; - } - displaytext[0][255]=' '; - displayselected--; - displaychars[0]--; - } - if(i==SDLK_LEFT&&displayselected!=0){ - displayselected--; - } - if(i==SDLK_RIGHT&&displayselected.4){ - togglekey[i]=0; - togglekeydelay[i]=.36; - } - if(!togglekey[i]){ - if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){ - for(j=255;j>=consoleselected+1;j--){ - consoletext[0][j]=consoletext[0][j-1]; - } - consoletext[0][consoleselected]=KeyToSingleChar(i); - if(Input::isKeyDown(SDLK_LSHIFT))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]); - consoleselected++; - consolechars[0]++; - } - else if(i==SDLK_RETURN){ - for(j=255;j>=consoleselected+1;j--){ - consoletext[0][j]=consoletext[0][j-1]; - } - consoletext[0][consoleselected]='\n'; - consoleselected++; - consolechars[0]++; - } - if(i==SDLK_DELETE&&consoleselected!=0){ - for(j=consoleselected-1;j<255;j++){ - consoletext[0][j]=consoletext[0][j+1]; - } - consoletext[0][255]=' '; - consoleselected--; - consolechars[0]--; - } - if(i==SDLK_UP){ - if(archiveselected<14)archiveselected++; - for(j=0;j<255;j++){ - consolechars[0]=consolechars[archiveselected]; - consoletext[0][j]=consoletext[archiveselected][j]; - consoleselected=consolechars[0]; - } - } - if(i==SDLK_DOWN){ - if(archiveselected>0)archiveselected--; - for(j=0;j<255;j++){ - consolechars[0]=consolechars[archiveselected]; - consoletext[0][j]=consoletext[archiveselected][j]; - consoleselected=consolechars[0]; - } - } - if(i==SDLK_LEFT&&consoleselected!=0){ - consoleselected--; - } - if(i==SDLK_RIGHT&&consoleselected0){ - for(k=14;k>=1;k--){ - for(j=0;j<255;j++){ - consoletext[k][j]=consoletext[k-1][j]; - } - consolechars[k]=consolechars[k-1]; - } - for(j=0;j<255;j++){ - consoletext[0][j]=' '; - } - consolechars[0]=0; - consoleselected=0; - } + inputText(consoletext[0],&consoleselected,&consolechars[0]); + if(!waiting) { + archiveselected=0; + cmd_dispatch(this, consoletext[0]); + if(consolechars[0]>0){ + + for(k=14;k>=1;k--){ + for(j=0;j<255;j++){ + consoletext[k][j]=consoletext[k-1][j]; } + consolechars[k]=consolechars[k-1]; } - togglekey[i]=1; - } - else { - togglekey[i]=0; - togglekeydelay[i]=0; + for(j=0;j<255;j++){ + consoletext[0][j]=' '; + } + consolechars[0]=0; + consoleselected=0; } } @@ -3260,9 +2909,7 @@ void Game::Tick() static int oldwinfreeze; if(winfreeze&&!oldwinfreeze){ OPENAL_SetFrequency(OPENAL_ALL, 0.001); - PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true); - OPENAL_SetVolume(channels[consolesuccesssound], 256); - OPENAL_SetPaused(channels[consolesuccesssound], false); + emit_sound_np(consolesuccesssound); } if(winfreeze==0)oldwinfreeze=winfreeze; else oldwinfreeze++; @@ -3334,19 +2981,12 @@ void Game::Tick() dialoguetime=0; dialoguegonethrough[i]++; if(dialogueboxsound[whichdialogue][indialogue]!=0){ - static float gLoc[3]; - static float vel[3]; XYZ temppos; temppos=player[participantfocus[whichdialogue][indialogue]].coords; temppos=temppos-viewer; Normalise(&temppos); temppos+=viewer; - gLoc[0]=temppos.x; - gLoc[1]=temppos.y; - gLoc[2]=temppos.z;vel[0]=0; - vel[1]=0; - vel[2]=0; int whichsoundplay; if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter; if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2; @@ -3368,10 +3008,7 @@ void Game::Tick() if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound; if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound; if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound; - PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true); - OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel); - OPENAL_SetVolume(channels[whichsoundplay], 256); - OPENAL_SetPaused(channels[whichsoundplay], false); + emit_sound_at(whichsoundplay, temppos); } if(Input::isKeyDown(attackkey))oldbuttondialogue=1; } @@ -3397,7 +3034,7 @@ void Game::Tick() hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360); hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0); hotspotsprite+=hotspot[i]; - sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4); + Sprite::MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4); hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i]; } } @@ -3458,18 +3095,7 @@ void Game::Tick() player[1].coords=(temp+temp2)/2; - 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); + emit_sound_at(fireendsound, player[1].coords); for(i=0;i=1){ @@ -3885,16 +3498,12 @@ void Game::Tick() if(tutoriallevel!=1){ if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){ - PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true); - OPENAL_SetVolume(channels[consolesuccesssound], 256); - OPENAL_SetPaused(channels[consolesuccesssound], false); + emit_sound_np(consolesuccesssound); } } else if(bonustime==0){ - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); + emit_sound_np(fireendsound); } if(bonustime==0){ if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++; @@ -3917,7 +3526,7 @@ void Game::Tick() footpoint.y+=((float)abs(Random()%1200))/100-6; footpoint.x+=((float)abs(Random()%1200))/100-6; footpoint.z+=((float)abs(Random()%1200))/100-6; - sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1); + Sprite::MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1); } } for(k=0;k10||!player[k].isRun()){ if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){ - if(k==0)OPENAL_SetPaused(channels[whooshsound], true); + if(k==0)pause_sound(whooshsound); } - float gLoc[3]; - float vel[3]; - gLoc[0]=player[k].coords.x; - gLoc[1]=player[k].coords.y; - gLoc[2]=player[k].coords.z; - vel[0]=player[k].velocity.x; - vel[1]=player[k].velocity.y; - vel[2]=player[k].velocity.z; - PlaySoundEx( jumpsound, samp[jumpsound], NULL, true); - OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel); - OPENAL_SetVolume(channels[jumpsound], 128); - OPENAL_SetPaused(channels[jumpsound], false); + emit_sound_at(jumpsound, player[k].coords, 128.); lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); player[k].rotation=-asin(0-lowpointtarget.x); @@ -4319,20 +3862,8 @@ void Game::Tick() player[k].targetframe=0; player[k].target=0; - float gLoc[3]; - float vel[3]; - gLoc[0]=player[k].coords.x; - gLoc[1]=player[k].coords.y; - gLoc[2]=player[k].coords.z; - vel[0]=player[k].velocity.x; - vel[1]=player[k].velocity.y; - vel[2]=player[k].velocity.z; - if(k==0){ - PlaySoundEx( whooshsound, samp[whooshsound], NULL, true); - OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel); - OPENAL_SetVolume(channels[whooshsound], 128); - OPENAL_SetPaused(channels[whooshsound], false); - } + if(!k) + emit_sound_at(whooshsound, player[k].coords, 128.); } player[k].velocity.y+=gravity; } @@ -4424,19 +3955,12 @@ void Game::Tick() indialogue++; if(indialogue150&&(i!=0&&k!=0))||(findLengthfast(&rotatetarget)>50&&player[0].rabbitkickragdoll/*currentanimation==rabbitkickanim*/&&(i==0||k==0)))&&normaldotproduct(rotatetarget,player[k].coords-player[i].coords)>0)&&((i==0||k==0)||((player[i].skeleton.oldfree==1&&k!=0&&animation[player[k].currentanimation].attack==neutral)||(player[k].skeleton.oldfree==1&&i!=0&&animation[player[i].currentanimation].attack==neutral)||(player[i].isFlip()&&!player[i].skeleton.oldfree&&(i==0||k==0))||(player[k].isFlip()&&!player[k].skeleton.oldfree&&(i==0||k==0))||(i==0||k==0))))||((player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip())&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&(i==0||k==0)&&(!player[i].skeleton.oldfree&&!player[k].skeleton.oldfree))){ //If hit by body if((i!=0||player[i].skeleton.free)&&(k!=0||player[k].skeleton.free)||(animation[player[i].targetanimation].height==highheight&&animation[player[k].targetanimation].height==highheight)){ - static float gLoc[3]; - static float vel[3]; - gLoc[0]=player[i].coords.x; - gLoc[1]=player[i].coords.y; - gLoc[2]=player[i].coords.z; - vel[0]=player[i].velocity.x; - vel[1]=player[i].velocity.y; - vel[2]=player[i].velocity.z; if(tutoriallevel!=1){ - PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true); - OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel); - OPENAL_SetVolume(channels[heavyimpactsound], 256); - OPENAL_SetPaused(channels[heavyimpactsound], false); + emit_sound_at(heavyimpactsound, player[i].coords); } //player[i].velocity=player[k].velocity; //player[k].velocity=player[i].velocity; player[i].RagDoll(0); if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){ - bonus=aimbonus; - bonustime=0; - bonusvalue=150; + award_bonus(0, aimbonus); } player[i].DoDamage(findLengthfast(&rotatetarget)/4); player[k].RagDoll(0); if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){ - bonus=aimbonus; - bonustime=0; - bonusvalue=150; + award_bonus(0, aimbonus); // Huh, again? } player[k].DoDamage(findLengthfast(&rotatetarget)/4); @@ -6010,11 +5441,7 @@ void Game::Tick() player[i].DoDamage(20); player[i].RagDoll(0); player[k].lastcollide=1; - if(k==0){ - bonus=AboveBonus; - bonustime=0; - bonusvalue=50; - } + award_bonus(k, AboveBonus); } if(i==0&&k!=0&&player[i].targetanimation==jumpdownanim&&!player[k].isCrouch()&&player[k].targetanimation!=rollanim&&!player[i].skeleton.oldfree&&!player[i].skeleton.free&&player[i].lastcollide<=0&&player[i].velocity.y<-10){ player[k].velocity=player[i].velocity; @@ -6024,11 +5451,7 @@ void Game::Tick() player[k].DoDamage(20); player[k].RagDoll(0); player[i].lastcollide=1; - if(i==0){ - bonus=AboveBonus; - bonustime=0; - bonusvalue=50; - } + award_bonus(i, AboveBonus); } } } @@ -6844,21 +6267,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; @@ -7182,20 +6590,8 @@ void Game::Tick() if((((weapons.velocity[j].x==0&&weapons.velocity[j].y==0&&weapons.velocity[j].z==0)||player[i].aitype==playercontrolled)&&weapons.owner[j]==-1)||(player[i].victim&&weapons.owner[j]==player[i].victim->id)) if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){ if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){ - float gLoc[3]; - float vel[3]; - gLoc[0]=player[i].coords.x; - gLoc[1]=player[i].coords.y; - gLoc[2]=player[i].coords.z; - vel[0]=player[i].velocity.x; - vel[1]=player[i].velocity.y; - vel[2]=player[i].velocity.z; - if(weapons.type[j]!=staff){ - PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true); - OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel); - OPENAL_SetVolume(channels[knifedrawsound], 128); - OPENAL_SetPaused(channels[knifedrawsound], false); - } + if(weapons.type[j]!=staff) + emit_sound_at(knifedrawsound, player[i].coords, 128.); player[i].weaponactive=0; weapons.owner[j]=player[i].id; @@ -7229,20 +6625,8 @@ void Game::Tick() if(player[i].weaponactive==-1) if((((weapons.velocity[k].x==0&&weapons.velocity[k].y==0&&weapons.velocity[k].z==0)||player[i].aitype==playercontrolled)&&weapons.owner[k]==-1)||(player[i].victim&&weapons.owner[k]==player[i].victim->id)) if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){ - float gLoc[3]; - float vel[3]; - gLoc[0]=player[i].coords.x; - gLoc[1]=player[i].coords.y; - gLoc[2]=player[i].coords.z; - vel[0]=player[i].velocity.x; - vel[1]=player[i].velocity.y; - vel[2]=player[i].velocity.z; - if(weapons.type[k]!=staff){ - PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true); - OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel); - OPENAL_SetVolume(channels[knifedrawsound], 128); - OPENAL_SetPaused(channels[knifedrawsound], false); - } + if(weapons.type[k]!=staff) + emit_sound_at(knifedrawsound, player[i].coords, 128.); player[i].weaponactive=0; weapons.owner[k]=player[i].id; @@ -7282,14 +6666,6 @@ void Game::Tick() player[i].hasvictim=1; int k = player[j].weaponids[0]; if(player[i].hasvictim){ - float gLoc[3]; - float vel[3]; - gLoc[0]=player[i].coords.x; - gLoc[1]=player[i].coords.y; - gLoc[2]=player[i].coords.z; - vel[0]=player[i].velocity.x; - vel[1]=player[i].velocity.y; - vel[2]=player[i].velocity.z; bool fleshstuck; fleshstuck=0; if(player[i].victim->weaponstuck!=-1){ @@ -7298,19 +6674,11 @@ void Game::Tick() } } if(!fleshstuck){ - if(weapons.type[k]!=staff){ - PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true); - OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel); - OPENAL_SetVolume(channels[knifedrawsound], 128); - OPENAL_SetPaused(channels[knifedrawsound], false); - } - } - if(fleshstuck){ - PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true); - OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel); - OPENAL_SetVolume(channels[fleshstabremovesound], 128); - OPENAL_SetPaused(channels[fleshstabremovesound], false); + if(weapons.type[k]!=staff) + emit_sound_at(knifedrawsound, player[i].coords, 128.); } + if(fleshstuck) + emit_sound_at(fleshstabremovesound, player[i].coords, 128.); player[i].weaponactive=0; if(weapons.owner[k]!=-1){ @@ -7335,7 +6703,7 @@ void Game::Tick() footpoint=weapons.position[k]; if(player[i].victim->weaponstuck!=-1){ if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){ - if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3); + if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3); weapons.bloody[k]=2; weapons.blooddrip[k]=5; player[i].victim->weaponstuck=-1; @@ -7724,26 +7092,10 @@ void Game::Tick() player[i].coords.y+=.2; player[i].jumppower-=1; - static float gLoc[3]; - static float vel[3]; - gLoc[0]=player[i].coords.x; - gLoc[1]=player[i].coords.y; - gLoc[2]=player[i].coords.z; - vel[0]=player[i].velocity.x; - vel[1]=player[i].velocity.y; - vel[2]=player[i].velocity.z; - - if(i==0){ - PlaySoundEx( whooshsound, samp[whooshsound], NULL, true); - OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel); - OPENAL_SetVolume(channels[whooshsound], 128); - OPENAL_SetPaused(channels[whooshsound], false); - } + if (!i) + emit_sound_at(whooshsound, player[i].coords, 128.); - PlaySoundEx( jumpsound, samp[jumpsound], NULL, true); - OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel); - OPENAL_SetVolume(channels[jumpsound], 128); - OPENAL_SetPaused(channels[jumpsound], false); + emit_sound_at(jumpsound, player[i].coords, 128.); } if((player[i].isIdle())&&player[i].jumppower>1){ player[i].targetanimation=player[i].getLanding(); @@ -7835,160 +7187,128 @@ void Game::Tick() for(k=0;k=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); + + emit_stream_np(stream_music3); + + 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); + emit_sound_at(fireendsound, player[0].coords); - 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); - 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){ - 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); - - 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;i=14&&tutorialstage<50) + if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){ + emit_sound_at(fireendsound, player[1].coords); + + for(int i=0;i90)rotation2=90; if(rotation2<-70)rotation2=-70; } - if(mainmenu)rotation+=multiplier*5; } void Game::TickOnceAfter(){ @@ -8063,17 +7384,7 @@ void Game::TickOnceAfter(){ if(musictoggle){ if(musictype!=oldmusictype&&musictype==stream_music2){ - static float gLoc[3]; - static float vel[3]; - gLoc[0]=cameraloc.x; - gLoc[1]=cameraloc.y; - gLoc[2]=cameraloc.z; - vel[0]=0; - vel[1]=0; - vel[2]=0; - PlaySoundEx( alarmsound, samp[alarmsound], NULL, true); - OPENAL_SetVolume(channels[alarmsound], 512); - OPENAL_SetPaused(channels[alarmsound], false); + emit_sound_np(alarmsound); } } @@ -8094,40 +7405,20 @@ void Game::TickOnceAfter(){ if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128; if(musictoggle){ - if(musicvolume[0]>0&&oldmusicvolume[0]<=0){ - PlayStreamEx( music1, strm[music1], NULL, true); - OPENAL_SetPaused(channels[music1], false); - } - if(musicvolume[1]>0&&oldmusicvolume[1]<=0){ - PlayStreamEx( stream_music2, strm[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); - 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) + emit_stream_np(music1, musicvolume[0]); + if(musicvolume[1]>0&&oldmusicvolume[1]<=0) + emit_stream_np(stream_music2, musicvolume[1]); + if(musicvolume[2]>0&&oldmusicvolume[2]<=0) + emit_stream_np(stream_music3, musicvolume[2]); if(musicvolume[0]<=0&&oldmusicvolume[0]>0){ - OPENAL_SetPaused(channels[music1], true); + pause_sound(music1); } if(musicvolume[1]<=0&&oldmusicvolume[1]>0){ - OPENAL_SetPaused(channels[stream_music2], true); + pause_sound(stream_music2); } if(musicvolume[2]<=0&&oldmusicvolume[2]>0){ - OPENAL_SetPaused(channels[stream_music3], true); + pause_sound(stream_music3); } if(musicvolume[0]!=oldmusicvolume[0]){ @@ -8143,283 +7434,243 @@ void Game::TickOnceAfter(){ for(i=0;i<3;i++){ oldmusicvolume[i]=musicvolume[i]; } + } else { + pause_sound(music1); + pause_sound(stream_music2); + pause_sound(stream_music3); + + 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; - } - } + Loadlevel(campaignmapname[levelorder[accountactive->getCampaignChoicesMade()]]); + + 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; + } + } + } - 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; + 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; - if(!stealthloading){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - fireSound(firestartsound); + if(!stealthloading){ + float gLoc[3]={0,0,0}; + float vel[3]={0,0,0}; + fireSound(firestartsound); - flash(); - } + flash(); + } - 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(); + 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]; + 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