#include <sstream>
#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
/**
* 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
#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
/**
* Write AddonManager configuration to Lisp
*/
- void write(lisp::Writer& writer);
+ void write(Writer& writer);
/**
* Read AddonManager configuration from Lisp
#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"
#include "badguy/badguy.hpp"
+#include <math.h>
+
#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 <math.h>
+#include "util/reader.hpp"
static const float SQUISH_TIME = 2;
#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"),
#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 */
#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"),
#include "sprite/sprite.hpp"
#include "supertux/object_factory.hpp"
#include "supertux/sector.hpp"
+#include "util/reader.hpp"
#define LIFETIME 5
#define MOVETIME 0.75
#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"),
#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 */
*/
void process_event(const SDL_Event& event);
- void write(lisp::Writer& writer);
+ void write(Writer& writer);
void read(const Reader& lisp);
void reset();
#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),
#include "object/firefly.hpp"
+#include <math.h>
+
#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 <math.h>
+#include "util/reader.hpp"
Firefly::Firefly(const Reader& lisp) :
MovingSprite(lisp, "images/objects/resetpoints/default-resetpoint.sprite", LAYER_TILES, COLGROUP_TOUCHABLE),
#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),
#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"),
#include "supertux/globals.hpp"
#include "supertux/object_factory.hpp"
#include "supertux/sector.hpp"
+#include "util/reader.hpp"
namespace {
const float MIN_INTENSITY = 0.8f;
#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) :
#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
virtual ~CometParticleSystem();
void parse(const Reader& lisp);
- void write(lisp::Writer& writer);
+ void write(Writer& writer);
virtual void update(float elapsed_time);
#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";
#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),
#include "sprite/sprite.hpp"
#include "sprite/sprite_manager.hpp"
#include "supertux/object_factory.hpp"
+#include "util/reader.hpp"
Spotlight::Spotlight(const Reader& lisp) :
position(),
#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. */
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());
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());
}
}
-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)
#include <squirrel.h>
-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
#include "lisp/list_iterator.hpp"
#include "util/log.hpp"
+#include "util/reader.hpp"
SpriteData::Action::Action() :
name(),
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;
}
}
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<float> 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) {
}
} else { // Load images
std::vector<std::string> images;
- if(!lisp->get("images", images)) {
+ if(!lisp.get("images", images)) {
std::stringstream msg;
msg << "Sprite '" << name << "' contains no images in action '"
<< action->name << "'.";
#define HEADER_SUPERTUX_SPRITE_SPRITE_DATA_HPP
#include <map>
+#include <vector>
-#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
typedef std::map <std::string, Action*> 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);
#include "lisp/parser.hpp"
#include "sprite/sprite.hpp"
#include "util/file_system.hpp"
+#include "util/reader.hpp"
SpriteManager* sprite_manager = NULL;
}
std::auto_ptr<SpriteData> data (
- new SpriteData(sprite, FileSystem::dirname(filename)) );
+ new SpriteData(*sprite, FileSystem::dirname(filename)) );
sprites[filename] = data.release();
return sprites[filename];
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);
} 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);
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") {
#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;
/// 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"
#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)
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);
#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),
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:
#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),
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()))
{
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);
#include "lisp/list_iterator.hpp"
#include "util/log.hpp"
+#include "util/reader.hpp"
#include "worldmap/spawn_point.hpp"
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") {
#include <string>
-#include "lisp/lisp.hpp"
+#include "util/reader_fwd.hpp"
#include "math/vector.hpp"
#include "supertux/game_object.hpp"
#include "worldmap/direction.hpp"
class SpawnPoint
{
public:
- SpawnPoint(const lisp::Lisp* lisp);
+ SpawnPoint(const Reader& lisp);
std::string name;
Vector pos;
#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(),
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;
#include <memory>
#include <string>
-#include "lisp/lisp.hpp"
+#include "util/reader_fwd.hpp"
#include "math/vector.hpp"
#include "supertux/game_object.hpp"
class SpecialTile : public GameObject
{
public:
- SpecialTile(const lisp::Lisp* lisp);
+ SpecialTile(const Reader& lisp);
virtual ~SpecialTile();
virtual void draw(DrawingContext& context);
#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(),
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);
}
#include <memory>
#include <string>
-#include "lisp/lisp.hpp"
+#include "util/reader_fwd.hpp"
#include "math/vector.hpp"
#include "supertux/game_object.hpp"
class SpriteChange : public GameObject
{
public:
- SpriteChange(const lisp::Lisp* lisp);
+ SpriteChange(const Reader& lisp);
virtual ~SpriteChange();
virtual void draw(DrawingContext& context);
#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(),
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
#include <memory>
#include <string>
-#include "lisp/lisp.hpp"
#include "math/vector.hpp"
#include "supertux/game_object.hpp"
+#include "util/reader_fwd.hpp"
class Sprite;
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);
#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"
} 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") {
#include <vector>
#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"