2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
// Processor.h
|
|
|
|
|
|
|
|
// Interfaces to the cProcessor class representing the overall processor engine that manages threads, calls callbacks etc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fwd:
|
|
|
|
class cCallback;
|
|
|
|
class cCallbackFactory;
|
|
|
|
class cParsedNBT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cProcessor
|
|
|
|
{
|
|
|
|
class cThread :
|
|
|
|
public cIsThread
|
|
|
|
{
|
|
|
|
typedef cIsThread super;
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
cCallback & m_Callback;
|
|
|
|
cProcessor & m_ParentProcessor;
|
2014-08-27 05:29:57 -04:00
|
|
|
cEvent m_HasStarted;
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
// cIsThread override:
|
|
|
|
virtual void Execute(void) override;
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
void ProcessFile(const AString & a_FileName);
|
|
|
|
void ProcessFileData(const char * a_FileData, size_t a_Size, int a_ChunkBaseX, int a_ChunkBaseZ);
|
|
|
|
void ProcessChunk(const char * a_FileData, int a_ChunkX, int a_ChunkZ, unsigned a_SectorStart, unsigned a_SectorSize, unsigned a_TimeStamp);
|
|
|
|
void ProcessCompressedChunkData(int a_ChunkX, int a_ChunkZ, const char * a_CompressedData, int a_CompressedSize);
|
|
|
|
void ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT);
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
// The following processing parts return true if they were interrupted by the callback, causing the processing of current chunk to abort
|
|
|
|
bool ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
|
|
|
|
bool ProcessChunkEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
|
|
|
|
bool ProcessChunkTileEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
|
|
|
|
bool ProcessChunkTileTicks(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
|
|
|
|
|
|
|
|
public:
|
|
|
|
cThread(cCallback & a_Callback, cProcessor & a_ParentProcessor);
|
2014-08-27 05:29:57 -04:00
|
|
|
|
|
|
|
/** Waits until the thread starts processing the callback code. */
|
|
|
|
void WaitForStart(void);
|
2013-07-29 07:13:03 -04:00
|
|
|
} ;
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
typedef std::vector<cThread *> cThreads;
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
public:
|
|
|
|
cProcessor(void);
|
|
|
|
~cProcessor();
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
void ProcessWorld(const AString & a_WorldFolder, cCallbackFactory & a_CallbackFactory);
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
protected:
|
|
|
|
bool m_IsShuttingDown; // If true, the threads should stop ASAP
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
cCriticalSection m_CS;
|
|
|
|
AStringList m_FileQueue;
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
cThreads m_Threads;
|
2014-08-27 05:29:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
/** Populates m_FileQueue with Anvil files from the specified folder. */
|
2013-07-29 07:13:03 -04:00
|
|
|
void PopulateFileQueue(const AString & a_WorldFolder);
|
2017-12-23 07:49:08 -05:00
|
|
|
|
2014-08-27 05:29:57 -04:00
|
|
|
/** Returns one filename from m_FileQueue, and removes the name from the queue. */
|
2013-07-29 07:13:03 -04:00
|
|
|
AString GetOneFileName(void);
|
|
|
|
} ;
|