the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 80 lines 2.4 kB view raw
1#pragma once 2using namespace std; 3 4#include "LevelGenerators.h" 5#include "LevelRules.h" 6class LevelGenerationOptions; 7class RootGameRulesDefinition; 8class LevelChunk; 9class DLCPack; 10class DLCGameRulesFile; 11class DLCGameRulesHeader; 12class StringTable; 13class GameRuleDefinition; 14class DataInputStream; 15class DataOutputStream; 16class WstringLookup; 17 18#define GAME_RULE_SAVENAME L"requiredGameRules.grf" 19 20// 4J-JEV: 21#define LEVEL_GEN_ID int 22#define LEVEL_GEN_ID_NULL 0 23 24class GameRuleManager 25{ 26public: 27 static WCHAR *wchTagNameA[ConsoleGameRules::eGameRuleType_Count]; 28 static WCHAR *wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count]; 29 30 static const short version_number = 2; 31 32private: 33 LevelGenerationOptions *m_currentLevelGenerationOptions; 34 LevelRuleset *m_currentGameRuleDefinitions; 35 LevelGenerators m_levelGenerators; 36 LevelRules m_levelRules; 37 38public: 39 GameRuleManager(); 40 41 void loadGameRules(DLCPack *); 42 43 LevelGenerationOptions *loadGameRules(byte *dIn, UINT dSize); 44 void loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT dSize); 45 46 void saveGameRules(byte **dOut, UINT *dSize); 47 48private: 49 LevelGenerationOptions *readHeader(DLCGameRulesHeader *grh); 50 51 void writeRuleFile(DataOutputStream *dos); 52 53public: 54 bool readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT dSize, StringTable *strings); //(DLCGameRulesFile *dlcFile, StringTable *strings); 55 56private: 57 void readAttributes(DataInputStream *dis, vector<wstring> *tagsAndAtts, GameRuleDefinition *rule); 58 void readChildren(DataInputStream *dis, vector<wstring> *tagsAndAtts, unordered_map<int, ConsoleGameRules::EGameRuleType> *tagIdMap, GameRuleDefinition *rule); 59 60public: 61 void processSchematics(LevelChunk *levelChunk); 62 void processSchematicsLighting(LevelChunk *levelChunk); 63 void loadDefaultGameRules(); 64 65private: 66 bool loadGameRulesPack(File *path); 67 68 LEVEL_GEN_ID addLevelGenerationOptions(LevelGenerationOptions *); 69 70public: 71 vector<LevelGenerationOptions *> *getLevelGenerators() { return m_levelGenerators.getLevelGenerators(); } 72 void setLevelGenerationOptions(LevelGenerationOptions *levelGen); 73 LevelRuleset *getGameRuleDefinitions() { return m_currentGameRuleDefinitions; } 74 LevelGenerationOptions *getLevelGenerationOptions() { return m_currentLevelGenerationOptions; } 75 LPCWSTR GetGameRulesString(const wstring &key); 76 77 // 4J-JEV: 78 // Properly cleans-up and unloads the current set of gameRules. 79 void unloadCurrentGameRules(); 80};