C++11 code modernization

This commit is contained in:
sfan5
2020-03-26 23:07:27 +01:00
parent 1d678ffa82
commit 9096f70188
8 changed files with 46 additions and 66 deletions

View File

@ -1,11 +1,7 @@
#ifndef BLOCKDECODER_H
#define BLOCKDECODER_H
#if __cplusplus >= 201103L
#include <unordered_map>
#else
#include <map>
#endif
#include "types.h"
@ -19,11 +15,7 @@ public:
std::string getNode(u8 x, u8 y, u8 z) const; // returns "" for air, ignore and invalid nodes
private:
#if __cplusplus >= 201103L
typedef std::unordered_map<int, std::string> NameMap;
#else
typedef std::map<int, std::string> NameMap;
#endif
NameMap m_nameMap;
int m_blockAirId;
int m_blockIgnoreId;

View File

@ -4,13 +4,8 @@
#include <iosfwd>
#include <list>
#include <config.h>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#else
#include <map>
#include <set>
#endif
#include <stdint.h>
#include <string>
@ -60,13 +55,8 @@ struct BitmapThing { // 16x16 bitmap
class TileGenerator
{
private:
#if __cplusplus >= 201103L
typedef std::unordered_map<std::string, ColorEntry> ColorMap;
typedef std::unordered_set<std::string> NameSet;
#else
typedef std::map<std::string, ColorEntry> ColorMap;
typedef std::set<std::string> NameSet;
#endif
public:
TileGenerator();
@ -98,7 +88,7 @@ private:
void loadBlocks();
void createImage();
void renderMap();
std::list<int> getZValueList() const;
std::list<int16_t> getZValueList() const;
void renderMapBlock(const BlockDecoder &blk, const BlockPos &pos);
void renderMapBlockBottom(const BlockPos &pos);
void renderShading(int zPos);
@ -140,7 +130,7 @@ private:
int m_geomY2;
int m_mapWidth;
int m_mapHeight;
std::list<std::pair<int, int> > m_positions;
std::list<std::pair<int16_t, int16_t>> m_positions;
ColorMap m_colorMap;
BitmapThing m_readPixels;
BitmapThing m_readInfo;

View File

@ -10,8 +10,7 @@
#include "types.h"
class BlockPos {
public:
struct BlockPos {
int16_t x;
int16_t y;
int16_t z;