fix redraw at top-left of map
[Tsunagari.git] / src / common.cpp
blobf60aabf7784e7046cf021ae36cfc4c1008aff17b
1 /******************************
2 ** Tsunagari Tile Engine **
3 ** common.cpp **
4 ** Copyright 2011 OmegaSDG **
5 ******************************/
7 #include <sstream>
9 #include "common.h"
11 coord_t coord(long x, long y, long z)
13 coord_t c;
14 c.x = x;
15 c.y = y;
16 c.z = z;
17 return c;
20 cube_t cube(long x1, long y1, long z1,
21 long x2, long y2, long z2)
23 cube_t c;
24 c.x1 = x1;
25 c.y1 = y1;
26 c.z1 = z1;
27 c.x2 = x2;
28 c.y2 = y2;
29 c.z2 = z2;
30 return c;
33 bool parseBool(const std::string& s)
35 return s == "true" ||
36 s == "True" ||
37 s == "TRUE" ||
38 s == "yes" ||
39 s == "Yes" ||
40 s == "YES" ||
41 s == "1";
44 std::vector<std::string> splitStr(std::string str, const std::string& delimiter)
46 std::vector<std::string> strlist;
47 size_t pos;
49 pos = str.find(delimiter);
51 while (pos != std::string::npos) {
52 if (pos != std::string::npos || pos+1 != str.size()) {
53 if (str.size() != 0 && pos != 0) // Don't save empty strings
54 strlist.push_back(str.substr(0, pos)); // Save
55 str = str.substr(pos+delimiter.size()); // Cut delimiter
57 pos = str.find(delimiter);
60 if (pos == std::string::npos && str.size() != 0)
61 strlist.push_back(str);
63 return strlist;
66 std::string itostr(long in)
68 std::stringstream out;
69 out << in;
70 return out.str();