1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
#pragma once
using namespace std;
#pragma message("LevelGenerationOptions.h ")
#include "GameRuleDefinition.h"
#include "..\..\..\Minecraft.World\StructureFeature.h"
class ApplySchematicRuleDefinition;
class LevelChunk;
class ConsoleGenerateStructure;
class ConsoleSchematicFile;
class LevelRuleset;
class BiomeOverride;
class StartFeature;
class GrSource
{
public:
// 4J-JEV:
// Moved all this here; I didn't like that all this header information
// was being mixed in with all the game information as they have
// completely different lifespans.
virtual bool requiresTexturePack()=0;
virtual UINT getRequiredTexturePackId()=0;
virtual wstring getDefaultSaveName()=0;
virtual LPCWSTR getWorldName()=0;
virtual LPCWSTR getDisplayName()=0;
virtual wstring getGrfPath()=0;
virtual bool requiresBaseSave() = 0;
virtual wstring getBaseSavePath() = 0;
virtual void setRequiresTexturePack(bool)=0;
virtual void setRequiredTexturePackId(UINT)=0;
virtual void setDefaultSaveName(const wstring &)=0;
virtual void setWorldName(const wstring &)=0;
virtual void setDisplayName(const wstring &)=0;
virtual void setGrfPath(const wstring &)=0;
virtual void setBaseSavePath(const wstring &)=0;
virtual bool ready()=0;
//virtual void getGrfData(PBYTE &pData, DWORD &pSize)=0;
};
class JustGrSource : public GrSource
{
protected:
wstring m_worldName;
wstring m_displayName;
wstring m_defaultSaveName;
bool m_bRequiresTexturePack;
int m_requiredTexturePackId;
wstring m_grfPath;
wstring m_baseSavePath;
bool m_bRequiresBaseSave;
public:
virtual bool requiresTexturePack();
virtual UINT getRequiredTexturePackId();
virtual wstring getDefaultSaveName();
virtual LPCWSTR getWorldName();
virtual LPCWSTR getDisplayName();
virtual wstring getGrfPath();
virtual bool requiresBaseSave();
virtual wstring getBaseSavePath();
virtual void setRequiresTexturePack(bool x);
virtual void setRequiredTexturePackId(UINT x);
virtual void setDefaultSaveName(const wstring &x);
virtual void setWorldName(const wstring &x);
virtual void setDisplayName(const wstring &x);
virtual void setGrfPath(const wstring &x);
virtual void setBaseSavePath(const wstring &x);
virtual bool ready();
JustGrSource();
};
class LevelGenerationOptions : public GameRuleDefinition
{
public:
enum eSrc
{
eSrc_none,
eSrc_fromSave, // Neither content or header is persistent.
eSrc_fromDLC, // Header is persistent, content should be deleted to conserve space.
eSrc_tutorial, // Both header and content is persistent, content cannot be reloaded.
eSrc_MAX
};
private:
eSrc m_src;
GrSource *m_pSrc;
GrSource *info();
bool m_hasLoadedData;
PBYTE m_pbBaseSaveData;
DWORD m_dwBaseSaveSize;
public:
void setSrc(eSrc src);
eSrc getSrc();
bool isTutorial();
bool isFromSave();
bool isFromDLC();
bool requiresTexturePack();
UINT getRequiredTexturePackId();
wstring getDefaultSaveName();
LPCWSTR getWorldName();
LPCWSTR getDisplayName();
wstring getGrfPath();
bool requiresBaseSave();
wstring getBaseSavePath();
void setGrSource(GrSource *grs);
void setRequiresTexturePack(bool x);
void setRequiredTexturePackId(UINT x);
void setDefaultSaveName(const wstring &x);
void setWorldName(const wstring &x);
void setDisplayName(const wstring &x);
void setGrfPath(const wstring &x);
void setBaseSavePath(const wstring &x);
bool ready();
void setBaseSaveData(PBYTE pbData, DWORD dwSize);
PBYTE getBaseSaveData(DWORD &size);
bool hasBaseSaveData();
void deleteBaseSaveData();
bool hasLoadedData();
void setLoadedData();
private:
// This should match the "MapOptionsRule" definition in the XML schema
__int64 m_seed;
bool m_useFlatWorld;
Pos *m_spawnPos;
vector<ApplySchematicRuleDefinition *> m_schematicRules;
vector<ConsoleGenerateStructure *> m_structureRules;
bool m_bHaveMinY;
int m_minY;
unordered_map<wstring, ConsoleSchematicFile *> m_schematics;
vector<BiomeOverride *> m_biomeOverrides;
vector<StartFeature *> m_features;
bool m_bRequiresGameRules;
LevelRuleset *m_requiredGameRules;
StringTable *m_stringTable;
public:
LevelGenerationOptions();
~LevelGenerationOptions();
virtual ConsoleGameRules::EGameRuleType getActionType();
virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes);
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
__int64 getLevelSeed();
Pos *getSpawnPos();
bool getuseFlatWorld();
void processSchematics(LevelChunk *chunk);
void processSchematicsLighting(LevelChunk *chunk);
bool checkIntersects(int x0, int y0, int z0, int x1, int y1, int z1);
private:
void clearSchematics();
public:
ConsoleSchematicFile *loadSchematicFile(const wstring &filename, PBYTE pbData, DWORD dwLen);
public:
ConsoleSchematicFile *getSchematicFile(const wstring &filename);
void releaseSchematicFile(const wstring &filename);
bool requiresGameRules();
void setRequiredGameRules(LevelRuleset *rules);
LevelRuleset *getRequiredGameRules();
void getBiomeOverride(int biomeId, BYTE &tile, BYTE &topTile);
bool isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature);
void loadStringTable(StringTable *table);
LPCWSTR getString(const wstring &key);
unordered_map<wstring, ConsoleSchematicFile *> *getUnfinishedSchematicFiles();
// 4J-JEV:
// ApplySchematicRules contain limited state
// which needs to be reset BEFORE a new game starts.
void reset_start();
// 4J-JEV:
// This file contains state that needs to be deleted
// or reset once a game has finished.
void reset_finish();
};
|