forgot to add some files
authorMatthias Braun <matze@braunis.de>
Thu, 12 May 2005 15:16:52 +0000 (15:16 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 12 May 2005 15:16:52 +0000 (15:16 +0000)
SVN-Revision: 2476

src/spawn_point.cpp [new file with mode: 0644]
src/spawn_point.h [new file with mode: 0644]

diff --git a/src/spawn_point.cpp b/src/spawn_point.cpp
new file mode 100644 (file)
index 0000000..5906232
--- /dev/null
@@ -0,0 +1,39 @@
+#include <config.h>
+
+#include <stdexcept>
+#include <iostream>
+#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 (file)
index 0000000..b060263
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef __SPAWN_POINT_H__
+#define __SPAWN_POINT_H__
+
+#include <string>
+#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
+