From 2aa28ad6f453f65bdbf682a62ffae26fcecaa437 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 19 Jan 2014 12:50:07 -0800 Subject: [PATCH 01/10] First attempt at Compiling Generator seperatly --- CMakeLists.txt | 4 ++++ Tools/GeneratorPerformanceTest/CMakeLists.txt | 12 ++++++++++++ .../GeneratorPerformanceTest.cpp | 7 +++++++ 3 files changed, 23 insertions(+) create mode 100644 Tools/GeneratorPerformanceTest/CMakeLists.txt create mode 100644 Tools/GeneratorPerformanceTest/GeneratorPerformanceTest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ddd34db3..14db055ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,5 +203,9 @@ if (NOT MSVC) string(REPLACE "-w" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") endif() +if(${BUILD_TOOLS}) +add_subdirectory(Tools/GeneratorPerformanceTest/) +endif() + add_subdirectory (src) diff --git a/Tools/GeneratorPerformanceTest/CMakeLists.txt b/Tools/GeneratorPerformanceTest/CMakeLists.txt new file mode 100644 index 000000000..8adc88882 --- /dev/null +++ b/Tools/GeneratorPerformanceTest/CMakeLists.txt @@ -0,0 +1,12 @@ + +cmake_minimum_required(VERSION 2.8) +project(GeneratorPerformanceTest) + +include_directories(../../src/Generating) +include_directories(../../src) +include_directories(../../lib) + +add_executable(GeneratorPerformanceTest GeneratorPerformanceTest.cpp ../../src/StringUtils ../../src/MCLogger ../../src/Log ../../src/BlockID ../../src/Noise ../../src/Enchantments ../../src/BlockArea) + +target_link_libraries(GeneratorPerformanceTest Generating) + diff --git a/Tools/GeneratorPerformanceTest/GeneratorPerformanceTest.cpp b/Tools/GeneratorPerformanceTest/GeneratorPerformanceTest.cpp new file mode 100644 index 000000000..75d18149f --- /dev/null +++ b/Tools/GeneratorPerformanceTest/GeneratorPerformanceTest.cpp @@ -0,0 +1,7 @@ + +#include "Globals.h" +#include "ChunkGenerator.h" + +int main(int argc, char * argv[]) { + cChunkGenerator Generator = cChunkGenerator(); +} From bd4278aca18e4c1d6517eec04583d1aef8800aea Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 19 Jan 2014 12:51:23 -0800 Subject: [PATCH 02/10] Added Inifile and OSSupport Linking --- src/Generating/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt index e1ba299fc..793f48890 100644 --- a/src/Generating/CMakeLists.txt +++ b/src/Generating/CMakeLists.txt @@ -9,3 +9,5 @@ file(GLOB SOURCE ) add_library(Generating ${SOURCE}) + +target_link_libraries(Generating OSSupport iniFile) From 9bb61e6e2e23fc8a66dbc95d918f23b89ba60314 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 20 Jan 2014 09:17:24 -0800 Subject: [PATCH 03/10] Seperated BlockArea From World If anyone can come up with a better name for the interface I'll change it, It contians to methods which do compleatly unrelated things --- src/BlockArea.cpp | 9 ++++----- src/BlockArea.h | 9 +++------ src/ForEachChunkProvider.h | 10 ++++++++++ src/World.h | 6 +++--- 4 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 src/ForEachChunkProvider.h diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 910661f60..c33d2712b 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -6,7 +6,6 @@ #include "Globals.h" #include "BlockArea.h" -#include "World.h" #include "OSSupport/GZipFile.h" #include "WorldStorage/FastNBT.h" #include "Blocks/BlockHandler.h" @@ -266,7 +265,7 @@ void cBlockArea::SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ) -bool cBlockArea::Read(cWorld * a_World, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes) +bool cBlockArea::Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes) { // Normalize the coords: if (a_MinBlockX > a_MaxBlockX) @@ -327,7 +326,7 @@ bool cBlockArea::Read(cWorld * a_World, int a_MinBlockX, int a_MaxBlockX, int a_ cChunkDef::AbsoluteToRelative(a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ, MaxChunkX, MaxChunkZ); // Query block data: - if (!a_World->ForEachChunkInRect(MinChunkX, MaxChunkX, MinChunkZ, MaxChunkZ, Reader)) + if (!a_ForEachChunkProvider->ForEachChunkInRect(MinChunkX, MaxChunkX, MinChunkZ, MaxChunkZ, Reader)) { Clear(); return false; @@ -340,7 +339,7 @@ bool cBlockArea::Read(cWorld * a_World, int a_MinBlockX, int a_MaxBlockX, int a_ -bool cBlockArea::Write(cWorld * a_World, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) +bool cBlockArea::Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) { ASSERT((a_DataTypes & GetDataTypes()) == a_DataTypes); // Are you requesting only the data that I have? a_DataTypes = a_DataTypes & GetDataTypes(); // For release builds, silently cut off the datatypes that I don't have @@ -357,7 +356,7 @@ bool cBlockArea::Write(cWorld * a_World, int a_MinBlockX, int a_MinBlockY, int a a_MinBlockY = cChunkDef::Height - m_SizeY; } - return a_World->WriteBlockArea(*this, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes); + return a_ForEachChunkProvider->WriteBlockArea(*this, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes); } diff --git a/src/BlockArea.h b/src/BlockArea.h index 075cc99ec..ae23c76c6 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -12,13 +12,10 @@ #pragma once +#include "ForEachChunkProvider.h" - -// fwd: World.h -class cWorld; - // fwd: FastNBT.h class cParsedNBT; @@ -68,13 +65,13 @@ public: void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ); /// Reads an area of blocks specified. Returns true if successful. All coords are inclusive. - bool Read(cWorld * a_World, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas); + bool Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas); // TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write // A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again /// Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all - bool Write(cWorld * a_World, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas); + bool Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas); /// Copies this object's contents into the specified BlockArea. void CopyTo(cBlockArea & a_Into) const; diff --git a/src/ForEachChunkProvider.h b/src/ForEachChunkProvider.h new file mode 100644 index 000000000..9092fcb0a --- /dev/null +++ b/src/ForEachChunkProvider.h @@ -0,0 +1,10 @@ + +class cBlockArea; + +class cForEachChunkProvider +{ +public: + virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) = 0; + + virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) = 0; +}; diff --git a/src/World.h b/src/World.h index ef74a65c7..f5134c223 100644 --- a/src/World.h +++ b/src/World.h @@ -59,7 +59,7 @@ typedef cItemCallback cNoteBlockCallback; // tolua_begin -class cWorld +class cWorld : public cForEachChunkProvider { public: @@ -315,7 +315,7 @@ public: bool IsChunkLighted(int a_ChunkX, int a_ChunkZ); /// Calls the callback for each chunk in the coords specified (all cords are inclusive). Returns true if all chunks have been processed successfully - bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback); + virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback); // tolua_begin @@ -361,7 +361,7 @@ public: Prefer cBlockArea::Write() instead, this is the internal implementation; cBlockArea does error checking, too. a_DataTypes is a bitmask of cBlockArea::baXXX constants ORed together. */ - bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes); + virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes); // tolua_begin From 4f09e8df6ecf20bd50573b7bf40c46f5ade21124 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 20 Jan 2014 09:59:12 -0800 Subject: [PATCH 04/10] Moved Schematic file methods to seperate class --- src/BlockArea.cpp | 159 +------------------- src/BlockArea.h | 18 +-- src/WorldStorage/SchematicFileSerilizer.cpp | 155 +++++++++++++++++++ src/WorldStorage/SchematicFileSerilizer.h | 20 +++ 4 files changed, 177 insertions(+), 175 deletions(-) create mode 100644 src/WorldStorage/SchematicFileSerilizer.cpp create mode 100644 src/WorldStorage/SchematicFileSerilizer.h diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index c33d2712b..194e2d68a 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -7,7 +7,6 @@ #include "Globals.h" #include "BlockArea.h" #include "OSSupport/GZipFile.h" -#include "WorldStorage/FastNBT.h" #include "Blocks/BlockHandler.h" @@ -447,85 +446,12 @@ void cBlockArea::DumpToRawFile(const AString & a_FileName) -bool cBlockArea::LoadFromSchematicFile(const AString & a_FileName) -{ - // Un-GZip the contents: - AString Contents; - cGZipFile File; - if (!File.Open(a_FileName, cGZipFile::fmRead)) - { - LOG("Cannot open the schematic file \"%s\".", a_FileName.c_str()); - return false; - } - int NumBytesRead = File.ReadRestOfFile(Contents); - if (NumBytesRead < 0) - { - LOG("Cannot read GZipped data in the schematic file \"%s\", error %d", a_FileName.c_str(), NumBytesRead); - return false; - } - File.Close(); - - // Parse the NBT: - cParsedNBT NBT(Contents.data(), Contents.size()); - if (!NBT.IsValid()) - { - LOG("Cannot parse the NBT in the schematic file \"%s\".", a_FileName.c_str()); - return false; - } - - return LoadFromSchematicNBT(NBT); -} -bool cBlockArea::SaveToSchematicFile(const AString & a_FileName) -{ - cFastNBTWriter Writer("Schematic"); - Writer.AddShort("Width", m_SizeX); - Writer.AddShort("Height", m_SizeY); - Writer.AddShort("Length", m_SizeZ); - Writer.AddString("Materials", "Alpha"); - if (HasBlockTypes()) - { - Writer.AddByteArray("Blocks", (const char *)m_BlockTypes, GetBlockCount()); - } - else - { - AString Dummy(GetBlockCount(), 0); - Writer.AddByteArray("Blocks", Dummy.data(), Dummy.size()); - } - if (HasBlockMetas()) - { - Writer.AddByteArray("Data", (const char *)m_BlockMetas, GetBlockCount()); - } - else - { - AString Dummy(GetBlockCount(), 0); - Writer.AddByteArray("Data", Dummy.data(), Dummy.size()); - } - // TODO: Save entities and block entities - Writer.BeginList("Entities", TAG_Compound); - Writer.EndList(); - Writer.BeginList("TileEntities", TAG_Compound); - Writer.EndList(); - Writer.Finish(); - - // Save to file - cGZipFile File; - if (!File.Open(a_FileName, cGZipFile::fmWrite)) - { - LOG("Cannot open file \"%s\" for writing.", a_FileName.c_str()); - return false; - } - if (!File.Write(Writer.GetResult())) - { - LOG("Cannot write data to file \"%s\".", a_FileName.c_str()); - return false; - } - return true; -} + @@ -2017,89 +1943,6 @@ void cBlockArea::ExpandNibbles(NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMa } - - - -bool cBlockArea::LoadFromSchematicNBT(cParsedNBT & a_NBT) -{ - int TMaterials = a_NBT.FindChildByName(a_NBT.GetRoot(), "Materials"); - if ((TMaterials > 0) && (a_NBT.GetType(TMaterials) == TAG_String)) - { - AString Materials = a_NBT.GetString(TMaterials); - if (Materials.compare("Alpha") != 0) - { - LOG("Materials tag is present and \"%s\" instead of \"Alpha\". Possibly a wrong-format schematic file.", Materials.c_str()); - return false; - } - } - int TSizeX = a_NBT.FindChildByName(a_NBT.GetRoot(), "Width"); - int TSizeY = a_NBT.FindChildByName(a_NBT.GetRoot(), "Height"); - int TSizeZ = a_NBT.FindChildByName(a_NBT.GetRoot(), "Length"); - if ( - (TSizeX < 0) || (TSizeY < 0) || (TSizeZ < 0) || - (a_NBT.GetType(TSizeX) != TAG_Short) || - (a_NBT.GetType(TSizeY) != TAG_Short) || - (a_NBT.GetType(TSizeZ) != TAG_Short) - ) - { - LOG("Dimensions are missing from the schematic file (%d, %d, %d), (%d, %d, %d)", - TSizeX, TSizeY, TSizeZ, - a_NBT.GetType(TSizeX), a_NBT.GetType(TSizeY), a_NBT.GetType(TSizeZ) - ); - return false; - } - - int SizeX = a_NBT.GetShort(TSizeX); - int SizeY = a_NBT.GetShort(TSizeY); - int SizeZ = a_NBT.GetShort(TSizeZ); - if ((SizeX < 1) || (SizeY < 1) || (SizeZ < 1)) - { - LOG("Dimensions are invalid in the schematic file: %d, %d, %d", SizeX, SizeY, SizeZ); - return false; - } - - int TBlockTypes = a_NBT.FindChildByName(a_NBT.GetRoot(), "Blocks"); - int TBlockMetas = a_NBT.FindChildByName(a_NBT.GetRoot(), "Data"); - if ((TBlockTypes < 0) || (a_NBT.GetType(TBlockTypes) != TAG_ByteArray)) - { - LOG("BlockTypes are invalid in the schematic file: %d", TBlockTypes); - return false; - } - bool AreMetasPresent = (TBlockMetas > 0) && (a_NBT.GetType(TBlockMetas) == TAG_ByteArray); - - Clear(); - SetSize(SizeX, SizeY, SizeZ, AreMetasPresent ? (baTypes | baMetas) : baTypes); - - // Copy the block types and metas: - int NumBytes = m_SizeX * m_SizeY * m_SizeZ; - if (a_NBT.GetDataLength(TBlockTypes) < NumBytes) - { - LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.", - NumBytes, a_NBT.GetDataLength(TBlockTypes) - ); - NumBytes = a_NBT.GetDataLength(TBlockTypes); - } - memcpy(m_BlockTypes, a_NBT.GetData(TBlockTypes), NumBytes); - - if (AreMetasPresent) - { - int NumBytes = m_SizeX * m_SizeY * m_SizeZ; - if (a_NBT.GetDataLength(TBlockMetas) < NumBytes) - { - LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.", - NumBytes, a_NBT.GetDataLength(TBlockMetas) - ); - NumBytes = a_NBT.GetDataLength(TBlockMetas); - } - memcpy(m_BlockMetas, a_NBT.GetData(TBlockMetas), NumBytes); - } - - return true; -} - - - - void cBlockArea::RelSetData( int a_RelX, int a_RelY, int a_RelZ, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, diff --git a/src/BlockArea.h b/src/BlockArea.h index ae23c76c6..59bc0f241 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -15,14 +15,6 @@ #include "ForEachChunkProvider.h" - -// fwd: FastNBT.h -class cParsedNBT; - - - - - // tolua_begin class cBlockArea { @@ -82,12 +74,6 @@ public: /// For testing purposes only, dumps the area into a file. void DumpToRawFile(const AString & a_FileName); - /// Loads an area from a .schematic file. Returns true if successful - bool LoadFromSchematicFile(const AString & a_FileName); - - /// Saves the area into a .schematic file. Returns true if successful - bool SaveToSchematicFile(const AString & a_FileName); - /// Crops the internal contents by the specified amount of blocks from each border. void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ); @@ -230,6 +216,7 @@ public: protected: friend class cChunkDesc; + friend class cSchematicFileSerializer; class cChunkReader : public cChunkDataCallback @@ -288,9 +275,6 @@ protected: // Expand helpers: void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); - - /// Loads the area from a schematic file uncompressed and parsed into a NBT tree. Returns true if successful. - bool LoadFromSchematicNBT(cParsedNBT & a_NBT); /// Sets the specified datatypes at the specified location. void RelSetData( diff --git a/src/WorldStorage/SchematicFileSerilizer.cpp b/src/WorldStorage/SchematicFileSerilizer.cpp new file mode 100644 index 000000000..bce0119ec --- /dev/null +++ b/src/WorldStorage/SchematicFileSerilizer.cpp @@ -0,0 +1,155 @@ + +bool cSchematicFileSerializer::LoadFromSchematicFile(const AString & a_FileName) +{ + // Un-GZip the contents: + AString Contents; + cGZipFile File; + if (!File.Open(a_FileName, cGZipFile::fmRead)) + { + LOG("Cannot open the schematic file \"%s\".", a_FileName.c_str()); + return false; + } + int NumBytesRead = File.ReadRestOfFile(Contents); + if (NumBytesRead < 0) + { + LOG("Cannot read GZipped data in the schematic file \"%s\", error %d", a_FileName.c_str(), NumBytesRead); + return false; + } + File.Close(); + + // Parse the NBT: + cParsedNBT NBT(Contents.data(), Contents.size()); + if (!NBT.IsValid()) + { + LOG("Cannot parse the NBT in the schematic file \"%s\".", a_FileName.c_str()); + return false; + } + + return LoadFromSchematicNBT(NBT); +} + +bool cSchematicFileSerializer::SaveToSchematicFile(const AString & a_FileName) +{ + cFastNBTWriter Writer("Schematic"); + Writer.AddShort("Width", m_SizeX); + Writer.AddShort("Height", m_SizeY); + Writer.AddShort("Length", m_SizeZ); + Writer.AddString("Materials", "Alpha"); + if (HasBlockTypes()) + { + Writer.AddByteArray("Blocks", (const char *)m_BlockTypes, GetBlockCount()); + } + else + { + AString Dummy(GetBlockCount(), 0); + Writer.AddByteArray("Blocks", Dummy.data(), Dummy.size()); + } + if (HasBlockMetas()) + { + Writer.AddByteArray("Data", (const char *)m_BlockMetas, GetBlockCount()); + } + else + { + AString Dummy(GetBlockCount(), 0); + Writer.AddByteArray("Data", Dummy.data(), Dummy.size()); + } + // TODO: Save entities and block entities + Writer.BeginList("Entities", TAG_Compound); + Writer.EndList(); + Writer.BeginList("TileEntities", TAG_Compound); + Writer.EndList(); + Writer.Finish(); + + // Save to file + cGZipFile File; + if (!File.Open(a_FileName, cGZipFile::fmWrite)) + { + LOG("Cannot open file \"%s\" for writing.", a_FileName.c_str()); + return false; + } + if (!File.Write(Writer.GetResult())) + { + LOG("Cannot write data to file \"%s\".", a_FileName.c_str()); + return false; + } + return true; +} + +bool cBlockArea::LoadFromSchematicNBT(cParsedNBT & a_NBT) +{ + int TMaterials = a_NBT.FindChildByName(a_NBT.GetRoot(), "Materials"); + if ((TMaterials > 0) && (a_NBT.GetType(TMaterials) == TAG_String)) + { + AString Materials = a_NBT.GetString(TMaterials); + if (Materials.compare("Alpha") != 0) + { + LOG("Materials tag is present and \"%s\" instead of \"Alpha\". Possibly a wrong-format schematic file.", Materials.c_str()); + return false; + } + } + int TSizeX = a_NBT.FindChildByName(a_NBT.GetRoot(), "Width"); + int TSizeY = a_NBT.FindChildByName(a_NBT.GetRoot(), "Height"); + int TSizeZ = a_NBT.FindChildByName(a_NBT.GetRoot(), "Length"); + if ( + (TSizeX < 0) || (TSizeY < 0) || (TSizeZ < 0) || + (a_NBT.GetType(TSizeX) != TAG_Short) || + (a_NBT.GetType(TSizeY) != TAG_Short) || + (a_NBT.GetType(TSizeZ) != TAG_Short) + ) + { + LOG("Dimensions are missing from the schematic file (%d, %d, %d), (%d, %d, %d)", + TSizeX, TSizeY, TSizeZ, + a_NBT.GetType(TSizeX), a_NBT.GetType(TSizeY), a_NBT.GetType(TSizeZ) + ); + return false; + } + + int SizeX = a_NBT.GetShort(TSizeX); + int SizeY = a_NBT.GetShort(TSizeY); + int SizeZ = a_NBT.GetShort(TSizeZ); + if ((SizeX < 1) || (SizeY < 1) || (SizeZ < 1)) + { + LOG("Dimensions are invalid in the schematic file: %d, %d, %d", SizeX, SizeY, SizeZ); + return false; + } + + int TBlockTypes = a_NBT.FindChildByName(a_NBT.GetRoot(), "Blocks"); + int TBlockMetas = a_NBT.FindChildByName(a_NBT.GetRoot(), "Data"); + if ((TBlockTypes < 0) || (a_NBT.GetType(TBlockTypes) != TAG_ByteArray)) + { + LOG("BlockTypes are invalid in the schematic file: %d", TBlockTypes); + return false; + } + bool AreMetasPresent = (TBlockMetas > 0) && (a_NBT.GetType(TBlockMetas) == TAG_ByteArray); + + Clear(); + SetSize(SizeX, SizeY, SizeZ, AreMetasPresent ? (baTypes | baMetas) : baTypes); + + // Copy the block types and metas: + int NumBytes = m_SizeX * m_SizeY * m_SizeZ; + if (a_NBT.GetDataLength(TBlockTypes) < NumBytes) + { + LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.", + NumBytes, a_NBT.GetDataLength(TBlockTypes) + ); + NumBytes = a_NBT.GetDataLength(TBlockTypes); + } + memcpy(m_BlockTypes, a_NBT.GetData(TBlockTypes), NumBytes); + + if (AreMetasPresent) + { + int NumBytes = m_SizeX * m_SizeY * m_SizeZ; + if (a_NBT.GetDataLength(TBlockMetas) < NumBytes) + { + LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.", + NumBytes, a_NBT.GetDataLength(TBlockMetas) + ); + NumBytes = a_NBT.GetDataLength(TBlockMetas); + } + memcpy(m_BlockMetas, a_NBT.GetData(TBlockMetas), NumBytes); + } + + return true; +} + + diff --git a/src/WorldStorage/SchematicFileSerilizer.h b/src/WorldStorage/SchematicFileSerilizer.h new file mode 100644 index 000000000..b8a7162c6 --- /dev/null +++ b/src/WorldStorage/SchematicFileSerilizer.h @@ -0,0 +1,20 @@ + +#include "../BlockArea.h" + +// fwd: FastNBT.h +class cParsedNBT; + +class cSchematicFileSerializer +{ +public: + + /// Loads an area from a .schematic file. Returns true if successful + static bool LoadFromSchematicFile(const AString & a_FileName); + + /// Saves the area into a .schematic file. Returns true if successful + static bool SaveToSchematicFile(const AString & a_FileName); + +private: + /// Loads the area from a schematic file uncompressed and parsed into a NBT tree. Returns true if successful. + static bool LoadFromSchematicNBT(cBlockArea& a_BlockArea, cParsedNBT & a_NBT); +}; From ca3389231e111d8ca0bf4ca60ae4f96896da48b0 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 20 Jan 2014 10:15:19 -0800 Subject: [PATCH 05/10] Actually implemented interfaces --- src/ForEachChunkProvider.h | 4 ++ src/World.h | 1 + src/WorldStorage/SchematicFileSerilizer.cpp | 45 ++++++++++++--------- src/WorldStorage/SchematicFileSerilizer.h | 4 +- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/ForEachChunkProvider.h b/src/ForEachChunkProvider.h index 9092fcb0a..70cd2196a 100644 --- a/src/ForEachChunkProvider.h +++ b/src/ForEachChunkProvider.h @@ -1,4 +1,8 @@ +#pragma once + +class cChunkDataCallback; + class cBlockArea; class cForEachChunkProvider diff --git a/src/World.h b/src/World.h index 9d342aceb..f0dd45c90 100644 --- a/src/World.h +++ b/src/World.h @@ -22,6 +22,7 @@ #include "Item.h" #include "Mobs/Monster.h" #include "Entities/ProjectileEntity.h" +#include "ForEachChunkProvider.h" diff --git a/src/WorldStorage/SchematicFileSerilizer.cpp b/src/WorldStorage/SchematicFileSerilizer.cpp index bce0119ec..df68f3436 100644 --- a/src/WorldStorage/SchematicFileSerilizer.cpp +++ b/src/WorldStorage/SchematicFileSerilizer.cpp @@ -1,5 +1,12 @@ -bool cSchematicFileSerializer::LoadFromSchematicFile(const AString & a_FileName) +#include "Globals.h" + +#include "OSSupport/GZipFile.h" +#include "FastNBT.h" + +#include "SchematicFileSerilizer.h" + +bool cSchematicFileSerializer::LoadFromSchematicFile(cBlockArea& a_BlockArea, const AString & a_FileName) { // Un-GZip the contents: AString Contents; @@ -25,32 +32,32 @@ bool cSchematicFileSerializer::LoadFromSchematicFile(const AString & a_FileName) return false; } - return LoadFromSchematicNBT(NBT); + return LoadFromSchematicNBT(a_BlockArea, NBT); } -bool cSchematicFileSerializer::SaveToSchematicFile(const AString & a_FileName) +bool cSchematicFileSerializer::SaveToSchematicFile(cBlockArea& a_BlockArea, const AString & a_FileName) { cFastNBTWriter Writer("Schematic"); - Writer.AddShort("Width", m_SizeX); - Writer.AddShort("Height", m_SizeY); - Writer.AddShort("Length", m_SizeZ); + Writer.AddShort("Width", a_BlockArea.m_SizeX); + Writer.AddShort("Height", a_BlockArea.m_SizeY); + Writer.AddShort("Length", a_BlockArea.m_SizeZ); Writer.AddString("Materials", "Alpha"); - if (HasBlockTypes()) + if (a_BlockArea.HasBlockTypes()) { - Writer.AddByteArray("Blocks", (const char *)m_BlockTypes, GetBlockCount()); + Writer.AddByteArray("Blocks", (const char *)a_BlockArea.m_BlockTypes, a_BlockArea.GetBlockCount()); } else { - AString Dummy(GetBlockCount(), 0); + AString Dummy(a_BlockArea.GetBlockCount(), 0); Writer.AddByteArray("Blocks", Dummy.data(), Dummy.size()); } - if (HasBlockMetas()) + if (a_BlockArea.HasBlockMetas()) { - Writer.AddByteArray("Data", (const char *)m_BlockMetas, GetBlockCount()); + Writer.AddByteArray("Data", (const char *)a_BlockArea.m_BlockMetas, a_BlockArea.GetBlockCount()); } else { - AString Dummy(GetBlockCount(), 0); + AString Dummy(a_BlockArea.GetBlockCount(), 0); Writer.AddByteArray("Data", Dummy.data(), Dummy.size()); } // TODO: Save entities and block entities @@ -75,7 +82,7 @@ bool cSchematicFileSerializer::SaveToSchematicFile(const AString & a_FileName) return true; } -bool cBlockArea::LoadFromSchematicNBT(cParsedNBT & a_NBT) +bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea& a_BlockArea, cParsedNBT & a_NBT) { int TMaterials = a_NBT.FindChildByName(a_NBT.GetRoot(), "Materials"); if ((TMaterials > 0) && (a_NBT.GetType(TMaterials) == TAG_String)) @@ -122,11 +129,11 @@ bool cBlockArea::LoadFromSchematicNBT(cParsedNBT & a_NBT) } bool AreMetasPresent = (TBlockMetas > 0) && (a_NBT.GetType(TBlockMetas) == TAG_ByteArray); - Clear(); - SetSize(SizeX, SizeY, SizeZ, AreMetasPresent ? (baTypes | baMetas) : baTypes); + a_BlockArea.Clear(); + a_BlockArea.SetSize(SizeX, SizeY, SizeZ, AreMetasPresent ? (cBlockArea::baTypes | cBlockArea::baMetas) : cBlockArea::baTypes); // Copy the block types and metas: - int NumBytes = m_SizeX * m_SizeY * m_SizeZ; + int NumBytes = a_BlockArea.m_SizeX * a_BlockArea.m_SizeY * a_BlockArea.m_SizeZ; if (a_NBT.GetDataLength(TBlockTypes) < NumBytes) { LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.", @@ -134,11 +141,11 @@ bool cBlockArea::LoadFromSchematicNBT(cParsedNBT & a_NBT) ); NumBytes = a_NBT.GetDataLength(TBlockTypes); } - memcpy(m_BlockTypes, a_NBT.GetData(TBlockTypes), NumBytes); + memcpy(a_BlockArea.m_BlockTypes, a_NBT.GetData(TBlockTypes), NumBytes); if (AreMetasPresent) { - int NumBytes = m_SizeX * m_SizeY * m_SizeZ; + int NumBytes = a_BlockArea.m_SizeX * a_BlockArea.m_SizeY * a_BlockArea.m_SizeZ; if (a_NBT.GetDataLength(TBlockMetas) < NumBytes) { LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.", @@ -146,7 +153,7 @@ bool cBlockArea::LoadFromSchematicNBT(cParsedNBT & a_NBT) ); NumBytes = a_NBT.GetDataLength(TBlockMetas); } - memcpy(m_BlockMetas, a_NBT.GetData(TBlockMetas), NumBytes); + memcpy(a_BlockArea.m_BlockMetas, a_NBT.GetData(TBlockMetas), NumBytes); } return true; diff --git a/src/WorldStorage/SchematicFileSerilizer.h b/src/WorldStorage/SchematicFileSerilizer.h index b8a7162c6..e4dcf3eb9 100644 --- a/src/WorldStorage/SchematicFileSerilizer.h +++ b/src/WorldStorage/SchematicFileSerilizer.h @@ -9,10 +9,10 @@ class cSchematicFileSerializer public: /// Loads an area from a .schematic file. Returns true if successful - static bool LoadFromSchematicFile(const AString & a_FileName); + static bool LoadFromSchematicFile(cBlockArea& a_BlockArea, const AString & a_FileName); /// Saves the area into a .schematic file. Returns true if successful - static bool SaveToSchematicFile(const AString & a_FileName); + static bool SaveToSchematicFile(cBlockArea& a_BlockArea, const AString & a_FileName); private: /// Loads the area from a schematic file uncompressed and parsed into a NBT tree. Returns true if successful. From 1c320fa18c65ddb546ec5ff396f5554db306bd8b Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 22 Jan 2014 10:13:41 -0800 Subject: [PATCH 06/10] formatting changes --- src/WorldStorage/SchematicFileSerilizer.cpp | 16 +++++++++++++--- src/WorldStorage/SchematicFileSerilizer.h | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/WorldStorage/SchematicFileSerilizer.cpp b/src/WorldStorage/SchematicFileSerilizer.cpp index df68f3436..4e2ecb752 100644 --- a/src/WorldStorage/SchematicFileSerilizer.cpp +++ b/src/WorldStorage/SchematicFileSerilizer.cpp @@ -6,7 +6,7 @@ #include "SchematicFileSerilizer.h" -bool cSchematicFileSerializer::LoadFromSchematicFile(cBlockArea& a_BlockArea, const AString & a_FileName) +bool cSchematicFileSerializer::LoadFromSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName) { // Un-GZip the contents: AString Contents; @@ -35,7 +35,12 @@ bool cSchematicFileSerializer::LoadFromSchematicFile(cBlockArea& a_BlockArea, co return LoadFromSchematicNBT(a_BlockArea, NBT); } -bool cSchematicFileSerializer::SaveToSchematicFile(cBlockArea& a_BlockArea, const AString & a_FileName) + + + + + +bool cSchematicFileSerializer::SaveToSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName) { cFastNBTWriter Writer("Schematic"); Writer.AddShort("Width", a_BlockArea.m_SizeX); @@ -82,7 +87,12 @@ bool cSchematicFileSerializer::SaveToSchematicFile(cBlockArea& a_BlockArea, cons return true; } -bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea& a_BlockArea, cParsedNBT & a_NBT) + + + + + +bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cParsedNBT & a_NBT) { int TMaterials = a_NBT.FindChildByName(a_NBT.GetRoot(), "Materials"); if ((TMaterials > 0) && (a_NBT.GetType(TMaterials) == TAG_String)) diff --git a/src/WorldStorage/SchematicFileSerilizer.h b/src/WorldStorage/SchematicFileSerilizer.h index e4dcf3eb9..cb30e55d8 100644 --- a/src/WorldStorage/SchematicFileSerilizer.h +++ b/src/WorldStorage/SchematicFileSerilizer.h @@ -1,20 +1,30 @@ +#pragma once + #include "../BlockArea.h" + + + + // fwd: FastNBT.h class cParsedNBT; + + + + class cSchematicFileSerializer { public: /// Loads an area from a .schematic file. Returns true if successful - static bool LoadFromSchematicFile(cBlockArea& a_BlockArea, const AString & a_FileName); + static bool LoadFromSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName); /// Saves the area into a .schematic file. Returns true if successful - static bool SaveToSchematicFile(cBlockArea& a_BlockArea, const AString & a_FileName); + static bool SaveToSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName); private: /// Loads the area from a schematic file uncompressed and parsed into a NBT tree. Returns true if successful. - static bool LoadFromSchematicNBT(cBlockArea& a_BlockArea, cParsedNBT & a_NBT); + static bool LoadFromSchematicNBT(cBlockArea & a_BlockArea, cParsedNBT & a_NBT); }; From 571200019d7f0a948145b6cf8c2594d3e75cb375 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 22 Jan 2014 10:35:36 -0800 Subject: [PATCH 07/10] Added manual bindings for moved functions --- src/Bindings/AllToLua.pkg | 1 + src/Bindings/ManualBindings.cpp | 66 +++++++++++++++++++++++ src/WorldStorage/SchematicFileSerilizer.h | 6 ++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg index f65aed9bb..9ad45d1bd 100644 --- a/src/Bindings/AllToLua.pkg +++ b/src/Bindings/AllToLua.pkg @@ -70,6 +70,7 @@ $cfile "../Generating/ChunkDesc.h" $cfile "../CraftingRecipes.h" $cfile "../UI/Window.h" $cfile "../Mobs/Monster.h" +$cfile "../WorldStorage/SchematicFileSerilizer.h" diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index f1160f941..1b7651acd 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -13,6 +13,7 @@ #include "../Entities/Player.h" #include "../WebAdmin.h" #include "../ClientHandle.h" +#include "../BlockArea.h" #include "../BlockEntities/ChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" #include "../BlockEntities/DispenserEntity.h" @@ -22,6 +23,7 @@ #include "../BlockEntities/NoteEntity.h" #include "md5/md5.h" #include "../LineBlockTracer.h" +#include "../WorldStorage/SchematicFileSerilizer.h" @@ -2234,6 +2236,65 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S) + +static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S) +{ + // function cBlockArea::LoadFromSchematicFile + // Exported manually because function has been moved to SchematicFileSerilizer.cpp + cLuaState L(tolua_S); + if ( + !L.CheckParamUserType(1, "cBlockArea") || + !L.CheckParamString (2) || + !L.CheckParamEnd (3) + ) + { + return 0; + } + cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, 0); + if (self == NULL) + { + tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", NULL); + return 0; + } + + AString Filename = tolua_tostring(tolua_S, 2, 0); + LOGWARNING("cBlockArea::LoadFromSchematic file is depreciated. Please use cSchematicFileSerilizer::LoadFromSchematicFile."); + bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self,Filename); + tolua_pushboolean(tolua_S, res); + return 1; +} + + + + +static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S) +{ + // function cBlockArea::SaveToSchematicFile + // Exported manually because function has been moved to SchematicFileSerilizer.cpp + cLuaState L(tolua_S); + if ( + !L.CheckParamUserType(1, "cBlockArea") || + !L.CheckParamString (2) || + !L.CheckParamEnd (3) + ) + { + return 0; + } + cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, 0); + if (self == NULL) + { + tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", NULL); + return 0; + } + AString Filename = tolua_tostring(tolua_S, 2, 0); + LOGWARNING("cBlockArea::SaveToSchematic file is depreciated. Please use cSchematicFileSerializer::SaveToSchematicFile."); + bool res = cSchematicFileSerializer::SaveToSchematicFile(*self,Filename); + tolua_pushboolean(tolua_S, res); + return 1; +} + + + void ManualBindings::Bind(lua_State * tolua_S) { tolua_beginmodule(tolua_S, NULL); @@ -2250,6 +2311,11 @@ void ManualBindings::Bind(lua_State * tolua_S) tolua_endmodule(tolua_S); tolua_beginmodule(tolua_S, "cHopperEntity"); + tolua_function(tolua_S, "LoadFromSchematicFile", tolua_cBlockArea_LoadFromSchematicFile); + tolua_function(tolua_S, "SaveToSchematicFile", tolua_cBlockArea_SaveToSchematicFile); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cBlockArea"); tolua_function(tolua_S, "GetOutputBlockPos", tolua_cHopperEntity_GetOutputBlockPos); tolua_endmodule(tolua_S); diff --git a/src/WorldStorage/SchematicFileSerilizer.h b/src/WorldStorage/SchematicFileSerilizer.h index cb30e55d8..31b36695c 100644 --- a/src/WorldStorage/SchematicFileSerilizer.h +++ b/src/WorldStorage/SchematicFileSerilizer.h @@ -13,7 +13,7 @@ class cParsedNBT; - +// tolua_begin class cSchematicFileSerializer { public: @@ -24,7 +24,9 @@ public: /// Saves the area into a .schematic file. Returns true if successful static bool SaveToSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName); + // tolua_end + private: /// Loads the area from a schematic file uncompressed and parsed into a NBT tree. Returns true if successful. static bool LoadFromSchematicNBT(cBlockArea & a_BlockArea, cParsedNBT & a_NBT); -}; +}; // tolua_export From 5ef0a00a6c11c183070b97d2121009de27830713 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 22 Jan 2014 10:39:09 -0800 Subject: [PATCH 08/10] Fixed spelling error --- src/Bindings/AllToLua.pkg | 2 +- src/Bindings/ManualBindings.cpp | 2 +- .../{SchematicFileSerilizer.cpp => SchematicFileSerializer.cpp} | 2 +- .../{SchematicFileSerilizer.h => SchematicFileSerializer.h} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename src/WorldStorage/{SchematicFileSerilizer.cpp => SchematicFileSerializer.cpp} (99%) rename src/WorldStorage/{SchematicFileSerilizer.h => SchematicFileSerializer.h} (100%) diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg index 9ad45d1bd..8b2a78d05 100644 --- a/src/Bindings/AllToLua.pkg +++ b/src/Bindings/AllToLua.pkg @@ -70,7 +70,7 @@ $cfile "../Generating/ChunkDesc.h" $cfile "../CraftingRecipes.h" $cfile "../UI/Window.h" $cfile "../Mobs/Monster.h" -$cfile "../WorldStorage/SchematicFileSerilizer.h" +$cfile "../WorldStorage/SchematicFileSerializer.h" diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 1b7651acd..299dfd9ee 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -23,7 +23,7 @@ #include "../BlockEntities/NoteEntity.h" #include "md5/md5.h" #include "../LineBlockTracer.h" -#include "../WorldStorage/SchematicFileSerilizer.h" +#include "../WorldStorage/SchematicFileSerializer.h" diff --git a/src/WorldStorage/SchematicFileSerilizer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp similarity index 99% rename from src/WorldStorage/SchematicFileSerilizer.cpp rename to src/WorldStorage/SchematicFileSerializer.cpp index 4e2ecb752..45fd967bd 100644 --- a/src/WorldStorage/SchematicFileSerilizer.cpp +++ b/src/WorldStorage/SchematicFileSerializer.cpp @@ -4,7 +4,7 @@ #include "OSSupport/GZipFile.h" #include "FastNBT.h" -#include "SchematicFileSerilizer.h" +#include "SchematicFileSerializer.h" bool cSchematicFileSerializer::LoadFromSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName) { diff --git a/src/WorldStorage/SchematicFileSerilizer.h b/src/WorldStorage/SchematicFileSerializer.h similarity index 100% rename from src/WorldStorage/SchematicFileSerilizer.h rename to src/WorldStorage/SchematicFileSerializer.h From 2806b48afa4e3d087c8a123d81f9eabe3ec797c5 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 25 Jan 2014 06:06:30 -0800 Subject: [PATCH 09/10] Fixed exports --- src/Bindings/AllToLua.pkg | 1 - src/Bindings/ManualBindings.cpp | 2 -- src/WorldStorage/SchematicFileSerializer.h | 5 +---- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg index 8b2a78d05..f65aed9bb 100644 --- a/src/Bindings/AllToLua.pkg +++ b/src/Bindings/AllToLua.pkg @@ -70,7 +70,6 @@ $cfile "../Generating/ChunkDesc.h" $cfile "../CraftingRecipes.h" $cfile "../UI/Window.h" $cfile "../Mobs/Monster.h" -$cfile "../WorldStorage/SchematicFileSerializer.h" diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 299dfd9ee..4e92da5ae 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -2258,7 +2258,6 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S) } AString Filename = tolua_tostring(tolua_S, 2, 0); - LOGWARNING("cBlockArea::LoadFromSchematic file is depreciated. Please use cSchematicFileSerilizer::LoadFromSchematicFile."); bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self,Filename); tolua_pushboolean(tolua_S, res); return 1; @@ -2287,7 +2286,6 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S) return 0; } AString Filename = tolua_tostring(tolua_S, 2, 0); - LOGWARNING("cBlockArea::SaveToSchematic file is depreciated. Please use cSchematicFileSerializer::SaveToSchematicFile."); bool res = cSchematicFileSerializer::SaveToSchematicFile(*self,Filename); tolua_pushboolean(tolua_S, res); return 1; diff --git a/src/WorldStorage/SchematicFileSerializer.h b/src/WorldStorage/SchematicFileSerializer.h index 31b36695c..9be2e5b57 100644 --- a/src/WorldStorage/SchematicFileSerializer.h +++ b/src/WorldStorage/SchematicFileSerializer.h @@ -13,7 +13,6 @@ class cParsedNBT; -// tolua_begin class cSchematicFileSerializer { public: @@ -24,9 +23,7 @@ public: /// Saves the area into a .schematic file. Returns true if successful static bool SaveToSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName); - // tolua_end - private: /// Loads the area from a schematic file uncompressed and parsed into a NBT tree. Returns true if successful. static bool LoadFromSchematicNBT(cBlockArea & a_BlockArea, cParsedNBT & a_NBT); -}; // tolua_export +}; From 2a18feb0159da6288efab79e39550b3c31bb71c1 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 25 Jan 2014 10:13:54 -0800 Subject: [PATCH 10/10] Stupid Mistake fixed --- src/Bindings/ManualBindings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 4e92da5ae..e7c66c6fb 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -2308,12 +2308,12 @@ void ManualBindings::Bind(lua_State * tolua_S) tolua_function(tolua_S, "GetFolderContents", tolua_cFile_GetFolderContents); tolua_endmodule(tolua_S); - tolua_beginmodule(tolua_S, "cHopperEntity"); + tolua_beginmodule(tolua_S, "cBlockArea"); tolua_function(tolua_S, "LoadFromSchematicFile", tolua_cBlockArea_LoadFromSchematicFile); tolua_function(tolua_S, "SaveToSchematicFile", tolua_cBlockArea_SaveToSchematicFile); tolua_endmodule(tolua_S); - tolua_beginmodule(tolua_S, "cBlockArea"); + tolua_beginmodule(tolua_S, "cHopperEntity"); tolua_function(tolua_S, "GetOutputBlockPos", tolua_cHopperEntity_GetOutputBlockPos); tolua_endmodule(tolua_S);