Fix choice between c++11 unordered_map and c++0x regular (ordered) map

This commit is contained in:
Rogier 2014-05-06 16:44:29 +02:00
parent 0aee764203
commit 49cb97598d
3 changed files with 14 additions and 4 deletions

View File

@ -965,7 +965,7 @@ inline void TileGenerator::renderMapBlock(const ustring &mapBlock, const BlockPo
if (content == m_blockIgnoreId || content == m_blockAirId) { if (content == m_blockIgnoreId || content == m_blockAirId) {
continue; continue;
} }
std::map<int, std::string>::iterator blockName = m_nameMap.find(content); NodeID2NameMap::iterator blockName = m_nameMap.find(content);
if (blockName == m_nameMap.end()) if (blockName == m_nameMap.end())
continue; continue;
const string &name = blockName->second; const string &name = blockName->second;

View File

@ -14,7 +14,11 @@
#include <climits> #include <climits>
#include <iosfwd> #include <iosfwd>
#include <list> #include <list>
#if __cplusplus >= 201103L
#include <unordered_map>
#else
#include <map> #include <map>
#endif
#include <set> #include <set>
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>
@ -31,7 +35,13 @@
class TileGenerator class TileGenerator
{ {
private: private:
#if __cplusplus >= 201103L
typedef std::unordered_map<std::string, ColorEntry> ColorMap;
typedef std::unordered_map<int, std::string> NodeID2NameMap;
#else
typedef std::map<std::string, ColorEntry> ColorMap; typedef std::map<std::string, ColorEntry> ColorMap;
typedef std::map<int, std::string> NodeID2NameMap;
#endif
public: public:
TileGenerator(); TileGenerator();
@ -158,7 +168,7 @@ private:
int m_pictWidth; int m_pictWidth;
int m_pictHeight; int m_pictHeight;
std::list<BlockPos> m_positions; std::list<BlockPos> m_positions;
std::map<int, std::string> m_nameMap; NodeID2NameMap m_nameMap;
ColorMap m_colors; ColorMap m_colors;
uint16_t m_readedPixels[16]; uint16_t m_readedPixels[16];
std::set<std::string> m_unknownNodes; std::set<std::string> m_unknownNodes;

View File

@ -3,7 +3,7 @@
#include "db.h" #include "db.h"
#include <sqlite3.h> #include <sqlite3.h>
#if _cplusplus >= 201103L #if __cplusplus >= 201103L
#include <unordered_map> #include <unordered_map>
#else #else
#include <map> #include <map>
@ -14,7 +14,7 @@
#include "types.h" #include "types.h"
class DBSQLite3 : public DB { class DBSQLite3 : public DB {
#if _cplusplus >= 201103L #if __cplusplus >= 201103L
typedef std::unordered_map<int64_t, ustring> BlockCache; typedef std::unordered_map<int64_t, ustring> BlockCache;
#else #else
typedef std::map<int64_t, ustring> BlockCache; typedef std::map<int64_t, ustring> BlockCache;