From c3265b46c9cb77782a0427b5128609e638ca0215 Mon Sep 17 00:00:00 2001 From: grumbel Date: Wed, 18 Nov 2009 15:28:30 +0000 Subject: [PATCH] Replaced more lisp::Lisp/lisp::Writer with Reader/Writer git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6028 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/addon/addon.cpp | 4 ++-- src/addon/addon.hpp | 2 +- src/addon/addon_manager.cpp | 3 ++- src/addon/addon_manager.hpp | 2 +- src/audio/sound_file.cpp | 2 +- src/badguy/badguy.cpp | 5 +++-- src/badguy/crystallo.cpp | 1 + src/badguy/darttrap.cpp | 1 + src/badguy/dispenser.cpp | 1 + src/badguy/kugelblitz.cpp | 1 + src/badguy/mrbomb.cpp | 1 + src/badguy/willowisp.cpp | 1 + src/control/joystickkeyboardcontroller.hpp | 2 +- src/object/candle.cpp | 1 + src/object/firefly.cpp | 5 +++-- src/object/ispy.cpp | 1 + src/object/lantern.cpp | 1 + src/object/magicblock.cpp | 1 + src/object/moving_sprite.cpp | 1 + src/object/particlesystem_interactive.cpp | 1 + src/object/particlesystem_interactive.hpp | 2 +- src/object/pushbutton.cpp | 1 + src/object/scripted_object.cpp | 1 + src/object/spotlight.cpp | 1 + src/object/trampoline.cpp | 1 + src/scripting/serialize.cpp | 8 ++++---- src/scripting/serialize.hpp | 10 ++++------ src/sprite/sprite_data.cpp | 21 +++++++++++---------- src/sprite/sprite_data.hpp | 7 ++++--- src/sprite/sprite_manager.cpp | 3 ++- src/supertux/player_status.hpp | 2 +- src/supertux/sector.cpp | 2 +- src/supertux/spawn_point.cpp | 4 ++-- src/supertux/spawn_point.hpp | 4 ++-- src/supertux/statistics.hpp | 2 +- src/supertux/world.cpp | 3 ++- src/trigger/door.cpp | 1 + src/trigger/scripttrigger.hpp | 2 +- src/worldmap/level.cpp | 15 ++++++++------- src/worldmap/level.hpp | 2 +- src/worldmap/spawn_point.cpp | 5 +++-- src/worldmap/spawn_point.hpp | 4 ++-- src/worldmap/special_tile.cpp | 19 ++++++++++--------- src/worldmap/special_tile.hpp | 4 ++-- src/worldmap/sprite_change.cpp | 17 +++++++++-------- src/worldmap/sprite_change.hpp | 4 ++-- src/worldmap/teleporter.cpp | 17 +++++++++-------- src/worldmap/teleporter.hpp | 4 ++-- src/worldmap/worldmap.cpp | 12 ++++++------ src/worldmap/worldmap.hpp | 2 +- 50 files changed, 122 insertions(+), 95 deletions(-) diff --git a/src/addon/addon.cpp b/src/addon/addon.cpp index 2f166f1fe..c4bc5adcb 100644 --- a/src/addon/addon.cpp +++ b/src/addon/addon.cpp @@ -21,9 +21,9 @@ #include #include "addon/md5.hpp" -#include "lisp/lisp.hpp" #include "lisp/parser.hpp" -#include "lisp/writer.hpp" +#include "util/reader.hpp" +#include "util/writer.hpp" #include "util/log.hpp" std::string diff --git a/src/addon/addon.hpp b/src/addon/addon.hpp index 033b14f7b..10f72e898 100644 --- a/src/addon/addon.hpp +++ b/src/addon/addon.hpp @@ -58,7 +58,7 @@ public: /** * Writes out Add-on metainformation to a Lisp Writer */ - void write(lisp::Writer& writer) const; + void write(Writer& writer) const; /** * Writes out Add-on metainformation to a file diff --git a/src/addon/addon_manager.cpp b/src/addon/addon_manager.cpp index 245bb4b4f..4b54a2d54 100644 --- a/src/addon/addon_manager.cpp +++ b/src/addon/addon_manager.cpp @@ -33,8 +33,9 @@ #include "addon/addon.hpp" #include "lisp/list_iterator.hpp" -#include "lisp/writer.hpp" #include "lisp/parser.hpp" +#include "util/reader.hpp" +#include "util/writer.hpp" #include "util/log.hpp" #ifdef HAVE_LIBCURL diff --git a/src/addon/addon_manager.hpp b/src/addon/addon_manager.hpp index 693acd3de..3cebc8c1d 100644 --- a/src/addon/addon_manager.hpp +++ b/src/addon/addon_manager.hpp @@ -84,7 +84,7 @@ public: /** * Write AddonManager configuration to Lisp */ - void write(lisp::Writer& writer); + void write(Writer& writer); /** * Read AddonManager configuration from Lisp diff --git a/src/audio/sound_file.cpp b/src/audio/sound_file.cpp index 5283ff594..c710c3b97 100644 --- a/src/audio/sound_file.cpp +++ b/src/audio/sound_file.cpp @@ -27,8 +27,8 @@ #include "audio/sound_error.hpp" #include "audio/ogg_sound_file.hpp" #include "audio/wav_sound_file.hpp" -#include "lisp/lisp.hpp" #include "lisp/parser.hpp" +#include "util/reader.hpp" #include "util/file_system.hpp" #include "util/log.hpp" diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index acdde41fe..e14e81c47 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -16,14 +16,15 @@ #include "badguy/badguy.hpp" +#include + #include "audio/sound_manager.hpp" #include "object/bullet.hpp" #include "object/player.hpp" #include "supertux/level.hpp" #include "supertux/sector.hpp" #include "supertux/tile.hpp" - -#include +#include "util/reader.hpp" static const float SQUISH_TIME = 2; diff --git a/src/badguy/crystallo.cpp b/src/badguy/crystallo.cpp index 57ae0334a..7273d4d14 100644 --- a/src/badguy/crystallo.cpp +++ b/src/badguy/crystallo.cpp @@ -18,6 +18,7 @@ #include "sprite/sprite.hpp" #include "supertux/object_factory.hpp" +#include "util/reader.hpp" Crystallo::Crystallo(const Reader& reader) : WalkingBadguy(reader, "images/creatures/crystallo/crystallo.sprite", "left", "right"), diff --git a/src/badguy/darttrap.cpp b/src/badguy/darttrap.cpp index 3e66642ed..de0bada8a 100644 --- a/src/badguy/darttrap.cpp +++ b/src/badguy/darttrap.cpp @@ -21,6 +21,7 @@ #include "sprite/sprite.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" +#include "util/reader.hpp" namespace { const float MUZZLE_Y = 25; /**< [px] muzzle y-offset from top */ diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index 2c3322b4e..975441e2a 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -22,6 +22,7 @@ #include "object/player.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" +#include "util/reader.hpp" Dispenser::Dispenser(const Reader& reader) : BadGuy(reader, "images/creatures/dispenser/dispenser.sprite"), diff --git a/src/badguy/kugelblitz.cpp b/src/badguy/kugelblitz.cpp index 5a94bac89..2e304bb54 100644 --- a/src/badguy/kugelblitz.cpp +++ b/src/badguy/kugelblitz.cpp @@ -21,6 +21,7 @@ #include "sprite/sprite.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" +#include "util/reader.hpp" #define LIFETIME 5 #define MOVETIME 0.75 diff --git a/src/badguy/mrbomb.cpp b/src/badguy/mrbomb.cpp index 2e8a4531e..67efd6486 100644 --- a/src/badguy/mrbomb.cpp +++ b/src/badguy/mrbomb.cpp @@ -22,6 +22,7 @@ #include "sprite/sprite_manager.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" +#include "util/reader.hpp" MrBomb::MrBomb(const Reader& reader) : WalkingBadguy(reader, "images/creatures/mr_bomb/mr_bomb.sprite", "left", "right"), diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index bb48cb43c..3ed8f9f1a 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -26,6 +26,7 @@ #include "supertux/game_session.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" +#include "util/reader.hpp" static const float FLYSPEED = 64; /**< speed in px per second */ static const float TRACK_RANGE = 384; /**< at what distance to start tracking the player */ diff --git a/src/control/joystickkeyboardcontroller.hpp b/src/control/joystickkeyboardcontroller.hpp index 2a66f1681..1bcf23b12 100644 --- a/src/control/joystickkeyboardcontroller.hpp +++ b/src/control/joystickkeyboardcontroller.hpp @@ -42,7 +42,7 @@ public: */ void process_event(const SDL_Event& event); - void write(lisp::Writer& writer); + void write(Writer& writer); void read(const Reader& lisp); void reset(); diff --git a/src/object/candle.cpp b/src/object/candle.cpp index fc06de227..f4b28a1e7 100644 --- a/src/object/candle.cpp +++ b/src/object/candle.cpp @@ -21,6 +21,7 @@ #include "scripting/squirrel_util.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" +#include "util/reader.hpp" Candle::Candle(const Reader& lisp) : MovingSprite(lisp, "images/objects/candle/candle.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_DISABLED), burning(true), diff --git a/src/object/firefly.cpp b/src/object/firefly.cpp index 792c69d9c..2241a3c4a 100644 --- a/src/object/firefly.cpp +++ b/src/object/firefly.cpp @@ -16,14 +16,15 @@ #include "object/firefly.hpp" +#include + #include "math/random_generator.hpp" #include "object/player.hpp" #include "object/sprite_particle.hpp" #include "supertux/game_session.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" - -#include +#include "util/reader.hpp" Firefly::Firefly(const Reader& lisp) : MovingSprite(lisp, "images/objects/resetpoints/default-resetpoint.sprite", LAYER_TILES, COLGROUP_TOUCHABLE), diff --git a/src/object/ispy.cpp b/src/object/ispy.cpp index 3d0c16969..5a7092ef9 100644 --- a/src/object/ispy.cpp +++ b/src/object/ispy.cpp @@ -22,6 +22,7 @@ #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" #include "supertux/tile.hpp" +#include "util/reader.hpp" Ispy::Ispy(const Reader& reader) : MovingSprite(reader, "images/objects/ispy/ispy.sprite", LAYER_TILES+5, COLGROUP_DISABLED), diff --git a/src/object/lantern.cpp b/src/object/lantern.cpp index 800e17707..065f53768 100644 --- a/src/object/lantern.cpp +++ b/src/object/lantern.cpp @@ -22,6 +22,7 @@ #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" #include "supertux/object_factory.hpp" +#include "util/reader.hpp" Lantern::Lantern(const Reader& reader) : Rock(reader, "images/objects/lantern/lantern.sprite"), diff --git a/src/object/magicblock.cpp b/src/object/magicblock.cpp index 4081cf9d5..9064d5dd4 100644 --- a/src/object/magicblock.cpp +++ b/src/object/magicblock.cpp @@ -26,6 +26,7 @@ #include "supertux/globals.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" +#include "util/reader.hpp" namespace { const float MIN_INTENSITY = 0.8f; diff --git a/src/object/moving_sprite.cpp b/src/object/moving_sprite.cpp index 24f0877b4..646addbd1 100644 --- a/src/object/moving_sprite.cpp +++ b/src/object/moving_sprite.cpp @@ -17,6 +17,7 @@ #include "object/moving_sprite.hpp" #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" +#include "util/reader.hpp" MovingSprite::MovingSprite(const Vector& pos, const std::string& sprite_name, int layer, CollisionGroup collision_group) : diff --git a/src/object/particlesystem_interactive.cpp b/src/object/particlesystem_interactive.cpp index 1628af675..e9a28bec7 100644 --- a/src/object/particlesystem_interactive.cpp +++ b/src/object/particlesystem_interactive.cpp @@ -24,6 +24,7 @@ #include "supertux/collision.hpp" #include "supertux/globals.hpp" #include "supertux/tile.hpp" +#include "util/reader.hpp" //TODO: Find a way to make rain collide with objects like bonus blocks // Add an option to set rain strength diff --git a/src/object/particlesystem_interactive.hpp b/src/object/particlesystem_interactive.hpp index 296b3ff59..b7d841176 100644 --- a/src/object/particlesystem_interactive.hpp +++ b/src/object/particlesystem_interactive.hpp @@ -109,7 +109,7 @@ public: virtual ~CometParticleSystem(); void parse(const Reader& lisp); - void write(lisp::Writer& writer); + void write(Writer& writer); virtual void update(float elapsed_time); diff --git a/src/object/pushbutton.cpp b/src/object/pushbutton.cpp index 5488de345..027274f51 100644 --- a/src/object/pushbutton.cpp +++ b/src/object/pushbutton.cpp @@ -20,6 +20,7 @@ #include "sprite/sprite.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" +#include "util/reader.hpp" namespace { const std::string BUTTON_SOUND = "sounds/switch.ogg"; diff --git a/src/object/scripted_object.cpp b/src/object/scripted_object.cpp index 2da88188c..56a1fd5da 100644 --- a/src/object/scripted_object.cpp +++ b/src/object/scripted_object.cpp @@ -21,6 +21,7 @@ #include "scripting/squirrel_util.hpp" #include "sprite/sprite.hpp" #include "supertux/object_factory.hpp" +#include "util/reader.hpp" ScriptedObject::ScriptedObject(const Reader& lisp) : MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING_STATIC), diff --git a/src/object/spotlight.cpp b/src/object/spotlight.cpp index 36b7bef9f..194776607 100644 --- a/src/object/spotlight.cpp +++ b/src/object/spotlight.cpp @@ -18,6 +18,7 @@ #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" #include "supertux/object_factory.hpp" +#include "util/reader.hpp" Spotlight::Spotlight(const Reader& lisp) : position(), diff --git a/src/object/trampoline.cpp b/src/object/trampoline.cpp index 3b6630c39..e097dcd01 100644 --- a/src/object/trampoline.cpp +++ b/src/object/trampoline.cpp @@ -22,6 +22,7 @@ #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" #include "supertux/object_factory.hpp" +#include "util/reader.hpp" /* Trampoline will accelerate player to to VY_INITIAL, if * he jumps on it to VY_MIN. */ diff --git a/src/scripting/serialize.cpp b/src/scripting/serialize.cpp index 59dc46a99..5dbc6d1f9 100644 --- a/src/scripting/serialize.cpp +++ b/src/scripting/serialize.cpp @@ -24,14 +24,14 @@ namespace Scripting { -void load_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, const lisp::Lisp* lisp) +void load_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, const Reader& lisp) { using namespace lisp; if(table_idx < 0) table_idx -= 2; - lisp::ListIterator iter(lisp); + lisp::ListIterator iter(&lisp); while(iter.next() && iter.lisp() != NULL) { const std::string& token = iter.item(); sq_pushstring(vm, token.c_str(), token.size()); @@ -40,7 +40,7 @@ void load_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, const lisp::Lisp* switch(value->get_type()) { case Lisp::TYPE_CONS: sq_newtable(vm); - load_squirrel_table(vm, sq_gettop(vm), iter.lisp()); + load_squirrel_table(vm, sq_gettop(vm), *iter.lisp()); break; case Lisp::TYPE_INTEGER: sq_pushinteger(vm, value->get_int()); @@ -68,7 +68,7 @@ void load_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, const lisp::Lisp* } } -void save_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, lisp::Writer& writer) +void save_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, Writer& writer) { // offset because of sq_pushnull if(table_idx < 0) diff --git a/src/scripting/serialize.hpp b/src/scripting/serialize.hpp index 3779d544a..036327914 100644 --- a/src/scripting/serialize.hpp +++ b/src/scripting/serialize.hpp @@ -19,15 +19,13 @@ #include -namespace lisp { -class Lisp; -class Writer; -} // namespace lisp +#include "util/writer_fwd.hpp" +#include "util/reader_fwd.hpp" namespace Scripting { -void save_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, lisp::Writer& writer); -void load_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, const lisp::Lisp* lisp); +void save_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, Writer& writer); +void load_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, const Reader& lisp); } // namespace Scripting diff --git a/src/sprite/sprite_data.cpp b/src/sprite/sprite_data.cpp index 6d2d2a558..4b1d8b4ce 100644 --- a/src/sprite/sprite_data.cpp +++ b/src/sprite/sprite_data.cpp @@ -21,6 +21,7 @@ #include "lisp/list_iterator.hpp" #include "util/log.hpp" +#include "util/reader.hpp" SpriteData::Action::Action() : name(), @@ -47,16 +48,16 @@ SpriteData::Action::~Action() delete *i; } -SpriteData::SpriteData(const lisp::Lisp* lisp, const std::string& basedir) : +SpriteData::SpriteData(const Reader& lisp, const std::string& basedir) : actions(), name() { - lisp::ListIterator iter(lisp); + lisp::ListIterator iter(&lisp); while(iter.next()) { if(iter.item() == "name") { iter.value()->get(name); } else if(iter.item() == "action") { - parse_action(iter.lisp(), basedir); + parse_action(*iter.lisp(), basedir); } else { log_warning << "Unknown sprite field: " << iter.item() << std::endl; } @@ -72,28 +73,28 @@ SpriteData::~SpriteData() } void -SpriteData::parse_action(const lisp::Lisp* lisp, const std::string& basedir) +SpriteData::parse_action(const Reader& lisp, const std::string& basedir) { Action* action = new Action; - if(!lisp->get("name", action->name)) { + if(!lisp.get("name", action->name)) { if(!actions.empty()) throw std::runtime_error( "If there are more than one action, they need names!"); } std::vector hitbox; - if (lisp->get("hitbox", hitbox)) { + if (lisp.get("hitbox", hitbox)) { if (hitbox.size() != 4) throw std::runtime_error("hitbox must specify exactly 4 coordinates"); action->x_offset = hitbox[0]; action->y_offset = hitbox[1]; action->hitbox_w = hitbox[2]; action->hitbox_h = hitbox[3]; } - lisp->get("z-order", action->z_order); - lisp->get("fps", action->fps); + lisp.get("z-order", action->z_order); + lisp.get("fps", action->fps); std::string mirror_action; - lisp->get("mirror-action", mirror_action); + lisp.get("mirror-action", mirror_action); if(!mirror_action.empty()) { Action* act_tmp = get_action(mirror_action); if(act_tmp == NULL) { @@ -114,7 +115,7 @@ SpriteData::parse_action(const lisp::Lisp* lisp, const std::string& basedir) } } else { // Load images std::vector images; - if(!lisp->get("images", images)) { + if(!lisp.get("images", images)) { std::stringstream msg; msg << "Sprite '" << name << "' contains no images in action '" << action->name << "'."; diff --git a/src/sprite/sprite_data.hpp b/src/sprite/sprite_data.hpp index 85940e218..f732cbeda 100644 --- a/src/sprite/sprite_data.hpp +++ b/src/sprite/sprite_data.hpp @@ -18,15 +18,16 @@ #define HEADER_SUPERTUX_SPRITE_SPRITE_DATA_HPP #include +#include -#include "lisp/lisp.hpp" +#include "util/reader_fwd.hpp" #include "video/surface.hpp" class SpriteData { public: /** cur has to be a pointer to data in the form of ((hitbox 5 10 0 0) ...) */ - SpriteData(const lisp::Lisp* cur, const std::string& basedir); + SpriteData(const Reader& cur, const std::string& basedir); ~SpriteData(); const std::string& get_name() const @@ -65,7 +66,7 @@ private: typedef std::map Actions; - void parse_action(const lisp::Lisp* lispreader, const std::string& basedir); + void parse_action(const Reader& lispreader, const std::string& basedir); /** Get an action */ Action* get_action(std::string act); diff --git a/src/sprite/sprite_manager.cpp b/src/sprite/sprite_manager.cpp index a12fff501..0ef214a20 100644 --- a/src/sprite/sprite_manager.cpp +++ b/src/sprite/sprite_manager.cpp @@ -19,6 +19,7 @@ #include "lisp/parser.hpp" #include "sprite/sprite.hpp" #include "util/file_system.hpp" +#include "util/reader.hpp" SpriteManager* sprite_manager = NULL; @@ -77,7 +78,7 @@ SpriteManager::load(const std::string& filename) } std::auto_ptr data ( - new SpriteData(sprite, FileSystem::dirname(filename)) ); + new SpriteData(*sprite, FileSystem::dirname(filename)) ); sprites[filename] = data.release(); return sprites[filename]; diff --git a/src/supertux/player_status.hpp b/src/supertux/player_status.hpp index 631534c41..454ac1706 100644 --- a/src/supertux/player_status.hpp +++ b/src/supertux/player_status.hpp @@ -47,7 +47,7 @@ public: void reset(); void add_coins(int count, bool play_sound = true); - void write(lisp::Writer& writer); + void write(Writer& writer); void read(const Reader& lisp); void draw(DrawingContext& context); diff --git a/src/supertux/sector.cpp b/src/supertux/sector.cpp index 11f536719..62fb618f3 100644 --- a/src/supertux/sector.cpp +++ b/src/supertux/sector.cpp @@ -193,7 +193,7 @@ Sector::parse(const Reader& sector) } else if(token == "music") { iter.value()->get(music); } else if(token == "spawnpoint") { - SpawnPoint* sp = new SpawnPoint(iter.lisp()); + SpawnPoint* sp = new SpawnPoint(*iter.lisp()); spawnpoints.push_back(sp); } else if(token == "init-script") { iter.value()->get(init_script); diff --git a/src/supertux/spawn_point.cpp b/src/supertux/spawn_point.cpp index 3175da834..8cc24c00e 100644 --- a/src/supertux/spawn_point.cpp +++ b/src/supertux/spawn_point.cpp @@ -30,13 +30,13 @@ SpawnPoint::SpawnPoint(const SpawnPoint& other) : pos(other.pos) {} -SpawnPoint::SpawnPoint(const lisp::Lisp* slisp) : +SpawnPoint::SpawnPoint(const Reader& slisp) : name(), pos() { pos.x = -1; pos.y = -1; - lisp::ListIterator iter(slisp); + lisp::ListIterator iter(&slisp); while(iter.next()) { const std::string& token = iter.item(); if(token == "name") { diff --git a/src/supertux/spawn_point.hpp b/src/supertux/spawn_point.hpp index 4b0268e30..5526e8d56 100644 --- a/src/supertux/spawn_point.hpp +++ b/src/supertux/spawn_point.hpp @@ -18,14 +18,14 @@ #define HEADER_SUPERTUX_SUPERTUX_SPAWN_POINT_HPP #include "math/vector.hpp" -namespace lisp { class Lisp; } +#include "util/reader_fwd.hpp" class SpawnPoint { public: SpawnPoint(); SpawnPoint(const SpawnPoint& other); - SpawnPoint(const lisp::Lisp* lisp); + SpawnPoint(const Reader& lisp); std::string name; Vector pos; diff --git a/src/supertux/statistics.hpp b/src/supertux/statistics.hpp index 450f03db1..35266024d 100644 --- a/src/supertux/statistics.hpp +++ b/src/supertux/statistics.hpp @@ -51,7 +51,7 @@ public: /// read statistics from lisp file //void parse(const Reader& lisp); /// write statistics to lisp file - //void write(lisp::Writer& writer); + //void write(Writer& writer); /** * serialize statistics object as squirrel table "statistics" diff --git a/src/supertux/world.cpp b/src/supertux/world.cpp index acbd69023..a8fda6ba7 100644 --- a/src/supertux/world.cpp +++ b/src/supertux/world.cpp @@ -23,6 +23,7 @@ #include "supertux/player_status.hpp" #include "supertux/world.hpp" #include "util/file_system.hpp" +#include "util/reader.hpp" #include "worldmap/worldmap.hpp" static bool has_suffix(const std::string& data, const std::string& suffix) @@ -225,7 +226,7 @@ World::load_state() sq_pushstring(global_vm, "state", -1); sq_newtable(global_vm); - load_squirrel_table(global_vm, -1, state); + load_squirrel_table(global_vm, -1, *state); if(SQ_FAILED(sq_createslot(global_vm, -3))) throw std::runtime_error("Couldn't create state table"); sq_pop(global_vm, 1); diff --git a/src/trigger/door.cpp b/src/trigger/door.cpp index 2f44ac280..59091f781 100644 --- a/src/trigger/door.cpp +++ b/src/trigger/door.cpp @@ -20,6 +20,7 @@ #include "supertux/game_session.hpp" #include "supertux/object_factory.hpp" #include "trigger/door.hpp" +#include "util/reader.hpp" Door::Door(const Reader& reader) : state(CLOSED), diff --git a/src/trigger/scripttrigger.hpp b/src/trigger/scripttrigger.hpp index fb0c37db8..e93824d22 100644 --- a/src/trigger/scripttrigger.hpp +++ b/src/trigger/scripttrigger.hpp @@ -26,7 +26,7 @@ public: ScriptTrigger(const Vector& pos, const std::string& script); ~ScriptTrigger(); - void write(lisp::Writer& writer); + void write(Writer& writer); void event(Player& player, EventType type); private: diff --git a/src/worldmap/level.cpp b/src/worldmap/level.cpp index 8a4330e8f..3529a4c59 100644 --- a/src/worldmap/level.cpp +++ b/src/worldmap/level.cpp @@ -23,12 +23,13 @@ #include "sprite/sprite_manager.hpp" #include "util/file_system.hpp" #include "util/log.hpp" +#include "util/reader.hpp" #include "video/drawing_context.hpp" #include "worldmap/level.hpp" namespace WorldMapNS { -LevelTile::LevelTile(const std::string& basedir, const lisp::Lisp* lisp) : +LevelTile::LevelTile(const std::string& basedir, const Reader& lisp) : pos(), title(), solved(false), @@ -40,16 +41,16 @@ LevelTile::LevelTile(const std::string& basedir, const lisp::Lisp* lisp) : picture_cached(false), picture(0) { - lisp->get("name", name); - lisp->get("x", pos.x); - lisp->get("y", pos.y); - lisp->get("auto-play", auto_play); + lisp.get("name", name); + lisp.get("x", pos.x); + lisp.get("y", pos.y); + lisp.get("auto-play", auto_play); std::string spritefile = "images/worldmap/common/leveldot.sprite"; - lisp->get("sprite", spritefile); + lisp.get("sprite", spritefile); sprite = sprite_manager->create(spritefile); - lisp->get("extro-script", extro_script); + lisp.get("extro-script", extro_script); if (!PHYSFS_exists((basedir + name).c_str())) { diff --git a/src/worldmap/level.hpp b/src/worldmap/level.hpp index 9d9db4f3c..8c3e859df 100644 --- a/src/worldmap/level.hpp +++ b/src/worldmap/level.hpp @@ -33,7 +33,7 @@ namespace WorldMapNS { class LevelTile : public GameObject { public: - LevelTile(const std::string& basedir, const lisp::Lisp* lisp); + LevelTile(const std::string& basedir, const Reader& lisp); virtual ~LevelTile(); virtual void draw(DrawingContext& context); diff --git a/src/worldmap/spawn_point.cpp b/src/worldmap/spawn_point.cpp index 15905010e..e805fc0f6 100644 --- a/src/worldmap/spawn_point.cpp +++ b/src/worldmap/spawn_point.cpp @@ -18,6 +18,7 @@ #include "lisp/list_iterator.hpp" #include "util/log.hpp" +#include "util/reader.hpp" #include "worldmap/spawn_point.hpp" namespace WorldMapNS { @@ -25,14 +26,14 @@ namespace WorldMapNS { // from worldmap.cpp Direction string_to_direction(const std::string& directory); -SpawnPoint::SpawnPoint(const lisp::Lisp* slisp) : +SpawnPoint::SpawnPoint(const Reader& slisp) : name(), pos(), auto_dir(D_NONE) { pos.x = -1; pos.y = -1; - lisp::ListIterator iter(slisp); + lisp::ListIterator iter(&slisp); while(iter.next()) { const std::string& token = iter.item(); if(token == "name") { diff --git a/src/worldmap/spawn_point.hpp b/src/worldmap/spawn_point.hpp index 0a6237b48..ba98c9f27 100644 --- a/src/worldmap/spawn_point.hpp +++ b/src/worldmap/spawn_point.hpp @@ -19,7 +19,7 @@ #include -#include "lisp/lisp.hpp" +#include "util/reader_fwd.hpp" #include "math/vector.hpp" #include "supertux/game_object.hpp" #include "worldmap/direction.hpp" @@ -29,7 +29,7 @@ namespace WorldMapNS { class SpawnPoint { public: - SpawnPoint(const lisp::Lisp* lisp); + SpawnPoint(const Reader& lisp); std::string name; Vector pos; diff --git a/src/worldmap/special_tile.cpp b/src/worldmap/special_tile.cpp index 9bc419d72..9fba90b46 100644 --- a/src/worldmap/special_tile.cpp +++ b/src/worldmap/special_tile.cpp @@ -18,12 +18,13 @@ #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" +#include "util/reader.hpp" #include "video/drawing_context.hpp" #include "worldmap/special_tile.hpp" namespace WorldMapNS { -SpecialTile::SpecialTile(const lisp::Lisp* lisp) : +SpecialTile::SpecialTile(const Reader& lisp) : pos(), sprite(), map_message(), @@ -35,22 +36,22 @@ SpecialTile::SpecialTile(const lisp::Lisp* lisp) : apply_action_south(true), apply_action_west(true) { - lisp->get("x", pos.x); - lisp->get("y", pos.y); - lisp->get("invisible-tile", invisible); + lisp.get("x", pos.x); + lisp.get("y", pos.y); + lisp.get("invisible-tile", invisible); if(!invisible) { std::string spritefile = ""; - lisp->get("sprite", spritefile); + lisp.get("sprite", spritefile); sprite = sprite_manager->create(spritefile); } - lisp->get("map-message", map_message); - lisp->get("passive-message", passive_message); - lisp->get("script", script); + lisp.get("map-message", map_message); + lisp.get("passive-message", passive_message); + lisp.get("script", script); std::string apply_direction; - lisp->get("apply-to-direction", apply_direction); + lisp.get("apply-to-direction", apply_direction); if(!apply_direction.empty()) { apply_action_north = false; apply_action_south = false; diff --git a/src/worldmap/special_tile.hpp b/src/worldmap/special_tile.hpp index b2ea7ffd2..b17abe58e 100644 --- a/src/worldmap/special_tile.hpp +++ b/src/worldmap/special_tile.hpp @@ -21,7 +21,7 @@ #include #include -#include "lisp/lisp.hpp" +#include "util/reader_fwd.hpp" #include "math/vector.hpp" #include "supertux/game_object.hpp" @@ -32,7 +32,7 @@ namespace WorldMapNS { class SpecialTile : public GameObject { public: - SpecialTile(const lisp::Lisp* lisp); + SpecialTile(const Reader& lisp); virtual ~SpecialTile(); virtual void draw(DrawingContext& context); diff --git a/src/worldmap/sprite_change.cpp b/src/worldmap/sprite_change.cpp index 18c10cf41..48c425ae2 100644 --- a/src/worldmap/sprite_change.cpp +++ b/src/worldmap/sprite_change.cpp @@ -17,12 +17,13 @@ #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" +#include "util/reader.hpp" #include "video/drawing_context.hpp" #include "worldmap/sprite_change.hpp" namespace WorldMapNS { -SpriteChange::SpriteChange(const lisp::Lisp* lisp) : +SpriteChange::SpriteChange(const Reader& lisp) : pos(), change_on_touch(false), sprite(), @@ -30,18 +31,18 @@ SpriteChange::SpriteChange(const lisp::Lisp* lisp) : stay_group(), in_stay_action(false) { - lisp->get("x", pos.x); - lisp->get("y", pos.y); - lisp->get("change-on-touch", change_on_touch); + lisp.get("x", pos.x); + lisp.get("y", pos.y); + lisp.get("change-on-touch", change_on_touch); std::string spritefile = ""; - lisp->get("sprite", spritefile); + lisp.get("sprite", spritefile); sprite = sprite_manager->create(spritefile); - lisp->get("stay-action", stay_action); - lisp->get("initial-stay-action", in_stay_action); + lisp.get("stay-action", stay_action); + lisp.get("initial-stay-action", in_stay_action); - lisp->get("stay-group", stay_group); + lisp.get("stay-group", stay_group); all_sprite_changes.push_back(this); } diff --git a/src/worldmap/sprite_change.hpp b/src/worldmap/sprite_change.hpp index 4f22ae1c2..fc9b9a2d4 100644 --- a/src/worldmap/sprite_change.hpp +++ b/src/worldmap/sprite_change.hpp @@ -21,7 +21,7 @@ #include #include -#include "lisp/lisp.hpp" +#include "util/reader_fwd.hpp" #include "math/vector.hpp" #include "supertux/game_object.hpp" @@ -32,7 +32,7 @@ namespace WorldMapNS { class SpriteChange : public GameObject { public: - SpriteChange(const lisp::Lisp* lisp); + SpriteChange(const Reader& lisp); virtual ~SpriteChange(); virtual void draw(DrawingContext& context); diff --git a/src/worldmap/teleporter.cpp b/src/worldmap/teleporter.cpp index 832fd6b42..620a500cf 100644 --- a/src/worldmap/teleporter.cpp +++ b/src/worldmap/teleporter.cpp @@ -17,12 +17,13 @@ #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" +#include "util/reader.hpp" #include "video/drawing_context.hpp" #include "worldmap/teleporter.hpp" namespace WorldMapNS { -Teleporter::Teleporter(const lisp::Lisp* lisp) : +Teleporter::Teleporter(const Reader& lisp) : pos(), sprite(), worldmap(), @@ -30,18 +31,18 @@ Teleporter::Teleporter(const lisp::Lisp* lisp) : automatic(false), message() { - lisp->get("x", pos.x); - lisp->get("y", pos.y); + lisp.get("x", pos.x); + lisp.get("y", pos.y); std::string spritefile = ""; - if (lisp->get("sprite", spritefile)) { + if (lisp.get("sprite", spritefile)) { sprite = sprite_manager->create(spritefile); } - lisp->get("worldmap", worldmap); - lisp->get("spawnpoint", spawnpoint); - lisp->get("automatic", automatic); - lisp->get("message", message); + lisp.get("worldmap", worldmap); + lisp.get("spawnpoint", spawnpoint); + lisp.get("automatic", automatic); + lisp.get("message", message); } void diff --git a/src/worldmap/teleporter.hpp b/src/worldmap/teleporter.hpp index 0ab3d2576..18c423671 100644 --- a/src/worldmap/teleporter.hpp +++ b/src/worldmap/teleporter.hpp @@ -20,9 +20,9 @@ #include #include -#include "lisp/lisp.hpp" #include "math/vector.hpp" #include "supertux/game_object.hpp" +#include "util/reader_fwd.hpp" class Sprite; @@ -31,7 +31,7 @@ namespace WorldMapNS { class Teleporter : public GameObject { public: - Teleporter(const lisp::Lisp* lisp); + Teleporter(const Reader& lisp); virtual void draw(DrawingContext& context); virtual void update(float elapsed_time); diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index cbf550f65..7ee24fcf8 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -58,7 +58,7 @@ #include "util/file_system.hpp" #include "util/gettext.hpp" #include "util/log.hpp" -#include "util/log.hpp" +#include "util/reader.hpp" #include "video/drawing_context.hpp" #include "video/surface.hpp" #include "worldmap/level.hpp" @@ -356,22 +356,22 @@ WorldMap::load(const std::string& filename) } else if(iter.item() == "init-script") { iter.value()->get(init_script); } else if(iter.item() == "worldmap-spawnpoint") { - SpawnPoint* sp = new SpawnPoint(iter.lisp()); + SpawnPoint* sp = new SpawnPoint(*iter.lisp()); spawn_points.push_back(sp); } else if(iter.item() == "level") { - LevelTile* level = new LevelTile(levels_path, iter.lisp()); + LevelTile* level = new LevelTile(levels_path, *iter.lisp()); levels.push_back(level); add_object(level); } else if(iter.item() == "special-tile") { - SpecialTile* special_tile = new SpecialTile(iter.lisp()); + SpecialTile* special_tile = new SpecialTile(*iter.lisp()); special_tiles.push_back(special_tile); add_object(special_tile); } else if(iter.item() == "sprite-change") { - SpriteChange* sprite_change = new SpriteChange(iter.lisp()); + SpriteChange* sprite_change = new SpriteChange(*iter.lisp()); sprite_changes.push_back(sprite_change); add_object(sprite_change); } else if(iter.item() == "teleporter") { - Teleporter* teleporter = new Teleporter(iter.lisp()); + Teleporter* teleporter = new Teleporter(*iter.lisp()); teleporters.push_back(teleporter); add_object(teleporter); } else if(iter.item() == "ambient-light") { diff --git a/src/worldmap/worldmap.hpp b/src/worldmap/worldmap.hpp index 8ca3bb359..b22cea131 100644 --- a/src/worldmap/worldmap.hpp +++ b/src/worldmap/worldmap.hpp @@ -22,7 +22,7 @@ #include #include "control/controller.hpp" -#include "lisp/lisp.hpp" +#include "util/reader_fwd.hpp" #include "math/vector.hpp" #include "supertux/console.hpp" #include "supertux/game_object.hpp" -- 2.11.0