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 #ifndef MAPSECTOR_HEADER
21 #define MAPSECTOR_HEADER
23 #include "irrlichttypes.h"
34 This is an Y-wise stack of MapBlocks.
37 #define MAPSECTOR_SERVER 0
38 #define MAPSECTOR_CLIENT 1
44 MapSector(Map *parent, v2s16 pos, IGameDef *gamedef);
47 virtual u32 getId() const = 0;
56 MapBlock * getBlockNoCreateNoEx(s16 y);
57 MapBlock * createBlankBlockNoInsert(s16 y);
58 MapBlock * createBlankBlock(s16 y);
60 void insertBlock(MapBlock *block);
62 void deleteBlock(MapBlock *block);
64 void getBlocks(MapBlockVect &dest);
66 // Always false at the moment, because sector contains no metadata.
67 bool differs_from_disk;
71 // The pile of MapBlocks
72 std::map<s16, MapBlock*> m_blocks;
75 // Position on parent (in MapBlock widths)
80 // Last-used block is cached here for quicker access.
81 // Be sure to set this to NULL when the cached block is deleted
82 MapBlock *m_block_cache;
88 MapBlock *getBlockBuffered(s16 y);
92 class ServerMapSector : public MapSector
95 ServerMapSector(Map *parent, v2s16 pos, IGameDef *gamedef);
100 return MAPSECTOR_SERVER;
104 These functions handle metadata.
105 They do not handle blocks.
108 void serialize(std::ostream &os, u8 version);
110 static ServerMapSector* deSerialize(
114 std::map<v2s16, MapSector*> & sectors,
122 class ClientMapSector : public MapSector
125 ClientMapSector(Map *parent, v2s16 pos, IGameDef *gamedef);
130 return MAPSECTOR_CLIENT;