// // LoadObjectFile // // Load a object definition file into current state, false if not found // Bool LoadObjectFile(const char *name) { ASSERT(name); PTree pTree; Bool safe = Missions::GetSafeLoad(); // Parse the file GameGod::Loader::SubSystem("#game.loader.createobjects", 1); if (pTree.AddFile(name)) { // Get the global scope FScope *gScope = pTree.GetGlobalScope(); FScope *sScope; // Process each function GameGod::Loader::SubSystem("#game.loader.createobjects", gScope->GetBodyCount()); while ((sScope = gScope->NextFunction()) != NULL) { switch (sScope->NameCrc()) { case 0xCAE286FA: // "CreateObject" LoadCreateObject(sScope, safe); GameGod::Loader::Advance(); break; } } if (GameGod::CheckObjects()) { FSCOPE_CHECK(gScope) } // Call each existing game object GameGod::Loader::SubSystem("#game.loader.configureobjects", GameObjCtrl::listAll.GetCount()); for (NList<GameObj>::Iterator i(&GameObjCtrl::listAll); *i; i++) { // Are we in safe-mode and this is a map object if (safe && Promote::Object<MapObjType, MapObj>(*i)) { } else { // Call virtual post-load function (*i)->PostLoad(); } GameGod::Loader::Advance(); } return (TRUE); }
// // LoadConfig // // Load the configured difficulty settings // static void LoadConfig() { PTree pTree; GameIdent defaultName; // Clear any current settings ClearSettings(); // Open the configuration file if (pTree.AddFile(configName)) { FScope *gScope = pTree.GetGlobalScope(); FScope *sScope; // Parse each function while ((sScope = gScope->NextFunction()) != NULL) { switch (sScope->NameCrc()) { case 0x12AFF0D8: // "CreateSetting" ProcessCreateSetting(sScope); break; case 0x733C1EB5: // "DefaultSetting" defaultName = StdLoad::TypeString(sScope); break; } } // Ensure at least one setting is configured if (settings.GetCount()) { // Setup the default setting if ((defaultSetting = FindSetting(defaultName)) == NULL) { defaultSetting = settings.GetHead(); } // Set the current from the default currentSetting = defaultSetting; } else { ERR_CONFIG(("At least one difficulty setting must be supplied in [%s]", configName)); } } else { ERR_CONFIG(("Unable to load difficulty settings configuration [%s]", configName)); } }
// // ExecInitialConfig // // Executes the config file for this application // void ExecInitialConfig() { PTree pTree; // Attempt to open the file if (pTree.AddFile(APPLICATION_CONFIGFILE)) { // Find our startup scope FScope *fScope = pTree.GetGlobalScope()->GetFunction("StartupConfig", FALSE); // Config is not required if (fScope) { Main::ProcessCmdScope(fScope); } } else { ERR_FATAL(("Unable to execute the required file '%s'", APPLICATION_CONFIGFILE)); } }
// // LoadConfig // // Load the group configuration file // void Group::LoadConfig() { FilePath configPath; PTree pTree; // Generate the config name Dir::PathMake(configPath, GetPath().str, MISSIONS_FILE_GROUP); // Add the campaign config if (pTree.AddFile(configPath.str)) { FScope *gScope = pTree.GetGlobalScope(); FScope *sScope; // Process each function while ((sScope = gScope->NextFunction()) != NULL) { switch (sScope->NameCrc()) { case 0x47CB37F2: // "Description" description = StdLoad::TypeString(sScope); break; case 0xF81D1051: // "System" system = StdLoad::TypeU32(sScope); break; case 0xC2B3BE7B: // "InstantAction" instantAction = StdLoad::TypeU32(sScope); break; case 0x7BB50683: // "Campaign" Campaigns::CreateCampaign(*this, sScope); break; } } } }
// // Init // // Initialize system // void Init() { ASSERT(!initialized) ASSERT(!items.GetCount()) PTree pTree; // Process the configuration if (pTree.AddFile(configName)) { FScope *fScope = pTree.GetGlobalScope(); FScope *sScope; while ((sScope = fScope->NextFunction()) != NULL) { switch (sScope->NameCrc()) { case 0x64FFFFD7: // "Place" { // Load the data const char *type = StdLoad::TypeString(sScope); F32 direction = StdLoad::TypeCompassAngle(sScope); F32 distance = StdLoad::TypeF32(sScope); F32 orientation = StdLoad::TypeCompassAngle(sScope); // Create the item items.Append(new Item(type, direction, distance, orientation)); break; } } } } // System now initialized initialized = TRUE; }
// // Preview::Preview // Preview::Preview(const Missions::Mission *missionIn) : teams(&TeamInfo::node), terrain(NULL), ruleSetFixed(FALSE) { if (missionIn) { name = missionIn->GetName().str; path = missionIn->GetGroup().GetPath().str; } else { name = ""; path = ""; } // Open mission stream const char *oldStream = OpenMissionStream(); // Open the game configuration file PTree pTree; // Parse the file if (pTree.AddFile(FILENAME_MISSION_CONFIG)) { // Get the global scope FScope *gScope = pTree.GetGlobalScope(); FScope *sScope; // Process each function while ((sScope = gScope->NextFunction()) != NULL) { switch (sScope->NameCrc()) { case 0xEDF7E07D: // "DefaultRule" ruleSet = StdLoad::TypeString(sScope); break; case 0x7F6A7C11: // "FixedRule" ruleSetFixed = StdLoad::TypeU32(sScope); break; case 0x1D4A8250: // "WorldInfo" // Load map size size = StdLoad::TypeU32(sScope, "CellMapX"); break; case 0xCA519158: // "DefineTeams" { ASSERT(!teams.GetCount()) // Count the number of teams we find FScope *fScope; // Process each function while ((fScope = sScope->NextFunction()) != NULL) { switch (fScope->NameCrc()) { case 0xB884B9E8: // "CreateTeam" { // Is this team available for play if (StdLoad::TypeU32(fScope, "AvailablePlay", 1)) { // Create new team info TeamInfo *info = new TeamInfo(fScope); // Add to the tree teams.Add(info->GetName().crc, info); } break; } } } break; } } } } else { size = 0; } // Load preview texture ReloadTextures(); // Restore old stuff if (oldStream) { CloseMissionStream(oldStream); } }