#include <fstream>
#include "MacCompatibility.h"
#include "string.h"
+#include <iostream>
using namespace std;
int numaccounts;
int accountactive;
- tfile = fopen(ConvertFileName(filename.c_str()), "rb" );
+ tfile = fopen(filename.c_str(), "rb" );
if (tfile) {
funpackf(tfile, "Bi", &numaccounts);
fclose(tfile);
return get(accountactive);
} else {
- printf("filenotfound\n");
+ perror(("Couldn't load users from " + filename).c_str());
return NULL;
}
}
{
FILE *tfile;
- tfile = fopen(ConvertFileName(filename.c_str(), "wb"), "wb" );
+ tfile = fopen(filename.c_str(), "wb" );
if (tfile) {
printf("writing %d accounts :\n", getNbAccounts());
fpackf(tfile, "Bi", getNbAccounts());
}
fclose(tfile);
+ } else {
+ perror(("Couldn't save users in " + filename).c_str());
}
}
#include "ConsoleCmds.h"
#include "Game.h"
#include "Dialog.h"
+#include "Utils/Folders.h"
const char *cmd_names[cmd_count] = {
#define DECLARE_COMMAND(cmd) #cmd,
static void set_clothes(int pnum, const char *args)
{
char buf[64];
- snprintf(buf, 63, ":Data:Textures:%s.png", args);
+ snprintf(buf, 63, "Textures/%s.png", args);
int id = Person::players[pnum]->numclothes;
strcpy(Person::players[pnum]->clothes[id], buf);
void ch_save(const char *args)
{
- char buf[64];
- snprintf(buf, 63, ":Data:Maps:%s", args);
+ std::string map_path = Folders::getUserDataPath() + "/Maps/" + args;
int mapvers = 12;
FILE *tfile;
- tfile = fopen( ConvertFileName(buf), "wb" );
+ tfile = fopen( map_path.c_str(), "wb" );
fpackf(tfile, "Bi", mapvers);
fpackf(tfile, "Bi", maptype);
fpackf(tfile, "Bi", hostile);
void ch_cellar(const char *args)
{
- Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:Furdarko.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
+ Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Furdarko.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
void ch_tint(const char *args)
void ch_funnybunny(const char *args)
{
Person::players[0]->skeleton.id = 0;
- Person::players[0]->skeleton.Load(":Data:Skeleton:Basic Figure", ":Data:Skeleton:Basic Figurelow",
- ":Data:Skeleton:Rabbitbelt", ":Data:Models:Body.solid",
- ":Data:Models:Body2.solid", ":Data:Models:Body3.solid",
- ":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);
- Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:fur3.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
+ Person::players[0]->skeleton.Load("Skeleton/Basic Figure", "Skeleton/Basic Figurelow",
+ "Skeleton/Rabbitbelt", "Models/Body.solid",
+ "Models/Body2.solid", "Models/Body3.solid",
+ "Models/Body4.solid", "Models/Body5.solid",
+ "Models/Body6.solid", "Models/Body7.solid",
+ "Models/Bodylow.solid", "Models/Belt.solid", 1);
+ Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/fur3.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
Person::players[0]->creature = rabbittype;
Person::players[0]->scale = .2;
Person::players[0]->headless = 0;
void ch_wolfie(const char *args)
{
Person::players[0]->skeleton.id = 0;
- Person::players[0]->skeleton.Load(":Data:Skeleton:Basic Figure Wolf", ":Data:Skeleton:Basic Figure Wolf Low",
- ":Data:Skeleton:Rabbitbelt", ":Data:Models:Wolf.solid",
- ":Data:Models:Wolf2.solid", ":Data:Models:Wolf3.solid",
- ":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);
- Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
+ Person::players[0]->skeleton.Load("Skeleton/Basic Figure Wolf", "Skeleton/Basic Figure Wolf Low",
+ "Skeleton/Rabbitbelt", "Models/Wolf.solid",
+ "Models/Wolf2.solid", "Models/Wolf3.solid",
+ "Models/Wolf4.solid", "Models/Wolf5.solid",
+ "Models/Wolf6.solid", "Models/Wolf7.solid",
+ "Models/Wolflow.solid", "Models/Belt.solid", 0);
+ Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Wolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
Person::players[0]->creature = wolftype;
Person::players[0]->damagetolerance = 300;
set_proportion(0, "1 1 1 1");
void ch_wolf(const char *args)
{
- Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
+ Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Wolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
void ch_snowwolf(const char *args)
{
- Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:SnowWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
+ Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/SnowWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
void ch_darkwolf(const char *args)
{
- Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:DarkWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
+ Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/DarkWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
void ch_lizardwolf(const char *args)
{
- Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:Lizardwolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
+ Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Lizardwolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
void ch_white(const char *args)
{
- Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:fur.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
+ Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/fur.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
void ch_brown(const char *args)
{
- Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:fur3.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
+ Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/fur3.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
void ch_black(const char *args)
{
- Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:fur2.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
+ Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/fur2.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
void ch_sizemin(const char *args)
void ch_dialogue(const char *args)
{
int type;
- char buf1[32], filename[64];
+ char buf1[32];
sscanf(args, "%d %31s", &type, buf1);
- snprintf(filename, 63, ":Data:Dialogues:%s.txt", buf1);
+ std::string filename = std::string("Dialogues/") + buf1 + ".txt";
Dialog::dialogs.push_back(Dialog(type, filename));
void ch_fixdialogue(const char *args)
{
- char buf1[32], filename[64];
+ char buf1[32];
int whichdi;
sscanf(args, "%d %31s", &whichdi, buf1);
- snprintf(filename, 63, ":Data:Dialogues:%s.txt", buf1);
+ std::string filename = std::string("Dialogues/") + buf1 + ".txt";
Dialog::dialogs[whichdi] = Dialog(Dialog::dialogs[whichdi].type, filename);
}
#include "Input.h"
#include "Game.h"
#include "binio.h"
+#include "Utils/Folders.h"
extern int hostile;
/* Load dialog from txt file, used by console */
Dialog::Dialog(int type, std::string filename) : type(type)
{
- ifstream ipstream(ConvertFileName(filename.c_str()));
+ ifstream ipstream(Folders::getResourcePath(filename));
ipstream.ignore(256, ':');
int numscenes;
ipstream >> numscenes;
void playdialoguescenesound();
int findClosestPlayer();
void Loadlevel(int which);
-void Loadlevel(const char *name);
+void Loadlevel(const std::string& name);
void Tick();
void TickOnce();
void TickOnceAfter();
#include "openal_wrapper.h"
#include "Animation.h"
#include "Texture.h"
+#include "Utils/Folders.h"
extern float screenwidth, screenheight;
extern float viewdistance;
Game::endgame = 0;
}
- Account::saveFile(":Data:Users", Game::accountactive);
+ Account::saveFile(Folders::getUserDataPath()+"/users", Game::accountactive);
//textures.clear();
//Load Image
ImageRec texture;
- load_image(ConvertFileName(fileName), texture);
+ load_image(Folders::getResourcePath(fileName).c_str(), texture);
texdetail = temptexdetail;
int bytesPerPixel = texture.bpp / 8;
numchallengelevels = 14;
- accountactive = Account::loadFile(":Data:Users");
+ accountactive = Account::loadFile(Folders::getUserDataPath()+"/users");
whichjointstartarray[0] = righthip;
whichjointendarray[0] = rightfoot;
int temptexdetail = texdetail;
texdetail = 1;
- text->LoadFontTexture(":Data:Textures:Font.png");
+ text->LoadFontTexture("Textures/Font.png");
text->BuildFont();
texdetail = temptexdetail;
if (musictoggle)
emit_stream_np(stream_menutheme);
- cursortexture.load(":Data:Textures:Cursor.png", 0);
+ cursortexture.load("Textures/Cursor.png", 0);
- Mapcircletexture.load(":Data:Textures:MapCircle.png", 0);
- Mapboxtexture.load(":Data:Textures:MapBox.png", 0);
- Maparrowtexture.load(":Data:Textures:MapArrow.png", 0);
+ Mapcircletexture.load("Textures/MapCircle.png", 0);
+ Mapboxtexture.load("Textures/MapBox.png", 0);
+ Maparrowtexture.load("Textures/MapArrow.png", 0);
temptexdetail = texdetail;
if (texdetail > 2)
texdetail = 2;
- Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0);
- Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0);
- Mainmenuitems[2].load(":Data:Textures:Options.png", 0);
- Mainmenuitems[3].load(":Data:Textures:Quit.png", 0);
- Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0);
- Mainmenuitems[5].load(":Data:Textures:Resume.png", 0);
- Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0);
+ Mainmenuitems[0].load("Textures/Lugaru.png", 0);
+ Mainmenuitems[1].load("Textures/Newgame.png", 0);
+ Mainmenuitems[2].load("Textures/Options.png", 0);
+ Mainmenuitems[3].load("Textures/Quit.png", 0);
+ Mainmenuitems[4].load("Textures/Eyelid.png", 0);
+ Mainmenuitems[5].load("Textures/Resume.png", 0);
+ Mainmenuitems[6].load("Textures/Endgame.png", 0);
texdetail = temptexdetail;
i = abs(Random() % 4);
visibleloading = 0; //don't use loadscreentexture yet
- loadscreentexture.load(":Data:Textures:fire.jpg", 1);
+ loadscreentexture.load("Textures/fire.jpg", 1);
visibleloading = 1;
temptexdetail = texdetail;
texdetail = 1;
- text->LoadFontTexture(":Data:Textures:Font.png");
+ text->LoadFontTexture("Textures/Font.png");
text->BuildFont();
texdetail = temptexdetail;
LOG("Loading weapon data...");
- Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0);
- Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0);
- Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0);
- Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1);
- Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1);
- Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1);
- Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1);
+ Weapon::knifetextureptr.load("Textures/knife.png", 0);
+ Weapon::bloodknifetextureptr.load("Textures/bloodknife.png", 0);
+ Weapon::lightbloodknifetextureptr.load("Textures/lightbloodknife.png", 0);
+ Weapon::swordtextureptr.load("Textures/sword.jpg", 1);
+ Weapon::bloodswordtextureptr.load("Textures/Swordblood.jpg", 1);
+ Weapon::lightbloodswordtextureptr.load("Textures/Swordbloodlight.jpg", 1);
+ Weapon::stafftextureptr.load("Textures/Staff.jpg", 1);
- Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
+ Weapon::throwingknifemodel.load((char *)"Models/throwingknife.solid", 1);
Weapon::throwingknifemodel.Scale(.001, .001, .001);
Weapon::throwingknifemodel.Rotate(90, 0, 0);
Weapon::throwingknifemodel.Rotate(0, 90, 0);
Weapon::throwingknifemodel.flat = 0;
Weapon::throwingknifemodel.CalculateNormals(1);
- Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
+ Weapon::swordmodel.load((char *)"Models/sword.solid", 1);
Weapon::swordmodel.Scale(.001, .001, .001);
Weapon::swordmodel.Rotate(90, 0, 0);
Weapon::swordmodel.Rotate(0, 90, 0);
Weapon::swordmodel.flat = 1;
Weapon::swordmodel.CalculateNormals(1);
- Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
+ Weapon::staffmodel.load((char *)"Models/staff.solid", 1);
Weapon::staffmodel.Scale(.005, .005, .005);
Weapon::staffmodel.Rotate(90, 0, 0);
Weapon::staffmodel.Rotate(0, 90, 0);
Weapon::staffmodel.flat = 1;
Weapon::staffmodel.CalculateNormals(1);
- terrain.shadowtexture.load(":Data:Textures:shadow.png", 0);
- terrain.bloodtexture.load(":Data:Textures:blood.png", 0);
- terrain.breaktexture.load(":Data:Textures:break.png", 0);
- terrain.bloodtexture2.load(":Data:Textures:blood.png", 0);
+ terrain.shadowtexture.load("Textures/shadow.png", 0);
+ terrain.bloodtexture.load("Textures/blood.png", 0);
+ terrain.breaktexture.load("Textures/break.png", 0);
+ terrain.bloodtexture2.load("Textures/blood.png", 0);
- terrain.footprinttexture.load(":Data:Textures:footprint.png", 0);
- terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0);
- hawktexture.load(":Data:Textures:hawk.png", 0);
+ terrain.footprinttexture.load("Textures/footprint.png", 0);
+ terrain.bodyprinttexture.load("Textures/bodyprint.png", 0);
+ hawktexture.load("Textures/hawk.png", 0);
- Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1);
- Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1);
- Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1);
- Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1);
- Sprite::flametexture.load(":Data:Textures:flame.png", 1);
- Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1);
- Sprite::smoketexture.load(":Data:Textures:smoke.png", 1);
- Sprite::shinetexture.load(":Data:Textures:shine.png", 1);
- Sprite::splintertexture.load(":Data:Textures:splinter.png", 1);
- Sprite::leaftexture.load(":Data:Textures:leaf.png", 1);
- Sprite::toothtexture.load(":Data:Textures:tooth.png", 1);
+ Sprite::cloudtexture.load("Textures/cloud.png", 1);
+ Sprite::cloudimpacttexture.load("Textures/cloudimpact.png", 1);
+ Sprite::bloodtexture.load("Textures/bloodparticle.png", 1);
+ Sprite::snowflaketexture.load("Textures/snowflake.png", 1);
+ Sprite::flametexture.load("Textures/flame.png", 1);
+ Sprite::bloodflametexture.load("Textures/bloodflame.png", 1);
+ Sprite::smoketexture.load("Textures/smoke.png", 1);
+ Sprite::shinetexture.load("Textures/shine.png", 1);
+ Sprite::splintertexture.load("Textures/splinter.png", 1);
+ Sprite::leaftexture.load("Textures/leaf.png", 1);
+ Sprite::toothtexture.load("Textures/tooth.png", 1);
yaw = 0;
pitch = 0;
viewer.x = terrain.size / 2 * terrain.scale;
viewer.z = terrain.size / 2 * terrain.scale;
- hawk.load((char *)":Data:Models:hawk.solid", 1);
+ hawk.load((char *)"Models/hawk.solid", 1);
hawk.Scale(.03, .03, .03);
hawk.Rotate(90, 1, 1);
hawk.CalculateNormals(0);
hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
- eye.load((char *)":Data:Models:eye.solid", 1);
+ eye.load((char *)"Models/eye.solid", 1);
eye.Scale(.03, .03, .03);
eye.CalculateNormals(0);
- cornea.load((char *)":Data:Models:cornea.solid", 1);
+ cornea.load((char *)"Models/cornea.solid", 1);
cornea.Scale(.03, .03, .03);
cornea.CalculateNormals(0);
- iris.load((char *)":Data:Models:iris.solid", 1);
+ iris.load((char *)"Models/iris.solid", 1);
iris.Scale(.03, .03, .03);
iris.CalculateNormals(0);
- LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
- LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
+ LoadSave("Textures/Bloodfur.png", 0, 1, &bloodText[0], 0);
+ LoadSave("Textures/Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
oldenvironment = -4;
#include "Menu.h"
#include "ConsoleCmds.h"
#include "Dialog.h"
+#include "Utils/Folders.h"
#include <algorithm>
#include <set>
int musicselected = 0;
const char *rabbitskin[] = {
- ":Data:Textures:Fur3.jpg",
- ":Data:Textures:Fur.jpg",
- ":Data:Textures:Fur2.jpg",
- ":Data:Textures:Lynx.jpg",
- ":Data:Textures:Otter.jpg",
- ":Data:Textures:Opal.jpg",
- ":Data:Textures:Sable.jpg",
- ":Data:Textures:Chocolate.jpg",
- ":Data:Textures:BW2.jpg",
- ":Data:Textures:WB2.jpg"
+ "Textures/Fur3.jpg",
+ "Textures/Fur.jpg",
+ "Textures/Fur2.jpg",
+ "Textures/Lynx.jpg",
+ "Textures/Otter.jpg",
+ "Textures/Opal.jpg",
+ "Textures/Sable.jpg",
+ "Textures/Chocolate.jpg",
+ "Textures/BW2.jpg",
+ "Textures/WB2.jpg"
};
const char *wolfskin[] = {
- ":Data:Textures:Wolf.jpg",
- ":Data:Textures:Darkwolf.jpg",
- ":Data:Textures:Snowwolf.jpg"
+ "Textures/Wolf.jpg",
+ "Textures/Darkwolf.jpg",
+ "Textures/Snowwolf.jpg"
};
const char **creatureskin[] = {rabbitskin, wolfskin};
if (ambientsound)
emit_stream_np(stream_wind);
- objects.treetextureptr.load(":Data:Textures:snowtree.png", 0);
- objects.bushtextureptr.load(":Data:Textures:bushsnow.png", 0);
- objects.rocktextureptr.load(":Data:Textures:bouldersnow.jpg", 1);
- objects.boxtextureptr.load(":Data:Textures:snowbox.jpg", 1);
+ 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);
footstepsound = footstepsn1;
footstepsound2 = footstepsn2;
footstepsound3 = footstepst1;
footstepsound4 = footstepst2;
- terraintexture.load(":Data:Textures:snow.jpg", 1);
- terraintexture2.load(":Data:Textures:rock.jpg", 1);
+ terraintexture.load("Textures/snow.jpg", 1);
+ terraintexture2.load("Textures/rock.jpg", 1);
temptexdetail = texdetail;
if (texdetail > 1)
texdetail = 4;
- skybox->load( ":Data:Textures:Skybox(snow):Front.jpg",
- ":Data:Textures:Skybox(snow):Left.jpg",
- ":Data:Textures:Skybox(snow):Back.jpg",
- ":Data:Textures:Skybox(snow):Right.jpg",
- ":Data:Textures:Skybox(snow):Up.jpg",
- ":Data:Textures:Skybox(snow):Down.jpg");
+ skybox->load( "Textures/Skybox(snow):Front.jpg",
+ "Textures/Skybox(snow):Left.jpg",
+ "Textures/Skybox(snow):Back.jpg",
+ "Textures/Skybox(snow):Right.jpg",
+ "Textures/Skybox(snow):Up.jpg",
+ "Textures/Skybox(snow):Down.jpg");
} else if (environment == desertenvironment) {
windvector = 0;
windvector.z = 2;
- objects.treetextureptr.load(":Data:Textures:deserttree.png", 0);
- objects.bushtextureptr.load(":Data:Textures:bushdesert.png", 0);
- objects.rocktextureptr.load(":Data:Textures:boulderdesert.jpg", 1);
- objects.boxtextureptr.load(":Data:Textures:desertbox.jpg", 1);
+ 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);
if (ambientsound)
footstepsound3 = footstepsn1;
footstepsound4 = footstepsn2;
- terraintexture.load(":Data:Textures:sand.jpg", 1);
- terraintexture2.load(":Data:Textures:sandslope.jpg", 1);
+ terraintexture.load("Textures/sand.jpg", 1);
+ terraintexture2.load("Textures/sandslope.jpg", 1);
temptexdetail = texdetail;
if (texdetail > 1)
texdetail = 4;
- skybox->load( ":Data:Textures:Skybox(sand):Front.jpg",
- ":Data:Textures:Skybox(sand):Left.jpg",
- ":Data:Textures:Skybox(sand):Back.jpg",
- ":Data:Textures:Skybox(sand):Right.jpg",
- ":Data:Textures:Skybox(sand):Up.jpg",
- ":Data:Textures:Skybox(sand):Down.jpg");
+ skybox->load( "Textures/Skybox(sand):Front.jpg",
+ "Textures/Skybox(sand):Left.jpg",
+ "Textures/Skybox(sand):Back.jpg",
+ "Textures/Skybox(sand):Right.jpg",
+ "Textures/Skybox(sand):Up.jpg",
+ "Textures/Skybox(sand):Down.jpg");
} else if (environment == grassyenvironment) {
windvector = 0;
windvector.z = 2;
- objects.treetextureptr.load(":Data:Textures:tree.png", 0);
- objects.bushtextureptr.load(":Data:Textures:bush.png", 0);
- objects.rocktextureptr.load(":Data:Textures:boulder.jpg", 1);
- objects.boxtextureptr.load(":Data:Textures:grassbox.jpg", 1);
+ 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);
if (ambientsound)
emit_stream_np(stream_wind, 100.);
footstepsound3 = footstepst1;
footstepsound4 = footstepst2;
- terraintexture.load(":Data:Textures:grassdirt.jpg", 1);
- terraintexture2.load(":Data:Textures:mossrock.jpg", 1);
+ terraintexture.load("Textures/grassdirt.jpg", 1);
+ terraintexture2.load("Textures/mossrock.jpg", 1);
temptexdetail = texdetail;
if (texdetail > 1)
texdetail = 4;
- skybox->load( ":Data:Textures:Skybox(grass):Front.jpg",
- ":Data:Textures:Skybox(grass):Left.jpg",
- ":Data:Textures:Skybox(grass):Back.jpg",
- ":Data:Textures:Skybox(grass):Right.jpg",
- ":Data:Textures:Skybox(grass):Up.jpg",
- ":Data:Textures:Skybox(grass):Down.jpg");
+ skybox->load( "Textures/Skybox(grass):Front.jpg",
+ "Textures/Skybox(grass):Left.jpg",
+ "Textures/Skybox(grass):Back.jpg",
+ "Textures/Skybox(grass):Right.jpg",
+ "Textures/Skybox(grass):Up.jpg",
+ "Textures/Skybox(grass):Down.jpg");
}
temptexdetail = texdetail;
texdetail = 1;
- terrain.load(":Data:Textures:heightmap.png");
+ terrain.load("Textures/heightmap.png");
texdetail = temptexdetail;
}
{
if (!accountactive)
return;
- ifstream ipstream(ConvertFileName((":Data:Campaigns:" + accountactive->getCurrentCampaign() + ".txt").c_str()));
+ ifstream ipstream(Folders::getResourcePath("Campaigns/" + accountactive->getCurrentCampaign() + ".txt"));
if (!ipstream.good()) {
if (accountactive->getCurrentCampaign() == "main") {
cerr << "Could not found main campaign!" << endl;
}
ipstream.close();
- ifstream test(ConvertFileName((":Data:Textures:" + accountactive->getCurrentCampaign() + ":World.png").c_str()));
+ ifstream test(Folders::getResourcePath("Textures/" + accountactive->getCurrentCampaign() + ":World.png"));
if (test.good()) {
- Mainmenuitems[7].load((":Data:Textures:" + accountactive->getCurrentCampaign() + ":World.png").c_str(), 0);
+ Mainmenuitems[7].load("Textures/" + accountactive->getCurrentCampaign() + ":World.png", 0);
} else {
- Mainmenuitems[7].load(":Data:Textures:World.png", 0);
+ Mainmenuitems[7].load("Textures/World.png", 0);
}
if (accountactive->getCampaignChoicesMade() == 0) {
vector<string> ListCampaigns()
{
- DIR *campaigns = opendir(ConvertFileName(":Data:Campaigns"));
+ DIR *campaigns = opendir(Folders::getResourcePath("Campaigns").c_str());
struct dirent *campaign = NULL;
if (!campaigns) {
perror("Problem while loading campaigns");
- cerr << "campaign folder was : " << ConvertFileName(":Data:Campaigns") << endl;
+ cerr << "campaign folder was : " << Folders::getResourcePath("Campaigns") << endl;
exit(EXIT_FAILURE);
}
vector<string> campaignNames;
Loadlevel("mapsave");
}
-void Game::Loadlevel(const char *name)
+void Game::Loadlevel(const std::string& name)
{
int indemo; // FIXME this should be removed
int templength;
float lamefloat;
- static const char *pfx = ":Data:Maps:";
- char *buf;
LOGFUNC;
pause_sound(whooshsound);
pause_sound(stream_firesound);
- // Change the map filename into something that is os specific
- buf = (char*) alloca(strlen(pfx) + strlen(name) + 1);
- sprintf(buf, "%s%s", pfx, name);
- const char *FixedFN = ConvertFileName(buf);
-
int mapvers;
FILE *tfile;
- tfile = fopen( FixedFN, "rb" );
+ tfile = fopen( Folders::getResourcePath("Maps/"+name).c_str(), "rb" );
if (tfile) {
pause_sound(stream_firesound);
scoreadded = 0;
Person::players[i]->creature = rabbittype;
if (Person::players[i]->creature != wolftype) {
Person::players[i]->skeleton.Load(
- (char *)":Data:Skeleton:Basic Figure",
- (char *)":Data:Skeleton:Basic Figurelow",
- (char *)":Data:Skeleton:Rabbitbelt",
- (char *)":Data:Models:Body.solid",
- (char *)":Data:Models:Body2.solid",
- (char *)":Data:Models:Body3.solid",
- (char *)":Data:Models:Body4.solid",
- (char *)":Data:Models:Body5.solid",
- (char *)":Data:Models:Body6.solid",
- (char *)":Data:Models:Body7.solid",
- (char *)":Data:Models:Bodylow.solid",
- (char *)":Data:Models:Belt.solid", 0);
+ (char *)"Skeleton/Basic Figure",
+ (char *)"Skeleton/Basic Figurelow",
+ (char *)"Skeleton/Rabbitbelt",
+ (char *)"Models/Body.solid",
+ (char *)"Models/Body2.solid",
+ (char *)"Models/Body3.solid",
+ (char *)"Models/Body4.solid",
+ (char *)"Models/Body5.solid",
+ (char *)"Models/Body6.solid",
+ (char *)"Models/Body7.solid",
+ (char *)"Models/Bodylow.solid",
+ (char *)"Models/Belt.solid", 0);
} else {
if (Person::players[i]->creature != wolftype) {
Person::players[i]->skeleton.Load(
- (char *)":Data:Skeleton:Basic Figure",
- (char *)":Data:Skeleton:Basic Figurelow",
- (char *)":Data:Skeleton:Rabbitbelt",
- (char *)":Data:Models:Body.solid",
- (char *)":Data:Models:Body2.solid",
- (char *)":Data:Models:Body3.solid",
- (char *)":Data:Models:Body4.solid",
- (char *)":Data:Models:Body5.solid",
- (char *)":Data:Models:Body6.solid",
- (char *)":Data:Models:Body7.solid",
- (char *)":Data:Models:Bodylow.solid",
- (char *)":Data:Models:Belt.solid", 1);
- Person::players[i]->skeleton.drawmodelclothes.textureptr.load(":Data:Textures:Belt.png", 1);
+ (char *)"Skeleton/Basic Figure",
+ (char *)"Skeleton/Basic Figurelow",
+ (char *)"Skeleton/Rabbitbelt",
+ (char *)"Models/Body.solid",
+ (char *)"Models/Body2.solid",
+ (char *)"Models/Body3.solid",
+ (char *)"Models/Body4.solid",
+ (char *)"Models/Body5.solid",
+ (char *)"Models/Body6.solid",
+ (char *)"Models/Body7.solid",
+ (char *)"Models/Bodylow.solid",
+ (char *)"Models/Belt.solid", 1);
+ Person::players[i]->skeleton.drawmodelclothes.textureptr.load("Textures/Belt.png", 1);
}
if (Person::players[i]->creature == wolftype) {
Person::players[i]->skeleton.Load(
- (char *)":Data:Skeleton:Basic Figure Wolf",
- (char *)":Data:Skeleton:Basic Figure Wolf Low",
- (char *)":Data:Skeleton:Rabbitbelt",
- (char *)":Data:Models:Wolf.solid",
- (char *)":Data:Models:Wolf2.solid",
- (char *)":Data:Models:Wolf3.solid",
- (char *)":Data:Models:Wolf4.solid",
- (char *)":Data:Models:Wolf5.solid",
- (char *)":Data:Models:Wolf6.solid",
- (char *)":Data:Models:Wolf7.solid",
- (char *)":Data:Models:Wolflow.solid",
- (char *)":Data:Models:Belt.solid", 0);
+ (char *)"Skeleton/Basic Figure Wolf",
+ (char *)"Skeleton/Basic Figure Wolf Low",
+ (char *)"Skeleton/Rabbitbelt",
+ (char *)"Models/Wolf.solid",
+ (char *)"Models/Wolf2.solid",
+ (char *)"Models/Wolf3.solid",
+ (char *)"Models/Wolf4.solid",
+ (char *)"Models/Wolf5.solid",
+ (char *)"Models/Wolf6.solid",
+ (char *)"Models/Wolf7.solid",
+ (char *)"Models/Wolflow.solid",
+ (char *)"Models/Belt.solid", 0);
}
}
if (Person::players[closest]->creature == rabbittype) {
Person::players[closest]->skeleton.id = closest;
- Person::players[closest]->skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf", (char *)":Data:Skeleton:Basic Figure Wolf Low", (char *)":Data:Skeleton:Rabbitbelt", (char *)":Data:Models:Wolf.solid", (char *)":Data:Models:Wolf2.solid", (char *)":Data:Models:Wolf3.solid", (char *)":Data:Models:Wolf4.solid", (char *)":Data:Models:Wolf5.solid", (char *)":Data:Models:Wolf6.solid", (char *)":Data:Models:Wolf7.solid", (char *)":Data:Models:Wolflow.solid", (char *)":Data:Models:Belt.solid", 0);
- Person::players[closest]->skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg", 1, &Person::players[closest]->skeleton.skinText[0], &Person::players[closest]->skeleton.skinsize);
+ Person::players[closest]->skeleton.Load((char *)"Skeleton/Basic Figure Wolf", (char *)"Skeleton/Basic Figure Wolf Low", (char *)"Skeleton/Rabbitbelt", (char *)"Models/Wolf.solid", (char *)"Models/Wolf2.solid", (char *)"Models/Wolf3.solid", (char *)"Models/Wolf4.solid", (char *)"Models/Wolf5.solid", (char *)"Models/Wolf6.solid", (char *)"Models/Wolf7.solid", (char *)"Models/Wolflow.solid", (char *)"Models/Belt.solid", 0);
+ Person::players[closest]->skeleton.drawmodel.textureptr.load("Textures/Wolf.jpg", 1, &Person::players[closest]->skeleton.skinText[0], &Person::players[closest]->skeleton.skinsize);
Person::players[closest]->whichskin = 0;
Person::players[closest]->creature = wolftype;
Person::players[closest]->damagetolerance = 300;
} else {
Person::players[closest]->skeleton.id = closest;
- Person::players[closest]->skeleton.Load((char *)":Data:Skeleton:Basic Figure", (char *)":Data:Skeleton:Basic Figurelow", (char *)":Data:Skeleton:Rabbitbelt", (char *)":Data:Models:Body.solid", (char *)":Data:Models:Body2.solid", (char *)":Data:Models:Body3.solid", (char *)":Data:Models:Body4.solid", (char *)":Data:Models:Body5.solid", (char *)":Data:Models:Body6.solid", (char *)":Data:Models:Body7.solid", (char *)":Data:Models:Bodylow.solid", (char *)":Data:Models:Belt.solid", 1);
- Person::players[closest]->skeleton.drawmodel.textureptr.load(":Data:Textures:Fur3.jpg", 1, &Person::players[closest]->skeleton.skinText[0], &Person::players[closest]->skeleton.skinsize);
+ Person::players[closest]->skeleton.Load((char *)"Skeleton/Basic Figure", (char *)"Skeleton/Basic Figurelow", (char *)"Skeleton/Rabbitbelt", (char *)"Models/Body.solid", (char *)"Models/Body2.solid", (char *)"Models/Body3.solid", (char *)"Models/Body4.solid", (char *)"Models/Body5.solid", (char *)"Models/Body6.solid", (char *)"Models/Body7.solid", (char *)"Models/Bodylow.solid", (char *)"Models/Belt.solid", 1);
+ Person::players[closest]->skeleton.drawmodel.textureptr.load("Textures/Fur3.jpg", 1, &Person::players[closest]->skeleton.skinText[0], &Person::players[closest]->skeleton.skinsize);
Person::players[closest]->whichskin = 0;
Person::players[closest]->creature = rabbittype;
Person::players.back()->creature = rabbittype;
Person::players.back()->howactive = editoractive;
Person::players.back()->skeleton.id = Person::players.size()-1;
- Person::players.back()->skeleton.Load((char *)":Data:Skeleton:Basic Figure", (char *)":Data:Skeleton:Basic Figurelow", (char *)":Data:Skeleton:Rabbitbelt", (char *)":Data:Models:Body.solid", (char *)":Data:Models:Body2.solid", (char *)":Data:Models:Body3.solid", (char *)":Data:Models:Body4.solid", (char *)":Data:Models:Body5.solid", (char *)":Data:Models:Body6.solid", (char *)":Data:Models:Body7.solid", (char *)":Data:Models:Bodylow.solid", (char *)":Data:Models:Belt.solid", 1);
+ Person::players.back()->skeleton.Load((char *)"Skeleton/Basic Figure", (char *)"Skeleton/Basic Figurelow", (char *)"Skeleton/Rabbitbelt", (char *)"Models/Body.solid", (char *)"Models/Body2.solid", (char *)"Models/Body3.solid", (char *)"Models/Body4.solid", (char *)"Models/Body5.solid", (char *)"Models/Body6.solid", (char *)"Models/Body7.solid", (char *)"Models/Bodylow.solid", (char *)"Models/Belt.solid", 1);
int k = abs(Random() % 2) + 1;
if (k == 0) {
- Person::players.back()->skeleton.drawmodel.textureptr.load(":Data:Textures:Fur3.jpg", 1, &Person::players.back()->skeleton.skinText[0], &Person::players.back()->skeleton.skinsize);
+ Person::players.back()->skeleton.drawmodel.textureptr.load("Textures/Fur3.jpg", 1, &Person::players.back()->skeleton.skinText[0], &Person::players.back()->skeleton.skinsize);
Person::players.back()->whichskin = 0;
} else if (k == 1) {
- Person::players.back()->skeleton.drawmodel.textureptr.load(":Data:Textures:Fur.jpg", 1, &Person::players.back()->skeleton.skinText[0], &Person::players.back()->skeleton.skinsize);
+ Person::players.back()->skeleton.drawmodel.textureptr.load("Textures/Fur.jpg", 1, &Person::players.back()->skeleton.skinText[0], &Person::players.back()->skeleton.skinsize);
Person::players.back()->whichskin = 1;
} else {
- Person::players.back()->skeleton.drawmodel.textureptr.load(":Data:Textures:Fur2.jpg", 1, &Person::players.back()->skeleton.skinText[0], &Person::players.back()->skeleton.skinsize);
+ Person::players.back()->skeleton.drawmodel.textureptr.load("Textures/Fur2.jpg", 1, &Person::players.back()->skeleton.skinText[0], &Person::players.back()->skeleton.skinsize);
Person::players.back()->whichskin = 2;
}
- Person::players.back()->skeleton.drawmodelclothes.textureptr.load(":Data:Textures:Belt.png", 1);
+ Person::players.back()->skeleton.drawmodelclothes.textureptr.load("Textures/Belt.png", 1);
Person::players.back()->power = 1;
Person::players.back()->speedmult = 1;
Person::players.back()->animCurrent = bounceidleanim;
#include "Game.h"
#include "ImageIO.h"
+#include "Utils/Folders.h"
extern bool visibleloading;
const char *ptr = strrchr((char *)file_name, '.');
if (ptr) {
if (strcasecmp(ptr + 1, "png") == 0)
- return save_screenshot_png(file_name);
+ return save_screenshot_png((Folders::getScreenshotDir() + '/' + file_name).c_str());
}
STUBBED("Unsupported image type");
if (fp)
fclose(fp);
if (!retval)
- unlink(ConvertFileName(file_name));
+ unlink(file_name);
return retval;
}
return(rc);
} /* locateCorrectFile */
#endif
-
-
-static char g_filename[4096];
-char* ConvertFileName( const char* orgfilename, const char *mode)
-{
- if (orgfilename == g_filename) // recursion?
- return g_filename;
-
- // translate filename into proper path name
- if (orgfilename[ 0] == ':')
- orgfilename++;
- strcpy( g_filename, orgfilename);
-
- for (int n = 0; g_filename[ n]; n++) {
- if (g_filename[ n] == ':')
- g_filename[ n] = '/';
-
- else if (g_filename[ n] == '\\')
- g_filename[ n] = '/';
- }
-
-#if PLATFORM_UNIX
- locateCorrectFile(g_filename, mode);
-#endif
-
- return g_filename;
-}
#include <stdint.h>
#endif
-
-// fix file names to use '/' instead of ':'
-char* ConvertFileName( const char* orgfilename, const char *mode = "rb" );
-
-#define fopen( a, b) fopen(ConvertFileName(a, b), b)
-
#endif
#include "Game.h"
#include "Models.h"
+#include "Utils/Folders.h"
extern float multiplier;
extern float viewdistance;
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);
type = normaltype;
color = 0;
- tfile = fopen( ConvertFileName(filename), "rb" );
+ tfile = fopen( Folders::getResourcePath(filename).c_str(), "rb" );
// read model settings
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
type = rawtype;
color = 0;
- tfile = fopen( ConvertFileName(filename), "rb" );
+ tfile = fopen( Folders::getResourcePath(filename).c_str(), "rb" );
// read model settings
rotx[numobjects] = 0;
roty[numobjects] = 0;
- if (atype == boxtype) model[numobjects].loaddecal((char *)":Data:Models:Box.solid", 0);
- if (atype == cooltype) model[numobjects].loaddecal((char *)":Data:Models:Cool.solid", 0);
- if (atype == walltype) model[numobjects].loaddecal((char *)":Data:Models:Wall.solid", 0);
- if (atype == tunneltype) model[numobjects].loaddecal((char *)":Data:Models:Tunnel.solid", 0);
- if (atype == chimneytype) model[numobjects].loaddecal((char *)":Data:Models:Chimney.solid", 0);
- if (atype == spiketype) model[numobjects].load((char *)":Data:Models:Spike.solid", 0);
- if (atype == weirdtype) model[numobjects].loaddecal((char *)":Data:Models:Weird.solid", 0);
- if (atype == rocktype) model[numobjects].loaddecal((char *)":Data:Models:Rock.solid", 0);
- if (atype == treetrunktype) model[numobjects].load((char *)":Data:Models:Treetrunk.solid", 0);
- if (atype == treeleavestype) model[numobjects].load((char *)":Data:Models:Leaves.solid", 0);
- if (atype == bushtype) model[numobjects].load((char *)":Data:Models:Bush.solid", 0);
+ if (atype == boxtype) model[numobjects].loaddecal((char *)"Models/Box.solid", 0);
+ if (atype == cooltype) model[numobjects].loaddecal((char *)"Models/Cool.solid", 0);
+ if (atype == walltype) model[numobjects].loaddecal((char *)"Models/Wall.solid", 0);
+ if (atype == tunneltype) model[numobjects].loaddecal((char *)"Models/Tunnel.solid", 0);
+ if (atype == chimneytype) model[numobjects].loaddecal((char *)"Models/Chimney.solid", 0);
+ if (atype == spiketype) model[numobjects].load((char *)"Models/Spike.solid", 0);
+ if (atype == weirdtype) model[numobjects].loaddecal((char *)"Models/Weird.solid", 0);
+ if (atype == rocktype) model[numobjects].loaddecal((char *)"Models/Rock.solid", 0);
+ if (atype == treetrunktype) model[numobjects].load((char *)"Models/Treetrunk.solid", 0);
+ if (atype == treeleavestype) model[numobjects].load((char *)"Models/Leaves.solid", 0);
+ if (atype == bushtype) model[numobjects].load((char *)"Models/Bush.solid", 0);
if (atype == boxtype) friction[numobjects] = 1.5;
if (atype == cooltype) friction[numobjects] = 1.5;
if (atype == treeleavestype) friction[numobjects] = 0;
if (atype == platformtype) {
- model[numobjects].loaddecal((char *)":Data:Models:Platform.solid", 0);
+ model[numobjects].loaddecal((char *)"Models/Platform.solid", 0);
model[numobjects].Rotate(90, 0, 0);
}
rotx[numobjects] = 0;
roty[numobjects] = 0;
- if (atype == boxtype) model[numobjects].loaddecal((char *)":Data:Models:Box.solid", 0);
- if (atype == cooltype) model[numobjects].loaddecal((char *)":Data:Models:Cool.solid", 0);
- if (atype == walltype) model[numobjects].loaddecal((char *)":Data:Models:Wall.solid", 0);
- if (atype == tunneltype) model[numobjects].loaddecal((char *)":Data:Models:Tunnel.solid", 0);
- if (atype == chimneytype) model[numobjects].loaddecal((char *)":Data:Models:Chimney.solid", 0);
- if (atype == spiketype) model[numobjects].load((char *)":Data:Models:Spike.solid", 0);
- if (atype == weirdtype) model[numobjects].loaddecal((char *)":Data:Models:Weird.solid", 0);
- if (atype == rocktype) model[numobjects].loaddecal((char *)":Data:Models:Rock.solid", 0);
- if (atype == treetrunktype) model[numobjects].load((char *)":Data:Models:Treetrunk.solid", 0);
- if (atype == treeleavestype) model[numobjects].load((char *)":Data:Models:Leaves.solid", 0);
- if (atype == bushtype) model[numobjects].load((char *)":Data:Models:Bush.solid", 0);
+ if (atype == boxtype) model[numobjects].loaddecal((char *)"Models/Box.solid", 0);
+ if (atype == cooltype) model[numobjects].loaddecal((char *)"Models/Cool.solid", 0);
+ if (atype == walltype) model[numobjects].loaddecal((char *)"Models/Wall.solid", 0);
+ if (atype == tunneltype) model[numobjects].loaddecal((char *)"Models/Tunnel.solid", 0);
+ if (atype == chimneytype) model[numobjects].loaddecal((char *)"Models/Chimney.solid", 0);
+ if (atype == spiketype) model[numobjects].load((char *)"Models/Spike.solid", 0);
+ if (atype == weirdtype) model[numobjects].loaddecal((char *)"Models/Weird.solid", 0);
+ if (atype == rocktype) model[numobjects].loaddecal((char *)"Models/Rock.solid", 0);
+ if (atype == treetrunktype) model[numobjects].load((char *)"Models/Treetrunk.solid", 0);
+ if (atype == treeleavestype) model[numobjects].load((char *)"Models/Leaves.solid", 0);
+ if (atype == bushtype) model[numobjects].load((char *)"Models/Bush.solid", 0);
if (atype == boxtype) friction[numobjects] = 1.5;
if (atype == cooltype) friction[numobjects] = 1.5;
friction[numobjects] = .5;
if (atype == platformtype) {
- model[numobjects].loaddecal((char *)":Data:Models:Platform.solid", 0);
+ model[numobjects].loaddecal((char *)"Models/Platform.solid", 0);
model[numobjects].Rotate(90, 0, 0);
}
if (newscreenheight < 0)
newscreenheight = screenheight;
ofstream opstream(Folders::getConfigFilePath());
+ if (opstream.fail()) {
+ perror(("Couldn't save config file " + Folders::getConfigFilePath()).c_str());
+ return;
+ }
opstream << "Screenwidth:\n";
opstream << newscreenwidth;
opstream << "\nScreenheight:\n";
bool LoadSettings()
{
ifstream ipstream(Folders::getConfigFilePath(), std::ios::in);
- if ( !ipstream || ipstream.fail() ) {
- printf("Config file not found\n");
+ if ( ipstream.fail() ) {
+ perror(("Couldn't read config file " + Folders::getConfigFilePath()).c_str());
return false;
}
char setting[256];
#include "Skeleton.h"
#include "openal_wrapper.h"
#include "Animation.h"
+#include "Utils/Folders.h"
extern float multiplier;
extern float gravity;
/* EFFECT
* load an animation from file
*/
-void Animation::Load(const char *filename, int aheight, int aattack)
+void Animation::Load(const std::string& filename, int aheight, int aattack)
{
FILE *tfile;
int i, j;
XYZ endoffset;
- // path to dir
- const char *anim_prefix = ":Data:Animations:";
-
-
LOGFUNC;
- // concatenate anim_prefix + filename
- int len = strlen(anim_prefix) + strlen(filename);
- char *buf = new char[len + 1];
- snprintf(buf, len + 1, "%s%s", anim_prefix, filename);
// Changing the filename into something the OS can understand
- char *fixedFN = ConvertFileName(buf);
- delete[] buf;
+ std::string filepath = Folders::getResourcePath("Animations/"+filename);
- LOG(std::string("Loading animation...") + fixedFN);
+ LOG(std::string("Loading animation...") + filepath);
// clear existing data
deallocate();
Game::LoadingScreen();
// read file in binary mode
- tfile = fopen( fixedFN, "rb" );
+ tfile = fopen( filepath.c_str(), "rb" );
if (tfile) {
// read numframes, joints to know how much memory to allocate
funpackf(tfile, "Bi Bi", &numframes, &joints);
// load skeleton
- tfile = fopen( ConvertFileName(filename), "rb" );
+ tfile = fopen( Folders::getResourcePath(filename).c_str(), "rb" );
if (1) { // FIXME: should this be if(tfile) ?
// read num_joints
// load ???
- tfile = fopen( ConvertFileName(lowfilename), "rb" );
+ tfile = fopen( Folders::getResourcePath(lowfilename).c_str(), "rb" );
if (1) { // FIXME: should this be if(tfile) ?
// skip joints section
// load clothes
if (clothes) {
- tfile = fopen( ConvertFileName(clothesfilename), "rb" ); // FIXME: where's the check for valid load
+ tfile = fopen( Folders::getResourcePath(clothesfilename).c_str(), "rb" ); // FIXME: where's the check for valid load
// skip num_joints
lSize = sizeof(num_joints);
~Animation();
Animation & operator = (const Animation & ani);
- void Load(const char *fileName, int aheight, int aattack);
+ void Load(const std::string& fileName, int aheight, int aattack);
protected:
void deallocate();
#include "Quaternions.h"
#include "Sounds.h"
#include "openal_wrapper.h"
+#include "Utils/Folders.h"
struct OPENAL_SAMPLE *samp[sounds_count];
void loadAllSounds()
{
for (int i = 0; i < sounds_count; i++) {
- char buf[64];
- snprintf(buf, 64, ":Data:Sounds:%s", sound_data[i]);
+ std::string buf = std::string("Sounds/") + sound_data[i];
samp[i] = OPENAL_Sample_Load(OPENAL_FREE,
- ConvertFileName(buf),
+ Folders::getResourcePath(buf).c_str(),
snd_mode(i),
0, 0);
}
#include "Game.h"
#include "Terrain.h"
#include "Objects.h"
+#include "Utils/Folders.h"
+
extern XYZ viewer;
extern float viewdistance;
extern float fadestart;
ImageRec texture;
//Load Image
- load_image(ConvertFileName(fileName), texture);
+ load_image(Folders::getResourcePath(fileName).c_str(), texture);
//Is it valid?
if (texture.bpp > 24) {
#include "gamegl.h"
#include "Texture.h"
#include "ImageIO.h"
+#include "Utils/Folders.h"
using namespace std;
ImageRec texture;
//load image into 'texture'
- load_image(ConvertFileName(filename.c_str()), texture);
+ load_image(filename.c_str(), texture);
skinsize = texture.sizeX;
GLuint type = GL_RGBA;
void Texture::load(const string& filename, bool hasMipmap)
{
destroy();
- tex = new TextureRes(filename, hasMipmap);
+ tex = new TextureRes(Folders::getResourcePath(filename), hasMipmap);
}
void Texture::load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep)
{
destroy();
- tex = new TextureRes(filename, hasMipmap, array, skinsizep);
+ tex = new TextureRes(Folders::getResourcePath(filename), hasMipmap, array, skinsizep);
}
void Texture::destroy()
return time;
}
-
-
-static char g_filename[ 256];
-char* ConvertFileName( const char* orgfilename)
-{
- // translate filename into proper path name
- if (orgfilename[ 0] == ':')
- orgfilename++;
- strcpy( g_filename, orgfilename);
-
- for (int n = 0; g_filename[ n]; n++) {
- if (g_filename[ n] == ':')
- g_filename[ n] = '/';
- }
-
- return g_filename;
-}
-
-char* ConvertFileName( const char* orgfilename, const char* junk)
-{
- return ConvertFileName(orgfilename);
-}
Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
-// fix file names to use '/' instead of ':'
-char* ConvertFileName( const char* orgfilename);
-char* ConvertFileName( const char* orgfilename, const char* junk);
-
-
-#define fopen(a, b) fopen(ConvertFileName(a), b);
-
#ifndef __MINGW32__
inline float abs(float f)
{
strcat(fname, ".ogg");
// just in case...
-#undef fopen
FILE *io = fopen(fname, "rb");
if (io == NULL)
return NULL;