Rebekah Rowe 6c4b2e9186
Implement GPL3+ and Apache2.0 Dual License.
Commit is being made to allow additions of GPL3+ code previously
un-addable. With these changes, contributions back to cuberite are
possible with the backporting exemtion, as well as adding stuff in
minetest with minetest code properly being read through and implimented
to upgrade it to GPL3 from GPL2.

project still has Apache2.0 license and credits to all its contributers, but now has the freedom of GPL3+ and all the code that can be implimented and shared with it.
2023-03-20 11:49:56 -04:00

93 lines
3.0 KiB
C++

/*
* Copyright 2011-2022 Cuberite Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Zapper.h
// Declares the cZapper class representing the processor that actually zaps blocks and entities
#pragma once
#include "Regions.h"
// fwd: ParsedNBT.h
class cParsedNBT;
class cFastNBTWriter;
class cZapper
{
public:
cZapper(const AString & a_MCAFolder);
/** Zaps all the specified regions */
void ZapRegions(const cRegionVector & a_Regions);
protected:
static const int BlocksPerChunkX = 16;
static const int BlocksPerChunkZ = 16;
static const int ChunksPerMCAX = 32;
static const int ChunksPerMCAZ = 32;
AString m_MCAFolder;
/** Converts from block coords to MCA coords */
void BlockToMCA(int a_BlockX, int a_BlockZ, int & a_MCAX, int & a_MCAZ);
/** Converts from block coords to chunk coords */
void BlockToChunk(int a_BlockX, int a_BlockZ, int & a_ChunkX, int & a_ChunkZ);
/** Zaps the specified region in the MCA file with the specified MCA coords */
void ZapRegionInMCAFile(const cRegion & a_Region, int a_MCAX, int a_MCAZ);
/** Loads raw compressed chunk data from the specified file
* chunk is specified by ChunkHeaderValue, which is the int describing the chunk in file header.
*/
void LoadChunkData(cFile & a_InFile, int a_ChunkHeaderValue, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ);
/** Zaps the specified region in the raw (compressed) chunk data. */
void ZapRegionInRawChunkData(const cRegion & a_Region, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ);
/** Zaps the specified region in the specified NBT structure */
void ZapRegionInNBTChunk(const cRegion & a_Region, cParsedNBT & a_NBT, int a_ChunkX, int a_ChunkZ);
/** Zaps the blocks in the specified region from the specified NBT */
void ZapRegionBlocksInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_SectionsTag);
/** Zaps the blocks in the specified bytes (types) from one vertical section (16^3 blocks) of a chunk. */
void ZapRegionInNBTSectionBytes(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockBytes);
/** Zaps the blocks in the specified nibbles (meta, add) from one vertical section (16^3 blocks) of a chunk. */
void ZapRegionInNBTSectionNibbles(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockNibbles);
/** Zaps entities in the specified region from the specified NBT */
void ZapRegionEntitiesInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_EntitiesTag);
/** Serializes the NBT subtree into a writer */
void SerializeNBTTag(const cParsedNBT & a_NBT, int a_Tag, cFastNBTWriter & a_Writer);
} ;