X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fobject%2Fpath.cpp;h=c69e1a5cd98f6474f316afc4bd742765d19b9244;hb=c73a530130ab85f54446517dca9d80713cbaaf7e;hp=5d7e88a7da8e0cca8a2401e17b3e32cadbc2a711;hpb=a564bdaf72edefea95ad768330131a009f1be37d;p=supertux.git diff --git a/src/object/path.cpp b/src/object/path.cpp index 5d7e88a7d..c69e1a5cd 100644 --- a/src/object/path.cpp +++ b/src/object/path.cpp @@ -1,14 +1,12 @@ -// $Id$ -// // SuperTux Path // Copyright (C) 2005 Philipp // Copyright (C) 2006 Christoph Sommer // Copyright (C) 2006 Matthias Braun // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,25 +14,19 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -#include - -#include "path.hpp" +// along with this program. If not, see . -#include "lisp/writer.hpp" -#include "lisp/lisp.hpp" -#include "lisp/list_iterator.hpp" -#include "object_factory.hpp" -#include "log.hpp" +#include "object/path.hpp" -#include -#include -#include #include +#include -Path::Path() +#include "lisp/list_iterator.hpp" +#include "util/log.hpp" + +Path::Path() : + nodes(), + mode() { } @@ -43,7 +35,7 @@ Path::~Path() } void -Path::read(const lisp::Lisp& reader) +Path::read(const Reader& reader) { lisp::ListIterator iter(&reader); @@ -78,7 +70,7 @@ Path::read(const lisp::Lisp& reader) Node node; node.time = 1; if( (!node_lisp->get("x", node.position.x) || - !node_lisp->get("y", node.position.y))) + !node_lisp->get("y", node.position.y))) throw std::runtime_error("Path node without x and y coordinate specified"); node_lisp->get("time", node.time); @@ -92,40 +84,6 @@ Path::read(const lisp::Lisp& reader) throw std::runtime_error("Path with zero nodes"); } -void -Path::write(lisp::Writer& writer) -{ - writer.start_list("path"); - - switch(mode) { - case ONE_SHOT: - writer.write_string("mode", "oneshot"); - break; - case PING_PONG: - writer.write_string("mode", "pingpong"); - break; - case CIRCULAR: - writer.write_string("mode", "circular"); - break; - default: - log_warning << "Don't know how to write mode " << (int) mode << " ?!?" << std::endl; - break; - } - - for (size_t i=0; i < nodes.size(); i++) { - const Node& node = nodes[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"); -} - Vector Path::get_base() const { @@ -167,3 +125,4 @@ Path::get_farthest_node_no(Vector reference_point) const return farthest_node_id; } +/* EOF */