// 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; 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::MigrateOldConfig () { // Set default key bindings. These will be overridden // by the bindings in the config file if it exists. C_SetDefaultBindings (); }
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; }