diff --git a/plugins/rendermax/renderer_light.hpp b/plugins/rendermax/renderer_light.hpp index 0f981cf8b..0e3d2c986 100644 --- a/plugins/rendermax/renderer_light.hpp +++ b/plugins/rendermax/renderer_light.hpp @@ -2,10 +2,44 @@ #define RENDERER_LIGHT_INCLUDED #include "renderer_opengl.hpp" #include "Types.h" -#include #include #include #include +#include +// we are not using boost so let's cheat: +template +inline void hash_combine(std::size_t & seed, const T & v) +{ + std::hash hasher; + seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); +} + +namespace std +{ + template struct hash> + { + inline size_t operator()(const pair & v) const + { + size_t seed = 0; + ::hash_combine(seed, v.first); + ::hash_combine(seed, v.second); + return seed; + } + }; + template struct hash> + { + inline size_t operator()(const tuple & v) const + { + size_t seed = 0; + ::hash_combine(seed,get<0>(v)); + ::hash_combine(seed,get<1>(v)); + ::hash_combine(seed,get<2>(v)); + return seed; + } + }; +} +// now we can hash pairs and tuples + #include "modules/MapCache.h" bool isInRect(const df::coord2d& pos,const DFHack::rect2d& rect); struct renderer_light : public renderer_wrap { @@ -267,9 +301,9 @@ private: matLightDef matCitizen; float levelDim; //materials - std::map,matLightDef> matDefs; + std::unordered_map,matLightDef> matDefs; //buildings - std::map,buildingLightDef> buildingDefs; + std::unordered_map,buildingLightDef> buildingDefs; int w,h; DFHack::rect2d mapPort; friend lightThreadDispatch;