the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2#include "..\Minecraft.World\net.minecraft.world.level.h"
3#include "..\Minecraft.World\File.h"
4#include "..\Minecraft.World\net.minecraft.world.level.storage.h"
5#include "..\Minecraft.World\JavaIntHash.h"
6#include "..\Minecraft.World\RandomLevelSource.h"
7#include "..\Minecraft.World\C4JThread.h"
8using namespace std;
9class ServerLevel;
10
11class ServerChunkCache : public ChunkSource
12{
13
14private:
15// unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
16private:
17 LevelChunk *emptyChunk;
18 ChunkSource *source;
19 ChunkStorage *storage;
20public:
21 bool autoCreate;
22private:
23 LevelChunk **cache;
24 vector<LevelChunk *> m_loadedChunkList;
25 ServerLevel *level;
26
27#ifdef _LARGE_WORLDS
28 deque<LevelChunk *> m_toDrop;
29 LevelChunk **m_unloadedCache;
30#endif
31
32 // 4J - added for multithreaded support
33 CRITICAL_SECTION m_csLoadCreate;
34 // 4J - size of cache is defined by size of one side - must be even
35 int XZSIZE;
36 int XZOFFSET;
37
38public:
39 ServerChunkCache(ServerLevel *level, ChunkStorage *storage, ChunkSource *source);
40 virtual ~ServerChunkCache();
41 virtual bool hasChunk(int x, int z);
42 vector<LevelChunk *> *getLoadedChunkList();
43 void drop(int x, int z);
44 void dropAll();
45 virtual LevelChunk *create(int x, int z);
46 LevelChunk *create(int x, int z, bool asyncPostProcess ); // 4J added
47 virtual LevelChunk *getChunk(int x, int z);
48#ifdef _LARGE_WORLDS
49 LevelChunk *getChunkLoadedOrUnloaded(int x, int z); // 4J added
50 void overwriteLevelChunkFromSource(int x, int z); // 4J MGH added, for expanding worlds, to kill any player changes and reset the chunk
51 void overwriteHellLevelChunkFromSource(int x, int z, int minVal, int maxVal); // 4J MGH added, for expanding worlds, to reset the outer tiles in the chunk
52 void updateOverwriteHellChunk(LevelChunk* origChunk, LevelChunk* playerChunk, int xMin, int xMax, int zMin, int zMax);
53
54#endif
55 virtual LevelChunk **getCache() { return cache; } // 4J added
56
57 // 4J-JEV Added; Remove chunk from the toDrop queue.
58#ifdef _LARGE_WORLDS
59 void dontDrop(int x, int z);
60#endif
61
62private:
63 LevelChunk *load(int x, int z);
64 void saveEntities(LevelChunk *levelChunk);
65 void save(LevelChunk *levelChunk);
66
67 void updatePostProcessFlag(short flag, int x, int z, int xo, int zo, LevelChunk *lc); // 4J added
68 void updatePostProcessFlags(int x, int z); // 4J added
69 void flagPostProcessComplete(short flag, int x, int z); // 4J added
70public:
71 virtual void postProcess(ChunkSource *parent, int x, int z);
72
73
74private:
75#ifdef _LARGE_WORLDS
76 static const int MAX_SAVES = 20;
77#else
78 // 4J Stu - Was 24, but lowering it drastically so that we can trickle save chunks
79 static const int MAX_SAVES = 1;
80#endif
81
82public:
83 virtual bool saveAllEntities();
84 virtual bool save(bool force, ProgressListener *progressListener);
85 virtual bool tick();
86 virtual bool shouldSave();
87 virtual wstring gatherStats();
88
89 virtual vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
90 virtual TilePos *findNearestMapFeature(Level *level, const wstring &featureName, int x, int y, int z);
91 virtual void recreateLogicStructuresForChunk(int chunkX, int chunkZ);
92
93private:
94 typedef struct _SaveThreadData
95 {
96 ServerChunkCache *cache;
97 LevelChunk *chunkToSave;
98 bool saveEntities;
99 bool useSharedThreadStorage;
100 C4JThread::Event *notificationEvent;
101 C4JThread::Event *wakeEvent; // This is a handle to the one fired by the producer thread
102 } SaveThreadData;
103
104public:
105 static int runSaveThreadProc(LPVOID lpParam);
106};