From: Matthias Braun Date: Thu, 12 May 2005 15:16:52 +0000 (+0000) Subject: forgot to add some files X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6a07a15af65f88cacbee1f9400d281df11e892a5;p=supertux.git forgot to add some files SVN-Revision: 2476 --- diff --git a/src/spawn_point.cpp b/src/spawn_point.cpp new file mode 100644 index 000000000..59062322e --- /dev/null +++ b/src/spawn_point.cpp @@ -0,0 +1,39 @@ +#include + +#include +#include +#include "spawn_point.h" +#include "lisp/lisp.h" +#include "lisp/list_iterator.h" + +SpawnPoint::SpawnPoint() +{} + +SpawnPoint::SpawnPoint(const SpawnPoint& other) + : name(other.name), pos(other.pos) +{} + +SpawnPoint::SpawnPoint(const lisp::Lisp* slisp) +{ + pos.x = -1; + pos.y = -1; + lisp::ListIterator iter(slisp); + while(iter.next()) { + const std::string& token = iter.item(); + if(token == "name") { + iter.value()->get(name); + } else if(token == "x") { + iter.value()->get(pos.x); + } else if(token == "y") { + iter.value()->get(pos.y); + } else { + std::cerr << "Warning: unknown token '" << token + << "' in SpawnPoint\n"; + } + } + + if(name == "") + throw std::runtime_error("No name specified for spawnpoint"); + if(pos.x < 0 || pos.y < 0) + throw std::runtime_error("Invalid coordinates for spawnpoint"); +} diff --git a/src/spawn_point.h b/src/spawn_point.h new file mode 100644 index 000000000..b0602639f --- /dev/null +++ b/src/spawn_point.h @@ -0,0 +1,20 @@ +#ifndef __SPAWN_POINT_H__ +#define __SPAWN_POINT_H__ + +#include +#include "math/vector.h" +#include "lisp/lisp.h" + +class SpawnPoint +{ +public: + SpawnPoint(); + SpawnPoint(const SpawnPoint& other); + SpawnPoint(const lisp::Lisp* lisp); + + std::string name; + Vector pos; +}; + +#endif +