Sfall: add VersionString, ConfigFile, PatchFile (#309)

This commit is contained in:
c6 2024-01-16 16:56:21 +04:00 committed by GitHub
parent 16f4ab7787
commit c6565ac96a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 5 deletions

View File

@ -1363,8 +1363,16 @@ static int gameDbInit()
return -1;
}
// SFALL: custom patch file name.
char* patch_filename = nullptr;
if (configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_PATCH_FILE, &patch_filename)) {
if (patch_filename == nullptr || *patch_file_name == '\0') {
patch_filename = "patch%03d.dat";
}
}
for (patch_index = 0; patch_index < 1000; patch_index++) {
snprintf(filename, sizeof(filename), "patch%03d.dat", patch_index);
snprintf(filename, sizeof(filename), patch_filename, patch_index);
if (compat_access(filename, 0) == 0) {
dbOpen(filename, 0, NULL, 1);

View File

@ -1,4 +1,5 @@
#include "game_config.h"
#include "sfall_config.h"
#include <stdio.h>
#include <string.h>
@ -120,6 +121,14 @@ bool gameConfigInit(bool isMapper, int argc, char** argv)
configSetInt(&gGameConfig, GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_SORT_SCRIPT_LIST_KEY, 0);
}
// SFALL: custom config file name.
char* configFileName = nullptr;
if (configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CONFIG_FILE, &configFileName)) {
if (configFileName == nullptr || *configFileName == '\0') {
configFileName = DEFAULT_GAME_CONFIG_FILE_NAME;
}
}
// Make `fallout2.cfg` file path.
char* executable = argv[0];
char* ch = strrchr(executable, '\\');
@ -136,14 +145,14 @@ bool gameConfigInit(bool isMapper, int argc, char** argv)
sizeof(gGameConfigFilePath),
"%s\\%s",
executable,
GAME_CONFIG_FILE_NAME);
configFileName);
}
*ch = '\\';
} else {
if (isMapper) {
strcpy(gGameConfigFilePath, MAPPER_CONFIG_FILE_NAME);
} else {
strcpy(gGameConfigFilePath, GAME_CONFIG_FILE_NAME);
strcpy(gGameConfigFilePath, configFileName);
}
}

View File

@ -5,7 +5,7 @@
namespace fallout {
#define GAME_CONFIG_FILE_NAME "fallout2.cfg"
#define DEFAULT_GAME_CONFIG_FILE_NAME "fallout2.cfg"
#define MAPPER_CONFIG_FILE_NAME "mapper2.cfg"
#define GAME_CONFIG_SYSTEM_KEY "system"

View File

@ -58,6 +58,9 @@ bool sfallConfigInit(int argc, char** argv)
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_MOVIE_TIMER_ARTIMER3, 270);
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_MOVIE_TIMER_ARTIMER4, 360);
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_AUTO_QUICK_SAVE, 0);
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_VERSION_STRING, "");
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CONFIG_FILE, "");
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_PATCH_FILE, "");
configSetString(&gSfallConfig, SFALL_CONFIG_SCRIPTS_KEY, SFALL_CONFIG_INI_CONFIG_FOLDER, "");
configSetString(&gSfallConfig, SFALL_CONFIG_SCRIPTS_KEY, SFALL_CONFIG_GLOBAL_SCRIPT_PATHS, "");

View File

@ -72,6 +72,9 @@ namespace fallout {
#define SFALL_CONFIG_INI_CONFIG_FOLDER "IniConfigFolder"
#define SFALL_CONFIG_GLOBAL_SCRIPT_PATHS "GlobalScriptPaths"
#define SFALL_CONFIG_AUTO_QUICK_SAVE "AutoQuickSave"
#define SFALL_CONFIG_VERSION_STRING "VersionString"
#define SFALL_CONFIG_CONFIG_FILE "ConfigFile"
#define SFALL_CONFIG_PATCH_FILE "PatchFile"
#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER 1
#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR 3

View File

@ -1,4 +1,5 @@
#include "version.h"
#include "sfall_config.h"
#include <stdio.h>
@ -7,7 +8,14 @@ namespace fallout {
// 0x4B4580
void versionGetVersion(char* dest, size_t size)
{
snprintf(dest, size, "FALLOUT II %d.%02d", VERSION_MAJOR, VERSION_MINOR);
// SFALL: custom version string.
char* versionString = nullptr;
if (configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_VERSION_STRING, &versionString)) {
if (*versionString == '\0') {
versionString = nullptr;
}
}
snprintf(dest, size, (versionString != nullptr ? versionString : "FALLOUT II %d.%02d"), VERSION_MAJOR, VERSION_MINOR);
}
} // namespace fallout