3 Copyright (C) 2010 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 General Public License as published by
7 the Free Software Foundation; either version 2 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 General Public License for more details.
15 You should have received a copy of the GNU 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.
21 (c) 2010 Perttu Ahola <celeron55@gmail.com>
24 #ifndef MAPSECTOR_HEADER
25 #define MAPSECTOR_HEADER
28 #include "common_irrlicht.h"
29 #include "exceptions.h"
37 This is an Y-wise stack of MapBlocks.
40 #define MAPSECTOR_SERVER 0
41 #define MAPSECTOR_CLIENT 1
47 MapSector(Map *parent, v2s16 pos, IGameDef *gamedef);
50 virtual u32 getId() const = 0;
59 MapBlock * getBlockNoCreateNoEx(s16 y);
60 MapBlock * createBlankBlockNoInsert(s16 y);
61 MapBlock * createBlankBlock(s16 y);
63 void insertBlock(MapBlock *block);
65 void deleteBlock(MapBlock *block);
67 void getBlocks(core::list<MapBlock*> &dest);
69 // Always false at the moment, because sector contains no metadata.
70 bool differs_from_disk;
74 // The pile of MapBlocks
75 core::map<s16, MapBlock*> m_blocks;
78 // Position on parent (in MapBlock widths)
83 // Last-used block is cached here for quicker access.
84 // Be sure to set this to NULL when the cached block is deleted
85 MapBlock *m_block_cache;
91 MapBlock *getBlockBuffered(s16 y);
95 class ServerMapSector : public MapSector
98 ServerMapSector(Map *parent, v2s16 pos, IGameDef *gamedef);
103 return MAPSECTOR_SERVER;
107 These functions handle metadata.
108 They do not handle blocks.
111 void serialize(std::ostream &os, u8 version);
113 static ServerMapSector* deSerialize(
117 core::map<v2s16, MapSector*> & sectors,
125 class ClientMapSector : public MapSector
128 ClientMapSector(Map *parent, v2s16 pos, IGameDef *gamedef);
133 return MAPSECTOR_CLIENT;