nlist: make selected list accessible globally
[waspsaliva.git] / src / mapsector.h
blobffd4cdd1daa142b48634661dc4dd164a714a9fc9
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
22 #include "irrlichttypes.h"
23 #include "irr_v2d.h"
24 #include "mapblock.h"
25 #include <ostream>
26 #include <map>
27 #include <vector>
29 class Map;
30 class IGameDef;
33 This is an Y-wise stack of MapBlocks.
36 #define MAPSECTOR_SERVER 0
37 #define MAPSECTOR_CLIENT 1
39 class MapSector
41 public:
43 MapSector(Map *parent, v2s16 pos, IGameDef *gamedef);
44 virtual ~MapSector();
46 void deleteBlocks();
48 v2s16 getPos()
50 return m_pos;
53 MapBlock * getBlockNoCreateNoEx(s16 y);
54 MapBlock * createBlankBlockNoInsert(s16 y);
55 MapBlock * createBlankBlock(s16 y);
57 void insertBlock(MapBlock *block);
59 void deleteBlock(MapBlock *block);
61 void getBlocks(MapBlockVect &dest);
63 bool empty() const { return m_blocks.empty(); }
65 int size() const { return m_blocks.size(); }
66 protected:
68 // The pile of MapBlocks
69 std::unordered_map<s16, MapBlock*> m_blocks;
71 Map *m_parent;
72 // Position on parent (in MapBlock widths)
73 v2s16 m_pos;
75 IGameDef *m_gamedef;
77 // Last-used block is cached here for quicker access.
78 // Be sure to set this to nullptr when the cached block is deleted
79 MapBlock *m_block_cache = nullptr;
80 s16 m_block_cache_y;
83 Private methods
85 MapBlock *getBlockBuffered(s16 y);