Removed Boost dependency.

This commit is contained in:
Miroslav Bendík 2012-09-01 13:01:31 +02:00
parent cb65bbbc4c
commit b9e40ed972
3 changed files with 57 additions and 39 deletions

@ -25,14 +25,11 @@ find_package_handle_standard_args(LibSqlite3 DEFAULT_MSG LIBSQLITE3_LIBRARY LIB
mark_as_advanced(LIBSQLITE3_INCLUDE_DIR LIBSQLITE3_LIBRARY ) mark_as_advanced(LIBSQLITE3_INCLUDE_DIR LIBSQLITE3_LIBRARY )
find_package(Boost COMPONENTS system filesystem)
include_directories( include_directories(
"${PROJECT_BINARY_DIR}" "${PROJECT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
${LIBSQLITE3_INCLUDE_DIRS} ${LIBSQLITE3_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
) )
set(mapper_HDRS set(mapper_HDRS
@ -54,7 +51,6 @@ add_executable(minetest_mapper
target_link_libraries( target_link_libraries(
minetest_mapper minetest_mapper
${LIBSQLITE3_LIBRARIES} ${LIBSQLITE3_LIBRARIES}
${Boost_LIBRARIES}
gd gd
z z
) )

@ -14,7 +14,8 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <zlib.h> #include <zlib.h>
#include <boost/filesystem.hpp> #include <dirent.h>
#include "config.h"
#include "TileGenerator.h" #include "TileGenerator.h"
using namespace std; using namespace std;
@ -554,41 +555,48 @@ void TileGenerator::renderPlayers(const std::string &inputPath)
int color = rgb2int(m_playerColor.r, m_playerColor.g, m_playerColor.b); int color = rgb2int(m_playerColor.r, m_playerColor.g, m_playerColor.b);
string playersPath = inputPath + "players"; string playersPath = inputPath + "players";
boost::filesystem::path path(playersPath.c_str()); DIR *dir;
boost::filesystem::directory_iterator end_iter; dir = opendir (playersPath.c_str());
boost::filesystem::directory_iterator iter(path); if (dir == NULL) {
for (; iter != end_iter; ++iter) { return;
if (!boost::filesystem::is_directory(iter->status())) {
string path = iter->path().string();
ifstream in;
in.open(path.c_str(), ifstream::in);
string buffer;
string name;
string position;
while (getline(in, buffer)) {
if (buffer.find("name = ") == 0) {
name = buffer.substr(7);
}
else if (buffer.find("position = ") == 0) {
position = buffer.substr(12, buffer.length() - 13);
}
}
double x, y, z;
char comma;
istringstream positionStream(position, istringstream::in);
positionStream >> x;
positionStream >> comma;
positionStream >> y;
positionStream >> comma;
positionStream >> z;
int imageX = x / 10 - m_xMin * 16 + m_border;
int imageY = m_mapHeight - (z / 10 - m_zMin * 16) + m_border;
gdImageArc(m_image, imageX, imageY, 5, 5, 0, 360, color);
gdImageString(m_image, gdFontGetMediumBold(), imageX + 2, imageY + 2, reinterpret_cast<unsigned char *>(const_cast<char *>(name.c_str())), color);
}
} }
struct dirent *ent;
while ((ent = readdir (dir)) != NULL) {
if (ent->d_type == DT_DIR) {
continue;
}
string path = playersPath + PATH_SEPARATOR + ent->d_name;
ifstream in;
in.open(path.c_str(), ifstream::in);
string buffer;
string name;
string position;
while (getline(in, buffer)) {
if (buffer.find("name = ") == 0) {
name = buffer.substr(7);
}
else if (buffer.find("position = ") == 0) {
position = buffer.substr(12, buffer.length() - 13);
}
}
double x, y, z;
char comma;
istringstream positionStream(position, istringstream::in);
positionStream >> x;
positionStream >> comma;
positionStream >> y;
positionStream >> comma;
positionStream >> z;
int imageX = x / 10 - m_xMin * 16 + m_border;
int imageY = m_mapHeight - (z / 10 - m_zMin * 16) + m_border;
gdImageArc(m_image, imageX, imageY, 5, 5, 0, 360, color);
gdImageString(m_image, gdFontGetMediumBold(), imageX + 2, imageY + 2, reinterpret_cast<unsigned char *>(const_cast<char *>(name.c_str())), color);
}
closedir(dir);
} }
inline std::list<int> TileGenerator::getZValueList() const inline std::list<int> TileGenerator::getZValueList() const

14
config.h Normal file

@ -0,0 +1,14 @@
/*
* =====================================================================
* Version: 1.0
* Created: 01.09.2012 12:58:02
* Author: Miroslav Bendík
* Company: LinuxOS.sk
* =====================================================================
*/
#if MSDOS || __OS2__ || __NT__ || _WIN32
#define PATH_SEPARATOR '\\'
#else
#define PATH_SEPARATOR '/'
#endif