X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=75d13958223f69ed036a538a4f5c7eacceeddbc6;hb=cfdbe0ad0521045b27a60dbb1c963ea6dfdcda5a;hp=b1f3ecc93e9496b582877b3b2a37a4c2fe81fc79;hpb=752c53b75078777dde112ebc552c860d8b7cfc28;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index b1f3ecc..75d1395 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -35,10 +35,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Input.h" #include "Animation.h" #include "Awards.h" +#include "Menu.h" #include using namespace std; +using namespace Game; // Added more evilness needed for MSVC #ifdef _MSC_VER @@ -82,6 +84,7 @@ extern XYZ windvector; extern bool debugmode; static int leveltheme; extern int mainmenu; +extern int oldmainmenu; extern bool visibleloading; extern XYZ envsound[30]; extern float envsoundvol[30]; @@ -122,8 +125,6 @@ extern float hostiletime; extern bool gamestarted; extern int numhotspots; -extern int winhotspot; -extern int windialogue; extern int killhotspot; extern XYZ hotspot[40]; extern int hotspottype[40]; @@ -169,14 +170,14 @@ static bool stripfx(const char *str, const char *pfx) } static const char *cmd_names[] = { -#define DECLARE_COMMAND(cmd) #cmd " ", +#define DECLARE_COMMAND(cmd) #cmd, #include "ConsoleCmds.h" #undef DECLARE_COMMAND }; -typedef void (*console_handler)(Game *game, const char *args); +typedef void (*console_handler)(const char *args); -#define DECLARE_COMMAND(cmd) static void ch_##cmd(Game *game, const char *args); +#define DECLARE_COMMAND(cmd) static void ch_##cmd(const char *args); #include "ConsoleCmds.h" #undef DECLARE_COMMAND @@ -190,13 +191,6 @@ static console_handler cmd_handlers[] = { // added utility functions -sf17k ============================================================= -//TODO: try to hide these variables completely with a better interface -inline void setAnimation(int playerid,int animation){ - player[playerid].targetanimation=animation; - player[playerid].targetframe=0; - player[playerid].target=0; -} - //TODO: this is incorrect but I'm afraid to change it and break something, //probably causes quirky behavior that I might want to preserve inline float roughDirection(XYZ vec){ @@ -219,13 +213,7 @@ inline float pitchTo(XYZ start, XYZ end){ return pitch(end-start); } -//change these to a Person method -inline Joint& playerJoint(int playerid, int bodypart){ - return player[playerid].skeleton.joints[player[playerid].skeleton.jointlabels[bodypart]]; } -inline Joint& playerJoint(Person* pplayer, int bodypart){ - return pplayer->skeleton.joints[pplayer->skeleton.jointlabels[bodypart]]; } - -inline float sq(float n){ return n*n; } +inline float sq(float n) { return n*n; } inline float stepTowardf(float from, float to, float by){ if(fabs(from-to)tryquit = 1; + tryquit = 1; } -static void ch_map(Game *game, const char *args) +static void ch_map(const char *args) { - game->Loadlevel(args); - game->whichlevel = -2; + Loadlevel(args); + whichlevel = -2; campaign = 0; } -static void ch_save(Game *game, const char *args){ +static void ch_save(const char *args){ char buf[64]; snprintf(buf, 63, ":Data:Maps:%s", args); @@ -303,7 +291,7 @@ static void ch_save(Game *game, const char *args){ player[0].rotation, player[0].targetrotation, player[0].num_weapons); if(player[0].num_weapons>0&&player[0].num_weapons<5) for(int j=0;jnumpathpoints); - for(int 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(int k=0;knumpathpointconnect[j];k++) - fpackf(tfile, "Bi", game->pathpointconnect[j][k]); + fpackf(tfile, "Bi", numpathpoints); + for(int j=0;jmapcenter.x, game->mapcenter.y, game->mapcenter.z, game->mapradius); + fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius); fclose(tfile); } -static void ch_cellar(Game *game, const char *args) +static void ch_cellar(const char *args) { - game->LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_tint(Game *game, const char *args) +static void ch_tint(const char *args) { sscanf(args, "%f%f%f", &tintr, &tintg, &tintb); } -static void ch_tintr(Game *game, const char *args) +static void ch_tintr(const char *args) { tintr = atof(args); } -static void ch_tintg(Game *game, const char *args) +static void ch_tintg(const char *args) { tintg = atof(args); } -static void ch_tintb(Game *game, const char *args) +static void ch_tintb(const char *args) { tintb = atof(args); } -static void ch_speed(Game *game, const char *args) +static void ch_speed(const char *args) { player[0].speedmult = atof(args); } -static void ch_strength(Game *game, const char *args) +static void ch_strength(const char *args) { player[0].power = atof(args); } -static void ch_power(Game *game, const char *args) +static void ch_power(const char *args) { player[0].power = atof(args); } -static void ch_size(Game *game, const char *args) +static void ch_size(const char *args) { player[0].scale = atof(args) * .2; } @@ -511,7 +499,7 @@ static int find_closest() return closest; } -static void ch_sizenear(Game *game, const char *args) +static void ch_sizenear(const char *args) { int closest = find_closest(); @@ -539,12 +527,12 @@ static void set_proportion(int pnum, const char *args) } } -static void ch_proportion(Game *game, const char *args) +static void ch_proportion(const char *args) { set_proportion(0, args); } -static void ch_proportionnear(Game *game, const char *args) +static void ch_proportionnear(const char *args) { int closest = find_closest(); if (closest) @@ -561,12 +549,12 @@ static void set_protection(int pnum, const char *args) player[pnum].protectionlow = low; } -static void ch_protection(Game *game, const char *args) +static void ch_protection(const char *args) { set_protection(0, args); } -static void ch_protectionnear(Game *game, const char *args) +static void ch_protectionnear(const char *args) { int closest = find_closest(); if (closest) @@ -583,19 +571,19 @@ static void set_armor(int pnum, const char *args) player[pnum].armorlow = low; } -static void ch_armor(Game *game, const char *args) +static void ch_armor(const char *args) { set_armor(0, args); } -static void ch_armornear(Game *game, const char *args) +static void ch_armornear(const char *args) { int closest = find_closest(); if (closest) set_armor(closest, args); } -static void ch_protectionreset(Game *game, const char *args) +static void ch_protectionreset(const char *args) { set_protection(0, "1 1 1"); set_armor(0, "1 1 1"); @@ -611,38 +599,38 @@ static void set_metal(int pnum, const char *args) player[pnum].metallow = low; } -static void ch_metal(Game *game, const char *args) +static void ch_metal(const char *args) { set_metal(0, args); } -static void set_noclothes(int pnum, Game *game, const char *args) +static void set_noclothes(int pnum, const char *args) { player[pnum].numclothes = 0; - game->LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin], + LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin], &player[pnum].skeleton.drawmodel.textureptr,1, &player[pnum].skeleton.skinText[0],&player[pnum].skeleton.skinsize); } -static void ch_noclothes(Game *game, const char *args) +static void ch_noclothes(const char *args) { - set_noclothes(0, game, args); + set_noclothes(0, args); } -static void ch_noclothesnear(Game *game, const char *args) +static void ch_noclothesnear(const char *args) { int closest = find_closest(); if (closest) - set_noclothes(closest, game, args); + set_noclothes(closest, args); } -static void set_clothes(int pnum, Game *game, const char *args) +static void set_clothes(int pnum, const char *args) { char buf[64]; snprintf(buf, 63, ":Data:Textures:%s.png", args); - if (!game->AddClothes(buf,&player[pnum].skeleton.skinText[pnum])) + if (!AddClothes(buf,&player[pnum].skeleton.skinText[pnum])) return; player[pnum].DoMipmaps(); @@ -653,25 +641,25 @@ static void set_clothes(int pnum, Game *game, const char *args) player[pnum].numclothes++; } -static void ch_clothes(Game *game, const char *args) +static void ch_clothes(const char *args) { - set_clothes(0, game, args); + set_clothes(0, args); } -static void ch_clothesnear(Game *game, const char *args) +static void ch_clothesnear(const char *args) { int closest = find_closest(); if (closest) - set_clothes(closest, game, args); + set_clothes(closest, args); } -static void ch_belt(Game *game, const char *args) +static void ch_belt(const char *args) { player[0].skeleton.clothes = !player[0].skeleton.clothes; } -static void ch_cellophane(Game *game, const char *args) +static void ch_cellophane(const char *args) { cellophane = !cellophane; float mul = cellophane ? 0 : 1; @@ -684,7 +672,7 @@ static void ch_cellophane(Game *game, const char *args) } } -static void ch_funnybunny(Game *game, const char *args) +static void ch_funnybunny(const char *args) { player[0].skeleton.id=0; player[0].skeleton.Load(":Data:Skeleton:Basic Figure",":Data:Skeleton:Basic Figurelow", @@ -693,7 +681,7 @@ static void ch_funnybunny(Game *game, const char *args) ":Data:Models:Body4.solid",":Data:Models:Body5.solid", ":Data:Models:Body6.solid",":Data:Models:Body7.solid", ":Data:Models:Bodylow.solid",":Data:Models:Belt.solid",1); - game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); player[0].creature=rabbittype; player[0].scale=.2; @@ -702,7 +690,7 @@ static void ch_funnybunny(Game *game, const char *args) set_proportion(0, "1 1 1 1"); } -static void ch_wolfie(Game *game, const char *args) +static void ch_wolfie(const char *args) { player[0].skeleton.id=0; player[0].skeleton.Load(":Data:Skeleton:Basic Figure Wolf",":Data:Skeleton:Basic Figure Wolf Low", @@ -711,80 +699,80 @@ static void ch_wolfie(Game *game, const char *args) ":Data:Models:Wolf4.solid",":Data:Models:Wolf5.solid", ":Data:Models:Wolf6.solid",":Data:Models:Wolf7.solid", ":Data:Models:Wolflow.solid",":Data:Models:Belt.solid",0); - game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); player[0].creature=wolftype; player[0].damagetolerance=300; set_proportion(0, "1 1 1 1"); } -static void ch_wolfieisgod(Game *game, const char *args) +static void ch_wolfieisgod(const char *args) { - ch_wolfie(game, args); + ch_wolfie(args); } -static void ch_wolf(Game *game, const char *args) +static void ch_wolf(const char *args) { - game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_snowwolf(Game *game, const char *args) +static void ch_snowwolf(const char *args) { - game->LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_darkwolf(Game *game, const char *args) +static void ch_darkwolf(const char *args) { - game->LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_lizardwolf(Game *game, const char *args) +static void ch_lizardwolf(const char *args) { - game->LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_white(Game *game, const char *args) +static void ch_white(const char *args) { - game->LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_brown(Game *game, const char *args) +static void ch_brown(const char *args) { - game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_black(Game *game, const char *args) +static void ch_black(const char *args) { - game->LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_sizemin(Game *game, const char *args) +static void ch_sizemin(const char *args) { for (int i = 1; i < numplayers; i++) if (player[i].scale < 0.8 * 0.2) player[i].scale = 0.8 * 0.2; } -static void ch_tutorial(Game *game, const char *args) +static void ch_tutorial(const char *args) { tutoriallevel = atoi(args); } -static void ch_hostile(Game *game, const char *args) +static void ch_hostile(const char *args) { hostile = atoi(args); } -static void ch_indemo(Game *game, const char *args) +static void ch_indemo(const char *args) { - game->indemo=1; + indemo=1; hotspot[numhotspots]=player[0].coords; hotspotsize[numhotspots]=0; hotspottype[numhotspots]=-111; @@ -792,13 +780,13 @@ static void ch_indemo(Game *game, const char *args) numhotspots++; } -static void ch_notindemo(Game *game, const char *args) +static void ch_notindemo(const char *args) { - game->indemo=0; + indemo=0; numhotspots--; } -static void ch_type(Game *game, const char *args) +static void ch_type(const char *args) { int n = sizeof(editortypenames) / sizeof(editortypenames[0]); for (int i = 0; i < n; i++) @@ -808,7 +796,7 @@ static void ch_type(Game *game, const char *args) } } -static void ch_path(Game *game, const char *args) +static void ch_path(const char *args) { int n = sizeof(pathtypenames) / sizeof(pathtypenames[0]); for (int i = 0; i < n; i++) @@ -818,7 +806,7 @@ static void ch_path(Game *game, const char *args) } } -static void ch_hs(Game *game, const char *args) +static void ch_hs(const char *args) { hotspot[numhotspots]=player[0].coords; @@ -835,7 +823,7 @@ static void ch_hs(Game *game, const char *args) numhotspots++; } -static void ch_dialogue(Game *game, const char *args) +static void ch_dialogue(const char *args) { int dlg; char buf1[32], buf2[64]; @@ -886,7 +874,7 @@ static void ch_dialogue(Game *game, const char *args) numdialogues++; } -static void ch_fixdialogue(Game *game, const char *args) +static void ch_fixdialogue(const char *args) { char buf1[32], buf2[64]; int whichdi; @@ -924,47 +912,47 @@ static void ch_fixdialogue(Game *game, const char *args) ipstream.close(); } -static void ch_fixtype(Game *game, const char *args) +static void ch_fixtype(const char *args) { int dlg; sscanf(args, "%d", &dlg); dialoguetype[0] = dlg; } -static void ch_fixrotation(Game *game, const char *args) +static void ch_fixrotation(const char *args) { participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation; } -static void ch_ddialogue(Game *game, const char *args) +static void ch_ddialogue(const char *args) { if (numdialogues) numdialogues--; } -static void ch_dhs(Game *game, const char *args) +static void ch_dhs(const char *args) { if (numhotspots) numhotspots--; } -static void ch_immobile(Game *game, const char *args) +static void ch_immobile(const char *args) { player[0].immobile = 1; } -static void ch_allimmobile(Game *game, const char *args) +static void ch_allimmobile(const char *args) { for (int i = 1; i < numplayers; i++) player[i].immobile = 1; } -static void ch_mobile(Game *game, const char *args) +static void ch_mobile(const char *args) { player[0].immobile = 0; } -static void ch_default(Game *game, const char *args) +static void ch_default(const char *args) { player[0].armorhead=1; player[0].armorhigh=1; @@ -993,7 +981,7 @@ static void ch_default(Game *game, const char *args) } player[0].numclothes=0; - game->LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin], + LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin], &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0], &player[0].skeleton.skinsize); @@ -1001,7 +989,7 @@ static void ch_default(Game *game, const char *args) player[0].immobile=0; } -static void ch_play(Game *game, const char *args) +static void ch_play(const char *args) { int dlg; sscanf(args, "%d", &dlg); @@ -1025,49 +1013,49 @@ static void ch_play(Game *game, const char *args) playdialogueboxsound(); } -static void ch_mapkilleveryone(Game *game, const char *args) +static void ch_mapkilleveryone(const char *args) { maptype = mapkilleveryone; } -static void ch_mapkillmost(Game *game, const char *args) +static void ch_mapkillmost(const char *args) { maptype = mapkillmost; } -static void ch_mapkillsomeone(Game *game, const char *args) +static void ch_mapkillsomeone(const char *args) { maptype = mapkillsomeone; } -static void ch_mapgosomewhere(Game *game, const char *args) +static void ch_mapgosomewhere(const char *args) { maptype = mapgosomewhere; } -static void ch_viewdistance(Game *game, const char *args) +static void ch_viewdistance(const char *args) { viewdistance = atof(args)*100; } -static void ch_fadestart(Game *game, const char *args) +static void ch_fadestart(const char *args) { fadestart = atof(args); } -static void ch_slomo(Game *game, const char *args) +static void ch_slomo(const char *args) { slomospeed = atof(args); slomo = !slomo; slomodelay = 1000; } -static void ch_slofreq(Game *game, const char *args) +static void ch_slofreq(const char *args) { slomofreq = atof(args); } -static void ch_skytint(Game *game, const char *args) +static void ch_skytint(const char *args) { sscanf(args, "%f%f%f", &skyboxr, &skyboxg, &skyboxb); @@ -1075,41 +1063,42 @@ static void ch_skytint(Game *game, const char *args) skyboxlightg=skyboxg; skyboxlightb=skyboxb; - game->SetUpLighting(); + SetUpLighting(); terrain.DoShadows(); objects.DoShadows(); } -static void ch_skylight(Game *game, const char *args) +static void ch_skylight(const char *args) { sscanf(args, "%f%f%f", &skyboxlightr, &skyboxlightg, &skyboxlightb); - game->SetUpLighting(); + SetUpLighting(); terrain.DoShadows(); objects.DoShadows(); } -static void ch_skybox(Game *game, const char *args) +static void ch_skybox(const char *args) { skyboxtexture = !skyboxtexture; - game->SetUpLighting(); + SetUpLighting(); terrain.DoShadows(); objects.DoShadows(); } -static void cmd_dispatch(Game *game, const char *cmd) +static void cmd_dispatch(const string cmd) { int i, n_cmds = sizeof(cmd_names) / sizeof(cmd_names[0]); for (i = 0; i < n_cmds; i++) - if (stripfx(cmd, cmd_names[i])) + if (cmd.substr(0,cmd.find(' '))==string(cmd_names[i])) { - cmd_handlers[i](game, cmd + strlen(cmd_names[i])); - break; + cout << "|" << cmd.substr(cmd.find(' ')+1) << "|" << endl; + cmd_handlers[i](cmd.substr(cmd.find(' ')+1).c_str()); + break; } emit_sound_np(i < n_cmds ? consolesuccesssound : consolefailsound); } @@ -1399,22 +1388,22 @@ void Game::Setenvironment(int which) texdetail=temptexdetail; } -void Game::Loadlevel(int which){ +void Game::Loadlevel(int which) { stealthloading=0; whichlevel=which; - if(which == -1){ + if(which == -1) { tutoriallevel = -1; Loadlevel("tutorial"); - }else if(which >= 0 && which <= 15){ + } else if(which >= 0 && which <= 15) { char buf[32]; snprintf(buf, 32, "map%d", which + 1); // challenges Loadlevel(buf); - }else + } else Loadlevel("mapsave"); } -void Game::Loadlevel(const char *name){ +void Game::Loadlevel(const char *name) { int templength; float lamefloat; static const char *pfx = ":Data:Maps:"; @@ -1435,7 +1424,7 @@ void Game::Loadlevel(const char *name){ gamestarted=1; numenvsounds=0; - //visibleloading=1; + if(tutoriallevel!=-1) tutoriallevel=0; else @@ -1443,7 +1432,7 @@ void Game::Loadlevel(const char *name){ if(tutoriallevel==1) tutorialstage=0; - if(tutorialstage==0){ + if(tutorialstage==0) { tutorialstagetime=0; tutorialmaxtime=1; } @@ -1458,11 +1447,14 @@ void Game::Loadlevel(const char *name){ int mapvers; FILE *tfile; + //~ char* buff=getcwd(NULL,0); + //~ cout << buff << " " << FixedFN << endl; + //~ free(buff); tfile=fopen( FixedFN, "rb" ); - if(tfile){ + if(tfile) { pause_sound(stream_firesound); scoreadded=0; - windialogue=0; + windialogue=false; hostiletime=0; won=0; @@ -1549,7 +1541,7 @@ void Game::Loadlevel(const char *name){ LoadingScreen(); } - weapons.numweapons=0; + weapons.clear(); funpackf(tfile, "Bi", &mapvers); if(mapvers>=15) @@ -1592,10 +1584,10 @@ void Game::Loadlevel(const char *name){ player[0].originalcoords=player[0].coords; if(player[0].num_weapons>0&&player[0].num_weapons<5) for(int j=0;j0&&player[i-howmanyremoved].num_weapons<5){ for(int j=0;j0){ - if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff; - else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife; - else weapons.type[player[0].weaponids[0]]=sword; - if(weapons.type[player[0].weaponids[0]]==sword){ - weapons.mass[player[0].weaponids[0]]=1.5; - weapons.tipmass[player[0].weaponids[0]]=1; - weapons.length[player[0].weaponids[0]]=.8; - } - if(weapons.type[player[0].weaponids[0]]==staff){ - weapons.mass[player[0].weaponids[0]]=2; - weapons.tipmass[player[0].weaponids[0]]=1; - weapons.length[player[0].weaponids[0]]=1.5; - } - - if(weapons.type[player[0].weaponids[0]]==knife){ - weapons.mass[player[0].weaponids[0]]=1; - weapons.tipmass[player[0].weaponids[0]]=1.2; - weapons.length[player[0].weaponids[0]]=.25; - } + if(weapons[player[0].weaponids[0]].getType()==sword) + weapons[player[0].weaponids[0]].setType(staff); + else if(weapons[player[0].weaponids[0]].getType()==staff) + weapons[player[0].weaponids[0]].setType(knife); + else + weapons[player[0].weaponids[0]].setType(sword); } } @@ -2570,44 +2507,19 @@ void Game::doDebugKeys(){ } if(closest!=-1){ if(player[closest].num_weapons){ - if(weapons.type[player[closest].weaponids[0]]==sword) - weapons.type[player[closest].weaponids[0]]=staff; - else if(weapons.type[player[closest].weaponids[0]]==staff) - weapons.type[player[closest].weaponids[0]]=knife; - else weapons.type[player[closest].weaponids[0]]=sword; - if(weapons.type[player[closest].weaponids[0]]==sword){ - weapons.mass[player[closest].weaponids[0]]=1.5; - weapons.tipmass[player[closest].weaponids[0]]=1; - weapons.length[player[closest].weaponids[0]]=.8; - } - if(weapons.type[player[0].weaponids[0]]==staff){ - weapons.mass[player[0].weaponids[0]]=2; - weapons.tipmass[player[0].weaponids[0]]=1; - weapons.length[player[0].weaponids[0]]=1.5; - } - if(weapons.type[player[closest].weaponids[0]]==knife){ - weapons.mass[player[closest].weaponids[0]]=1; - weapons.tipmass[player[closest].weaponids[0]]=1.2; - weapons.length[player[closest].weaponids[0]]=.25; - } + if(weapons[player[closest].weaponids[0]].getType()==sword) + weapons[player[closest].weaponids[0]].setType(staff); + else if(weapons[player[closest].weaponids[0]].getType()==staff) + weapons[player[closest].weaponids[0]].setType(knife); + else + weapons[player[closest].weaponids[0]].setType(sword); } if(!player[closest].num_weapons){ - player[closest].weaponids[0]=weapons.numweapons; - weapons.owner[weapons.numweapons]=closest; - weapons.type[weapons.numweapons]=knife; - weapons.damage[weapons.numweapons]=0; - weapons.numweapons++; + player[closest].weaponids[0]=weapons.size(); + + weapons.push_back(Weapon(knife,closest)); + player[closest].num_weapons=1; - if(weapons.type[player[closest].weaponids[0]]==sword){ - weapons.mass[player[closest].weaponids[0]]=1.5; - weapons.tipmass[player[closest].weaponids[0]]=1; - weapons.length[player[closest].weaponids[0]]=.8; - } - if(weapons.type[player[closest].weaponids[0]]==knife){ - weapons.mass[player[closest].weaponids[0]]=1; - weapons.tipmass[player[closest].weaponids[0]]=1.2; - weapons.length[player[closest].weaponids[0]]=.25; - } } } } @@ -2771,7 +2683,7 @@ void Game::doDebugKeys(){ if(closest!=-1){ XYZ headspurtdirection; //int i = player[closest].skeleton.jointlabels[head]; - Joint& headjoint=playerJoint(closest,head); + Joint& headjoint= player[closest].getJointFor(head); for(int k=0;k25){ - setAnimation(k,hanganim); + player[k].setAnimation(hanganim); player[k].jumppower=0; } } @@ -3759,7 +3671,7 @@ void Game::doAerialAcrobatics(){ //stagger off ledge (?) if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim) player[k].RagDoll(0); - setAnimation(k,jumpdownanim); + player[k].setAnimation(jumpdownanim); if(!k) emit_sound_at(whooshsound, player[k].coords, 128.); @@ -3834,14 +3746,14 @@ void Game::doAttacks(){ player[i].targetanimation==staffhitanim|| player[i].targetanimation==staffspinhitanim) if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){ - setAnimation(k,dodgebackanim); + player[k].setAnimation(dodgebackanim); player[k].targetrotation=roughDirectionTo(player[k].coords,player[i].coords); player[k].targettilt2=pitchTo(player[k].coords,player[i].coords); } } if(player[k].targetanimation!=dodgebackanim){ if(k==0)numflipped++; - setAnimation(k,backhandspringanim); + player[k].setAnimation(backhandspringanim); player[k].targetrotation=-rotation+180; if(player[k].leftkeydown) player[k].targetrotation-=45; @@ -3860,7 +3772,7 @@ void Game::doAttacks(){ player[k].targetanimation==walkanim|| player[k].targetanimation==sneakanim|| player[k].isCrouch())){ - const int attackweapon=player[k].weaponactive==-1?0:weapons.type[player[k].weaponids[player[k].weaponactive]]; + const int attackweapon=player[k].weaponactive==-1?0:weapons[player[k].weaponids[player[k].weaponactive]].getType(); //normal attacks (?) player[k].hasvictim=0; if(numplayers>1) @@ -4232,8 +4144,8 @@ void Game::doAttacks(){ if(player[k].targetanimation==crouchstabanim|| player[k].targetanimation==swordgroundstabanim|| player[k].targetanimation==staffgroundsmashanim){ - targetpoint+=(playerJoint(i,abdomen).position+ - playerJoint(i,neck).position)/2* + targetpoint+=(player[i].getJointFor(abdomen).position+ + player[i].getJointFor(neck).position)/2* player[i].scale; } player[k].targetrotation=roughDirectionTo(player[k].coords,targetpoint); @@ -4289,7 +4201,7 @@ void Game::doAttacks(){ player[k].rabbitkickenabled)|| player[k].jumpkeydown)){ oldattackkey=1; - setAnimation(k,rabbitkickanim); + player[k].setAnimation(rabbitkickanim); } //update counts if(animation[player[k].targetanimation].attack&&k==0){ @@ -4353,9 +4265,9 @@ void Game::doPlayerCollisions(){ XYZ tempcoords1=player[i].coords; XYZ tempcoords2=player[k].coords; if(!player[i].skeleton.oldfree) - tempcoords1.y+=playerJoint(i,abdomen).position.y*player[i].scale; + tempcoords1.y+=player[i].getJointFor(abdomen).position.y*player[i].scale; if(!player[k].skeleton.oldfree) - tempcoords2.y+=playerJoint(k,abdomen).position.y*player[k].scale; + tempcoords2.y+=player[k].getJointFor(abdomen).position.y*player[k].scale; collisionradius=1.2*sq((player[i].scale+player[k].scale)*2.5); if(player[0].hasvictim) if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free) @@ -4449,18 +4361,18 @@ void Game::doPlayerCollisions(){ if(player[k].howactive==typeactive||hostile) if(player[k].isIdle()){ if(player[k].howactive.8&&!player[i].jumpkeydown&&player[i].collided<.8) + if(player[i].avoidcollided>.8 && !player[i].jumpkeydown && player[i].collided<.8) player[i].targetrotation+=90*(player[i].whichdirection*2-1); if(player[i].collided<1||player[i].targetanimation!=jumpupanim) @@ -4676,9 +4588,9 @@ void Game::doAI(int i){ if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0) if(player[j].coords.y0)){ float smelldistance=50; if(j==0&&player[j].num_weapons>0){ - if(weapons.bloody[player[j].weaponids[0]]) + if(weapons[player[j].weaponids[0]].bloody) smelldistance=100; if(player[j].num_weapons==2) - if(weapons.bloody[player[j].weaponids[1]]) + if(weapons[player[j].weaponids[1]].bloody) smelldistance=100; } if(j!=0) @@ -4819,9 +4731,9 @@ void Game::doAI(int i){ if(findDistancefast(&player[i].coords,&player[j].coords)<400) if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0) if((-1==checkcollide( - DoRotation(playerJoint(i,head).position,0,player[i].rotation,0)* + DoRotation(player[i].getJointFor(head).position,0,player[i].rotation,0)* player[i].scale+player[i].coords, - DoRotation(playerJoint(j,head).position,0,player[j].rotation,0)* + DoRotation(player[j].getJointFor(head).position,0,player[j].rotation,0)* player[j].scale+player[j].coords)&& !player[j].isWallJump())|| (player[j].targetanimation==hanganim&& @@ -4876,7 +4788,7 @@ void Game::doAI(int i){ j=checkcollide(test2,test); if(j==-1){ player[i].velocity=0; - setAnimation(i,player[i].getStop()); + player[i].setAnimation(player[i].getStop()); player[i].targetrotation+=180; player[i].stunned=.5; //player[i].aitype=passivetype; @@ -4955,9 +4867,9 @@ void Game::doAI(int i){ if(findDistancefast(&player[i].coords,&player[0].coords)<400) if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0) if((checkcollide( - DoRotation(playerJoint(i,head).position,0,player[i].rotation,0)* + DoRotation(player[i].getJointFor(head).position,0,player[i].rotation,0)* player[i].scale+player[i].coords, - DoRotation(playerJoint(0,head).position,0,player[0].rotation,0)* + DoRotation(player[0].getJointFor(head).position,0,player[0].rotation,0)* player[0].scale+player[0].coords)==-1)|| (player[0].targetanimation==hanganim&&normaldotproduct( player[0].facing,player[i].coords-player[0].coords)<0)){ @@ -4988,25 +4900,25 @@ void Game::doAI(int i){ player[i].runninghowlong=0; //get help from buddies - if(player[i].aitype==gethelptype){ + if(player[i].aitype==gethelptype) { player[i].runninghowlong+=multiplier; player[i].aiupdatedelay-=multiplier; - if(player[i].aiupdatedelay<0||player[i].ally==0){ + if(player[i].aiupdatedelay<0||player[i].ally==0) { player[i].aiupdatedelay=.2; //find closest ally //TODO: factor out closest search somehow - if(!player[i].ally){ + if(!player[i].ally) { int closest=-1; float closestdist=-1; - for(int k=0;k=0){ - if(weapons.owner[player[i].ally]!=-1|| - findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){ + if(weapons[player[i].ally].owner!=-1|| + findDistancefast(&player[i].coords,&weapons[player[i].ally].position)>16){ player[i].aitype=attacktypecutoff; player[i].lastseentime=1; } //TODO: factor these out as moveToward() - player[i].targetrotation=roughDirectionTo(player[i].coords,weapons.position[player[i].ally]); + player[i].targetrotation=roughDirectionTo(player[i].coords,weapons[player[i].ally].position); player[i].lookrotation=player[i].targetrotation; player[i].aiupdatedelay=.05; player[i].forwardkeydown=1; @@ -5185,17 +5097,17 @@ void Game::doAI(int i){ if(player[i].isIdle()) player[i].crouchkeydown=1; if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){ - if(weapons.type[player[0].weaponids[0]]==knife){ + if(weapons[player[0].weaponids[0]].getType()==knife){ if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){ if(abs(Random()%2==0)) - setAnimation(i,backhandspringanim); + player[i].setAnimation(backhandspringanim); else - setAnimation(i,rollanim); + player[i].setAnimation(rollanim); player[i].targetrotation+=90*(abs(Random()%2)*2-1); player[i].wentforweapon=0; } if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim) - setAnimation(i,flipanim); + player[i].setAnimation(flipanim); } } player[i].forwardkeydown=0; @@ -5212,14 +5124,14 @@ void Game::doAI(int i){ } //go for weapon on the ground if(player[i].wentforweapon<3) - for(int k=0;k=2) if(-1!=checkcollide(facing,flatfacing)){ if(!player[i].pause) @@ -5483,6 +5395,64 @@ void Game::doAI(int i){ } } + + +void updateSettingsMenu(){ + char sbuf[256]; + if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59) + sprintf (sbuf, "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight); + else + sprintf (sbuf, "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight); + Menu::setText(0,sbuf); + if(newdetail==0) Menu::setText(1,"Detail: Low"); + if(newdetail==1) Menu::setText(1,"Detail: Medium"); + if(newdetail==2) Menu::setText(1,"Detail: High"); + if(bloodtoggle==0) Menu::setText(2,"Blood: Off"); + if(bloodtoggle==1) Menu::setText(2,"Blood: On, low detail"); + if(bloodtoggle==2) Menu::setText(2,"Blood: On, high detail (slower)"); + if(difficulty==0) Menu::setText(3,"Difficulty: Easier"); + if(difficulty==1) Menu::setText(3,"Difficulty: Difficult"); + if(difficulty==2) Menu::setText(3,"Difficulty: Insane"); + Menu::setText(4,ismotionblur?"Blur Effects: Enabled (less compatible)":"Blur Effects: Disabled (more compatible)"); + Menu::setText(5,decals?"Decals: Enabled (slower)":"Decals: Disabled"); + Menu::setText(6,musictoggle?"Music: Enabled":"Music: Disabled"); + Menu::setText(9,invertmouse?"Invert mouse: Yes":"Invert mouse: No"); + sprintf (sbuf, "Mouse Speed: %d", (int)(usermousesensitivity*5)); + Menu::setText(10,sbuf); + sprintf (sbuf, "Volume: %d%%", (int)(volume*100)); + Menu::setText(11,sbuf); + Menu::setText(13,showdamagebar?"Damage Bar: On":"Damage Bar: Off"); + if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth) + sprintf (sbuf, "Back"); + else + sprintf (sbuf, "Back (some changes take effect next time Lugaru is opened)"); + Menu::setText(8,sbuf); +} + +void updateStereoConfigMenu(){ + char sbuf[256]; + sprintf(sbuf, "Stereo mode: %s", StereoModeName(newstereomode)); + Menu::setText(0,sbuf); + sprintf(sbuf, "Stereo separation: %.3f", stereoseparation); + Menu::setText(1,sbuf); + sprintf(sbuf, "Reverse stereo: %s", stereoreverse ? "Yes" : "No"); + Menu::setText(2,sbuf); +} + +void updateControlsMenu(){ + Menu::setText(0,(string)"Forwards: "+(keyselect==0?"_":Input::keyToChar(forwardkey))); + Menu::setText(1,(string)"Back: " +(keyselect==1?"_":Input::keyToChar(backkey))); + Menu::setText(2,(string)"Left: " +(keyselect==2?"_":Input::keyToChar(leftkey))); + Menu::setText(3,(string)"Right: " +(keyselect==3?"_":Input::keyToChar(rightkey))); + Menu::setText(4,(string)"Crouch: " +(keyselect==4?"_":Input::keyToChar(crouchkey))); + Menu::setText(5,(string)"Jump: " +(keyselect==5?"_":Input::keyToChar(jumpkey))); + Menu::setText(6,(string)"Draw: " +(keyselect==6?"_":Input::keyToChar(drawkey))); + Menu::setText(7,(string)"Throw: " +(keyselect==7?"_":Input::keyToChar(throwkey))); + Menu::setText(8,(string)"Attack: " +(keyselect==8?"_":Input::keyToChar(attackkey))); + if(debugmode) + Menu::setText(9,(string)"Console: "+(keyselect==9?"_":Input::keyToChar(consolekey))); +} + /* Values of mainmenu : 1 Main menu @@ -5498,10 +5468,155 @@ Values of mainmenu : 11 Same that 9 ??? => unused 18 stereo configuration */ - + +void Game::LoadMenu(){ + Menu::clearMenu(); + switch(mainmenu) { + case 1: + case 2: + Menu::addImage(0,Mainmenuitems[0],150,480-128,256,128); + Menu::addButtonImage(1,Mainmenuitems[mainmenu==1?1:5],18,480-152-32,128,32); + Menu::addButtonImage(2,Mainmenuitems[2],18,480-228-32,112,32); + Menu::addButtonImage(3,Mainmenuitems[mainmenu==1?3:6],18,480-306-32,mainmenu==1?68:132,32); + break; + case 3: + Menu::addButton( 0,"",10+20,440); + Menu::addButton( 1,"",10+60,405); + Menu::addButton( 2,"",10+70,370); + Menu::addButton( 3,"",10+20-1000,335-1000); + Menu::addButton( 4,"",10 ,335); + Menu::addButton( 5,"",10+60,300); + Menu::addButton( 6,"",10+70,265); + Menu::addButton( 9,"",10 ,230); + Menu::addButton(10,"",20 ,195); + Menu::addButton(11,"",10+60,160); + Menu::addButton(13,"",30 ,125); + Menu::addButton( 7,"-Configure Controls-",10+15, 90); + Menu::addButton(12,"-Configure Stereo -",10+15, 55); + Menu::addButton(8,"Back",10,10); + updateSettingsMenu(); + break; + case 4: + Menu::addButton(0,"",10 ,400); + Menu::addButton(1,"",10+40,360); + Menu::addButton(2,"",10+40,320); + Menu::addButton(3,"",10+30,280); + Menu::addButton(4,"",10+20,240); + Menu::addButton(5,"",10+40,200); + Menu::addButton(6,"",10+40,160); + Menu::addButton(7,"",10+30,120); + Menu::addButton(8,"",10+20,80); + if(debugmode) + Menu::addButton(9,"",10+10,40); + Menu::addButton(debugmode?10:9,"Back",10,10); + updateControlsMenu(); + break; + case 5: { + LoadCampaign(); + Menu::addLabel(-1,accountactive->getName(),5,400); + Menu::addButton(1,"Tutorial",5,300); + Menu::addButton(2,"Challenge",5,240); + Menu::addButton(3,"Delete User",400,10); + Menu::addButton(4,"Main Menu",5,10); + Menu::addButton(5,"Change User",5,180); + Menu::addButton(6,"Campaign : "+accountactive->getCurrentCampaign(),200,420); + + //show campaign map + //with (2,-5) offset from old code + Menu::addImage(-1,Mainmenuitems[7],150+2,60-5,400,400); + //show levels + int numlevels = accountactive->getCampaignChoicesMade(); + numlevels += numlevels>0 ? campaignlevels[numlevels-1].nextlevel.size() : 1; + for(int i=0;i=accountactive->getCampaignChoicesMade(); + if(!active) + itemsize/=2; + + if(i>=1){ + XYZ start=campaignlevels[i-1].getCenter(); + Menu::addMapLine(start.x,start.y,midpoint.x-start.x,midpoint.y-start.y,0.5,active?1:0.5,active?1:0.5,0,0); + } + Menu::addMapMarker(NB_CAMPAIGN_MENU_ITEM+i, Mapcircletexture, + midpoint.x-itemsize/2, midpoint.y-itemsize/2, itemsize, itemsize, active?1:0.5, 0, 0); + + if(active){ + Menu::addMapLabel(-2,campaignlevels[i].description, + campaignlevels[i].getStartX()+10, + campaignlevels[i].getStartY()-4); + } + } + } break; + case 6: + Menu::addLabel(-1,"Are you sure you want to delete this user?",10,400); + Menu::addButton(1,"Yes",10,360); + Menu::addButton(2,"No",10,320); + break; + case 7: + if(Account::getNbAccounts()<8) + Menu::addButton(0,"New User",10,400); + else + Menu::addLabel(0,"No More Users",10,400); + Menu::addLabel(-2,"",20,400); + Menu::addButton(Account::getNbAccounts()+1,"Back",10,10); + for(int i=0;igetName(),10,340-20*(i+1)); + break; + case 8: + Menu::addButton(0,"Easier",10,400); + Menu::addButton(1,"Difficult",10,360); + Menu::addButton(2,"Insane",10,320); + break; + case 9: + for(int i=0;igetHighScore(i)); + for(int j=strlen(temp);j<(32-17);j++) + strcat(temp," "); + name+=temp; + sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(i)-(int)(accountactive->getFastTime(i))%60)/60)); + if((int)(accountactive->getFastTime(i))%60<10)strcat(temp,"0"); + name+=temp; + sprintf (temp, "%d",(int)(accountactive->getFastTime(i))%60); + name+=temp; + + Menu::addButton(i,name,10,400-i*25,i>accountactive->getProgress()?0.5:1,0,0); + } + + Menu::addButton(-1," High Score Best Time",10,440); + Menu::addButton(numchallengelevels,"Back",10,10); + break; + case 10: { + Menu::addLabel(0,"Congratulations!",220,330); + Menu::addLabel(1,"You have avenged your family and",140,300); + Menu::addLabel(2,"restored peace to the island of Lugaru.",110,270); + Menu::addButton(3,"Back",10,10); + char sbuf[256]; + sprintf(sbuf,"Your score: %d",(int)accountactive->getCampaignScore()); + Menu::addLabel(4,sbuf,190,200); + sprintf(sbuf,"Highest score: %d",(int)accountactive->getCampaignHighScore()); + Menu::addLabel(5,sbuf,190,180); + } break; + case 18: + Menu::addButton(0,"",70,400); + Menu::addButton(1,"",10,360); + Menu::addButton(2,"",40,320); + Menu::addButton(3,"Back",10,10); + updateStereoConfigMenu(); + break; + } +} + void Game::MenuTick(){ //menu buttons - + selected=Menu::getSelected(mousecoordh*640/screenwidth,480-mousecoordv*480/screenheight); + // some specific case where we do something even if the left mouse button is not pressed. if((mainmenu==5) && (endgame==2)) { accountactive->endGame(); @@ -5509,9 +5624,15 @@ void Game::MenuTick(){ } if(mainmenu==10) endgame=2; - if( (mainmenu==18) && Input::isKeyPressed(MOUSEBUTTON2) && (selected==1) ) + if(mainmenu==18 && Input::isKeyPressed(MOUSEBUTTON2) && selected==1){ stereoseparation-=0.001; - + updateStereoConfigMenu(); + } + + static int oldmainmenu=mainmenu; + + char sbuf[256]; + if(Input::MouseClicked() && (selected >= 0)) { // handling of the left mouse clic in menus switch(mainmenu) { case 1: @@ -5611,7 +5732,6 @@ void Game::MenuTick(){ break; case 6: musictoggle = !musictoggle; - if(musictoggle) { emit_stream_np(stream_menutheme); } else { @@ -5624,7 +5744,6 @@ void Game::MenuTick(){ musicvolume[i]=0; } } - break; case 7: // controls flash(); @@ -5634,8 +5753,7 @@ void Game::MenuTick(){ break; case 8: flash(); - - SaveSettings(*this); + SaveSettings(); mainmenu=gameon?2:1; break; case 9: @@ -5643,16 +5761,17 @@ void Game::MenuTick(){ break; case 10: usermousesensitivity+=.2; - if(usermousesensitivity>2) usermousesensitivity=.2; + if(usermousesensitivity>2) + usermousesensitivity=.2; break; case 11: volume+=.1f; - if(volume>1.0001f) volume=0; + if(volume>1.0001f) + volume=0; OPENAL_SetSFXMasterVolume((int)(volume*255)); break; case 12: flash(); - newstereomode = stereomode; mainmenu=18; keyselect=-1; @@ -5661,25 +5780,26 @@ void Game::MenuTick(){ showdamagebar = !showdamagebar; break; } + updateSettingsMenu(); break; case 4: if(!waiting) { fireSound(); - if(selected<9 && keyselect==-1) + if(selected<(debugmode?10:9) && keyselect==-1) keyselect=selected; if(keyselect!=-1) setKeySelected(); - if(selected==9){ + if(selected==(debugmode?10:9)){ flash(); - mainmenu=3; } } + updateControlsMenu(); break; case 5: fireSound(); flash(); - if((selected-NB_CAMPAIGN_MENU_ITEM-1 >= accountactive->getCampaignChoicesMade())) { + if((selected-NB_CAMPAIGN_MENU_ITEM >= accountactive->getCampaignChoicesMade())) { startbonustotal=0; loading=2; @@ -5689,10 +5809,11 @@ void Game::MenuTick(){ TickOnceAfter(); else LoadStuff(); - whichchoice=selected-NB_CAMPAIGN_MENU_ITEM-1-accountactive->getCampaignChoicesMade(); + whichchoice=selected-NB_CAMPAIGN_MENU_ITEM-accountactive->getCampaignChoicesMade(); + actuallevel=(accountactive->getCampaignChoicesMade()>0?campaignlevels[accountactive->getCampaignChoicesMade()-1].nextlevel[whichchoice]:0); visibleloading=1; stillloading=1; - Loadlevel(campaignmapname[campaignchoicewhich[whichchoice]]); + Loadlevel(campaignlevels[actuallevel].mapname.c_str()); campaign=1; mainmenu=0; gameon=1; @@ -5707,9 +5828,9 @@ void Game::MenuTick(){ targetlevel=-1; if(firstload) { TickOnceAfter(); - Loadlevel(-1); } else LoadStuff(); + Loadlevel(-1); mainmenu=0; gameon=1; @@ -5739,10 +5860,7 @@ void Game::MenuTick(){ c=campaigns.begin(); accountactive->setCurrentCampaign(*c); } - if(Mainmenuitems[7]) - glDeleteTextures(1,&Mainmenuitems[7]); // we delete the world texture so load campaign will reload it - Mainmenuitems[7] = 0; - LoadCampaign(); + LoadMenu(); break; } break; @@ -5767,7 +5885,10 @@ void Game::MenuTick(){ accountactive=Account::get(selected-1); } else if (selected == Account::getNbAccounts()+1) { flash(); - mainmenu=5; + if(accountactive) + mainmenu=5; + else + mainmenu=1; for(int j=0;j<255;j++){ displaytext[0][j]=0; } @@ -5793,9 +5914,11 @@ void Game::MenuTick(){ loading=2; loadtime=0; targetlevel=selected; - if(firstload)TickOnceAfter(); - if(!firstload)LoadStuff(); - else Loadlevel(selected); + if(firstload) + TickOnceAfter(); + else + LoadStuff(); + Loadlevel(selected); campaign=0; mainmenu=0; @@ -5838,6 +5961,7 @@ void Game::MenuTick(){ InitStereo(stereomode); } } + updateStereoConfigMenu(); break; } } @@ -5845,13 +5969,13 @@ void Game::MenuTick(){ if(Input::isKeyDown(SDLK_q) && Input::isKeyDown(SDLK_LMETA)){ tryquit=1; if(mainmenu==3) { - SaveSettings(*this); + SaveSettings(); } } OPENAL_SetFrequency(channels[stream_menutheme], 22050); - if(entername) { + if(entername){ inputText(displaytext[0],&displayselected,&displaychars[0]); if(!waiting) { // the input as finished if(displaychars[0]){ // with enter @@ -5879,6 +6003,16 @@ void Game::MenuTick(){ displayblink=1-displayblink; } } + + if(entername){ + Menu::setText(0,displaytext[0],20,400,-1,-1); + Menu::setText(-2,displayblink?"_":"",20+displayselected*10,400,-1,-1); + } + + if(oldmainmenu!=mainmenu) + LoadMenu(); + oldmainmenu=mainmenu; + } void Game::Tick(){ @@ -5948,18 +6082,18 @@ void Game::Tick(){ if(mainmenu&&endgame==1) mainmenu=10; //go to level select after completing a campaign level - if(campaign&&winfreeze&&mainmenu==0&&campaignchoosenext[campaignchoicewhich[whichchoice]]==1) { + if(campaign&&winfreeze&&mainmenu==0&&campaignlevels[actuallevel].choosenext==1) { mainmenu=5; gameon=0; winfreeze=0; fireSound(); flash(); - if(musictoggle){ + if(musictoggle) { OPENAL_SetFrequency(OPENAL_ALL, 0.001); emit_stream_np(stream_menutheme); pause_sound(leveltheme); } - LoadCampaign(); + LoadMenu(); } //escape key pressed //TODO: there must be code somewhere else that handles clicking the Back button, merge it with this @@ -5984,7 +6118,7 @@ void Game::Tick(){ } //finished with settings menu if(mainmenu==3){ - SaveSettings(*this); + SaveSettings(); } //effects if(mainmenu>=3&&mainmenu!=8){ @@ -6044,9 +6178,9 @@ void Game::Tick(){ if(chatting) keyboardfrozen=true; - if(Input::isKeyPressed(SDLK_BACKQUOTE)&&debugmode){ + if(Input::isKeyPressed(consolekey)&&debugmode) { console=!console; - if(console){ + if(console) { OPENAL_SetFrequency(OPENAL_ALL, 0.001); } else { freeze=0; @@ -6056,14 +6190,14 @@ void Game::Tick(){ if(console) freeze=1; - if(console&&!Input::isKeyDown(SDLK_LMETA)){ + if(console&&!Input::isKeyDown(SDLK_LMETA)) { inputText(consoletext[0],&consoleselected,&consolechars[0]); if(!waiting) { archiveselected=0; - if(consolechars[0]>0){ - consoletext[0][consolechars[0]]=' '; - cmd_dispatch(this, consoletext[0]); - for(int k=14;k>=1;k--){ + if(consolechars[0]>0) { + consoletext[0][consolechars[0]]='\0'; + cmd_dispatch(consoletext[0]); + for(int k=14;k>=1;k--) { for(int j=0;j<255;j++) consoletext[k][j]=consoletext[k-1][j]; consolechars[k]=consolechars[k-1]; @@ -6076,7 +6210,7 @@ void Game::Tick(){ } consoleblinkdelay-=multiplier; - if(consoleblinkdelay<=0){ + if(consoleblinkdelay<=0) { consoleblinkdelay=.3; consoleblink=1-consoleblink; } @@ -6087,7 +6221,7 @@ void Game::Tick(){ if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){ tryquit=1; if(mainmenu==3) { - SaveSettings(*this); + SaveSettings(); } } @@ -6454,7 +6588,7 @@ void Game::Tick(){ hostile=1; } if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){ - windialogue=1; + windialogue=true; } if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){ hostile=1; @@ -6706,39 +6840,39 @@ void Game::Tick(){ player[i].isFlip()|| player[i].isFlip()|| player[i].aitype!=playercontrolled)){ - for(int j=0;jid) - 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){ - if(weapons.type[j]!=staff) + weapons[j].owner==player[i].victim->id) + if(findDistancefastflat(&player[i].coords,&weapons[j].position)<2&&player[i].weaponactive==-1) + if(findDistancefast(&player[i].coords,&weapons[j].position)<1||player[i].victim){ + if(weapons[j].getType()!=staff) emit_sound_at(knifedrawsound, player[i].coords, 128.); player[i].weaponactive=0; - weapons.owner[j]=player[i].id; + weapons[j].owner=player[i].id; if(player[i].num_weapons>0) player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0]; player[i].num_weapons++; @@ -6748,31 +6882,31 @@ void Game::Tick(){ }else if((player[i].isIdle()|| player[i].isFlip()|| player[i].aitype!=playercontrolled)&& - findDistancefast(&player[i].coords,&weapons.position[j])<5&& - player[i].coords.yid) - if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&& + weapons[k].owner==player[i].victim->id) + if(findDistancefastflat(&player[i].coords,&weapons[k].position)<3&& player[i].weaponactive==-1){ - if(weapons.type[k]!=staff) + if(weapons[k].getType()!=staff) emit_sound_at(knifedrawsound, player[i].coords, 128.); player[i].weaponactive=0; - weapons.owner[k]=player[i].id; + weapons[k].owner=player[i].id; if(player[i].num_weapons>0) player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0]; player[i].num_weapons++; @@ -6805,7 +6939,7 @@ void Game::Tick(){ player[i].throwtogglekeydown=1; player[i].victim=&player[j]; player[i].hasvictim=1; - setAnimation(i,crouchremoveknifeanim); + player[i].setAnimation(crouchremoveknifeanim); player[i].targetrotation=roughDirectionTo(player[i].coords,player[j].coords); } if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){ @@ -6822,14 +6956,14 @@ void Game::Tick(){ } } if(!fleshstuck){ - if(weapons.type[k]!=staff) + if(weapons[k].getType()!=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){ + if(weapons[k].owner!=-1){ if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0; else player[i].victim->num_weapons=1; @@ -6848,12 +6982,12 @@ void Game::Tick(){ Normalise(&relative); XYZ footvel,footpoint; footvel=0; - footpoint=weapons.position[k]; + footpoint=weapons[k].position; if(player[i].victim->weaponstuck!=-1){ if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3); - weapons.bloody[k]=2; - weapons.blooddrip[k]=5; + weapons[k].bloody=2; + weapons[k].blooddrip=5; player[i].victim->weaponstuck=-1; player[i].victim->bloodloss+=2000; player[i].victim->DoDamage(2000); @@ -6867,12 +7001,12 @@ void Game::Tick(){ player[i].victim->weaponactive=-1; - playerJoint(player[i].victim,abdomen).velocity+=relative*6; - playerJoint(player[i].victim,neck).velocity+=relative*6; - playerJoint(player[i].victim,rightshoulder).velocity+=relative*6; - playerJoint(player[i].victim,leftshoulder).velocity+=relative*6; + player[i].victim->getJointFor(abdomen).velocity+=relative*6; + player[i].victim->getJointFor(neck).velocity+=relative*6; + player[i].victim->getJointFor(rightshoulder).velocity+=relative*6; + player[i].victim->getJointFor(leftshoulder).velocity+=relative*6; } - weapons.owner[k]=i; + weapons[k].owner=i; if(player[i].num_weapons>0){ player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0]; } @@ -6885,7 +7019,7 @@ void Game::Tick(){ } } if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){ - if(weapons.type[player[i].weaponids[0]]==knife){ + if(weapons[player[i].weaponids[0]].getType()==knife){ if(player[i].isIdle()|| player[i].isRun()|| player[i].isCrouch()|| @@ -6900,11 +7034,11 @@ void Game::Tick(){ findDistancefast(&player[i].coords,&player[j].coords)<100&& findDistancefast(&player[i].coords,&player[j].coords)>1.5&& !player[j].skeleton.free&& - -1==checkcollide(DoRotation(playerJoint(j,head).position,0,player[j].rotation,0)*player[j].scale+player[j].coords,DoRotation(playerJoint(i,head).position,0,player[i].rotation,0)*player[i].scale+player[i].coords)){ + -1==checkcollide(DoRotation(player[j].getJointFor(head).position,0,player[j].rotation,0)*player[j].scale+player[j].coords,DoRotation(player[i].getJointFor(head).position,0,player[i].rotation,0)*player[i].scale+player[i].coords)){ if(!player[i].isFlip()){ player[i].throwtogglekeydown=1; player[i].victim=&player[j]; - setAnimation(i,knifethrowanim); + player[i].setAnimation(knifethrowanim); player[i].targetrotation=roughDirectionTo(player[i].coords,player[j].coords); player[i].targettilt2=pitchTo(player[i].coords,player[j].coords); } @@ -6913,18 +7047,18 @@ void Game::Tick(){ player[i].throwtogglekeydown=1; player[i].victim=&player[j]; XYZ aim; - weapons.owner[player[i].weaponids[0]]=-1; - aim=player[i].victim->coords+DoRotation(playerJoint(player[i].victim,abdomen).position,0,player[i].victim->rotation,0)*player[i].victim->scale+player[i].victim->velocity*findDistance(&player[i].victim->coords,&player[i].coords)/50-(player[i].coords+DoRotation(playerJoint(i,righthand).position,0,player[i].rotation,0)*player[i].scale); + weapons[player[i].weaponids[0]].owner=-1; + aim=player[i].victim->coords+DoRotation(player[i].victim->getJointFor(abdomen).position,0,player[i].victim->rotation,0)*player[i].victim->scale+player[i].victim->velocity*findDistance(&player[i].victim->coords,&player[i].coords)/50-(player[i].coords+DoRotation(player[i].getJointFor(righthand).position,0,player[i].rotation,0)*player[i].scale); Normalise(&aim); aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0); - weapons.velocity[player[i].weaponids[0]]=aim*50; - weapons.tipvelocity[player[i].weaponids[0]]=aim*50; - weapons.missed[player[i].weaponids[0]]=0; - weapons.freetime[player[i].weaponids[0]]=0; - weapons.firstfree[player[i].weaponids[0]]=1; - weapons.physics[player[i].weaponids[0]]=0; + weapons[player[i].weaponids[0]].velocity=aim*50; + weapons[player[i].weaponids[0]].tipvelocity=aim*50; + weapons[player[i].weaponids[0]].missed=0; + weapons[player[i].weaponids[0]].freetime=0; + weapons[player[i].weaponids[0]].firstfree=1; + weapons[player[i].weaponids[0]].physics=0; player[i].num_weapons--; if(player[i].num_weapons){ player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons]; @@ -6939,14 +7073,14 @@ void Game::Tick(){ if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){ if(player[i].isCrouch()||player[i].targetanimation==sneakanim){ player[i].throwtogglekeydown=1; - weapons.owner[player[i].weaponids[0]]=-1; - weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2; - if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1; - weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]]; - weapons.missed[player[i].weaponids[0]]=1; - weapons.freetime[player[i].weaponids[0]]=0; - weapons.firstfree[player[i].weaponids[0]]=1; - weapons.physics[player[i].weaponids[0]]=1; + weapons[player[i].weaponids[0]].owner=-1; + weapons[player[i].weaponids[0]].velocity=player[i].velocity*.2; + if(weapons[player[i].weaponids[0]].velocity.x==0)weapons[player[i].weaponids[0]].velocity.x=.1; + weapons[player[i].weaponids[0]].tipvelocity=weapons[player[i].weaponids[0]].velocity; + weapons[player[i].weaponids[0]].missed=1; + weapons[player[i].weaponids[0]].freetime=0; + weapons[player[i].weaponids[0]].firstfree=1; + weapons[player[i].weaponids[0]].physics=1; player[i].num_weapons--; if(player[i].num_weapons){ player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons]; @@ -6963,21 +7097,21 @@ void Game::Tick(){ } //draw weapon - if(i==0||!player[0].dead||player[i].weaponactive!=-1) + if(i==0||!player[0].dead||player[i].weaponactive!=-1) { if(player[i].drawkeydown&&!player[i].drawtogglekeydown|| player[i].num_weapons==2&& player[i].weaponactive==-1&& player[i].isIdle()|| player[0].dead&& player[i].weaponactive!=-1&& - i!=0){ - bool isgood=1; + i!=0) { + bool isgood=true; if(player[i].weaponactive!=-1) - if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff) - isgood=0; + if(weapons[player[i].weaponids[player[i].weaponactive]].getType()==staff) + isgood=false; if(isgood&&player[i].creature!=wolftype){ - if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){ - setAnimation(i,drawrightanim); + if(player[i].isIdle()&&player[i].num_weapons&&weapons[player[i].weaponids[0]].getType()==knife){ + player[i].setAnimation(drawrightanim); player[i].drawtogglekeydown=1; } if((player[i].isIdle()|| @@ -6985,47 +7119,46 @@ void Game::Tick(){ player[0].weaponactive!=-1&& player[i].isRun()))&& player[i].num_weapons&& - weapons.type[player[i].weaponids[0]]==sword){ - setAnimation(i,drawleftanim); + weapons[player[i].weaponids[0]].getType()==sword){ + player[i].setAnimation(drawleftanim); player[i].drawtogglekeydown=1; } - if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){ - setAnimation(i,crouchdrawrightanim); + if(player[i].isCrouch()&&player[i].num_weapons&&weapons[player[i].weaponids[0]].getType()==knife){ + player[i].setAnimation(crouchdrawrightanim); player[i].drawtogglekeydown=1; } } } - //clean weapon - if(player[i].isCrouch()&& - weapons.bloody[player[i].weaponids[player[i].weaponactive]]&& - bloodtoggle&& - player[i].onterrain&& - player[i].num_weapons&& - player[i].weaponactive!=-1&& - player[i].attackkeydown){ - if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&& - player[i].onterrain&& - bloodtoggle&&musictype!=stream_fighttheme){ - if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife) - setAnimation(i,crouchstabanim); - if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword) - setAnimation(i,swordgroundstabanim); - player[i].hasvictim=0; - //player[i].attacktogglekeydown=1; - } } + + //clean weapon + if(player[i].weaponactive!=-1) { + if (player[i].isCrouch()&& + weapons[player[i].weaponids[player[i].weaponactive]].bloody&& + bloodtoggle&& + player[i].onterrain&& + player[i].num_weapons&& + player[i].attackkeydown&& + musictype!=stream_fighttheme) { + if(weapons[player[i].weaponids[player[i].weaponactive]].getType()==knife) + player[i].setAnimation(crouchstabanim); + if(weapons[player[i].weaponids[player[i].weaponactive]].getType()==sword) + player[i].setAnimation(swordgroundstabanim); + player[i].hasvictim=0; + } + } if(!player[i].drawkeydown) player[i].drawtogglekeydown=0; XYZ absflatfacing; - if(i==0){ + if(i==0) { absflatfacing=0; absflatfacing.z=-1; absflatfacing=DoRotation(absflatfacing,0,-rotation,0); - } - else absflatfacing=flatfacing; + } else + absflatfacing=flatfacing; if(indialogue!=-1){ player[i].forwardkeydown=0; @@ -7083,7 +7216,7 @@ void Game::Tick(){ player[i].lowreversaldelay=.5; if(player[i].isIdle()){ - setAnimation(i,player[i].getCrouch()); + player[i].setAnimation(player[i].getCrouch()); player[i].transspeed=10; } if(player[i].isRun()|| @@ -7092,7 +7225,7 @@ void Game::Tick(){ player[i].rightkeydown|| player[i].forwardkeydown|| player[i].backkeydown))){ - setAnimation(i,rollanim); + player[i].setAnimation(rollanim); player[i].transspeed=20; } } @@ -7127,12 +7260,12 @@ void Game::Tick(){ player[i].currentanimation=player[i].getCrouch(); player[i].currentframe=0; } - setAnimation(i,player[i].getIdle()); + player[i].setAnimation(player[i].getIdle()); player[i].transspeed=10; } } if(player[i].targetanimation==sneakanim){ - setAnimation(i,player[i].getIdle()); + player[i].setAnimation(player[i].getIdle()); player[i].transspeed=10; } } @@ -7148,9 +7281,9 @@ void Game::Tick(){ !player[i].jumpkeydown&& player[i].crouchkeydown)){ if(player[i].aitype==passivetype) - setAnimation(i,walkanim); + player[i].setAnimation(walkanim); else - setAnimation(i,player[i].getRun()); + player[i].setAnimation(player[i].getRun()); } if(player[i].isCrouch()){ player[i].targetanimation=sneakanim; @@ -7159,7 +7292,7 @@ void Game::Tick(){ player[i].targetframe=0; } if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){ - setAnimation(i,climbanim); + player[i].setAnimation(climbanim); player[i].targetframe=1; player[i].jumpclimb=1; } @@ -7180,7 +7313,7 @@ void Game::Tick(){ player[i].targetframe>0&& !player[i].jumpkeydown&& player[i].crouchkeydown)){ - setAnimation(i,player[i].getRun()); + player[i].setAnimation(player[i].getRun()); } if(player[i].isCrouch()){ player[i].targetanimation=sneakanim; @@ -7207,7 +7340,7 @@ void Game::Tick(){ player[i].targetframe>0&& !player[i].jumpkeydown&& player[i].crouchkeydown)){ - setAnimation(i,player[i].getRun()); + player[i].setAnimation(player[i].getRun()); } if(player[i].isCrouch()){ player[i].targetanimation=sneakanim; @@ -7234,7 +7367,7 @@ void Game::Tick(){ player[i].targetframe>0&& !player[i].jumpkeydown&& player[i].crouchkeydown)){ - setAnimation(i,player[i].getRun()); + player[i].setAnimation(player[i].getRun()); } if(player[i].isCrouch()){ player[i].targetanimation=sneakanim; @@ -7270,7 +7403,7 @@ void Game::Tick(){ ((player[i].targetanimation!=rabbitrunninganim&& player[i].targetanimation!=wolfrunninganim)||i!=0)){ player[i].jumpstart=0; - setAnimation(i,jumpupanim); + player[i].setAnimation(jumpupanim); player[i].rotation=player[i].targetrotation; player[i].transspeed=20; player[i].FootLand(0,1); @@ -7317,7 +7450,7 @@ void Game::Tick(){ emit_sound_at(jumpsound, player[i].coords, 128.); } if((player[i].isIdle())&&player[i].jumppower>1){ - setAnimation(i,player[i].getLanding()); + player[i].setAnimation(player[i].getLanding()); player[i].targetframe=2; player[i].landhard=0; player[i].jumpstart=1; @@ -7342,7 +7475,7 @@ void Game::Tick(){ if(!movekey){ if(player[i].isRun()||player[i].targetanimation==walkanim) - setAnimation(i,player[i].getStop()); + player[i].setAnimation(player[i].getStop()); if(player[i].targetanimation==sneakanim){ player[i].targetanimation=player[i].getCrouch(); if(player[i].currentanimation==sneakanim) @@ -7355,9 +7488,9 @@ void Game::Tick(){ player[i].aitype==searchtype|| (player[i].aitype==passivetype&& player[i].numwaypoints<=1))) - setAnimation(i,player[i].getStop()); + player[i].setAnimation(player[i].getStop()); if(player[i].isRun()&&(player[i].aitype==passivetype)) - setAnimation(i,player[i].getStop()); + player[i].setAnimation(player[i].getStop()); } } if(player[i].targetanimation==rollanim) @@ -7375,7 +7508,7 @@ void Game::Tick(){ //stop to turn in right direction if(fabs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)) - setAnimation(k,player[k].getStop()); + player[k].setAnimation(player[k].getStop()); if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim) player[k].targettilt=0; @@ -7686,11 +7819,11 @@ void Game::TickOnceAfter(){ killhotspot=0; - winhotspot=0; + winhotspot=false; for(int i=0;inumchallengelevels-1)targetlevel=0; } - if(winhotspot||windialogue){ + if(winhotspot||windialogue) { changedelay=0.1; targetlevel=whichlevel+1; if(targetlevel>numchallengelevels-1)targetlevel=0; @@ -7745,8 +7881,8 @@ void Game::TickOnceAfter(){ if(leveltime<1){ loading=0; changedelay=.1; - alldead=0; - winhotspot=0; + alldead=false; + winhotspot=false; killhotspot=0; } @@ -7777,7 +7913,7 @@ void Game::TickOnceAfter(){ fireSound(firestartsound); - Loadlevel(campaignmapname[levelorder[accountactive->getCampaignChoicesMade()]]); + Loadlevel(campaignlevels[accountactive->getCampaignChoicesMade()].mapname.c_str()); fireSound(); @@ -7811,11 +7947,11 @@ void Game::TickOnceAfter(){ // 0 = load next level // 1 = go back to level select screen // 2 = stealthload next level - if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){ - if(campaignnumnext[campaignchoicewhich[whichchoice]]==0) + if(mainmenu==0&&winfreeze&&(campaignlevels[actuallevel].choosenext)==1) { + if(campaignlevels[actuallevel].nextlevel.empty()) endgame=1; } else if(mainmenu==0&&winfreeze) { - stealthloading = (campaignchoosenext[campaignchoicewhich[whichchoice]]==2); + stealthloading = (campaignlevels[actuallevel].choosenext==2); if(!stealthloading){ fireSound(firestartsound); @@ -7833,9 +7969,10 @@ void Game::TickOnceAfter(){ if(!firstload) LoadStuff(); whichchoice=0; + actuallevel=campaignlevels[actuallevel].nextlevel.front(); visibleloading=1; stillloading=1; - Loadlevel(campaignmapname[campaignchoicewhich[0]]); + Loadlevel(campaignlevels[actuallevel].mapname.c_str()); campaign=1; mainmenu=0; gameon=1;