/************************************************************************************************ * CRMInstanceFile::Open * Opens the given instance file and prepares it for use in instance creation * * inputs: * instance: Name of instance to open. Note that the root path will be automatically * added and shouldnt be included in the given name * * return: * true: instance file successfully loaded * false: instance file could not be loaded for some reason * ************************************************************************************************/ bool CRMInstanceFile::Open ( const char* instance ) { char instanceDef[MAX_QPATH]; CGPGroup *basegroup; // Build the filename Com_sprintf(instanceDef, MAX_QPATH, "ext_data/rmg/%s.instance", instance ); #ifndef FINAL_BUILD // Debug message Com_Printf("CM_Terrain: Loading and parsing instanceDef %s.....\n", instance); #endif // Parse the text file using the generic parser if(!Com_ParseTextFile(instanceDef, mParser )) { Com_sprintf(instanceDef, MAX_QPATH, "ext_data/arioche/%s.instance", instance ); if(!Com_ParseTextFile(instanceDef, mParser )) { Com_Printf(va("CM_Terrain: Could not open instance file '%s'\n", instanceDef)); return false; } } // The whole file.... basegroup = mParser.GetBaseParseGroup(); // The root { } struct mInstances = basegroup->GetSubGroups(); // The "instances" { } structure mInstances = mInstances->GetSubGroups ( ); return true; }
void CRMLandScape::LoadMiscentDef(const char *td) { char miscentDef[MAX_QPATH]; CGenericParser2 parse; CGPGroup *basegroup, *classes, *items, *model; CGPValue *pair; Com_sprintf(miscentDef, MAX_QPATH, "ext_data/RMG/%s.miscents", Info_ValueForKey(td, "miscentDef")); Com_DPrintf("CG_Terrain: Loading and parsing miscentDef %s.....\n", Info_ValueForKey(td, "miscentDef")); if(!Com_ParseTextFile(miscentDef, parse)) { Com_sprintf(miscentDef, MAX_QPATH, "ext_data/arioche/%s.miscents", Info_ValueForKey(td, "miscentDef")); if(!Com_ParseTextFile(miscentDef, parse)) { Com_Printf("Could not open %s\n", miscentDef); return; } } // The whole file.... basegroup = parse.GetBaseParseGroup(); // The root { } struct classes = basegroup->GetSubGroups(); while(classes) { items = classes->GetSubGroups(); while(items) { if(!stricmp(items->GetName(), "miscent")) { int height, maxheight; // Height must exist - the rest are optional height = atol(items->FindPairValue("height", "0")); maxheight = atol(items->FindPairValue("maxheight", "255")); model = items->GetSubGroups(); while(model) { if(!stricmp(model->GetName(), "model")) { CRandomModel hd; // Set defaults hd.SetModel(""); hd.SetFrequency(1.0f); hd.SetMinScale(1.0f); hd.SetMaxScale(1.0f); pair = model->GetPairs(); while(pair) { if(!stricmp(pair->GetName(), "name")) { hd.SetModel(pair->GetTopValue()); } else if(!stricmp(pair->GetName(), "frequency")) { hd.SetFrequency((float)atof(pair->GetTopValue())); } else if(!stricmp(pair->GetName(), "minscale")) { hd.SetMinScale((float)atof(pair->GetTopValue())); } else if(!stricmp(pair->GetName(), "maxscale")) { hd.SetMaxScale((float)atof(pair->GetTopValue())); } pair = (CGPValue *)pair->GetNext(); } AddModel(height, maxheight, &hd); } model = (CGPGroup *)model->GetNext(); } } items = (CGPGroup *)items->GetNext(); } classes = (CGPGroup *)classes->GetNext(); } Com_ParseTextFileDestroy(parse); }
/************************************************************************************************ * CRMManager::LoadMission * Loads the mission using the mission name stored in the ar_mission cvar * * inputs: * none * * return: * none * ************************************************************************************************/ bool CRMManager::LoadMission ( qboolean IsServer ) { char instances[MAX_QPATH]; char mission[MAX_QPATH]; char course[MAX_QPATH]; char map[MAX_QPATH]; char temp[MAX_QPATH]; #ifndef FINAL_BUILD Com_Printf ("--------- Random Mission Manager ---------\n\n"); Com_Printf ("RMG version : 1.01\n\n"); #endif if (!mTerrain) { return false; } // Grab the arioche variables Cvar_VariableStringBuffer("rmg_usetimelimit", temp, MAX_QPATH); if (Q_stricmp(temp, "yes") == 0) { mUseTimeLimit = true; } Cvar_VariableStringBuffer("rmg_instances", instances, MAX_QPATH); Cvar_VariableStringBuffer("RMG_mission", temp, MAX_QPATH); Cvar_VariableStringBuffer("rmg_map", map, MAX_QPATH); Com_sprintf(mission, sizeof(mission), "%s_%s", temp, map); Cvar_VariableStringBuffer("rmg_course", course, MAX_QPATH); // dump existing mission, if any if (mMission) { delete mMission; mMission = NULL; } // Create a new mission file mMission = new CRMMission ( mTerrain ); if ( IsServer ) { // Load the mission using the arioche variables if ( !mMission->Load ( mission, instances, course ) ) { return false; } // set the names of the teams CGenericParser2 parser; CGPGroup* root; Cvar_VariableStringBuffer("RMG_terrain", temp, MAX_QPATH); // Create the parser for the mission file if(Com_ParseTextFile(va("ext_data/rmg/%s.teams", temp), parser)) { root = parser.GetBaseParseGroup()->GetSubGroups(); if (0 == stricmp(root->GetName(), "teams")) { /* SV_SetConfigstring( CS_GAMETYPE_REDTEAM, root->FindPairValue ( "red", "marine" )); SV_SetConfigstring( CS_GAMETYPE_BLUETEAM, root->FindPairValue ( "blue", "thug" )); */ //rwwFIXMEFIXME: Do we care about this? } parser.Clean(); } } // Must have a valid landscape before we can spawn the mission assert ( mLandScape ); #ifndef FINAL_BUILD Com_Printf ("------------------------------------------\n"); #endif return true; }