From 7a3f75400c0518b72f04fe4209145301191ba151 Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Thu, 23 Mar 2006 23:47:04 +0000 Subject: [PATCH] Forward declarations stink / Path is now serializable / Forward declarations stink SVN-Revision: 3114 --- src/object/path.cpp | 23 +++++++++++++++++++++++ src/object/path.hpp | 5 ++++- src/serializable.hpp | 4 +--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/object/path.cpp b/src/object/path.cpp index be234d712..e98264775 100644 --- a/src/object/path.cpp +++ b/src/object/path.cpp @@ -161,6 +161,29 @@ Path::draw(DrawingContext& ) // TODO: Add a visible flag, draw the path if true } +void +Path::write(lisp::Writer& writer) +{ + writer.start_list("path"); + + writer.write_string("name", name); + writer.write_bool("circular", circular); + writer.write_bool("forward", forward); + + for (int i=0; i < (int)pathNodes.size(); i++) { + PathNode node = pathNodes[i]; + + writer.start_list("node"); + writer.write_float("x", node.position.x); + writer.write_float("y", node.position.y); + writer.write_float("time", node.time); + + writer.end_list("node"); + } + + writer.end_list("path"); +} + const Vector& Path::GetPosition() { return position; diff --git a/src/object/path.hpp b/src/object/path.hpp index 68a1161a8..f04623bc0 100644 --- a/src/object/path.hpp +++ b/src/object/path.hpp @@ -28,6 +28,7 @@ #include "math/vector.hpp" #include "game_object.hpp" #include "lisp/lisp.hpp" +#include "serializable.hpp" /** @@ -44,7 +45,7 @@ public: /** * Path an object can travel along. Made up of multiple nodes of type PathNode. */ -class Path : public GameObject +class Path : public GameObject, public Serializable { public: Path(const lisp::Lisp& reader); @@ -53,6 +54,8 @@ public: virtual void update(float elapsed_time); virtual void draw(DrawingContext& context); + virtual void write(lisp::Writer& writer); + const Vector& GetPosition(); const Vector& GetLastMovement(); diff --git a/src/serializable.hpp b/src/serializable.hpp index 06a8234e3..6534db16c 100644 --- a/src/serializable.hpp +++ b/src/serializable.hpp @@ -19,9 +19,7 @@ #ifndef SUPERTUX_SERIALIZABLE_H #define SUPERTUX_SERIALIZABLE_H -namespace lisp { -class Writer; -} +#include "lisp/writer.hpp" class Serializable { -- 2.11.0