void FGameConfigFile::AddAutoexec (FArgs *list, const char *game) { char section[64]; const char *key; const char *value; mysnprintf (section, countof(section), "%s.AutoExec", game); // If <game>.AutoExec section does not exist, create it // with a default autoexec.cfg file present. CreateStandardAutoExec(section, false); // Run any files listed in the <game>.AutoExec section if (!SectionIsEmpty()) { while (NextInSection (key, value)) { if (stricmp (key, "Path") == 0 && *value != '\0') { FString expanded_path = ExpandEnvVars(value); if (FileExists(expanded_path)) { list->AppendArg (ExpandEnvVars(value)); } } } } }
// Moved from DoGameSetup so that it can happen after wads are loaded void FGameConfigFile::DoKeySetup(const char *gamename) { static const struct { const char *label; FKeyBindings *bindings; } binders[] = { { "Bindings", &Bindings }, { "DoubleBindings", &DoubleBindings }, { "AutomapBindings", &AutomapBindings }, { NULL, NULL } }; const char *key, *value; sublen = countof(section) - 1 - mysnprintf(section, countof(section), "%s.", gamename); subsection = section + countof(section) - sublen - 1; section[countof(section) - 1] = '\0'; C_SetDefaultBindings (); for (int i = 0; binders[i].label != NULL; ++i) { strncpy(subsection, binders[i].label, sublen); if (SetSection(section)) { FKeyBindings *bindings = binders[i].bindings; bindings->UnbindAll(); while (NextInSection(key, value)) { bindings->DoBind(key, value); } } } }
void FGameConfigFile::DoGameSetup (const char *gamename) { const char *key; const char *value; sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename); subsection = section + countof(section) - sublen - 1; section[countof(section) - 1] = '\0'; strncpy (subsection, "UnknownConsoleVariables", sublen); if (SetSection (section)) { ReadCVars (0); } strncpy (subsection, "ConsoleVariables", sublen); if (SetSection (section)) { ReadCVars (0); } if (gameinfo.gametype & GAME_Raven) { SetRavenDefaults (gameinfo.gametype == GAME_Hexen); } // The NetServerInfo section will be read and override anything loaded // here when it's determined that a netgame is being played. strncpy (subsection, "LocalServerInfo", sublen); if (SetSection (section)) { ReadCVars (0); } strncpy (subsection, "Player", sublen); if (SetSection (section)) { ReadCVars (0); } strncpy (subsection, "ConsoleAliases", sublen); if (SetSection (section)) { const char *name = NULL; while (NextInSection (key, value)) { if (stricmp (key, "Name") == 0) { name = value; } else if (stricmp (key, "Command") == 0 && name != NULL) { C_SetAlias (name, value); name = NULL; } } } OkayToWrite = true; }
void FGameConfigFile::AddAutoexec (DArgs *list, const char *game) { char section[64]; const char *key; const char *value; mysnprintf (section, countof(section), "%s.AutoExec", game); if (bMigrating) { FBaseCVar *autoexec = FindCVar ("autoexec", NULL); if (autoexec != NULL) { UCVarValue val; char *path; val = autoexec->GetGenericRep (CVAR_String); path = copystring (val.String); delete autoexec; SetSection (section, true); SetValueForKey ("Path", path); list->AppendArg (path); delete[] path; } } else { // If <game>.AutoExec section does not exist, create it // with a default autoexec.cfg file present. CreateStandardAutoExec(section, false); // Run any files listed in the <game>.AutoExec section if (!SectionIsEmpty()) { while (NextInSection (key, value)) { if (stricmp (key, "Path") == 0 && *value != '\0') { FString expanded_path = ExpandEnvVars(value); if (FileExists(expanded_path)) { list->AppendArg (ExpandEnvVars(value)); } } } } } }
void FGameConfigFile::ReadCVars (DWORD flags) { const char *key, *value; FBaseCVar *cvar; UCVarValue val; while (NextInSection (key, value)) { cvar = FindCVar (key, NULL); if (cvar == NULL) { cvar = new FStringCVar (key, NULL, CVAR_AUTO|CVAR_UNSETTABLE|CVAR_ARCHIVE|flags); } val.String = const_cast<char *>(value); cvar->SetGenericRep (val, CVAR_String); } }
void FGameConfigFile::DoGameSetup (const char *gamename) { const char *key; const char *value; enum { Doom, Heretic, Hexen, Strife, Chex } game; if (strcmp (gamename, "Heretic") == 0) game = Heretic; else if (strcmp (gamename, "Hexen") == 0) game = Hexen; else if (strcmp (gamename, "Strife") == 0) game = Strife; else if (strcmp (gamename, "Chex") == 0) game = Chex; else game = Doom; if (bMigrating) { MigrateOldConfig (); } sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename); subsection = section + countof(section) - sublen - 1; section[countof(section) - 1] = '\0'; strncpy (subsection, "UnknownConsoleVariables", sublen); if (SetSection (section)) { ReadCVars (0); } strncpy (subsection, "ConsoleVariables", sublen); if (SetSection (section)) { ReadCVars (0); } if (game != Doom && game != Strife && game != Chex) { SetRavenDefaults (game == Hexen); } // The NetServerInfo section will be read when it's determined that // a netgame is being played. strncpy (subsection, "LocalServerInfo", sublen); if (SetSection (section)) { ReadCVars (0); } strncpy (subsection, "Player", sublen); if (SetSection (section)) { ReadCVars (0); } strncpy (subsection, "Bindings", sublen); if (!SetSection (section)) { // Config has no bindings for the given game if (!bMigrating) { C_SetDefaultBindings (); } } else { C_UnbindAll (); while (NextInSection (key, value)) { C_DoBind (key, value, false); } } strncpy (subsection, "DoubleBindings", sublen); if (SetSection (section)) { while (NextInSection (key, value)) { C_DoBind (key, value, true); } } strncpy (subsection, "ConsoleAliases", sublen); if (SetSection (section)) { const char *name = NULL; while (NextInSection (key, value)) { if (stricmp (key, "Name") == 0) { name = value; } else if (stricmp (key, "Command") == 0 && name != NULL) { C_SetAlias (name, value); name = NULL; } } } }
void FGameConfigFile::DoGameSetup (const char *gamename) { const char *key; const char *value; if (bMigrating) { MigrateOldConfig (); } sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename); subsection = section + countof(section) - sublen - 1; section[countof(section) - 1] = '\0'; strncpy (subsection, "UnknownConsoleVariables", sublen); if (SetSection (section)) { ReadCVars (0); } strncpy (subsection, "ConsoleVariables", sublen); if (SetSection (section)) { ReadCVars (0); } if (gameinfo.gametype & GAME_Raven) { SetRavenDefaults (gameinfo.gametype == GAME_Hexen); } // The NetServerInfo section will be read when it's determined that // a netgame is being played. strncpy (subsection, "LocalServerInfo", sublen); if (SetSection (section)) { ReadCVars (0); } strncpy (subsection, "Player", sublen); if (SetSection (section)) { ReadCVars (0); } if (!bMigrating) { C_SetDefaultBindings (); } strncpy (subsection, "Bindings", sublen); if (SetSection (section)) { Bindings.UnbindAll(); while (NextInSection (key, value)) { Bindings.DoBind (key, value); } } strncpy (subsection, "DoubleBindings", sublen); if (SetSection (section)) { DoubleBindings.UnbindAll(); while (NextInSection (key, value)) { DoubleBindings.DoBind (key, value); } } strncpy (subsection, "AutomapBindings", sublen); if (SetSection (section)) { AutomapBindings.UnbindAll(); while (NextInSection (key, value)) { AutomapBindings.DoBind (key, value); } } strncpy (subsection, "ConsoleAliases", sublen); if (SetSection (section)) { const char *name = NULL; while (NextInSection (key, value)) { if (stricmp (key, "Name") == 0) { name = value; } else if (stricmp (key, "Command") == 0 && name != NULL) { C_SetAlias (name, value); name = NULL; } } } OkayToWrite = true; }