]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameTick.cpp
Stopped using Account pointers, and removed general difficulty setting (difficulty...
[lugaru.git] / Source / GameTick.cpp
index 1dfebb29955118d4bdef80c76b18a149c64382bd..1b865f13c9b2b63a77d8478b0d6a21bccf986a42 100644 (file)
@@ -90,7 +90,7 @@ extern bool mousejump;
 extern float viewdistance;
 extern bool freeze;
 extern XYZ windvector;
-extern bool debugmode;
+extern bool devtools;
 int leveltheme;
 extern int mainmenu;
 extern int oldmainmenu;
@@ -692,8 +692,9 @@ void Game::Loadlevel(const std::string& name)
     damagedealt = 0;
     damagetaken = 0;
 
-    if (accountactive)
-        difficulty = accountactive->getDifficulty();
+    if (Account::hasActive()) {
+        difficulty = Account::active().getDifficulty();
+    }
 
     Hotspot::hotspots.clear();
     Hotspot::current = -1;
@@ -908,12 +909,13 @@ void Game::Loadlevel(const std::string& name)
     if (numplayers > maxplayers) {
         cout << "Warning: this level contains more players than allowed" << endl;
     }
+    unsigned j = 1;
     for (int i = 1; i < numplayers; i++) {
-        unsigned j = 1;
         try {
             Person::players.push_back(shared_ptr<Person>(new Person(tfile, mapvers, j)));
             j++;
         } catch (InvalidPersonException e) {
+            cerr << "Invalid Person found in " << name << endl;
         }
     }
     if (visibleloading)
@@ -1105,6 +1107,7 @@ void Game::Loadlevel(const std::string& name)
         firstload = 1;
 
     leveltime = 0;
+    wonleveltime = 0;
     visibleloading = 0;
 }
 
@@ -1637,10 +1640,10 @@ void doTutorial()
     }
 }
 
-void doDebugKeys()
+void doDevKeys()
 {
     float headprop, bodyprop, armprop, legprop;
-    if (!debugmode) {
+    if (!devtools) {
         return;
     }
 
@@ -4602,14 +4605,14 @@ void Game::Tick()
             leveltime += multiplier;
 
         //keys
-        if (Input::isKeyDown(SDL_SCANCODE_LALT) && Input::isKeyPressed(SDL_SCANCODE_V) && debugmode) {
+        if (Input::isKeyDown(SDL_SCANCODE_LALT) && Input::isKeyPressed(SDL_SCANCODE_V) && devtools) {
             freeze = !freeze;
             if (freeze) {
                 OPENAL_SetFrequency(OPENAL_ALL);
             }
         }
 
-        if (Input::isKeyPressed(consolekey) && debugmode) {
+        if (Input::isKeyPressed(consolekey) && devtools) {
             console = !console;
             if (console) {
                 OPENAL_SetFrequency(OPENAL_ALL);
@@ -4974,7 +4977,7 @@ void Game::Tick()
                 hawkcalldelay = 16 + abs(Random() % 8);
             }
 
-            doDebugKeys();
+            doDevKeys();
 
             doAttacks();
 
@@ -5000,7 +5003,7 @@ void Game::Tick()
                     (whichlevel != -2 &&
                      (Input::isKeyDown(SDL_SCANCODE_Z) &&
                       Input::isKeyDown(SDL_SCANCODE_LGUI) &&
-                      debugmode) ||
+                      devtools) ||
                      (Input::isKeyDown(jumpkey) &&
                       !respawnkeydown &&
                       !oldattackkey &&
@@ -5770,7 +5773,7 @@ void Game::Tick()
                                     Person::players[i]->crouchtogglekeydown = 1;
                                 } else Person::players[i]->velocity.y = 5;
 
-                                if (mousejump && i == 0 && debugmode) {
+                                if (mousejump && i == 0 && devtools) {
                                     if (!Person::players[i]->isLanding())
                                         Person::players[i]->tempdeltav = deltav;
                                     if (Person::players[i]->tempdeltav < 0)
@@ -5795,7 +5798,7 @@ void Game::Tick()
                             if (Person::players[i]->animTarget == jumpupanim &&
                                     (((!floatjump &&
                                        !editorenabled) ||
-                                      !debugmode) ||
+                                      !devtools) ||
                                      Person::players[i]->aitype != playercontrolled)) {
                                 if (Person::players[i]->jumppower > multiplier * 6) {
                                     Person::players[i]->velocity.y += multiplier * 6;
@@ -5806,7 +5809,7 @@ void Game::Tick()
                                     Person::players[i]->jumppower = 0;
                                 }
                             }
-                            if (((floatjump || editorenabled) && debugmode) && i == 0)
+                            if (((floatjump || editorenabled) && devtools) && i == 0)
                                 Person::players[i]->velocity.y += multiplier * 30;
                         }
 
@@ -6215,10 +6218,11 @@ void Game::TickOnceAfter()
             if (changedelay > 0 && !Person::players[0]->dead && !won) {
                 //high scores, awards, win
                 if (campaign) {
-                    accountactive->winCampaignLevel(whichchoice, bonustotal, leveltime);
+                    Account::active().winCampaignLevel(whichchoice, bonustotal, leveltime);
                     scoreadded = 1;
                 } else {
-                    accountactive->winLevel(whichlevel, bonustotal - startbonustotal, leveltime);
+                    wonleveltime = leveltime;
+                    Account::active().winLevel(whichlevel, bonustotal - startbonustotal, leveltime);
                 }
                 won = 1;
             }
@@ -6261,7 +6265,7 @@ void Game::TickOnceAfter()
 
                     fireSound(firestartsound);
 
-                    Loadlevel(campaignlevels[accountactive->getCampaignChoicesMade()].mapname.c_str());
+                    Loadlevel(campaignlevels[Account::active().getCampaignChoicesMade()].mapname.c_str());
 
                     fireSound();