Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
dummymap.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2022 TurkeyMcMac, Jude Melton-Houghton <jwmhjwmh@gmail.com>
4
5#pragma once
6
7#include "map.h"
8#include "mapsector.h"
9
10class DummyMap : public Map
11{
12public:
13 DummyMap(IGameDef *gamedef, v3s16 bpmin, v3s16 bpmax): Map(gamedef)
14 {
15 for (s16 z = bpmin.Z; z <= bpmax.Z; z++)
16 for (s16 x = bpmin.X; x <= bpmax.X; x++) {
17 v2s16 p2d(x, z);
18 MapSector *sector = new MapSector(this, p2d, gamedef);
19 m_sectors[p2d] = sector;
20 for (s16 y = bpmin.Y; y <= bpmax.Y; y++)
21 sector->createBlankBlock(y);
22 }
23 }
24
25 ~DummyMap() = default;
26
27 void fill(v3s16 bpmin, v3s16 bpmax, MapNode n)
28 {
29 for (s16 z = bpmin.Z; z <= bpmax.Z; z++)
30 for (s16 y = bpmin.Y; y <= bpmax.Y; y++)
31 for (s16 x = bpmin.X; x <= bpmax.X; x++) {
32 MapBlock *block = getBlockNoCreateNoEx({x, y, z});
33 if (block) {
34 for (size_t i = 0; i < MapBlock::nodecount; i++)
35 block->getData()[i] = n;
36 block->expireIsAirCache();
37 }
38 }
39 }
40
41 bool maySaveBlocks() override { return false; }
42};
Definition dummymap.h:11
DummyMap(IGameDef *gamedef, v3s16 bpmin, v3s16 bpmax)
Definition dummymap.h:13
bool maySaveBlocks() override
Definition dummymap.h:41
~DummyMap()=default
void fill(v3s16 bpmin, v3s16 bpmax, MapNode n)
Definition dummymap.h:27
Definition gamedef.h:36
Definition mapblock.h:58
static const u32 nodecount
Definition mapblock.h:431
MapNode * getData()
Definition mapblock.h:83
void expireIsAirCache()
Definition mapblock.cpp:194
Definition mapsector.h:25
MapBlock * createBlankBlock(s16 y)
Definition mapsector.cpp:67
Definition map.h:101
std::unordered_map< v2s16, MapSector * > m_sectors
Definition map.h:282
MapBlock * getBlockNoCreateNoEx(v3s16 p)
Definition map.cpp:84
core::vector2d< s16 > v2s16
Definition irr_v2d.h:12
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
Definition mapnode.h:124