]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Models.cpp
Switched all data access to the new methods
[lugaru.git] / Source / Models.cpp
index 20c30f7eba719626e22a2d7548f1a93ba155d37a..16f92badf78552f5d1667896e0485184ba7276b1 100644 (file)
@@ -1,5 +1,6 @@
 /*
 Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
 
 This file is part of Lugaru.
 
@@ -19,6 +20,7 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "Game.h"
 #include "Models.h"
+#include "Utils/Folders.h"
 
 extern float multiplier;
 extern float viewdistance;
@@ -153,7 +155,6 @@ int Model::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate)
     static int firstintersecting;
     static XYZ point;
     static XYZ oldp1;
-    static XYZ start, end;
 
     firstintersecting = -1;
 
@@ -207,7 +208,6 @@ int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate)
     static int firstintersecting;
     static XYZ point;
     static XYZ oldp1;
-    static XYZ start, end;
 
     firstintersecting = -1;
 
@@ -405,14 +405,10 @@ bool Model::loadnotex(const char *filename )
     FILE *tfile;
     long i;
 
-    //~ int oldvertexNum, oldTriangleNum;
-    //~ oldvertexNum = vertexNum;
-    //~ oldTriangleNum = TriangleNum;
-
     type = notextype;
     color = 0;
 
-    tfile = fopen( ConvertFileName(filename), "rb" );
+    tfile = fopen( Folders::getResourcePath(filename).c_str(), "rb" );
     // read model settings
 
     fseek(tfile, 0, SEEK_SET);
@@ -434,7 +430,6 @@ bool Model::loadnotex(const char *filename )
     }
 
     for (i = 0; i < TriangleNum; i++) {
-        //funpackf(tfile, "Bi Bi Bi", &Triangles[i].vertex[0], &Triangles[i].vertex[1], &Triangles[i].vertex[2]);
         short vertex[ 6];
         funpackf(tfile, "Bs Bs Bs Bs Bs Bs", &vertex[ 0], &vertex[ 1], &vertex[ 2], &vertex[ 3], &vertex[ 4], &vertex[ 5]);
         Triangles[i].vertex[ 0] = vertex[ 0];
@@ -480,14 +475,10 @@ bool Model::load(const char *filename, bool texture )
     if (visibleloading)
         Game::LoadingScreen();
 
-    //~ int oldvertexNum, oldTriangleNum;
-    //~ oldvertexNum = vertexNum;
-    //~ oldTriangleNum = TriangleNum;
-
     type = normaltype;
     color = 0;
 
-    tfile = fopen( ConvertFileName(filename), "rb" );
+    tfile = fopen( Folders::getResourcePath(filename).c_str(), "rb" );
     // read model settings
 
 
@@ -512,7 +503,6 @@ bool Model::load(const char *filename, bool texture )
     }
 
     for (i = 0; i < TriangleNum; i++) {
-        //funpackf(tfile, "Bi Bi Bi", &Triangles[i].vertex[0], &Triangles[i].vertex[1], &Triangles[i].vertex[2]);
         short vertex[ 6];
         funpackf(tfile, "Bs Bs Bs Bs Bs Bs", &vertex[ 0], &vertex[ 1], &vertex[ 2], &vertex[ 3], &vertex[ 4], &vertex[ 5]);
         Triangles[i].vertex[ 0] = vertex[ 0];
@@ -554,16 +544,13 @@ bool Model::loaddecal(const char *filename, bool texture )
 
     LOGFUNC;
 
-    // Changing the filename so that its more os specific
-    char * FixedFN = ConvertFileName(filename);
-
-    LOG(std::string("Loading decal...") + FixedFN);
+    LOG(std::string("Loading decal...") + Folders::getResourcePath(filename));
 
     type = decalstype;
     numdecals = 0;
     color = 0;
 
-    tfile = fopen( FixedFN, "rb" );
+    tfile = fopen( Folders::getResourcePath(filename).c_str(), "rb" );
     // read model settings
 
 
@@ -590,7 +577,6 @@ bool Model::loaddecal(const char *filename, bool texture )
     }
 
     for (i = 0; i < TriangleNum; i++) {
-        //funpackf(tfile, "Bi Bi Bi", &Triangles[i].vertex[0], &Triangles[i].vertex[1], &Triangles[i].vertex[2]);
         short vertex[ 6];
         funpackf(tfile, "Bs Bs Bs Bs Bs Bs", &vertex[ 0], &vertex[ 1], &vertex[ 2], &vertex[ 3], &vertex[ 4], &vertex[ 5]);
         Triangles[i].vertex[ 0] = vertex[ 0];
@@ -655,14 +641,10 @@ bool Model::loadraw(char *filename )
 
     LOG(std::string("Loading raw...") + filename);
 
-    //~ int oldvertexNum, oldTriangleNum;
-    //~ oldvertexNum = vertexNum;
-    //~ oldTriangleNum = TriangleNum;
-
     type = rawtype;
     color = 0;
 
-    tfile = fopen( ConvertFileName(filename), "rb" );
+    tfile = fopen( Folders::getResourcePath(filename).c_str(), "rb" );
     // read model settings
 
 
@@ -686,7 +668,6 @@ bool Model::loadraw(char *filename )
     }
 
     for (i = 0; i < TriangleNum; i++) {
-        //funpackf(tfile, "Bi Bi Bi", &Triangles[i].vertex[0], &Triangles[i].vertex[1], &Triangles[i].vertex[2]);
         short vertex[ 6];
         funpackf(tfile, "Bs Bs Bs Bs Bs Bs", &vertex[ 0], &vertex[ 1], &vertex[ 2], &vertex[ 3], &vertex[ 4], &vertex[ 5]);
         Triangles[i].vertex[ 0] = vertex[ 0];