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