Moved Direction related code to worldmap/direction.cpp
authorIngo Ruhnke <grumbel@gmx.de>
Sat, 21 Nov 2009 01:49:56 +0000 (01:49 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Sat, 21 Nov 2009 01:49:56 +0000 (01:49 +0000)
SVN-Revision: 6076

src/worldmap/direction.cpp [new file with mode: 0644]
src/worldmap/direction.hpp
src/worldmap/worldmap.cpp

diff --git a/src/worldmap/direction.cpp b/src/worldmap/direction.cpp
new file mode 100644 (file)
index 0000000..d0eac61
--- /dev/null
@@ -0,0 +1,80 @@
+//  SuperTux
+//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+//  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
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  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, see <http://www.gnu.org/licenses/>.
+
+#include "direction.hpp"
+
+#include "util/log.hpp"
+
+namespace WorldMapNS {
+
+Direction reverse_dir(Direction direction)
+{
+  switch(direction)
+  {
+    case D_WEST:
+      return D_EAST;
+    case D_EAST:
+      return D_WEST;
+    case D_NORTH:
+      return D_SOUTH;
+    case D_SOUTH:
+      return D_NORTH;
+    case D_NONE:
+      return D_NONE;
+  }
+  return D_NONE;
+}
+
+std::string
+direction_to_string(Direction direction)
+{
+  switch(direction)
+  {
+    case D_WEST:
+      return "west";
+    case D_EAST:
+      return "east";
+    case D_NORTH:
+      return "north";
+    case D_SOUTH:
+      return "south";
+    default:
+      return "none";
+  }
+}
+
+Direction
+string_to_direction(const std::string& directory)
+{
+  if (directory == "west")
+    return D_WEST;
+  else if (directory == "east")
+    return D_EAST;
+  else if (directory == "north")
+    return D_NORTH;
+  else if (directory == "south")
+    return D_SOUTH;
+  else if (directory == "none")
+    return D_NONE;
+  else {
+    log_warning << "unknown direction: \"" << directory << "\"" << std::endl;
+    return D_NONE;
+  }
+}
+
+} // namespace WorldMapNS
+
+/* EOF */
index c22530a..764c9c0 100644 (file)
 #ifndef HEADER_SUPERTUX_WORLDMAP_DIRECTION_HPP
 #define HEADER_SUPERTUX_WORLDMAP_DIRECTION_HPP
 
+#include <string>
+
 namespace WorldMapNS {
 
 enum Direction { D_NONE, D_WEST, D_EAST, D_NORTH, D_SOUTH };
 
-}
+Direction reverse_dir(Direction direction);
+Direction string_to_direction(const std::string& directory);
+std::string direction_to_string(Direction direction);
+
+} // namespace WorldMapNS
 
 #endif
 
index c61e667..0f91b0a 100644 (file)
@@ -76,63 +76,6 @@ namespace WorldMapNS {
 
 WorldMap* WorldMap::current_ = NULL;
 
-Direction reverse_dir(Direction direction)
-{
-  switch(direction)
-  {
-    case D_WEST:
-      return D_EAST;
-    case D_EAST:
-      return D_WEST;
-    case D_NORTH:
-      return D_SOUTH;
-    case D_SOUTH:
-      return D_NORTH;
-    case D_NONE:
-      return D_NONE;
-  }
-  return D_NONE;
-}
-
-std::string
-direction_to_string(Direction direction)
-{
-  switch(direction)
-  {
-    case D_WEST:
-      return "west";
-    case D_EAST:
-      return "east";
-    case D_NORTH:
-      return "north";
-    case D_SOUTH:
-      return "south";
-    default:
-      return "none";
-  }
-}
-
-Direction
-string_to_direction(const std::string& directory)
-{
-  if (directory == "west")
-    return D_WEST;
-  else if (directory == "east")
-    return D_EAST;
-  else if (directory == "north")
-    return D_NORTH;
-  else if (directory == "south")
-    return D_SOUTH;
-  else if (directory == "none")
-    return D_NONE;
-  else {
-    log_warning << "unknown direction: \"" << directory << "\"" << std::endl;
-    return D_NONE;
-  }
-}
-
-//---------------------------------------------------------------------------
-
 WorldMap::WorldMap(const std::string& filename, const std::string& force_spawnpoint) :
   tux(0),
   tileset(NULL),