LucidCube/Tools/AnvilStats/ChunkExtract.h
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

79 lines
2.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.
*/
// ChunkExtract.h
// Declares the cChunkExtract class representing a cCallback descendant that extracts raw chunk data into separate .chunk files
#pragma once
#include "Callback.h"
class cChunkExtract :
public cCallback
{
public:
cChunkExtract(const AString & iWorldFolder);
protected:
AString mWorldFolder;
cFile mAnvilFile;
int mCurAnvilX; // X-coord of mAnvilFile, in Anvil-coords (1 Anvil-coord = 32 chunks)
int mCurAnvilZ; // Z-coord of mAnvilFile, -"-
int mCurChunkX; // X-coord of the chunk being processed
int mCurChunkZ; // Z-coord of the chunk being processed
/** Opens new anvil file into mAnvilFile, sets mCurAnvilX and mCurAnvilZ */
void OpenAnvilFile(int a_AnvilX, int a_AnvilZ);
// cCallback overrides:
virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override;
virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override;
} ;
class cChunkExtractFactory :
public cCallbackFactory
{
public:
cChunkExtractFactory(const AString & iWorldFolder) :
mWorldFolder(iWorldFolder)
{
}
virtual cCallback * CreateNewCallback(void) override
{
return new cChunkExtract(mWorldFolder);
}
protected:
AString mWorldFolder;
} ;