From 35c8bc4c5807af41a37cc901dcbbfee7ab73f7bf Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 7 May 2012 20:22:04 +0000 Subject: Fast NBT Parser (loading a chunk is now about 10 times faster) git-svn-id: http://mc-server.googlecode.com/svn/trunk@481 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/WSSAnvil.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source/WSSAnvil.h') diff --git a/source/WSSAnvil.h b/source/WSSAnvil.h index 37d813f28..58259f0e8 100644 --- a/source/WSSAnvil.h +++ b/source/WSSAnvil.h @@ -9,6 +9,7 @@ #pragma once #include "WorldStorage.h" +#include "FastNBT.h" @@ -99,24 +100,27 @@ protected: bool SaveChunkToData(const cChunkCoords & a_Chunk, AString & a_Data); /// Loads the chunk from NBT data (no locking needed) - bool LoadChunkFromNBT(const cChunkCoords & a_Chunk, cNBTTag & a_NBT); + bool LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT & a_NBT); /// Saves the chunk into NBT data; returns NULL for failure cNBTTag * SaveChunkToNBT(const cChunkCoords & a_Chunk); - /// Loads the chunk's entities from NBT data (a_NBT is the Level\\Entities list tag; may be NULL) - void LoadEntitiesFromNBT(cEntityList & a_Entitites, const cNBTList * a_NBT); + /// Loads the chunk's entities from NBT data (a_Tag is the Level\\Entities list tag; may be -1) + void LoadEntitiesFromNBT(cEntityList & a_Entitites, const cParsedNBT & a_NBT, int a_Tag); - /// Loads the chunk's BlockEntities from NBT data (a_NBT is the Level\\TileEntities list tag; may be NULL) - void LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntitites, const cNBTList * a_NBT); + /// Loads the chunk's BlockEntities from NBT data (a_Tag is the Level\\TileEntities list tag; may be -1) + void LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntitites, const cParsedNBT & a_NBT, int a_Tag); - void LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cNBTCompound * a_NBT); + void LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); /// Helper function for extracting the X, Y, and Z int subtags of a NBT compound; returns true if successful - bool GetBlockEntityNBTPos(const cNBTCompound * a_NBT, int & a_X, int & a_Y, int & a_Z); + bool GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int & a_X, int & a_Y, int & a_Z); /// Gets the correct MCA file either from cache or from disk, manages the m_MCAFiles cache; assumes m_CS is locked cMCAFile * LoadMCAFile(const cChunkCoords & a_Chunk); + + /// Copies a_Length bytes of data from the specified NBT Tag's Child into the a_Destination buffer + void CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, int a_Length); // cWSSchema overrides: virtual bool LoadChunk(const cChunkCoords & a_Chunk) override; -- cgit v1.2.3