From: Christoph Sommer Date: Thu, 23 Mar 2006 23:47:04 +0000 (+0000) Subject: Forward declarations stink / Path is now serializable / Forward declarations stink X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=7a3f75400c0518b72f04fe4209145301191ba151;p=supertux.git Forward declarations stink / Path is now serializable / Forward declarations stink SVN-Revision: 3114 --- 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 {