// // 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)); } }
// // 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); } }
// // LoadState // // Load state information // void Base::LoadState(FScope *scope, void *context) { FScope *sScope; while ((sScope = scope->NextFunction()) != NULL) { switch (sScope->NameCrc()) { case 0x411AC76D: // "Parent" Item::LoadState(sScope, context); break; case 0x48096F5A: // "AllTokens" { FScope *fScope; while ((fScope = sScope->NextFunction()) != NULL) { switch (fScope->NameCrc()) { case 0x9F1D54D0: // "Add" { // Constructor adds token to the all lists new Token(fScope, manager); break; } } } break; } case 0xEB9C8D59: // "States" { for (NBinTree<State>::Iterator i(&states); *i; ++i) { if (FScope *fScope = sScope->NextFunction()) { (*i)->LoadState(fScope); } } break; } case 0xFE325917: // "CurrentState" currentState = states.Find(StdLoad::TypeU32(sScope)); break; case 0x35BC5703: // "NewState" newState = StdLoad::TypeU32(sScope); break; case 0xD20160BE: // "ProcessTokens" processTokens = StdLoad::TypeU32(sScope); break; case 0xCED02493: // "Units" StdLoad::TypeReaperList(sScope, units); Resolver::ObjList<UnitObj, UnitObjType, UnitObjListNode>(units); break; case 0x1BF75F38: // "Disruptors" StdLoad::TypeReaperList(sScope, disruptors); Resolver::ObjList<UnitObj, UnitObjType, UnitObjListNode>(disruptors); break; case 0x93075ED7: // "AutoDisrupt" autoDisrupt = StdLoad::TypeU32(sScope); break; case 0xD9D7B747: // "DisruptorIndex" disruptorIndex = StdLoad::TypeU32(sScope); break; case 0xC134342B: // "DisruptorCycle" disruptorCycle = StdLoad::TypeU32(sScope); break; case 0x95358C83: // "ConstructorsIdle" StdLoad::TypeReaperList(sScope, constructorsIdle); Resolver::ObjList<UnitObj, UnitObjType, UnitObjListNode>(constructorsIdle); break; case 0xB6194C3B: // "ConstructorsWorking" StdLoad::TypeReaperList(sScope, constructorsWorking); Resolver::ObjList<UnitObj, UnitObjType, UnitObjListNode>(constructorsWorking); break; case 0x7D4149AB: // "TokensSearching" manager.LoadTokenBinTree(tokensSearching, sScope); break; case 0x52015470: // "TokensWaiting" manager.LoadTokenBinTree(tokensWaiting, sScope); break; case 0x6C5528B7: // "TokensConstructing" manager.LoadTokenBinTree(tokensConstructing, sScope); break; case 0xFF360560: // "TokensOrphaned" manager.LoadTokenList(tokensOrphaned, sScope); break; } } }
// // Constructor // Script::State::State(Script &script, const char *name, FScope *fScope) : script(script), settings(&Setting::nodeState), conditions(&Condition::nodeState), transitions(&Transition::nodeState), name(name) { FScope *sScope; FScope *iScope; // Load the settings iScope = fScope->GetFunction("Settings", FALSE); if (iScope) { while ((sScope = iScope->NextFunction()) != NULL) { switch (sScope->NameCrc()) { case 0x32BBA19C: // "Setting" settings.Append(Setting::Create(script, sScope)); break; default: sScope->ScopeError("Unknown function '%s' in settings", sScope->NameStr()); } } } // Load the action iScope = fScope->GetFunction("Action", FALSE); if (iScope) { action = Action::Create(script, iScope); } else { action = NULL; } // Load the conditions iScope = fScope->GetFunction("Conditions", FALSE); if (iScope) { while ((sScope = iScope->NextFunction()) != NULL) { switch (sScope->NameCrc()) { case 0x6A34146A: // "Condition" conditions.Append(Condition::Create(script, sScope)); break; case 0xFBCD164A: // "Status" { GameIdent code = StdLoad::TypeString(sScope); if (transitions.Exists(code.crc)) { sScope->ScopeError("Status '%s' already defined", code.str); } // Add the new transition transitions.Add(code.crc, Transition::Create(sScope)); break; } default: sScope->ScopeError("Unknown function '%s' in conditions", sScope->NameStr()); } } } completed = transitions.Find(Status::Completed); }
// // LoadState // // Load object state information // void Object::LoadState(FScope *scope) { FScope *sScope; while ((sScope = scope->NextFunction()) != NULL) { switch (sScope->NameCrc()) { case 0x4F12C753: // "ScriptManager" scriptManager.LoadState(sScope); break; case 0x393E9106: // "TransportManager" transportManager.LoadState(sScope); break; case 0x2C287ED7: // "AssetManager" assetManager.LoadState(sScope); break; case 0xB0F126DB: // "BombardierManager" bombardierManager.LoadState(sScope); break; case 0x87824959: // "IntelManager" intelManager.LoadState(sScope); break; case 0x021DD97F: // "PlacementManager" placementManager.LoadState(sScope); break; case 0x9022D919: // "RuleManager" ruleManager.LoadState(sScope); break; case 0x4CEB40FE: // "ResourceManager" resourceManager.LoadState(sScope); break; case 0x45DA4572: // "WaterManager" waterManager.LoadState(sScope); break; case 0x57E13FCA: // "BaseManager" baseManager.LoadState(sScope); break; case 0x23DF48AA: // "Notifications" { FScope *ssScope; while ((ssScope = sScope->NextFunction()) != NULL) { switch (ssScope->NameCrc()) { case 0x9F1D54D0: // "Add" { // Load the game object reaper GameObjPtr from; StdLoad::TypeReaper(ssScope, "From", from); Resolver::Object<GameObj, GameObjType>(from); // Add the notification notifications.Append ( new Notification ( from.GetPointer(), StdLoad::TypeU32(ssScope, "Message"), StdLoad::TypeU32(ssScope, "Param1"), StdLoad::TypeU32(ssScope, "Param2") ) ); break; } } } break; } } } }