From da1808961b2eef0a3ed56344baad72fafe784cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0imek?= Date: Wed, 25 May 2022 21:15:04 +0200 Subject: [PATCH] Add StartingMap configuration option from Sfall (#15) Closes #14 --- src/game_config.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/game_config.cc b/src/game_config.cc index d4cdd0e..349bb2d 100644 --- a/src/game_config.cc +++ b/src/game_config.cc @@ -1,5 +1,7 @@ #include "game_config.h" +#include "main.h" + #include #include @@ -19,7 +21,7 @@ Config gGameConfig; // 0x58E978 char gGameConfigFilePath[FILENAME_MAX]; -// Inits main game config. +// Inits main game config and optionally Sfall config. // // [isMapper] is a flag indicating whether we're initing config for a main // game, or a mapper. This value is `false` for the game itself. @@ -134,6 +136,22 @@ bool gameConfigInit(bool isMapper, int argc, char** argv) // whatever was loaded from `fallout2.cfg`. configParseCommandLineArguments(&gGameConfig, argc, argv); + // Optional Sfall extension + Config sfallConfig; + if (configInit(&sfallConfig)) { + configRead(&sfallConfig, "ddraw.ini", false); + + configParseCommandLineArguments(&sfallConfig, argc, argv); + + char* startingMap; + if (configGetString(&sfallConfig, "misc", "StartingMap", &startingMap)) { + if (*startingMap != '\0') { + strncpy(_mainMap, startingMap, 16); + } + } + } + configFree(&sfallConfig); + gGameConfigInitialized = true; return true;