X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FModels.cpp;h=2c301689ea38f8cd3695e7ebd5693fc2d838ec0c;hb=8a32dc9e4e1011b10f009e999d7d008aa2711d8a;hp=d0a991b8217a5b6eed602b44b613913ce6664dd9;hpb=2d54e57ffa32e0a02013d79be57b8a2f3bc8db05;p=lugaru.git diff --git a/Source/Models.cpp b/Source/Models.cpp index d0a991b..2c30168 100644 --- a/Source/Models.cpp +++ b/Source/Models.cpp @@ -20,6 +20,7 @@ along with Lugaru. If not, see . #include "Game.h" #include "Models.h" +#include "Utils/Folders.h" extern float multiplier; extern float viewdistance; @@ -399,7 +400,7 @@ void Model::UpdateVertexArrayNoTexNoNorm() } } -bool Model::loadnotex(const char *filename ) +bool Model::loadnotex(const std::string& filename ) { FILE *tfile; long i; @@ -407,7 +408,8 @@ bool Model::loadnotex(const char *filename ) type = notextype; color = 0; - tfile = fopen( ConvertFileName(filename), "rb" ); + tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" ); + // read model settings fseek(tfile, 0, SEEK_SET); @@ -458,11 +460,11 @@ bool Model::loadnotex(const char *filename ) } boundingsphereradius = fast_sqrt(boundingsphereradius); - return 1; + return true; } -bool Model::load(const char *filename, bool texture ) +bool Model::load(const std::string& filename, bool texture ) { FILE *tfile; long i; @@ -477,9 +479,9 @@ bool Model::load(const char *filename, bool texture ) type = normaltype; color = 0; - tfile = fopen( ConvertFileName(filename), "rb" ); - // read model settings + tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" ); + // read model settings fseek(tfile, 0, SEEK_SET); funpackf(tfile, "Bs Bs", &vertexNum, &TriangleNum); @@ -533,28 +535,25 @@ bool Model::load(const char *filename, bool texture ) } boundingsphereradius = fast_sqrt(boundingsphereradius); - return 1; + return true; } -bool Model::loaddecal(const char *filename, bool texture ) +bool Model::loaddecal(const std::string& filename, bool texture ) { FILE *tfile; long i, j; 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" ); - // read model settings + tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" ); + // read model settings fseek(tfile, 0, SEEK_SET); funpackf(tfile, "Bs Bs", &vertexNum, &TriangleNum); @@ -631,10 +630,10 @@ bool Model::loaddecal(const char *filename, bool texture ) decalposition = (XYZ*)malloc(sizeof(XYZ) * max_model_decals); } - return 1; + return true; } -bool Model::loadraw(char *filename ) +bool Model::loadraw(const std::string& filename) { FILE *tfile; long i; @@ -646,9 +645,9 @@ bool Model::loadraw(char *filename ) type = rawtype; color = 0; - tfile = fopen( ConvertFileName(filename), "rb" ); - // read model settings + tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" ); + // read model settings fseek(tfile, 0, SEEK_SET); funpackf(tfile, "Bs Bs", &vertexNum, &TriangleNum); @@ -686,7 +685,7 @@ bool Model::loadraw(char *filename ) owner[i] = -1; } - return 1; + return true; }