-
-#include <iostream>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-#include "globals.h"
-#include "scene.h"
-#include "screen.h"
-#include "defines.h"
-#include "world.h"
-#include "level.h"
-#include "tile.h"
-#include "resources.h"
-#include "gameobjs.h"
-#include "camera.h"
-#include "display_manager.h"
-#include "background.h"
-#include "tilemap.h"
-
-Surface* img_distro[4];
-
-World* World::current_ = 0;
-
-World::World(const std::string& filename, int level_nr)
- : level(0), tux(0), background(0), camera(0)
-{
- // FIXME: Move this to action and draw and everywhere else where the
- // world calls child functions
- current_ = this;
-
- tux = new Player(displaymanager);
- add_object(tux);
-
- level = new Level();
- camera = new Camera(tux, level);
- add_object(camera);
-
- if(level_nr >= 0) {
- level->load(filename, level_nr, this);
- } else {
- level->load(filename, this);
- }
- tux->move(level->start_pos);
-
- set_defaults();
-
- level->load_gfx();
- // add background
- activate_particle_systems();
- background = new Background(displaymanager);
- if(level->img_bkgd) {
- background->set_image(level->img_bkgd, level->bkgd_speed);
- } else {
- background->set_gradient(level->bkgd_top, level->bkgd_bottom);
- }
- add_object(background);
-
- // add tilemap
- add_object(new TileMap(displaymanager, level));
- level->load_song();
-
- apply_bonuses();
-}
-
-void
-World::apply_bonuses()
-{
- // Apply bonuses from former levels
- switch (player_status.bonus)
- {
- case PlayerStatus::NO_BONUS:
- break;
-
- case PlayerStatus::FLOWER_BONUS:
- tux->got_power = Player::FIRE_POWER; // FIXME: add ice power to here
- // fall through
-
- case PlayerStatus::GROWUP_BONUS:
- tux->grow();
- break;
- }
-}
-
-World::~World()
-{
- for (std::vector<GameObject*>::iterator i = gameobjects.begin();
- i != gameobjects.end(); ++i) {
- delete *i;
- }
-
- delete level;
-
- current_ = 0;
-}
-
-void
-World::set_defaults()
-{
- player_status.score_multiplier = 1;
-
- counting_distros = false;
- distro_counter = 0;
-
- /* set current song/music */
- currentmusic = LEVEL_MUSIC;
-}
-
-void
-World::add_object(GameObject* object)
-{
- // XXX hack for now until new collision code is ready
- BadGuy* badguy = dynamic_cast<BadGuy*> (object);
- if(badguy)
- bad_guys.push_back(badguy);
- Bullet* bullet = dynamic_cast<Bullet*> (object);
- if(bullet)
- bullets.push_back(bullet);
- Upgrade* upgrade = dynamic_cast<Upgrade*> (object);
- if(upgrade)
- upgrades.push_back(upgrade);
- Trampoline* trampoline = dynamic_cast<Trampoline*> (object);
- if(trampoline)
- trampolines.push_back(trampoline);
- FlyingPlatform* flying_platform = dynamic_cast<FlyingPlatform*> (object);
- if(flying_platform)
- flying_platforms.push_back(flying_platform);
-
- gameobjects.push_back(object);
+#include <config.h>
+
+#include <stddef.h>
+#include <physfs.h>
+#include <stdexcept>
+
+#include "world.hpp"
+#include "file_system.hpp"
+#include "lisp/parser.hpp"
+#include "lisp/lisp.hpp"
+#include "physfs/physfs_stream.hpp"
+#include "scripting/squirrel_util.hpp"
+#include "scripting/serialize.hpp"
+#include "log.hpp"
+#include "worldmap/worldmap.hpp"
+#include "mainloop.hpp"
+
+static bool has_suffix(const std::string& data, const std::string& suffix)
+{
+ if (data.length() >= suffix.length())
+ return data.compare(data.length() - suffix.length(), suffix.length(), suffix) == 0;
+ else
+ return false;