]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/minimap.h
Cpp11 patchset 11: continue working on constructor style migration (#6004)
[dragonfireclient.git] / src / minimap.h
index 743b2bff2fcec4562d2652d7f209a9a05405af25..04ac27a04984c838f7031f15235ec16c5b400337 100644 (file)
@@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "irrlichttypes_extrabloated.h"
 #include "client.h"
 #include "voxel.h"
-#include "threading/mutex.h"
 #include "threading/semaphore.h"
 #include <map>
 #include <string>
@@ -45,6 +44,11 @@ enum MinimapMode {
        MINIMAP_MODE_COUNT,
 };
 
+enum MinimapShape {
+       MINIMAP_SHAPE_SQUARE,
+       MINIMAP_SHAPE_ROUND,
+};
+
 struct MinimapModeDef {
        bool is_radar;
        u16 scan_height;
@@ -52,10 +56,10 @@ struct MinimapModeDef {
 };
 
 struct MinimapPixel {
-       u16 id;
+       //! The topmost node that the minimap displays.
+       MapNode n;
        u16 height;
        u16 air_count;
-       u16 light;
 };
 
 struct MinimapMapblock {
@@ -74,21 +78,19 @@ struct MinimapData {
        MinimapPixel minimap_scan[MINIMAP_MAX_SX * MINIMAP_MAX_SY];
        bool map_invalidated;
        bool minimap_shape_round;
-       video::IImage *minimap_image;
-       video::IImage *heightmap_image;
-       video::IImage *minimap_mask_round;
-       video::IImage *minimap_mask_square;
-       video::ITexture *texture;
-       video::ITexture *heightmap_texture;
-       video::ITexture *minimap_overlay_round;
-       video::ITexture *minimap_overlay_square;
-       video::ITexture *player_marker;
-       video::ITexture *object_marker_red;
+       video::IImage *minimap_mask_round = nullptr;
+       video::IImage *minimap_mask_square = nullptr;
+       video::ITexture *texture = nullptr;
+       video::ITexture *heightmap_texture = nullptr;
+       video::ITexture *minimap_overlay_round = nullptr;
+       video::ITexture *minimap_overlay_square = nullptr;
+       video::ITexture *player_marker = nullptr;
+       video::ITexture *object_marker_red = nullptr;
 };
 
 struct QueuedMinimapUpdate {
        v3s16 pos;
-       MinimapMapblock *data;
+       MinimapMapblock *data = nullptr;
 };
 
 class MinimapUpdateThread : public UpdateThread {
@@ -96,41 +98,40 @@ class MinimapUpdateThread : public UpdateThread {
        MinimapUpdateThread() : UpdateThread("Minimap") {}
        virtual ~MinimapUpdateThread();
 
-       void getMap(v3s16 pos, s16 size, s16 height, bool radar);
-       MinimapPixel *getMinimapPixel(v3s16 pos, s16 height, s16 *pixel_height);
-       s16 getAirCount(v3s16 pos, s16 height);
-       video::SColor getColorFromId(u16 id);
-
+       void getMap(v3s16 pos, s16 size, s16 height);
        void enqueueBlock(v3s16 pos, MinimapMapblock *data);
-
        bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data);
        bool popBlockUpdate(QueuedMinimapUpdate *update);
 
-       MinimapData *data;
+       MinimapData *data = nullptr;
 
 protected:
        virtual void doUpdate();
 
 private:
-       Mutex m_queue_mutex;
+       std::mutex m_queue_mutex;
        std::deque<QueuedMinimapUpdate> m_update_queue;
        std::map<v3s16, MinimapMapblock *> m_blocks_cache;
 };
 
-class Mapper {
+class Minimap {
 public:
-       Mapper(IrrlichtDevice *device, Client *client);
-       ~Mapper();
+       Minimap(IrrlichtDevice *device, Client *client);
+       ~Minimap();
 
        void addBlock(v3s16 pos, MinimapMapblock *data);
 
        v3f getYawVec();
-       MinimapMode getMinimapMode();
 
        void setPos(v3s16 pos);
+       v3s16 getPos() const { return data->pos; }
        void setAngle(f32 angle);
+       f32 getAngle() const { return m_angle; }
        void setMinimapMode(MinimapMode mode);
+       MinimapMode getMinimapMode() const { return data->mode; }
        void toggleMinimapShape();
+       void setMinimapShape(MinimapShape shape);
+       MinimapShape getMinimapShape();
 
 
        video::ITexture *getMinimapTexture();
@@ -157,7 +158,7 @@ class Mapper {
        bool m_enable_shaders;
        u16 m_surface_mode_scan_height;
        f32 m_angle;
-       Mutex m_mutex;
+       std::mutex m_mutex;
        std::list<v2f> m_active_markers;
 };