00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "direction.hpp"
00018
00019 #include "util/log.hpp"
00020
00021 namespace worldmap {
00022
00023 Direction reverse_dir(Direction direction)
00024 {
00025 switch(direction)
00026 {
00027 case D_WEST:
00028 return D_EAST;
00029 case D_EAST:
00030 return D_WEST;
00031 case D_NORTH:
00032 return D_SOUTH;
00033 case D_SOUTH:
00034 return D_NORTH;
00035 case D_NONE:
00036 return D_NONE;
00037 }
00038 return D_NONE;
00039 }
00040
00041 std::string
00042 direction_to_string(Direction direction)
00043 {
00044 switch(direction)
00045 {
00046 case D_WEST:
00047 return "west";
00048 case D_EAST:
00049 return "east";
00050 case D_NORTH:
00051 return "north";
00052 case D_SOUTH:
00053 return "south";
00054 default:
00055 return "none";
00056 }
00057 }
00058
00059 Direction
00060 string_to_direction(const std::string& directory)
00061 {
00062 if (directory == "west")
00063 return D_WEST;
00064 else if (directory == "east")
00065 return D_EAST;
00066 else if (directory == "north")
00067 return D_NORTH;
00068 else if (directory == "south")
00069 return D_SOUTH;
00070 else if (directory == "none")
00071 return D_NONE;
00072 else {
00073 log_warning << "unknown direction: \"" << directory << "\"" << std::endl;
00074 return D_NONE;
00075 }
00076 }
00077
00078 }
00079
00080