From 354cd9ff21e878c9a34866b0c3916e42e226d105 Mon Sep 17 00:00:00 2001 From: Reimar Date: Sat, 12 Dec 2015 16:20:42 +0100 Subject: Now taking env variable RCADE_DATA and RCADE_SAVE. Default: data/ and save/ . also old saves are not compatible --- engine.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'engine.cpp') diff --git a/engine.cpp b/engine.cpp index 50b39ee..41d6a95 100644 --- a/engine.cpp +++ b/engine.cpp @@ -2,7 +2,7 @@ UserShip* getShipWithName(string shipname) { - string path = "data/ships/user/"; + string path = get_data_path() + "ships/user/"; ifstream ships; ships.open((path + "userships.txt").c_str()); char workaround; @@ -34,7 +34,7 @@ UserShip* getShipWithName(string shipname) Weapon* getWeaponWithName(string weaponname) { - string path = "data/weapons/"; + string path = get_data_path() + "weapons/"; ifstream weapons; weapons.open((path + "weapons.txt").c_str()); char workaround; @@ -68,7 +68,7 @@ Account::Account() gold = 0; highscore = 0; ifstream ins; - string path = "data/ships/user/"; + string path = get_data_path() + "ships/user/"; ins.open((path + "userships.txt").c_str()); current = 0; string shippath; @@ -361,14 +361,14 @@ HUD::HUD(long long *nhighscore, double *nhp, double nhpmax, double *nenergy, dou maxEnergy = nmaxEnergy; gold = ngold; exp = nexp; - energyRaw = loadBMP("data/images/energy_raw2.bmp"); - SDL_Surface *bubbles = loadBMP("data/images/energy_bubbles3.bmp"); + energyRaw = loadBMP(get_data_path() + "images/energy_raw2.bmp"); + SDL_Surface *bubbles = loadBMP(get_data_path() + "images/energy_bubbles3.bmp"); energyBubbles = new SlidingBackground(bubbles,0,-200); - energyMasc = loadBMP("data/images/energy_masc2.bmp"); - hpRaw = loadBMP("data/images/hp_raw.bmp"); - hpMasc = loadBMP("data/images/hp_masc2.bmp"); - background = loadBMP("data/images/hud_background.bmp"); - font = TTF_OpenFont("data/fonts/OpenSans-Semibold.ttf",12); + energyMasc = loadBMP(get_data_path() + "images/energy_masc2.bmp"); + hpRaw = loadBMP(get_data_path() + "images/hp_raw.bmp"); + hpMasc = loadBMP(get_data_path() + "images/hp_masc2.bmp"); + background = loadBMP(get_data_path() + "images/hud_background.bmp"); + font = TTF_OpenFont((get_data_path() + "fonts/OpenSans-Semibold.ttf").c_str(),12); if(font == NULL) { cout << "Error loading font in HUD" << endl; @@ -683,15 +683,15 @@ vector > > > generateWave(int number, int /*structure of a LevelFile IntroLevel #name -data/images/bg_stars.bmp #path of background +images/bg_stars.bmp #path of background 30 #speed of background 1 #wether to randomize background position 60 #duration [s] 12346543 #seed 2 #number of Shiptypes -data/tork_capsule.txt #path of Ship +tork_capsule.txt #path of Ship 50 #how many of them should spawn -data/tork_spacerocket.txt #path of Ship +tork_spacerocket.txt #path of Ship 12 #how many 1 #how many events shall happen 0.5 #percentage of completion the event happens @@ -701,7 +701,7 @@ LevelGenerator::LevelGenerator(string filename, Account* user, SDL_Surface* nscr { vector shouldSpawn; screen = nscreen; - SDL_Surface* fakeScreen = loadBMP("data/images/game_screen.bmp"); + SDL_Surface* fakeScreen = loadBMP(get_data_path() + "images/game_screen.bmp"); current = 0; completed = 0; event = false; @@ -716,7 +716,7 @@ LevelGenerator::LevelGenerator(string filename, Account* user, SDL_Surface* nscr getline(ins, name); string backgroundPath; getline(ins, backgroundPath); - SDL_Surface* background = loadBMP(backgroundPath); + SDL_Surface* background = loadBMP(get_data_path() + backgroundPath); OH = new ObjectHandler(user, fakeScreen,background); UserShip *s = user->ships[user->current]; hud = new HUD(&OH->highscore, &s->hp, s->maxhp, &s->energy, s->maxEnergy, &OH->gold, user->getExpPointer()); @@ -735,7 +735,7 @@ LevelGenerator::LevelGenerator(string filename, Account* user, SDL_Surface* nscr ins >> workaround; string shipFilename; getline(ins, shipFilename); - EnemyShip* enemy = new EnemyShip(workaround + shipFilename); + EnemyShip* enemy = new EnemyShip(get_data_path() + workaround + shipFilename); prototypes.push_back(enemy); for(int l = 0; l < (int) enemy->weapons.size(); ++l) for(int i = 0; i < (int) enemy->weapons[l]->sounds.size(); ++i) -- cgit v1.2.3