]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameTick.cpp
Removed forgotten debug output
[lugaru.git] / Source / GameTick.cpp
index fab80e9e5ac4c29b7c07fc9422e0e27236ae2d80..68010da4ee70514eede346cd5cbcdd984d90be60 100644 (file)
@@ -21,6 +21,20 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 // Enable full math definitions
 #define _USE_MATH_DEFINES
 
+#include "Game.hpp"
+
+#include "Animation/Animation.hpp"
+#include "Audio/openal_wrapper.hpp"
+#include "Devtools/ConsoleCmds.hpp"
+#include "Level/Awards.hpp"
+#include "Level/Campaign.hpp"
+#include "Level/Dialog.hpp"
+#include "Level/Hotspot.hpp"
+#include "Menu/Menu.hpp"
+#include "User/Settings.hpp"
+#include "Utils/Folders.hpp"
+#include "Utils/Input.hpp"
+
 #if PLATFORM_UNIX
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -29,25 +43,11 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #include <direct.h>
 #endif
 
-
-#include <limits>
-#include <ctime>
+#include <algorithm>
 #include <cmath>
+#include <ctime>
 #include <dirent.h>
-#include "Game.h"
-#include "openal_wrapper.h"
-#include "Settings.h"
-#include "Input.h"
-#include "Animation/Animation.h"
-#include "Awards.h"
-#include "Menu.h"
-#include "ConsoleCmds.h"
-#include "Dialog.h"
-#include "Utils/Folders.h"
-#include "Hotspot.h"
-#include "Campaign.h"
-
-#include <algorithm>
+#include <limits>
 #include <set>
 
 using namespace std;
@@ -68,7 +68,6 @@ extern float screenwidth, screenheight;
 extern float gravity;
 extern int detail;
 extern float texdetail;
-extern Objects objects;
 extern int slomo;
 extern float slomodelay;
 extern bool floatjump;
@@ -318,8 +317,8 @@ static int findClosestObject()
     int closest = -1;
     float closestdist = std::numeric_limits<float>::max();
 
-    for (int i = 0; i < objects.numobjects; i++) {
-        float distance = distsq(&objects.position[i], &Person::players[0]->coords);
+    for (int i = 0; i < Object::objects.size(); i++) {
+        float distance = distsq(&Object::objects[i]->position, &Person::players[0]->coords);
         if (distance < closestdist) {
             closestdist = distance;
             closest = i;
@@ -348,13 +347,9 @@ void Screenshot (void)
     char filename[1024];
     time_t t = time(NULL);
     struct tm *tme = localtime(&t);
-    sprintf(filename, "Screenshots/Screenshot-%04d%02d%02d-%02d%02d%02d.png",
+    sprintf(filename, "Screenshot-%04d%02d%02d-%02d%02d%02d.png",
             tme->tm_year + 1900, tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min, tme->tm_sec);
 
-#if defined(_WIN32)
-    mkdir("Screenshots");
-#endif
-
     save_screenshot(filename);
 }
 
@@ -435,19 +430,19 @@ int Game::checkcollide(XYZ startpoint, XYZ endpoint)
     maxy = max(startpoint.y, endpoint.y) + 1;
     maxz = max(startpoint.z, endpoint.z) + 1;
 
-    for (int i = 0; i < objects.numobjects; i++) {
-        if (     objects.position[i].x > minx - objects.model[i].boundingsphereradius &&
-                 objects.position[i].x < maxx + objects.model[i].boundingsphereradius &&
-                 objects.position[i].y > miny - objects.model[i].boundingsphereradius &&
-                 objects.position[i].y < maxy + objects.model[i].boundingsphereradius &&
-                 objects.position[i].z > minz - objects.model[i].boundingsphereradius &&
-                 objects.position[i].z < maxz + objects.model[i].boundingsphereradius) {
-            if (     objects.type[i] != treeleavestype &&
-                     objects.type[i] != bushtype &&
-                     objects.type[i] != firetype) {
+    for (int i = 0; i < Object::objects.size(); i++) {
+        if (     Object::objects[i]->position.x > minx - Object::objects[i]->model.boundingsphereradius &&
+                 Object::objects[i]->position.x < maxx + Object::objects[i]->model.boundingsphereradius &&
+                 Object::objects[i]->position.y > miny - Object::objects[i]->model.boundingsphereradius &&
+                 Object::objects[i]->position.y < maxy + Object::objects[i]->model.boundingsphereradius &&
+                 Object::objects[i]->position.z > minz - Object::objects[i]->model.boundingsphereradius &&
+                 Object::objects[i]->position.z < maxz + Object::objects[i]->model.boundingsphereradius) {
+            if (     Object::objects[i]->type != treeleavestype &&
+                     Object::objects[i]->type != bushtype &&
+                     Object::objects[i]->type != firetype) {
                 colviewer = startpoint;
                 coltarget = endpoint;
-                if (objects.model[i].LineCheck(&colviewer, &coltarget, &colpoint, &objects.position[i], &objects.yaw[i]) != -1)
+                if (Object::objects[i]->model.LineCheck(&colviewer, &coltarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1)
                     return i;
             }
         }
@@ -470,19 +465,19 @@ int Game::checkcollide(XYZ startpoint, XYZ endpoint, int what)
     maxz = max(startpoint.z, endpoint.z) + 1;
 
     if (what != 1000) {
-        if (     objects.position[what].x > minx - objects.model[what].boundingsphereradius &&
-                 objects.position[what].x < maxx + objects.model[what].boundingsphereradius &&
-                 objects.position[what].y > miny - objects.model[what].boundingsphereradius &&
-                 objects.position[what].y < maxy + objects.model[what].boundingsphereradius &&
-                 objects.position[what].z > minz - objects.model[what].boundingsphereradius &&
-                 objects.position[what].z < maxz + objects.model[what].boundingsphereradius) {
-            if (     objects.type[what] != treeleavestype &&
-                     objects.type[what] != bushtype &&
-                     objects.type[what] != firetype) {
+        if (     Object::objects[what]->position.x > minx - Object::objects[what]->model.boundingsphereradius &&
+                 Object::objects[what]->position.x < maxx + Object::objects[what]->model.boundingsphereradius &&
+                 Object::objects[what]->position.y > miny - Object::objects[what]->model.boundingsphereradius &&
+                 Object::objects[what]->position.y < maxy + Object::objects[what]->model.boundingsphereradius &&
+                 Object::objects[what]->position.z > minz - Object::objects[what]->model.boundingsphereradius &&
+                 Object::objects[what]->position.z < maxz + Object::objects[what]->model.boundingsphereradius) {
+            if (     Object::objects[what]->type != treeleavestype &&
+                     Object::objects[what]->type != bushtype &&
+                     Object::objects[what]->type != firetype) {
                 colviewer = startpoint;
                 coltarget = endpoint;
                 //FIXME: i/what
-                if (objects.model[what].LineCheck(&colviewer, &coltarget, &colpoint, &objects.position[what], &objects.yaw[what]) != -1)
+                if (Object::objects[what]->model.LineCheck(&colviewer, &coltarget, &colpoint, &Object::objects[what]->position, &Object::objects[what]->yaw) != -1)
                     return i;
             }
         }
@@ -517,10 +512,10 @@ void Setenvironment(int which)
         if (ambientsound)
             emit_stream_np(stream_wind);
 
-        objects.treetextureptr.load("Textures/SnowTree.png", 0);
-        objects.bushtextureptr.load("Textures/BushSnow.png", 0);
-        objects.rocktextureptr.load("Textures/BoulderSnow.jpg", 1);
-        objects.boxtextureptr.load("Textures/SnowBox.jpg", 1);
+        Object::treetextureptr.load("Textures/SnowTree.png", 0);
+        Object::bushtextureptr.load("Textures/BushSnow.png", 0);
+        Object::rocktextureptr.load("Textures/BoulderSnow.jpg", 1);
+        Object::boxtextureptr.load("Textures/SnowBox.jpg", 1);
 
         footstepsound = footstepsn1;
         footstepsound2 = footstepsn2;
@@ -548,10 +543,10 @@ void Setenvironment(int which)
     } else if (environment == desertenvironment) {
         windvector = 0;
         windvector.z = 2;
-        objects.treetextureptr.load("Textures/DesertTree.png", 0);
-        objects.bushtextureptr.load("Textures/BushDesert.png", 0);
-        objects.rocktextureptr.load("Textures/BoulderDesert.jpg", 1);
-        objects.boxtextureptr.load("Textures/DesertBox.jpg", 1);
+        Object::treetextureptr.load("Textures/DesertTree.png", 0);
+        Object::bushtextureptr.load("Textures/BushDesert.png", 0);
+        Object::rocktextureptr.load("Textures/BoulderDesert.jpg", 1);
+        Object::boxtextureptr.load("Textures/DesertBox.jpg", 1);
 
 
         if (ambientsound)
@@ -583,10 +578,10 @@ void Setenvironment(int which)
     } else if (environment == grassyenvironment) {
         windvector = 0;
         windvector.z = 2;
-        objects.treetextureptr.load("Textures/Tree.png", 0);
-        objects.bushtextureptr.load("Textures/Bush.png", 0);
-        objects.rocktextureptr.load("Textures/Boulder.jpg", 1);
-        objects.boxtextureptr.load("Textures/GrassBox.jpg", 1);
+        Object::treetextureptr.load("Textures/Tree.png", 0);
+        Object::bushtextureptr.load("Textures/Bush.png", 0);
+        Object::rocktextureptr.load("Textures/Boulder.jpg", 1);
+        Object::boxtextureptr.load("Textures/GrassBox.jpg", 1);
 
         if (ambientsound)
             emit_stream_np(stream_wind, 100.);
@@ -692,8 +687,9 @@ void Game::Loadlevel(const std::string& name)
     damagedealt = 0;
     damagetaken = 0;
 
-    if (Account::active)
-        difficulty = Account::active->getDifficulty();
+    if (Account::hasActive()) {
+        difficulty = Account::active().getDifficulty();
+    }
 
     Hotspot::hotspots.clear();
     Hotspot::current = -1;
@@ -740,19 +736,12 @@ void Game::Loadlevel(const std::string& name)
     if (!stealthloading) {
         terrain.numdecals = 0;
         Sprite::deleteSprites();
-        for (int i = 0; i < objects.numobjects; i++)
-            objects.model[i].numdecals = 0;
-
-        int j = objects.numobjects;
-        for (int i = 0; i < j; i++) {
-            objects.DeleteObject(0);
-            if (visibleloading)
-                LoadingScreen();
-        }
 
-        for (int i = 0; i < subdivision; i++)
-            for (int j = 0; j < subdivision; j++)
+        for (int i = 0; i < subdivision; i++) {
+            for (int j = 0; j < subdivision; j++) {
                 terrain.patchobjectnum[i][j] = 0;
+            }
+        }
         if (visibleloading)
             LoadingScreen();
     }
@@ -847,12 +836,7 @@ void Game::Loadlevel(const std::string& name)
 
     funpackf(tfile, "Bi", &environment);
 
-    funpackf(tfile, "Bi", &objects.numobjects);
-    for (int i = 0; i < objects.numobjects; i++) {
-        funpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", &objects.type[i], &objects.yaw[i], &objects.pitch[i], &objects.position[i].x, &objects.position[i].y, &objects.position[i].z, &objects.scale[i]);
-        if (objects.type[i] == treeleavestype)
-            objects.scale[i] = objects.scale[i - 1];
-    }
+    Object::LoadObjectsFromFile(tfile, stealthloading);
 
     if (mapvers >= 7) {
         int numhotspots;
@@ -862,7 +846,7 @@ void Game::Loadlevel(const std::string& name)
             numhotspots = 0;
         }
         Hotspot::hotspots.resize(numhotspots);
-        for (int i = 0; i < Hotspot::hotspots.size(); i++) {
+        for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
             funpackf(tfile, "Bi Bf Bf Bf Bf", &Hotspot::hotspots[i].type, &Hotspot::hotspots[i].size, &Hotspot::hotspots[i].position.x, &Hotspot::hotspots[i].position.y, &Hotspot::hotspots[i].position.z);
             funpackf(tfile, "Bi", &templength);
             if (templength)
@@ -880,24 +864,12 @@ void Game::Loadlevel(const std::string& name)
         LoadingScreen();
 
     if (!stealthloading) {
-        objects.center = 0;
-        for (int i = 0; i < objects.numobjects; i++)
-            objects.center += objects.position[i];
-        objects.center /= objects.numobjects;
-
+        Object::ComputeCenter();
 
         if (visibleloading)
             LoadingScreen();
 
-        float maxdistance = 0;
-        float tempdist;
-        for (int i = 0; i < objects.numobjects; i++) {
-            tempdist = distsq(&objects.center, &objects.position[i]);
-            if (tempdist > maxdistance) {
-                maxdistance = tempdist;
-            }
-        }
-        objects.radius = fast_sqrt(maxdistance);
+        Object::ComputeRadius();
     }
 
     if (visibleloading)
@@ -940,18 +912,11 @@ void Game::Loadlevel(const std::string& name)
     oldenvironment = environment;
 
     if (!stealthloading) {
-        int j = objects.numobjects;
-        objects.numobjects = 0;
-        for (int i = 0; i < j; i++) {
-            objects.MakeObject(objects.type[i], objects.position[i], objects.yaw[i], objects.pitch[i], objects.scale[i]);
-            if (visibleloading)
-                LoadingScreen();
-        }
-
+        Object::AddObjectsToTerrain();
         terrain.DoShadows();
         if (visibleloading)
             LoadingScreen();
-        objects.DoShadows();
+        Object::DoShadows();
         if (visibleloading)
             LoadingScreen();
     }
@@ -1176,7 +1141,7 @@ void doTutorial()
 
             emit_sound_at(fireendsound, Person::players[1]->coords);
 
-            for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
+            for (unsigned i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
                 if (Random() % 2 == 0) {
                     if (!Person::players[1]->skeleton.free)
                         temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
@@ -1446,7 +1411,7 @@ void doTutorial()
             XYZ temp, temp2;
             emit_sound_at(fireendsound, Person::players[1]->coords);
 
-            for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
+            for (unsigned i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
                 if (Random() % 2 == 0) {
                     if (!Person::players[1]->skeleton.free)
                         temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
@@ -1684,9 +1649,9 @@ void doDevKeys()
 
         /* Grow tree leaves?? */
         if (Input::isKeyPressed(SDL_SCANCODE_Y)) {
-            for (int i = 0; i < objects.numobjects; i++) {
-                if (objects.type[i] == treeleavestype) {
-                    objects.scale[i] *= .9;
+            for (int i = 0; i < Object::objects.size(); i++) {
+                if (Object::objects[i]->type == treeleavestype) {
+                    Object::objects[i]->scale *= .9;
                 }
             }
         }
@@ -1775,9 +1740,8 @@ void doDevKeys()
                     bodyprop = Person::players[closest]->proportionbody.x / 1.1;
                     armprop = Person::players[closest]->proportionarms.x / 1.1;
                     legprop = Person::players[closest]->proportionlegs.x / 1.1;
-                }
-
-                if (Person::players[closest]->creature == rabbittype) {
+                } else {
+                    // rabbittype
                     headprop = Person::players[closest]->proportionhead.x / 1.2;
                     bodyprop = Person::players[closest]->proportionbody.x / 1.05;
                     armprop = Person::players[closest]->proportionarms.x / 1.00;
@@ -1852,7 +1816,7 @@ void doDevKeys()
                 XYZ headspurtdirection;
                 //int i = Person::players[closest]->skeleton.jointlabels[head];
                 Joint& headjoint = Person::players[closest]->joint(head);
-                for (int k = 0; k < Person::players[closest]->skeleton.joints.size(); k++) {
+                for (unsigned k = 0; k < Person::players[closest]->skeleton.joints.size(); k++) {
                     if (!Person::players[closest]->skeleton.free)
                         flatvelocity2 = Person::players[closest]->velocity;
                     if (Person::players[closest]->skeleton.free)
@@ -1896,7 +1860,7 @@ void doDevKeys()
                 emit_sound_at(splattersound, blah);
                 emit_sound_at(breaksound2, blah);
 
-                for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
+                for (unsigned i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
                     if (!Person::players[closest]->skeleton.free)
                         flatvelocity2 = Person::players[closest]->velocity;
                     if (Person::players[closest]->skeleton.free)
@@ -1913,7 +1877,7 @@ void doDevKeys()
                     Sprite::MakeSprite(cloudsprite, flatfacing2, flatvelocity2 * 0, .6, 0, 0, 1, .5);
                 }
 
-                for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
+                for (unsigned i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
                     if (!Person::players[closest]->skeleton.free)
                         flatvelocity2 = Person::players[closest]->velocity;
                     if (Person::players[closest]->skeleton.free)
@@ -1929,7 +1893,7 @@ void doDevKeys()
                     Sprite::MakeSprite(bloodsprite, flatfacing2, flatvelocity2, 1, 1, 1, .4, 1);
                 }
 
-                for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
+                for (unsigned i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
                     if (!Person::players[closest]->skeleton.free)
                         flatvelocity2 = Person::players[closest]->velocity;
                     if (Person::players[closest]->skeleton.free)
@@ -1945,7 +1909,7 @@ void doDevKeys()
                     Sprite::MakeSprite(bloodsprite, flatfacing2, flatvelocity2 * 2, 1, 1, 1, .4, 1);
                 }
 
-                for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
+                for (unsigned i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
                     if (!Person::players[closest]->skeleton.free)
                         flatvelocity2 = Person::players[closest]->velocity;
                     if (Person::players[closest]->skeleton.free)
@@ -1970,7 +1934,7 @@ void doDevKeys()
                                 Person::players[j]->skeleton.free = 1;
                             Person::players[j]->skeleton.longdead = 0;
                             Person::players[j]->RagDoll(0);
-                            for (int i = 0; i < Person::players[j]->skeleton.joints.size(); i++) {
+                            for (unsigned i = 0; i < Person::players[j]->skeleton.joints.size(); i++) {
                                 temppos = Person::players[j]->skeleton.joints[i].position + Person::players[j]->coords;
                                 if (distsq(&temppos, &Person::players[closest]->coords) < 25) {
                                     flatvelocity2 = temppos - Person::players[closest]->coords;
@@ -2028,12 +1992,13 @@ void doDevKeys()
 
         if (Input::isKeyPressed(SDL_SCANCODE_DELETE) && Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
             int closest = findClosestObject();
-            if (closest >= 0)
-                objects.position[closest].y -= 500;
+            if (closest >= 0) {
+                Object::objects[closest]->position.y -= 500;
+            }
         }
 
         if (Input::isKeyPressed(SDL_SCANCODE_M) && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
-            if (objects.numobjects < max_objects - 1) {
+            if (Object::objects.size() < max_objects - 1) {
                 XYZ scenecoords;
                 scenecoords.x = Person::players[0]->coords.x;
                 scenecoords.z = Person::players[0]->coords.z;
@@ -2042,7 +2007,6 @@ void doDevKeys()
                     scenecoords.y = Person::players[0]->coords.y - .5;
                 if (editortype == firetype)
                     scenecoords.y = Person::players[0]->coords.y - .5;
-                //objects.MakeObject(abs(Random()%3),scenecoords,Random()%360);
                 float temprotat, temprotat2;
                 temprotat = editoryaw;
                 temprotat2 = editorpitch;
@@ -2051,9 +2015,9 @@ void doDevKeys()
                 if (temprotat2 < 0)
                     temprotat2 = Random() % 360;
 
-                objects.MakeObject(editortype, scenecoords, (int)temprotat - ((int)temprotat) % 30, (int)temprotat2, editorsize);
+                Object::MakeObject(editortype, scenecoords, (int)temprotat - ((int)temprotat) % 30, (int)temprotat2, editorsize);
                 if (editortype == treetrunktype)
-                    objects.MakeObject(treeleavestype, scenecoords, Random() % 360 * (temprotat2 < 2) + (int)editoryaw - ((int)editoryaw) % 30, editorpitch, editorsize);
+                    Object::MakeObject(treeleavestype, scenecoords, Random() % 360 * (temprotat2 < 2) + (int)editoryaw - ((int)editoryaw) % 30, editorpitch, editorsize);
             }
         }
 
@@ -2092,9 +2056,8 @@ void doDevKeys()
                 bodyprop = Person::players[0]->proportionbody.x / 1.1;
                 armprop = Person::players[0]->proportionarms.x / 1.1;
                 legprop = Person::players[0]->proportionlegs.x / 1.1;
-            }
-
-            if (Person::players[0]->creature == rabbittype) {
+            } else {
+                // rabbittype
                 headprop = Person::players[0]->proportionhead.x / 1.2;
                 bodyprop = Person::players[0]->proportionbody.x / 1.05;
                 armprop = Person::players[0]->proportionarms.x / 1.00;
@@ -2199,11 +2162,13 @@ void doDevKeys()
             if (pathpointselected >= numpathpoints)
                 pathpointselected = -1;
         }
+
         if (Input::isKeyPressed(SDL_SCANCODE_COMMA) && !Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
             pathpointselected--;
             if (pathpointselected <= -2)
                 pathpointselected = numpathpoints - 1;
         }
+
         if (Input::isKeyPressed(SDL_SCANCODE_COMMA) && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
             if (pathpointselected != -1) {
                 numpathpoints--;
@@ -2271,6 +2236,7 @@ void doDevKeys()
         if (Input::isKeyPressed(SDL_SCANCODE_RIGHT) && Input::isKeyDown(SDL_SCANCODE_LSHIFT) && Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
             mapradius += multiplier * 10;
         }
+
         if (Input::isKeyDown(SDL_SCANCODE_UP) && Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
             editorpitch += multiplier * 100;
         }
@@ -2280,10 +2246,12 @@ void doDevKeys()
             if (editorpitch < -.01)
                 editorpitch = -.01;
         }
-        if (Input::isKeyPressed(SDL_SCANCODE_DELETE) && objects.numobjects && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
+
+        if (Input::isKeyPressed(SDL_SCANCODE_DELETE) && Object::objects.size() && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
             int closest = findClosestObject();
-            if (closest >= 0)
-                objects.DeleteObject(closest);
+            if (closest >= 0) {
+                Object::DeleteObject(closest);
+            }
         }
     }
 }
@@ -2450,9 +2418,9 @@ void doAerialAcrobatics()
 
             for (int l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
                 int i = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
-                if (objects.type[i] != rocktype ||
-                        objects.scale[i] > .5 && Person::players[k]->aitype == playercontrolled ||
-                        objects.position[i].y > Person::players[k]->coords.y) {
+                if (Object::objects[i]->type != rocktype ||
+                        Object::objects[i]->scale > .5 && Person::players[k]->aitype == playercontrolled ||
+                        Object::objects[i]->position.y > Person::players[k]->coords.y) {
                     lowpoint = Person::players[k]->coords;
                     if (Person::players[k]->animTarget != jumpupanim &&
                             Person::players[k]->animTarget != jumpdownanim &&
@@ -2463,7 +2431,7 @@ void doAerialAcrobatics()
                     if (     Person::players[k]->coords.y < terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z) &&
                              Person::players[k]->coords.y > terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z) - .1)
                         Person::players[k]->coords.y = terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z);
-                    if (Person::players[k]->SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.yaw[i], &objects.model[i]) != -1) {
+                    if (Person::players[k]->SphereCheck(&lowpoint, 1.3, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw, &Object::objects[i]->model) != -1) {
                         flatfacing = lowpoint - Person::players[k]->coords;
                         Person::players[k]->coords = lowpoint;
                         Person::players[k]->coords.y -= 1.3;
@@ -2479,14 +2447,14 @@ void doAerialAcrobatics()
                                 Person::players[k]->jumpkeydown) {
                             lowpointtarget = lowpoint + DoRotation(Person::players[k]->facing, 0, -90, 0) * 1.5;
                             XYZ tempcoords1 = lowpoint;
-                            whichhit = objects.model[i].LineCheck(&lowpoint, &lowpointtarget, &colpoint, &objects.position[i], &objects.yaw[i]);
-                            if (whichhit != -1 && fabs(objects.model[i].facenormals[whichhit].y) < .3) {
+                            whichhit = Object::objects[i]->model.LineCheck(&lowpoint, &lowpointtarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw);
+                            if (whichhit != -1 && fabs(Object::objects[i]->model.facenormals[whichhit].y) < .3) {
                                 Person::players[k]->setAnimation(walljumpleftanim);
                                 emit_sound_at(movewhooshsound, Person::players[k]->coords);
                                 if (k == 0)
                                     pause_sound(whooshsound);
 
-                                lowpointtarget = DoRotation(objects.model[i].facenormals[whichhit], 0, objects.yaw[i], 0);
+                                lowpointtarget = DoRotation(Object::objects[i]->model.facenormals[whichhit], 0, Object::objects[i]->yaw, 0);
                                 Person::players[k]->yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
                                 if (lowpointtarget.z < 0)
                                     Person::players[k]->yaw = 180 - Person::players[k]->yaw;
@@ -2497,14 +2465,14 @@ void doAerialAcrobatics()
                             } else {
                                 lowpoint = tempcoords1;
                                 lowpointtarget = lowpoint + DoRotation(Person::players[k]->facing, 0, 90, 0) * 1.5;
-                                whichhit = objects.model[i].LineCheck(&lowpoint, &lowpointtarget, &colpoint, &objects.position[i], &objects.yaw[i]);
-                                if (whichhit != -1 && fabs(objects.model[i].facenormals[whichhit].y) < .3) {
+                                whichhit = Object::objects[i]->model.LineCheck(&lowpoint, &lowpointtarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw);
+                                if (whichhit != -1 && fabs(Object::objects[i]->model.facenormals[whichhit].y) < .3) {
                                     Person::players[k]->setAnimation(walljumprightanim);
                                     emit_sound_at(movewhooshsound, Person::players[k]->coords);
                                     if (k == 0)
                                         pause_sound(whooshsound);
 
-                                    lowpointtarget = DoRotation(objects.model[i].facenormals[whichhit], 0, objects.yaw[i], 0);
+                                    lowpointtarget = DoRotation(Object::objects[i]->model.facenormals[whichhit], 0, Object::objects[i]->yaw, 0);
                                     Person::players[k]->yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
                                     if (lowpointtarget.z < 0)
                                         Person::players[k]->yaw = 180 - Person::players[k]->yaw;
@@ -2515,14 +2483,14 @@ void doAerialAcrobatics()
                                 } else {
                                     lowpoint = tempcoords1;
                                     lowpointtarget = lowpoint + Person::players[k]->facing * 2;
-                                    whichhit = objects.model[i].LineCheck(&lowpoint, &lowpointtarget, &colpoint, &objects.position[i], &objects.yaw[i]);
-                                    if (whichhit != -1 && fabs(objects.model[i].facenormals[whichhit].y) < .3) {
+                                    whichhit = Object::objects[i]->model.LineCheck(&lowpoint, &lowpointtarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw);
+                                    if (whichhit != -1 && fabs(Object::objects[i]->model.facenormals[whichhit].y) < .3) {
                                         Person::players[k]->setAnimation(walljumpbackanim);
                                         emit_sound_at(movewhooshsound, Person::players[k]->coords);
                                         if (k == 0)
                                             pause_sound(whooshsound);
 
-                                        lowpointtarget = DoRotation(objects.model[i].facenormals[whichhit], 0, objects.yaw[i], 0);
+                                        lowpointtarget = DoRotation(Object::objects[i]->model.facenormals[whichhit], 0, Object::objects[i]->yaw, 0);
                                         Person::players[k]->yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
                                         if (lowpointtarget.z < 0)
                                             Person::players[k]->yaw = 180 - Person::players[k]->yaw;
@@ -2533,14 +2501,14 @@ void doAerialAcrobatics()
                                     } else {
                                         lowpoint = tempcoords1;
                                         lowpointtarget = lowpoint - Person::players[k]->facing * 2;
-                                        whichhit = objects.model[i].LineCheck(&lowpoint, &lowpointtarget, &colpoint, &objects.position[i], &objects.yaw[i]);
-                                        if (whichhit != -1 && fabs(objects.model[i].facenormals[whichhit].y) < .3) {
+                                        whichhit = Object::objects[i]->model.LineCheck(&lowpoint, &lowpointtarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw);
+                                        if (whichhit != -1 && fabs(Object::objects[i]->model.facenormals[whichhit].y) < .3) {
                                             Person::players[k]->setAnimation(walljumpfrontanim);
                                             emit_sound_at(movewhooshsound, Person::players[k]->coords);
                                             if (k == 0)
                                                 pause_sound(whooshsound);
 
-                                            lowpointtarget = DoRotation(objects.model[i].facenormals[whichhit], 0, objects.yaw[i], 0);
+                                            lowpointtarget = DoRotation(Object::objects[i]->model.facenormals[whichhit], 0, Object::objects[i]->yaw, 0);
                                             Person::players[k]->yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
                                             if (lowpointtarget.z < 0)
                                                 Person::players[k]->yaw = 180 - Person::players[k]->yaw;
@@ -2555,11 +2523,11 @@ void doAerialAcrobatics()
                             }
                         }
                     }
-                } else if (objects.type[i] == rocktype) {
+                } else if (Object::objects[i]->type == rocktype) {
                     lowpoint2 = Person::players[k]->coords;
                     lowpoint = Person::players[k]->coords;
                     lowpoint.y += 2;
-                    if (objects.model[i].LineCheck(&lowpoint, &lowpoint2, &colpoint, &objects.position[i], &objects.yaw[i]) != -1) {
+                    if (Object::objects[i]->model.LineCheck(&lowpoint, &lowpoint2, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1) {
                         Person::players[k]->coords = colpoint;
                         Person::players[k]->collide = 1;
                         tempcollide = 1;
@@ -2602,8 +2570,8 @@ void doAerialAcrobatics()
                     int i = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
                     lowpoint = Person::players[k]->coords;
                     lowpoint.y += 1.35;
-                    if (objects.type[i] != rocktype)
-                        if (Person::players[k]->SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.yaw[i], &objects.model[i]) != -1) {
+                    if (Object::objects[i]->type != rocktype)
+                        if (Person::players[k]->SphereCheck(&lowpoint, 1.33, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw, &Object::objects[i]->model) != -1) {
                             if (Person::players[k]->animTarget != jumpupanim &&
                                     Person::players[k]->animTarget != jumpdownanim &&
                                     Person::players[k]->onterrain)
@@ -2619,14 +2587,14 @@ void doAerialAcrobatics()
                                      Person::players[k]->animTarget == jumpupanim ||
                                      Person::players[k]->animTarget == jumpdownanim)) {
                                 lowpoint = Person::players[k]->coords;
-                                objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.yaw[i]);
+                                Object::objects[i]->model.SphereCheckPossible(&lowpoint, 1.5, &Object::objects[i]->position, &Object::objects[i]->yaw);
                                 lowpoint = Person::players[k]->coords;
                                 lowpoint.y += .05;
                                 facing = 0;
                                 facing.z = -1;
                                 facing = DoRotation(facing, 0, Person::players[k]->targetyaw + 180, 0);
                                 lowpointtarget = lowpoint + facing * 1.4;
-                                whichhit = objects.model[i].LineCheckPossible(&lowpoint, &lowpointtarget, &colpoint, &objects.position[i], &objects.yaw[i]);
+                                whichhit = Object::objects[i]->model.LineCheckPossible(&lowpoint, &lowpointtarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw);
                                 if (whichhit != -1) {
                                     lowpoint = Person::players[k]->coords;
                                     lowpoint.y += .1;
@@ -2655,27 +2623,27 @@ void doAerialAcrobatics()
                                     lowpointtarget6.y += 45 / 13;
                                     lowpointtarget6 += facing * .6;
                                     lowpointtarget7.y += 90 / 13;
-                                    whichhit = objects.model[i].LineCheckPossible(&lowpoint, &lowpointtarget, &colpoint, &objects.position[i], &objects.yaw[i]);
-                                    if (objects.friction[i] > .5)
+                                    whichhit = Object::objects[i]->model.LineCheckPossible(&lowpoint, &lowpointtarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw);
+                                    if (Object::objects[i]->friction > .5)
                                         if (whichhit != -1) {
                                             if (whichhit != -1 && Person::players[k]->animTarget != jumpupanim && Person::players[k]->animTarget != jumpdownanim)
                                                 Person::players[k]->collided = 1;
                                             if (checkcollide(lowpoint7, lowpointtarget7) == -1)
                                                 if (checkcollide(lowpoint6, lowpointtarget6) == -1)
-                                                    if (     objects.model[i].LineCheckPossible(&lowpoint2, &lowpointtarget2,
-                                                             &colpoint, &objects.position[i], &objects.yaw[i]) != -1 &&
-                                                             objects.model[i].LineCheckPossible(&lowpoint3, &lowpointtarget3,
-                                                                     &colpoint, &objects.position[i], &objects.yaw[i]) != -1 &&
-                                                             objects.model[i].LineCheckPossible(&lowpoint4, &lowpointtarget4,
-                                                                     &colpoint, &objects.position[i], &objects.yaw[i]) != -1 &&
-                                                             objects.model[i].LineCheckPossible(&lowpoint5, &lowpointtarget5,
-                                                                     &colpoint, &objects.position[i], &objects.yaw[i]) != -1)
+                                                    if (     Object::objects[i]->model.LineCheckPossible(&lowpoint2, &lowpointtarget2,
+                                                             &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
+                                                             Object::objects[i]->model.LineCheckPossible(&lowpoint3, &lowpointtarget3,
+                                                                     &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
+                                                             Object::objects[i]->model.LineCheckPossible(&lowpoint4, &lowpointtarget4,
+                                                                     &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
+                                                             Object::objects[i]->model.LineCheckPossible(&lowpoint5, &lowpointtarget5,
+                                                                     &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1)
                                                         for (int j = 0; j < 45; j++) {
                                                             lowpoint = Person::players[k]->coords;
                                                             lowpoint.y += (float)j / 13;
                                                             lowpointtarget = lowpoint + facing * 1.4;
-                                                            if (objects.model[i].LineCheckPossible(&lowpoint, &lowpointtarget,
-                                                                                                   &colpoint2, &objects.position[i], &objects.yaw[i]) == -1) {
+                                                            if (Object::objects[i]->model.LineCheckPossible(&lowpoint, &lowpointtarget,
+                                                                                                   &colpoint2, &Object::objects[i]->position, &Object::objects[i]->yaw) == -1) {
                                                                 if (j <= 6 || j <= 25 && Person::players[k]->animTarget == jumpdownanim)
                                                                     break;
                                                                 if (Person::players[k]->animTarget == jumpupanim || Person::players[k]->animTarget == jumpdownanim) {
@@ -2683,7 +2651,7 @@ void doAerialAcrobatics()
                                                                     lowpoint.y += (float)j / 13;
                                                                     lowpointtarget = lowpoint + facing * 1.3;
                                                                     flatfacing = Person::players[k]->coords;
-                                                                    Person::players[k]->coords = colpoint - DoRotation(objects.model[i].facenormals[whichhit], 0, objects.yaw[k], 0) * .01;
+                                                                    Person::players[k]->coords = colpoint - DoRotation(Object::objects[i]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0) * .01;
                                                                     Person::players[k]->coords.y = lowpointtarget.y - .07;
                                                                     Person::players[k]->currentoffset = (flatfacing - Person::players[k]->coords) / Person::players[k]->scale;
 
@@ -2694,7 +2662,7 @@ void doAerialAcrobatics()
                                                                         }
                                                                         emit_sound_at(jumpsound, Person::players[k]->coords, 128.);
 
-                                                                        lowpointtarget = DoRotation(objects.model[i].facenormals[whichhit], 0, objects.yaw[i], 0);
+                                                                        lowpointtarget = DoRotation(Object::objects[i]->model.facenormals[whichhit], 0, Object::objects[i]->yaw, 0);
                                                                         Person::players[k]->yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
                                                                         if (lowpointtarget.z < 0)
                                                                             Person::players[k]->yaw = 180 - Person::players[k]->yaw;
@@ -3169,13 +3137,13 @@ void doAttacks()
                                                             terrain.decalalivetime[j] < 2)
                                                         terrain.DeleteDecal(j);
                                                 }
-                                                for (int l = 0; l < objects.numobjects; l++) {
-                                                    if (objects.model[l].type == decalstype)
-                                                        for (int j = 0; j < objects.model[l].numdecals; j++) {
-                                                            if ((objects.model[l].decaltype[j] == blooddecal ||
-                                                                    objects.model[l].decaltype[j] == blooddecalslow) &&
-                                                                    objects.model[l].decalalivetime[j] < 2)
-                                                                objects.model[l].DeleteDecal(j);
+                                                for (int l = 0; l < Object::objects.size(); l++) {
+                                                    if (Object::objects[l]->model.type == decalstype)
+                                                        for (int j = 0; j < Object::objects[l]->model.numdecals; j++) {
+                                                            if ((Object::objects[l]->model.decaltype[j] == blooddecal ||
+                                                                    Object::objects[l]->model.decaltype[j] == blooddecalslow) &&
+                                                                    Object::objects[l]->model.decalalivetime[j] < 2)
+                                                                Object::objects[l]->model.DeleteDecal(j);
                                                         }
                                                 }
                                             }
@@ -3195,13 +3163,13 @@ void doAttacks()
                                                             terrain.DeleteDecal(j);
                                                         }
                                                     }
-                                                    for (int l = 0; l < objects.numobjects; l++) {
-                                                        if (objects.model[l].type == decalstype)
-                                                            for (int j = 0; j < objects.model[l].numdecals; j++) {
-                                                                if ((objects.model[l].decaltype[j] == blooddecal ||
-                                                                        objects.model[l].decaltype[j] == blooddecalslow) &&
-                                                                        objects.model[l].decalalivetime[j] < 2) {
-                                                                    objects.model[l].DeleteDecal(j);
+                                                    for (int l = 0; l < Object::objects.size(); l++) {
+                                                        if (Object::objects[l]->model.type == decalstype)
+                                                            for (int j = 0; j < Object::objects[l]->model.numdecals; j++) {
+                                                                if ((Object::objects[l]->model.decaltype[j] == blooddecal ||
+                                                                        Object::objects[l]->model.decaltype[j] == blooddecalslow) &&
+                                                                        Object::objects[l]->model.decalalivetime[j] < 2) {
+                                                                    Object::objects[l]->model.DeleteDecal(j);
                                                                 }
                                                             }
                                                     }
@@ -3427,10 +3395,10 @@ void doPlayerCollisions()
                                                                                 }
                                                                                 Person::players[k]->DoDamage(findLengthfast(&rotatetarget) / 4);
 
-                                                                                for (int j = 0; j < Person::players[i]->skeleton.joints.size(); j++) {
+                                                                                for (unsigned j = 0; j < Person::players[i]->skeleton.joints.size(); j++) {
                                                                                     Person::players[i]->skeleton.joints[j].velocity = Person::players[i]->skeleton.joints[j].velocity / 5 + Person::players[k]->velocity;
                                                                                 }
-                                                                                for (int j = 0; j < Person::players[k]->skeleton.joints.size(); j++) {
+                                                                                for (unsigned j = 0; j < Person::players[k]->skeleton.joints.size(); j++) {
                                                                                     Person::players[k]->skeleton.joints[j].velocity = Person::players[k]->skeleton.joints[j].velocity / 5 + Person::players[i]->velocity;
                                                                                 }
 
@@ -3535,16 +3503,17 @@ void doAI(unsigned i)
                 XYZ colpoint;
                 closest = -1;
                 closestdistance = -1;
-                for (int j = 0; j < numpathpoints; j++)
+                for (int j = 0; j < numpathpoints; j++) {
                     if (closest == -1 || distsq(&Person::players[i]->finalfinaltarget, &pathpoint[j]) < closestdistance) {
                         closestdistance = distsq(&Person::players[i]->finalfinaltarget, &pathpoint[j]);
                         closest = j;
                         Person::players[i]->finaltarget = pathpoint[j];
                     }
+                }
                 Person::players[i]->finalpathfindpoint = closest;
-                for (int j = 0; j < numpathpoints; j++)
+                for (int j = 0; j < numpathpoints; j++) {
                     for (int k = 0; k < numpathpointconnect[j]; k++) {
-                        DistancePointLine(&Person::players[i]->finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist, &colpoint );
+                        DistancePointLine(&Person::players[i]->finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist, &colpoint);
                         if (sq(tempdist) < closestdistance)
                             if (findDistance(&colpoint, &pathpoint[j]) + findDistance(&colpoint, &pathpoint[pathpointconnect[j][k]]) <
                                     findDistance(&pathpoint[j], &pathpoint[pathpointconnect[j][k]]) + .1) {
@@ -3553,6 +3522,7 @@ void doAI(unsigned i)
                                 Person::players[i]->finaltarget = colpoint;
                             }
                     }
+                }
                 Person::players[i]->finalpathfindpoint = closest;
 
             }
@@ -4493,10 +4463,6 @@ void Game::Tick()
     static XYZ facing, flatfacing;
     static int target;
 
-    for (int i = 0; i < 15; i++) {
-        displaytime[i] += multiplier;
-    }
-
     Input::Tick();
 
     if (Input::isKeyPressed(SDL_SCANCODE_F6)) {
@@ -4678,7 +4644,7 @@ void Game::Tick()
             talkdelay -= multiplier;
 
             if (talkdelay <= 0 && !Dialog::inDialog() && Animation::animations[Person::players[0]->animTarget].height != highheight) {
-                for (int i = 0; i < Dialog::dialogs.size(); i++) {
+                for (unsigned i = 0; i < Dialog::dialogs.size(); i++) {
                     Dialog::dialogs[i].tick(i);
                 }
             }
@@ -4691,11 +4657,13 @@ void Game::Tick()
             static float hotspotvisual[40];
             if (Hotspot::hotspots.size()) {
                 XYZ hotspotsprite;
-                if (editorenabled)
-                    for (int i = 0; i < Hotspot::hotspots.size(); i++)
+                if (editorenabled) {
+                    for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
                         hotspotvisual[i] -= multiplier / 320;
+                    }
+                }
 
-                for (int i = 0; i < Hotspot::hotspots.size(); i++) {
+                for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
                     while (hotspotvisual[i] < 0) {
                         hotspotsprite = 0;
                         hotspotsprite.x = float(abs(Random() % 100000)) / 100000 * Hotspot::hotspots[i].size;
@@ -4707,7 +4675,7 @@ void Game::Tick()
                     }
                 }
 
-                for (int i = 0; i < Hotspot::hotspots.size(); i++) {
+                for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
                     if (Hotspot::hotspots[i].type <= 10 && Hotspot::hotspots[i].type > 0) {
                         Hotspot::hotspots[i].position = Person::players[Hotspot::hotspots[i].type]->coords;
                     }
@@ -4865,7 +4833,7 @@ void Game::Tick()
                         Dialog::currentScene().camerayaw = yaw;
                         Dialog::currentScene().camerapitch = pitch;
                         Dialog::indialogue++;
-                        if (Dialog::indialogue < Dialog::currentDialog().scenes.size()) {
+                        if (Dialog::indialogue < int(Dialog::currentDialog().scenes.size())) {
                             if (Dialog::currentScene().sound != 0) {
                                 playdialoguescenesound();
                             }
@@ -4899,7 +4867,7 @@ void Game::Tick()
                         if (Input::isKeyDown(SDL_SCANCODE_KP_0)) whichend = 0;
                         Dialog::currentScene().participantfacing[whichend] = facing;
                     }
-                    if (Dialog::indialogue >= Dialog::currentDialog().scenes.size()) {
+                    if (Dialog::indialogue >= int(Dialog::currentDialog().scenes.size())) {
                         Dialog::indialogue = -1;
                         Dialog::directing = false;
                         cameramode = 0;
@@ -4914,7 +4882,7 @@ void Game::Tick()
                     if (Dialog::dialoguetime > 0.5) {
                         if (Input::isKeyPressed(attackkey)) {
                             Dialog::indialogue++;
-                            if (Dialog::indialogue < Dialog::currentDialog().scenes.size()) {
+                            if (Dialog::indialogue < int(Dialog::currentDialog().scenes.size())) {
                                 if (Dialog::currentScene().sound != 0) {
                                     playdialoguescenesound();
                                     if (Dialog::currentScene().sound == -5) {
@@ -4933,7 +4901,7 @@ void Game::Tick()
                             }
                         }
                     }
-                    if (Dialog::indialogue >= Dialog::currentDialog().scenes.size()) {
+                    if (Dialog::indialogue >= int(Dialog::currentDialog().scenes.size())) {
                         Dialog::indialogue = -1;
                         Dialog::directing = false;
                         cameramode = 0;
@@ -5089,17 +5057,17 @@ void Game::Tick()
                     Person::players[i]->avoidsomething = 0;
 
                     //avoid flaming things
-                    for (int j = 0; j < objects.numobjects; j++)
-                        if (objects.onfire[j])
-                            if (distsq(&Person::players[i]->coords, &objects.position[j]) < sq(objects.scale[j]) * 200)
-                                if (     distsq(&Person::players[i]->coords, &objects.position[j]) <
+                    for (int j = 0; j < Object::objects.size(); j++)
+                        if (Object::objects[j]->onfire)
+                            if (distsq(&Person::players[i]->coords, &Object::objects[j]->position) < sq(Object::objects[j]->scale) * 200)
+                                if (     distsq(&Person::players[i]->coords, &Object::objects[j]->position) <
                                          distsq(&Person::players[i]->coords, &Person::players[0]->coords)) {
                                     Person::players[i]->collided = 0;
                                     Person::players[i]->avoidcollided = 1;
                                     if (Person::players[i]->avoidsomething == 0 ||
-                                            distsq(&Person::players[i]->coords, &objects.position[j]) <
+                                            distsq(&Person::players[i]->coords, &Object::objects[j]->position) <
                                             distsq(&Person::players[i]->coords, &Person::players[i]->avoidwhere)) {
-                                        Person::players[i]->avoidwhere = objects.position[j];
+                                        Person::players[i]->avoidwhere = Object::objects[j]->position;
                                         Person::players[i]->avoidsomething = 1;
                                     }
                                 }
@@ -5309,7 +5277,7 @@ void Game::Tick()
                                                                 Person::players[i]->victim->skeleton.free = 1;
                                                                 Person::players[i]->victim->skeleton.broken = 0;
 
-                                                                for (int l = 0; l < Person::players[i]->victim->skeleton.joints.size(); l++) {
+                                                                for (unsigned l = 0; l < Person::players[i]->victim->skeleton.joints.size(); l++) {
                                                                     Person::players[i]->victim->skeleton.joints[l].velchange = 0;
                                                                     Person::players[i]->victim->skeleton.joints[l].locked = 0;
                                                                 }
@@ -5881,7 +5849,7 @@ void Game::Tick()
             }
 
             //do stuff
-            objects.DoStuff();
+            Object::DoStuff();
 
             for (int j = numenvsounds - 1; j >= 0; j--) {
                 envsoundlife[j] -= multiplier;
@@ -5936,7 +5904,7 @@ void Game::Tick()
                     if (distsq(&temp, &Person::players[1]->coords) >= distsq(&temp, &temp2) - 1 || distsq(&temp3, &Person::players[1]->coords) < 4) {
                         emit_sound_at(fireendsound, Person::players[1]->coords);
 
-                        for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
+                        for (unsigned i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
                             if (Random() % 2 == 0) {
                                 if (!Person::players[1]->skeleton.free)
                                     temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
@@ -5951,7 +5919,7 @@ void Game::Tick()
                         }
 
                         Person::players[1]->coords = (oldtemp + oldtemp2) / 2;
-                        for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
+                        for (unsigned i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
                             Person::players[1]->skeleton.joints[i].velocity = 0;
                             if (Random() % 2 == 0) {
                                 if (!Person::players[1]->skeleton.free)
@@ -6154,7 +6122,7 @@ void Game::TickOnceAfter()
         }
 
         Hotspot::killhotspot = 2;
-        for (int i = 0; i < Hotspot::hotspots.size(); i++) {
+        for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
             if (Hotspot::hotspots[i].type > 10 && Hotspot::hotspots[i].type < 20) {
                 if (Person::players[Hotspot::hotspots[i].type - 10]->dead == 0)
                     Hotspot::killhotspot = 0;
@@ -6167,17 +6135,23 @@ void Game::TickOnceAfter()
 
 
         winhotspot = false;
-        for (int i = 0; i < Hotspot::hotspots.size(); i++)
-            if (Hotspot::hotspots[i].type == -1)
-                if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position) < Hotspot::hotspots[i].size)
+        for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
+            if (Hotspot::hotspots[i].type == -1) {
+                if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position) < Hotspot::hotspots[i].size) {
                     winhotspot = true;
+                }
+            }
+        }
 
         int numalarmed = 0;
-        for (unsigned i = 1; i < Person::players.size(); i++)
-            if (!Person::players[i]->dead && Person::players[i]->aitype == attacktypecutoff && Person::players[i]->surprised <= 0)
+        for (unsigned i = 1; i < Person::players.size(); i++) {
+            if (!Person::players[i]->dead && Person::players[i]->aitype == attacktypecutoff && Person::players[i]->surprised <= 0) {
                 numalarmed++;
-        if (numalarmed > maxalarmed)
+            }
+        }
+        if (numalarmed > maxalarmed) {
             maxalarmed = numalarmed;
+        }
 
         if (changedelay <= 0 && !loading && !editorenabled && gameon && !tutoriallevel && changedelay != -999 && !won) {
             if (Person::players[0]->dead && changedelay <= 0) {
@@ -6217,13 +6191,14 @@ void Game::TickOnceAfter()
             if (changedelay > 0 && !Person::players[0]->dead && !won) {
                 //high scores, awards, win
                 if (campaign) {
-                    Account::active->winCampaignLevel(whichchoice, bonustotal, leveltime);
+                    Account::active().winCampaignLevel(whichchoice, bonustotal, leveltime);
                     scoreadded = 1;
                 } else {
                     wonleveltime = leveltime;
-                    Account::active->winLevel(whichlevel, bonustotal - startbonustotal, leveltime);
+                    Account::active().winLevel(whichlevel, bonustotal - startbonustotal, leveltime);
                 }
                 won = 1;
+                Account::saveFile(Folders::getUserSavePath());
             }
         }
 
@@ -6264,7 +6239,7 @@ void Game::TickOnceAfter()
 
                     fireSound(firestartsound);
 
-                    Loadlevel(campaignlevels[Account::active->getCampaignChoicesMade()].mapname.c_str());
+                    Loadlevel(campaignlevels[Account::active().getCampaignChoicesMade()].mapname.c_str());
 
                     fireSound();
 
@@ -6355,7 +6330,7 @@ void Game::TickOnceAfter()
             target = Person::players[0]->oldcoords + Person::players[0]->currentoffset * (1 - Person::players[0]->target) * Person::players[0]->scale + Person::players[0]->targetoffset * Person::players[0]->target * Person::players[0]->scale - Person::players[0]->facing * .05;
         target.y += .1;
         if (Person::players[0]->skeleton.free) {
-            for (int i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+            for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
                 if (Person::players[0]->skeleton.joints[i].position.y * Person::players[0]->scale + Person::players[0]->coords.y > target.y)
                     target.y = Person::players[0]->skeleton.joints[i].position.y * Person::players[0]->scale + Person::players[0]->coords.y;
             }
@@ -6386,20 +6361,20 @@ void Game::TickOnceAfter()
             viewer = cameraloc - facing * cameradist;
             colviewer = viewer;
             coltarget = cameraloc;
-            objects.SphereCheckPossible(&colviewer, findDistance(&colviewer, &coltarget));
+            Object::SphereCheckPossible(&colviewer, findDistance(&colviewer, &coltarget));
             if (terrain.patchobjectnum[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz])
                 for (int j = 0; j < terrain.patchobjectnum[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz]; j++) {
                     int i = terrain.patchobjects[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz][j];
                     colviewer = viewer;
                     coltarget = cameraloc;
-                    if (objects.model[i].LineCheckPossible(&colviewer, &coltarget, &col, &objects.position[i], &objects.yaw[i]) != -1)
+                    if (Object::objects[i]->model.LineCheckPossible(&colviewer, &coltarget, &col, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1)
                         viewer = col;
                 }
             if (terrain.patchobjectnum[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz])
                 for (int j = 0; j < terrain.patchobjectnum[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz]; j++) {
                     int i = terrain.patchobjects[Person::players[0]->whichpatchx][Person::players[0]->whichpatchz][j];
                     colviewer = viewer;
-                    if (objects.model[i].SphereCheck(&colviewer, .15, &col, &objects.position[i], &objects.yaw[i]) != -1) {
+                    if (Object::objects[i]->model.SphereCheck(&colviewer, .15, &col, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1) {
                         viewer = colviewer;
                     }
                 }