#include <iostream>
#include <vector>
#include <assert.h>
+#include "globals.h"
#include "texture.h"
#include "screen.h"
#include "lispreader.h"
#include "gameloop.h"
+#include "setup.h"
#include "worldmap.h"
namespace WorldMapNS {
TileManager::TileManager()
{
- lisp_stream_t stream;
- FILE* in = fopen(DATA_PREFIX "images/worldmap/antarctica.scm", "r");
- assert(in);
- lisp_stream_init_file (&stream, in);
- lisp_object_t* root_obj = lisp_read (&stream);
-
+ std::string filename = datadir + "images/worldmap/antarctica.scm";
+ lisp_object_t* root_obj = lisp_read_from_file(filename);
+
+ if (!root_obj)
+ st_abort("Couldn't load file", filename);
+
if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-worldmap-tiles") == 0)
{
lisp_object_t* cur = lisp_cdr(root_obj);
reader.read_string("image", &filename);
texture_load(&tile->sprite,
- const_cast<char*>((std::string(DATA_PREFIX "/images/worldmap/") + filename).c_str()),
+ datadir + "/images/worldmap/" + filename,
USE_ALPHA);
if (id >= int(tiles.size()))
Tux::Tux(WorldMap* worldmap_)
: worldmap(worldmap_)
{
- texture_load(&sprite, DATA_PREFIX "/images/worldmap/tux.png", USE_ALPHA);
+ texture_load(&sprite, datadir + "/images/worldmap/tux.png", USE_ALPHA);
offset = 0;
moving = false;
tile_pos.x = 0;
width = 20;
height = 15;
- texture_load(&level_sprite, DATA_PREFIX "/images/worldmap/levelmarker.png", USE_ALPHA);
+ texture_load(&level_sprite, datadir + "/images/worldmap/levelmarker.png", USE_ALPHA);
input_direction = NONE;
enter_level = false;
void
WorldMap::load_map()
{
- lisp_stream_t stream;
- FILE* in = fopen(DATA_PREFIX "levels/default/worldmap.scm", "r");
- assert(in);
- lisp_stream_init_file (&stream, in);
- lisp_object_t* root_obj = lisp_read (&stream);
+ std::string filename = datadir + "levels/default/worldmap.stwm";
+
+ lisp_object_t* root_obj = lisp_read_from_file(filename);
+ if (!root_obj)
+ st_abort("Couldn't load file", filename);
if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-worldmap") == 0)
{
{
std::cout << "Enter the current level: " << i->name << std::endl;;
halt_music();
- gameloop(const_cast<char*>((DATA_PREFIX "levels/default/" + i->name).c_str()),
+ gameloop(const_cast<char*>((datadir + "levels/default/" + i->name).c_str()),
1, ST_GL_LOAD_LEVEL_FILE);
play_music(song, 1);
break;
{
quit = false;
- song = load_song(const_cast<char*>((DATA_PREFIX "/music/" + music).c_str()));
+ song = load_song(datadir + "/music/" + music);
play_music(song, 1);
while(!quit) {