Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sfall: add VersionString, ConfigFile, PatchFile #309

Merged
merged 5 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1348,8 +1348,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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this option? Any mod relies on it? We have a much better mods system in sfall 4.x. All this patch stuff is relics from early modding years.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patches is still vanilla engine feature, so i guess 'll be better have to stay that thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm talking about patch stuff added by sfall, that nobody uses now.


if (compat_access(filename, 0) == 0) {
dbOpen(filename, 0, NULL, 1);
Expand Down
13 changes: 11 additions & 2 deletions src/game_config.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "game_config.h"
#include "sfall_config.h"

#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -120,15 +121,23 @@ 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, '\\');
if (ch != NULL) {
*ch = '\0';
snprintf(gGameConfigFilePath, sizeof(gGameConfigFilePath), "%s\\%s", executable, GAME_CONFIG_FILE_NAME);
snprintf(gGameConfigFilePath, sizeof(gGameConfigFilePath), "%s\\%s", executable, configFileName);
*ch = '\\';
} else {
strcpy(gGameConfigFilePath, GAME_CONFIG_FILE_NAME);
strcpy(gGameConfigFilePath, configFileName);
}

// Read contents of `fallout2.cfg` into config. The values from the file
Expand Down
2 changes: 1 addition & 1 deletion src/game_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace fallout {

// The file name of the main config file.
#define GAME_CONFIG_FILE_NAME "fallout2.cfg"
#define DEFAULT_GAME_CONFIG_FILE_NAME "fallout2.cfg"

#define GAME_CONFIG_SYSTEM_KEY "system"
#define GAME_CONFIG_PREFERENCES_KEY "preferences"
Expand Down
3 changes: 3 additions & 0 deletions src/sfall_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
Expand Down
3 changes: 3 additions & 0 deletions src/sfall_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/version.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "version.h"
#include "sfall_config.h"

#include <stdio.h>

Expand All @@ -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