aboutsummaryrefslogtreecommitdiff
path: root/textures/base/pack/server_ping_2.png
blob: 8dca0be0d0a62de2046535079a018fb611b21388 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 06 00 00 00 1f f3 ff .PNG........IHDR................
0020 61 00 00 00 06 62 4b 47 44 00 38 00 38 00 38 6a 68 44 8e 00 00 00 09 70 48 59 73 00 00 0b 13 00 a....bKGD.8.8.8jhD.....pHYs.....
0040 00 0b 13 01 00 9a 9c 18 00 00 00 07 74 49 4d 45 07 e1 02 02 10 31 01 6c 79 6d 38 00 00 00 81 49 ............tIME.....1.lym8....I
0060 44 41 54 38 cb 63 b4 b0 b0 60 a0 04 30 31 50 08 86 a0 01 ca ca ca ff 95 95 95 ff c3 f8 2c 14 58 DAT8.c...`..01P..............,.X
0080 fe 9f 28 17 a0 db 88 0e 58 48 b5 91 60 18 9c 38 fe f2 ff 89 e3 2f ff 13 6b 2a 4e 17 9c f0 bf fe ..(.....XH..`..8...../..k*N.....
00a0 9f 81 81 81 41 f9 8a 32 fe 58 20 d5 46 9c 2e 80 d9 c8 c0 20 44 b2 01 8c 68 81 84 c2 5f ba e4 18 ....A..2.X..F.......D...h..._...
00c0 23 03 03 03 83 85 a5 38 56 3e 8b 85 a5 38 d4 05 ef 60 12 38 f8 d7 a1 7c 4d 14 3e e3 80 e7 46 00 #......8V>...8...`.8...|M.>...F.
00e0 5b c5 31 45 85 e8 32 b0 00 00 00 00 49 45 4e 44 ae 42 60 82 [.1E..2.....IEND.B`.
> 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "mapsector.h"
#include "exceptions.h"
#include "mapblock.h"
#include "serialization.h"

MapSector::MapSector(Map *parent, v2s16 pos, IGameDef *gamedef):
		m_parent(parent),
		m_pos(pos),
		m_gamedef(gamedef)
{
}

MapSector::~MapSector()
{
	deleteBlocks();
}

void MapSector::deleteBlocks()
{
	// Clear cache
	m_block_cache = nullptr;

	// Delete all
	for (auto &block : m_blocks) {
		delete block.second;
	}

	// Clear container
	m_blocks.clear();
}

MapBlock * MapSector::getBlockBuffered(s16 y)
{
	MapBlock *block;

	if (m_block_cache && y == m_block_cache_y) {
		return m_block_cache;
	}

	// If block doesn't exist, return NULL
	std::unordered_map<s16, MapBlock*>::const_iterator n = m_blocks.find(y);
	block = (n != m_blocks.end() ? n->second : nullptr);

	// Cache the last result
	m_block_cache_y = y;
	m_block_cache = block;

	return block;
}

MapBlock * MapSector::getBlockNoCreateNoEx(s16 y)
{
	return getBlockBuffered(y);
}

MapBlock * MapSector::createBlankBlockNoInsert(s16 y)
{
	assert(getBlockBuffered(y) == NULL);	// Pre-condition

	v3s16 blockpos_map(m_pos.X, y, m_pos.Y);

	MapBlock *block = new MapBlock(m_parent, blockpos_map, m_gamedef);

	return block;
}

MapBlock * MapSector::createBlankBlock(s16 y)
{
	MapBlock *block = createBlankBlockNoInsert(y);

	m_blocks[y] = block;

	return block;
}

void MapSector::insertBlock(MapBlock *block)
{
	s16 block_y = block->getPos().Y;

	MapBlock *block2 = getBlockBuffered(block_y);
	if (block2) {
		throw AlreadyExistsException("Block already exists");