00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <stdexcept>
00018
00019 #include "lisp/list_iterator.hpp"
00020 #include "util/log.hpp"
00021 #include "util/reader.hpp"
00022 #include "worldmap/spawn_point.hpp"
00023
00024 namespace worldmap {
00025
00026 SpawnPoint::SpawnPoint(const Reader& slisp) :
00027 name(),
00028 pos(),
00029 auto_dir(D_NONE)
00030 {
00031 pos.x = -1;
00032 pos.y = -1;
00033 lisp::ListIterator iter(&slisp);
00034 while(iter.next()) {
00035 const std::string& token = iter.item();
00036 if(token == "name") {
00037 iter.value()->get(name);
00038 } else if(token == "x") {
00039 iter.value()->get(pos.x);
00040 } else if(token == "y") {
00041 iter.value()->get(pos.y);
00042 } else if(token == "auto-dir") {
00043 std::string s = "";
00044 iter.value()->get(s);
00045 auto_dir = string_to_direction(s);
00046 } else {
00047 log_warning << "unknown token '" << token << "' in SpawnPoint" << std::endl;
00048 }
00049 }
00050
00051 if(name == "")
00052 throw std::runtime_error("No name specified for spawnpoint");
00053 if(pos.x < 0 || pos.y < 0)
00054 throw std::runtime_error("Invalid coordinates for spawnpoint");
00055 }
00056
00057 }
00058
00059