From: Ingo Ruhnke Date: Sat, 21 Nov 2009 01:49:56 +0000 (+0000) Subject: Moved Direction related code to worldmap/direction.cpp X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=045255cdf0a58161b908d769bc0bde1778c33e14;p=supertux.git Moved Direction related code to worldmap/direction.cpp SVN-Revision: 6076 --- diff --git a/src/worldmap/direction.cpp b/src/worldmap/direction.cpp new file mode 100644 index 000000000..d0eac612d --- /dev/null +++ b/src/worldmap/direction.cpp @@ -0,0 +1,80 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// 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 . + +#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 */ diff --git a/src/worldmap/direction.hpp b/src/worldmap/direction.hpp index c22530a6e..764c9c07f 100644 --- a/src/worldmap/direction.hpp +++ b/src/worldmap/direction.hpp @@ -17,11 +17,17 @@ #ifndef HEADER_SUPERTUX_WORLDMAP_DIRECTION_HPP #define HEADER_SUPERTUX_WORLDMAP_DIRECTION_HPP +#include + 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 diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index c61e667c9..0f91b0adf 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -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),