Refactor game config with Settings (#164)

This commit is contained in:
Alexander Batalov 2022-10-06 16:32:46 +03:00 committed by GitHub
parent 9663532e44
commit 54d230432b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 563 additions and 429 deletions

View File

@ -260,6 +260,8 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/platform_compat.h"
"src/pointer_registry.cc"
"src/pointer_registry.h"
"src/settings.cc"
"src/settings.h"
"src/sfall_config.cc"
"src/sfall_config.h"
)

View File

@ -13,7 +13,6 @@
#include "debug.h"
#include "display_monitor.h"
#include "game.h"
#include "game_config.h"
#include "game_sound.h"
#include "geometry.h"
#include "interface.h"
@ -28,6 +27,7 @@
#include "proto_types.h"
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "sfall_config.h"
#include "skill.h"
#include "stat.h"
@ -142,10 +142,7 @@ int actionKnockdown(Object* obj, int* anim, int maxDistance, int rotation, int d
// 0x410568
int _action_blood(Object* obj, int anim, int delay)
{
int violence_level = VIOLENCE_LEVEL_MAXIMUM_BLOOD;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, &violence_level);
if (violence_level == VIOLENCE_LEVEL_NONE) {
if (settings.preferences.violence_level == VIOLENCE_LEVEL_NONE) {
return anim;
}
@ -193,8 +190,7 @@ int _pick_death(Object* attacker, Object* defender, Object* weapon, int damage,
maximumBloodViolenceLevelDamageThreshold /= 3;
}
int violenceLevel = VIOLENCE_LEVEL_MAXIMUM_BLOOD;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, &violenceLevel);
int violenceLevel = settings.preferences.violence_level;
if (_critter_flag_check(defender->pid, CRITTER_SPECIAL_DEATH)) {
return _check_death(defender, ANIM_EXPLODED_TO_NOTHING, VIOLENCE_LEVEL_NORMAL, isFallingBack);
@ -251,9 +247,7 @@ int _check_death(Object* obj, int anim, int minViolenceLevel, bool isFallingBack
{
int fid;
int violenceLevel = VIOLENCE_LEVEL_MAXIMUM_BLOOD;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, &violenceLevel);
if (violenceLevel >= minViolenceLevel) {
if (settings.preferences.violence_level >= minViolenceLevel) {
fid = buildFid(OBJ_TYPE_CRITTER, obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
if (artExists(fid)) {
return anim;

View File

@ -11,7 +11,6 @@
#include "debug.h"
#include "display_monitor.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_sound.h"
#include "geometry.h"
@ -28,6 +27,7 @@
#include "proto_instance.h"
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "stat.h"
#include "svga.h"
#include "text_object.h"
@ -3000,9 +3000,7 @@ int _check_move(int* a1)
}
}
} else {
bool interruptWalk;
configGetBool(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_INTERRUPT_WALK_KEY, &interruptWalk);
if (interruptWalk) {
if (settings.system.interrupt_walk) {
reg_anim_clear(gDude);
}
}
@ -3334,13 +3332,8 @@ static unsigned int animationComputeTicksPerFrame(Object* object, int fid)
if (isInCombat()) {
if (FID_ANIM_TYPE(fid) == ANIM_WALK) {
int playerSpeedup = 0;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_PLAYER_SPEEDUP_KEY, &playerSpeedup);
if (object != gDude || playerSpeedup == 1) {
int combatSpeed = 0;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_SPEED_KEY, &combatSpeed);
fps += combatSpeed;
if (object != gDude || settings.preferences.player_speedup) {
fps += settings.preferences.combat_speed;
}
}
}

View File

@ -8,10 +8,10 @@
#include "debug.h"
#include "draw.h"
#include "game.h"
#include "game_config.h"
#include "memory.h"
#include "object.h"
#include "proto.h"
#include "settings.h"
#include "sfall_config.h"
namespace fallout {
@ -132,18 +132,14 @@ int artInit()
File* stream;
char string[200];
int cacheSize;
if (!configGetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_ART_CACHE_SIZE_KEY, &cacheSize)) {
cacheSize = 8;
}
int cacheSize = settings.system.art_cache_size;
if (!cacheInit(&gArtCache, artCacheGetFileSizeImpl, artCacheReadDataImpl, artCacheFreeImpl, cacheSize << 20)) {
debugPrint("cache_init failed in art_init\n");
return -1;
}
char* language;
if (configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, &language) && compat_stricmp(language, ENGLISH) != 0) {
const char* language = settings.system.language.c_str();
if (compat_stricmp(language, ENGLISH) != 0) {
strcpy(gArtLanguage, language);
gArtLanguageInitialized = true;
}

View File

@ -12,7 +12,6 @@
#include "debug.h"
#include "draw.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_sound.h"
#include "graph_lib.h"
@ -23,6 +22,7 @@
#include "memory.h"
#include "object.h"
#include "platform_compat.h"
#include "settings.h"
#include "svga.h"
#include "text_font.h"
#include "window_manager.h"
@ -271,12 +271,9 @@ int automapReset()
// 0x41B81C
void automapExit()
{
char* masterPatchesPath;
if (configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &masterPatchesPath)) {
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\%s\\%s", masterPatchesPath, "MAPS", AUTOMAP_DB);
compat_remove(path);
}
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\%s\\%s", settings.system.master_patches_path.c_str(), "MAPS", AUTOMAP_DB);
compat_remove(path);
}
// 0x41B87C
@ -830,15 +827,9 @@ int automapSaveCurrent()
internal_free(gAutomapEntry.data);
internal_free(gAutomapEntry.compressedData);
char* masterPatchesPath;
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &masterPatchesPath)) {
debugPrint("\nAUTOMAP: Error reading config info!\n");
return -1;
}
// NOTE: Not sure about the size.
char automapDbPath[512];
sprintf(automapDbPath, "%s\\%s\\%s", masterPatchesPath, "MAPS", AUTOMAP_DB);
sprintf(automapDbPath, "%s\\%s\\%s", settings.system.master_patches_path.c_str(), "MAPS", AUTOMAP_DB);
if (compat_remove(automapDbPath) != 0) {
debugPrint("\nAUTOMAP: Error removing database!\n");
return -1;
@ -846,7 +837,7 @@ int automapSaveCurrent()
// NOTE: Not sure about the size.
char automapTmpPath[512];
sprintf(automapTmpPath, "%s\\%s\\%s", masterPatchesPath, "MAPS", AUTOMAP_TMP);
sprintf(automapTmpPath, "%s\\%s\\%s", settings.system.master_patches_path.c_str(), "MAPS", AUTOMAP_TMP);
if (compat_rename(automapTmpPath, automapDbPath) != 0) {
debugPrint("\nAUTOMAP: Error renaming database!\n");
return -1;

View File

@ -14,7 +14,6 @@
#include "debug.h"
#include "draw.h"
#include "game.h"
#include "game_config.h"
#include "game_sound.h"
#include "input.h"
#include "kb.h"
@ -26,6 +25,7 @@
#include "palette.h"
#include "platform_compat.h"
#include "proto.h"
#include "settings.h"
#include "sfall_config.h"
#include "skill.h"
#include "stat.h"
@ -982,11 +982,7 @@ static void premadeCharactersLocalizePath(char* path)
return;
}
char* language;
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, &language)) {
return;
}
const char* language = settings.system.language.c_str();
if (compat_stricmp(language, ENGLISH) == 0) {
return;
}

View File

@ -16,7 +16,6 @@
#include "draw.h"
#include "elevator.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_sound.h"
#include "input.h"
@ -36,6 +35,7 @@
#include "queue.h"
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "sfall_config.h"
#include "skill.h"
#include "stat.h"
@ -2653,8 +2653,7 @@ static void _combat_begin_extra(Object* a1)
_combat_ai_begin(_list_total, _combat_list);
_combat_highlight = 2;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TARGET_HIGHLIGHT_KEY, &_combat_highlight);
_combat_highlight = settings.preferences.target_highlight;
}
// NOTE: Inlined.
@ -4457,9 +4456,7 @@ static int attackDetermineToHit(Object* attacker, int tile, Object* defender, in
}
if (attacker->data.critter.combat.team != gDude->data.critter.combat.team) {
int combatDifficuly = 1;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_DIFFICULTY_KEY, &combatDifficuly);
switch (combatDifficuly) {
switch (settings.preferences.combat_difficulty) {
case 0:
accuracy -= 20;
break;
@ -4534,10 +4531,7 @@ static void attackComputeDamage(Attack* attack, int ammoQuantity, int bonusDamag
int combatDifficultyDamageModifier = 100;
if (attack->attacker->data.critter.combat.team != gDude->data.critter.combat.team) {
int combatDifficulty = COMBAT_DIFFICULTY_NORMAL;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_DIFFICULTY_KEY, &combatDifficulty);
switch (combatDifficulty) {
switch (settings.preferences.combat_difficulty) {
case COMBAT_DIFFICULTY_EASY:
combatDifficultyDamageModifier = 75;
break;
@ -5065,10 +5059,7 @@ void _combat_display(Attack* attack)
}
}
int combatMessages = 1;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_MESSAGES_KEY, &combatMessages);
if (combatMessages == 1 && (attack->attackerFlags & DAM_CRITICAL) != 0 && attack->criticalMessageId != -1) {
if (settings.preferences.combat_messages && (attack->attackerFlags & DAM_CRITICAL) != 0 && attack->criticalMessageId != -1) {
messageListItem.num = attack->criticalMessageId;
if (messageListGetItem(&gCombatMessageList, &messageListItem)) {
strcat(text, messageListItem.text);
@ -5795,9 +5786,7 @@ void _combat_attack_this(Object* a1)
// 0x426AA8
void _combat_outline_on()
{
int targetHighlight = TARGET_HIGHLIGHT_TARGETING_ONLY;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TARGET_HIGHLIGHT_KEY, &targetHighlight);
if (targetHighlight == TARGET_HIGHLIGHT_OFF) {
if (settings.preferences.target_highlight == TARGET_HIGHLIGHT_OFF) {
return;
}
@ -5858,8 +5847,7 @@ void _combat_outline_off()
// 0x426C64
void _combat_highlight_change()
{
int targetHighlight = 2;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TARGET_HIGHLIGHT_KEY, &targetHighlight);
int targetHighlight = settings.preferences.target_highlight;
if (targetHighlight != _combat_highlight && isInCombat()) {
if (targetHighlight != 0) {
if (_combat_highlight == 0) {

View File

@ -13,7 +13,6 @@
#include "debug.h"
#include "display_monitor.h"
#include "game.h"
#include "game_config.h"
#include "game_sound.h"
#include "input.h"
#include "interface.h"
@ -29,6 +28,7 @@
#include "proto_instance.h"
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "skill.h"
#include "stat.h"
#include "svga.h"
@ -2505,8 +2505,7 @@ static int _ai_called_shot(Object* a1, Object* a2, int a3)
if (critterCanAim(a1, a3)) {
ai = aiGetPacket(a1);
if (randomBetween(1, ai->called_freq) == 1) {
combat_difficulty = 1;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_DIFFICULTY_KEY, &combat_difficulty);
combat_difficulty = settings.preferences.combat_difficulty;
if (combat_difficulty) {
if (combat_difficulty == 2) {
v6 = 3;
@ -3168,9 +3167,7 @@ int _combatai_msg(Object* a1, Attack* attack, int type, int delay)
return -1;
}
bool combatTaunts = true;
configGetBool(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_TAUNTS_KEY, &combatTaunts);
if (!combatTaunts) {
if (!settings.preferences.combat_taunts) {
return -1;
}
@ -3432,10 +3429,7 @@ static int aiMessageListInit()
return -1;
}
bool languageFilter;
configGetBool(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_FILTER_KEY, &languageFilter);
if (languageFilter) {
if (settings.preferences.language_filter) {
messageListFilterBadwords(&gCombatAiMessageList);
}
@ -3457,8 +3451,7 @@ static int aiMessageListFree()
// 0x42BBF0
void aiMessageListReloadIfNeeded()
{
int languageFilter = 0;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_FILTER_KEY, &languageFilter);
int languageFilter = static_cast<int>(settings.preferences.language_filter);
if (languageFilter != gLanguageFilter) {
gLanguageFilter = languageFilter;

View File

@ -1,9 +1,9 @@
#include "cycle.h"
#include "color.h"
#include "game_config.h"
#include "input.h"
#include "palette.h"
#include "settings.h"
#include "svga.h"
namespace fallout {
@ -122,12 +122,7 @@ void colorCycleInit()
return;
}
bool colorCycling;
if (!configGetBool(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_COLOR_CYCLING_KEY, &colorCycling)) {
colorCycling = true;
}
if (!colorCycling) {
if (!settings.system.color_cycling) {
return;
}
@ -156,12 +151,7 @@ void colorCycleInit()
gColorCycleInitialized = true;
gColorCycleEnabled = true;
int cycleSpeedFactor;
if (!configGetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CYCLE_SPEED_FACTOR_KEY, &cycleSpeedFactor)) {
cycleSpeedFactor = 1;
}
cycleSetSpeedFactor(cycleSpeedFactor);
cycleSetSpeedFactor(settings.system.cycle_speed_factor);
}
// 0x42E8CC
@ -209,7 +199,7 @@ bool colorCycleEnabled()
void cycleSetSpeedFactor(int value)
{
gColorCycleSpeedFactor = value;
configSetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CYCLE_SPEED_FACTOR_KEY, value);
settings.system.cycle_speed_factor = value;
}
// 0x42E97C

View File

@ -5,16 +5,15 @@
#include <windows.h>
#endif
#include "game_config.h"
#include "platform_compat.h"
#include "settings.h"
namespace fallout {
// 0x440DD0
void runElectronicRegistration()
{
int timesRun = 0;
configGetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_TIMES_RUN_KEY, &timesRun);
int timesRun = settings.system.times_run;
if (timesRun > 0 && timesRun < 5) {
#ifdef _WIN32
char path[COMPAT_MAX_PATH];
@ -40,10 +39,10 @@ void runElectronicRegistration()
}
#endif
configSetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_TIMES_RUN_KEY, timesRun + 1);
settings.system.times_run = timesRun + 1;
} else {
if (timesRun == 0) {
configSetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_TIMES_RUN_KEY, 1);
settings.system.times_run = 1;
}
}
}

View File

@ -15,7 +15,6 @@
#include "debug.h"
#include "draw.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_movie.h"
#include "game_sound.h"
@ -28,6 +27,7 @@
#include "pipboy.h"
#include "platform_compat.h"
#include "random.h"
#include "settings.h"
#include "stat.h"
#include "svga.h"
#include "text_font.h"
@ -84,9 +84,6 @@ static int endgameEndingInit();
static void endgameEndingFree();
static int endgameDeathEndingValidate(int* percentage);
// 0x50B00C
char _aEnglish_2[] = ENGLISH;
// The number of lines in current subtitles file.
//
// It's used as a length for two arrays:
@ -559,19 +556,12 @@ static int endgameEndingSlideshowWindowInit()
speechSetEndCallback(_endgame_voiceover_callback);
gEndgameEndingSubtitlesEnabled = false;
configGetBool(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_SUBTITLES_KEY, &gEndgameEndingSubtitlesEnabled);
gEndgameEndingSubtitlesEnabled = settings.preferences.subtitles;
if (!gEndgameEndingSubtitlesEnabled) {
return 0;
}
char* language;
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, &language)) {
gEndgameEndingSubtitlesEnabled = false;
return 0;
}
sprintf(gEndgameEndingSubtitlesLocalizedPath, "text\\%s\\cuts\\", language);
sprintf(gEndgameEndingSubtitlesLocalizedPath, "text\\%s\\cuts\\", settings.system.language.c_str());
gEndgameEndingSubtitles = (char**)internal_malloc(sizeof(*gEndgameEndingSubtitles) * ENDGAME_ENDING_MAX_SUBTITLES);
if (gEndgameEndingSubtitles == NULL) {

View File

@ -28,7 +28,6 @@
#include "electronic_registration.h"
#include "endgame.h"
#include "font_manager.h"
#include "game_config.h"
#include "game_dialog.h"
#include "game_memory.h"
#include "game_mouse.h"
@ -56,6 +55,7 @@
#include "queue.h"
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "sfall_config.h"
#include "skill.h"
#include "skilldex.h"
@ -139,12 +139,12 @@ int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int a4
// override it's file name.
sfallConfigInit(argc, argv);
gameConfigInit(isMapper, argc, argv);
settingsInit(isMapper, argc, argv);
gIsMapper = isMapper;
if (gameDbInit() == -1) {
gameConfigExit(false);
settingsExit(false);
sfallConfigExit();
return -1;
}
@ -154,17 +154,15 @@ int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int a4
_initWindow(1, a4);
paletteInit();
char* language;
if (configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, &language)) {
if (compat_stricmp(language, FRENCH) == 0) {
keyboardSetLayout(KEYBOARD_LAYOUT_FRENCH);
} else if (compat_stricmp(language, GERMAN) == 0) {
keyboardSetLayout(KEYBOARD_LAYOUT_GERMAN);
} else if (compat_stricmp(language, ITALIAN) == 0) {
keyboardSetLayout(KEYBOARD_LAYOUT_ITALIAN);
} else if (compat_stricmp(language, SPANISH) == 0) {
keyboardSetLayout(KEYBOARD_LAYOUT_SPANISH);
}
const char* language = settings.system.language.c_str();
if (compat_stricmp(language, FRENCH) == 0) {
keyboardSetLayout(KEYBOARD_LAYOUT_FRENCH);
} else if (compat_stricmp(language, GERMAN) == 0) {
keyboardSetLayout(KEYBOARD_LAYOUT_GERMAN);
} else if (compat_stricmp(language, ITALIAN) == 0) {
keyboardSetLayout(KEYBOARD_LAYOUT_ITALIAN);
} else if (compat_stricmp(language, SPANISH) == 0) {
keyboardSetLayout(KEYBOARD_LAYOUT_SPANISH);
}
// SFALL: Allow to skip splash screen
@ -433,7 +431,7 @@ void gameExit()
interfaceFontsExit();
_windowClose();
dbExit();
gameConfigExit(true);
settingsExit(true);
sfallConfigExit();
}
@ -1235,8 +1233,8 @@ int showQuitConfirmationDialog()
static int gameDbInit()
{
int hashing;
char* main_file_name;
char* patch_file_name;
const char* main_file_name;
const char* patch_file_name;
int patch_index;
char filename[COMPAT_MAX_PATH];
@ -1244,16 +1242,16 @@ static int gameDbInit()
main_file_name = NULL;
patch_file_name = NULL;
if (configGetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_HASHING_KEY, &hashing)) {
if (settings.system.hashing) {
_db_enable_hash_table_();
}
configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_DAT_KEY, &main_file_name);
main_file_name = settings.system.master_dat_path.c_str();
if (*main_file_name == '\0') {
main_file_name = NULL;
}
configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &patch_file_name);
patch_file_name = settings.system.master_patches_path.c_str();
if (*patch_file_name == '\0') {
patch_file_name = NULL;
}
@ -1264,12 +1262,12 @@ static int gameDbInit()
return -1;
}
configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CRITTER_DAT_KEY, &main_file_name);
main_file_name = settings.system.critter_dat_path.c_str();
if (*main_file_name == '\0') {
main_file_name = NULL;
}
configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CRITTER_PATCHES_KEY, &patch_file_name);
patch_file_name = settings.system.critter_patches_path.c_str();
if (*patch_file_name == '\0') {
patch_file_name = NULL;
}
@ -1297,12 +1295,11 @@ static int gameDbInit()
// 0x444384
static void showSplash()
{
int splash;
configGetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_SPLASH_KEY, &splash);
int splash = settings.system.splash;
char path[64];
char* language;
if (configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, &language) && compat_stricmp(language, ENGLISH) != 0) {
const char* language = settings.system.language.c_str();
if (compat_stricmp(language, ENGLISH) != 0) {
sprintf(path, "art\\%s\\splash\\", language);
} else {
sprintf(path, "art\\splash\\");
@ -1355,7 +1352,7 @@ static void showSplash()
internal_free(data);
internal_free(palette);
configSetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_SPLASH_KEY, splash + 1);
settings.system.splash = splash + 1;
}
int gameShowDeathDialog(const char* message)

View File

@ -12,7 +12,6 @@
#include "critter.h"
#include "draw.h"
#include "game.h"
#include "game_config.h"
#include "game_sound.h"
#include "input.h"
#include "interface.h"
@ -22,6 +21,7 @@
#include "object.h"
#include "proto.h"
#include "proto_instance.h"
#include "settings.h"
#include "sfall_config.h"
#include "skill.h"
#include "skilldex.h"
@ -740,9 +740,7 @@ void gameMouseRefresh()
if (pointedObject != NULL) {
bool pointedObjectIsCritter = FID_TYPE(pointedObject->fid) == OBJ_TYPE_CRITTER;
int combatLooks = 0;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_LOOKS_KEY, &combatLooks);
if (combatLooks != 0) {
if (settings.preferences.combat_looks) {
if (_obj_examine(gDude, pointedObject) == -1) {
_obj_look_at(gDude, pointedObject);
}
@ -938,16 +936,13 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
actionPoints = -1;
}
bool running;
configGetBool(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_RUNNING_KEY, &running);
if (gPressedPhysicalKeys[SDL_SCANCODE_LSHIFT] || gPressedPhysicalKeys[SDL_SCANCODE_RSHIFT]) {
if (running) {
if (settings.preferences.running) {
_dude_move(actionPoints);
return;
}
} else {
if (!running) {
if (!settings.preferences.running) {
_dude_move(actionPoints);
return;
}
@ -1945,10 +1940,7 @@ int gameMouseRenderActionPoints(const char* string, int color)
// 0x44D954
void gameMouseLoadItemHighlight()
{
bool itemHighlight;
if (configGetBool(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_ITEM_HIGHLIGHT_KEY, &itemHighlight)) {
gGameMouseItemHighlightEnabled = itemHighlight;
}
gGameMouseItemHighlightEnabled = settings.preferences.item_highlight;
}
// 0x44D984
@ -2256,9 +2248,7 @@ int _gmouse_3d_move_to(int x, int y, int elevation, Rect* a4)
x1 = -8;
y1 = 13;
char* executable;
configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_EXECUTABLE_KEY, &executable);
if (compat_stricmp(executable, "mapper") == 0) {
if (compat_stricmp(settings.system.executable.c_str(), "mapper") == 0) {
if (tileRoofIsVisible()) {
if ((gDude->flags & OBJECT_HIDDEN) == 0) {
y1 = -83;

View File

@ -7,7 +7,6 @@
#include "cycle.h"
#include "debug.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_sound.h"
#include "input.h"
@ -16,6 +15,7 @@
#include "movie_effect.h"
#include "palette.h"
#include "platform_compat.h"
#include "settings.h"
#include "svga.h"
#include "text_font.h"
#include "window_manager.h"
@ -143,13 +143,7 @@ int gameMoviePlay(int movie, int flags)
const char* movieFileName = gMovieFileNames[movie];
debugPrint("\nPlaying movie: %s\n", movieFileName);
char* language;
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, &language)) {
debugPrint("\ngmovie_play() - Error: Unable to determine language!\n");
gGameMovieIsPlaying = false;
return -1;
}
const char* language = settings.system.language.c_str();
char movieFilePath[COMPAT_MAX_PATH];
int movieFileSize;
bool movieFound = false;
@ -196,9 +190,8 @@ int gameMoviePlay(int movie, int flags)
windowRefresh(win);
bool subtitlesEnabled = false;
bool subtitlesEnabled = settings.preferences.subtitles;
int v1 = 4;
configGetBool(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_SUBTITLES_KEY, &subtitlesEnabled);
if (subtitlesEnabled) {
char* subtitlesFilePath = gameMovieBuildSubtitlesFilePath(movieFilePath);
@ -332,9 +325,6 @@ bool gameMovieIsPlaying()
// 0x44EB1C
static char* gameMovieBuildSubtitlesFilePath(char* movieFilePath)
{
char* language;
configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, &language);
char* path = movieFilePath;
char* separator = strrchr(path, '\\');
@ -342,7 +332,7 @@ static char* gameMovieBuildSubtitlesFilePath(char* movieFilePath)
path = separator + 1;
}
sprintf(gGameMovieSubtitlesFilePath, "text\\%s\\cuts\\%s", language, path);
sprintf(gGameMovieSubtitlesFilePath, "text\\%s\\cuts\\%s", settings.system.language.c_str(), path);
char* pch = strrchr(gGameMovieSubtitlesFilePath, '.');
if (*pch != '\0') {

View File

@ -19,6 +19,7 @@
#include "proto.h"
#include "queue.h"
#include "random.h"
#include "settings.h"
#include "sound_effects_cache.h"
#include "stat.h"
#include "svga.h"
@ -190,13 +191,11 @@ int gameSoundInit()
return -1;
}
bool initialize;
configGetBool(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_INITIALIZE_KEY, &initialize);
if (!initialize) {
if (!settings.sound.initialize) {
return 0;
}
configGetBool(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_DEBUG_KEY, &gGameSoundDebugEnabled);
gGameSoundDebugEnabled = settings.sound.debug;
if (gGameSoundDebugEnabled) {
debugPrint("Initializing sound system...");
@ -240,8 +239,7 @@ int gameSoundInit()
audioFileInit(gameSoundIsCompressed);
audioInit(gameSoundIsCompressed);
int cacheSize;
configGetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_CACHE_SIZE_KEY, &cacheSize);
int cacheSize = settings.sound.cache_size;
if (cacheSize >= 0x40000) {
debugPrint("\n!!! Config file needs adustment. Please remove the ");
debugPrint("cache_size line and run fallout again. This will reset ");
@ -266,14 +264,11 @@ int gameSoundInit()
gGameSoundInitialized = true;
// SOUNDS
bool sounds = 0;
configGetBool(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SOUNDS_KEY, &sounds);
if (gGameSoundDebugEnabled) {
debugPrint("Sounds are ");
}
if (sounds) {
if (settings.sound.sounds) {
// NOTE: Uninline.
soundEffectsEnable();
} else {
@ -287,14 +282,11 @@ int gameSoundInit()
}
// MUSIC
bool music = 0;
configGetBool(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_KEY, &music);
if (gGameSoundDebugEnabled) {
debugPrint("Music is ");
}
if (music) {
if (settings.sound.music) {
// NOTE: Uninline.
backgroundSoundEnable();
} else {
@ -308,14 +300,11 @@ int gameSoundInit()
}
// SPEEECH
bool speech = 0;
configGetBool(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SPEECH_KEY, &speech);
if (gGameSoundDebugEnabled) {
debugPrint("Speech is ");
}
if (speech) {
if (settings.sound.speech) {
// NOTE: Uninline.
speechEnable();
} else {
@ -328,16 +317,16 @@ int gameSoundInit()
debugPrint("on.\n");
}
configGetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MASTER_VOLUME_KEY, &gMasterVolume);
gMasterVolume = settings.sound.master_volume;
gameSoundSetMasterVolume(gMasterVolume);
configGetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_VOLUME_KEY, &gMusicVolume);
gMusicVolume = settings.sound.music_volume;
backgroundSoundSetVolume(gMusicVolume);
configGetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SNDFX_VOLUME_KEY, &gSoundEffectsVolume);
gSoundEffectsVolume = settings.sound.sndfx_volume;
soundEffectsSetVolume(gSoundEffectsVolume);
configGetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SPEECH_VOLUME_KEY, &gSpeechVolume);
gSpeechVolume = settings.sound.speech_volume;
speechSetVolume(gSpeechVolume);
_gsound_background_fade = 0;

View File

@ -15,7 +15,6 @@
#include "draw.h"
#include "endgame.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_sound.h"
#include "geometry.h"

View File

@ -16,7 +16,6 @@
#include "display_monitor.h"
#include "endgame.h"
#include "game.h"
#include "game_config.h"
#include "game_dialog.h"
#include "game_movie.h"
#include "game_sound.h"
@ -36,6 +35,7 @@
#include "random.h"
#include "reaction.h"
#include "scripts.h"
#include "settings.h"
#include "skill.h"
#include "stat.h"
#include "svga.h"
@ -1056,10 +1056,7 @@ static void opDisplayMsg(Program* program)
char* string = programStackPopString(program);
displayMonitorAddMessage(string);
bool showScriptMessages = false;
configGetBool(&gGameConfig, GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_SHOW_SCRIPT_MESSAGES_KEY, &showScriptMessages);
if (showScriptMessages) {
if (settings.debug.show_script_messages) {
debugPrint("\n");
debugPrint(string);
}
@ -2340,11 +2337,8 @@ static void opKillCritter(Program* program)
static int _correctDeath(Object* critter, int anim, bool forceBack)
{
if (anim >= ANIM_BIG_HOLE_SF && anim <= ANIM_FALL_FRONT_BLOOD_SF) {
int violenceLevel = VIOLENCE_LEVEL_MAXIMUM_BLOOD;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, &violenceLevel);
bool useStandardDeath = false;
if (violenceLevel < VIOLENCE_LEVEL_MAXIMUM_BLOOD) {
if (settings.preferences.violence_level < VIOLENCE_LEVEL_MAXIMUM_BLOOD) {
useStandardDeath = true;
} else {
int fid = buildFid(OBJ_TYPE_CRITTER, critter->fid & 0xFFF, anim, (critter->fid & 0xF000) >> 12, critter->rotation + 1);
@ -3301,10 +3295,10 @@ static void opMetarule(Program* program)
}
break;
case METARULE_LANGUAGE_FILTER:
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_FILTER_KEY, &result);
result = static_cast<int>(settings.preferences.language_filter);
break;
case METARULE_VIOLENCE_FILTER:
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, &result);
result = settings.preferences.violence_level;
break;
case METARULE_WEAPON_DAMAGE_TYPE:
if (1) {
@ -3493,8 +3487,7 @@ static void opRegAnimAnimate(Program* program)
Object* object = static_cast<Object*>(programStackPopPointer(program));
if (!isInCombat()) {
int violenceLevel = VIOLENCE_LEVEL_NONE;
if (anim != 20 || object == NULL || object->pid != 0x100002F || (configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, &violenceLevel) && violenceLevel >= 2)) {
if (anim != 20 || object == NULL || object->pid != 0x100002F || (settings.preferences.violence_level >= 2)) {
if (object != NULL) {
animationRegisterAnimate(object, anim, delay);
} else {
@ -4021,24 +4014,14 @@ static void _op_gdialog_barter(Program* program)
// 0x45B010
static void opGetGameDifficulty(Program* program)
{
int gameDifficulty;
if (!configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_GAME_DIFFICULTY_KEY, &gameDifficulty)) {
gameDifficulty = GAME_DIFFICULTY_NORMAL;
}
programStackPushInteger(program, gameDifficulty);
programStackPushInteger(program, settings.preferences.game_difficulty);
}
// running_burning_guy
// 0x45B05C
static void opGetRunningBurningGuy(Program* program)
{
int runningBurningGuy;
if (!configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_RUNNING_BURNING_GUY_KEY, &runningBurningGuy)) {
runningBurningGuy = 1;
}
programStackPushInteger(program, runningBurningGuy);
programStackPushInteger(program, static_cast<int>(settings.preferences.running_burning_guy));
}
// inven_unwield
@ -4691,12 +4674,7 @@ static void opGameDialogSetBarterMod(Program* program)
// 0x45C830
static void opGetCombatDifficulty(Program* program)
{
int combatDifficulty;
if (!configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_DIFFICULTY_KEY, &combatDifficulty)) {
combatDifficulty = 0;
}
programStackPushInteger(program, combatDifficulty);
programStackPushInteger(program, settings.preferences.combat_difficulty);
}
// obj_on_screen
@ -4784,9 +4762,7 @@ static void opDebugMessage(Program* program)
char* string = programStackPopString(program);
if (string != NULL) {
bool showScriptMessages = false;
configGetBool(&gGameConfig, GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_SHOW_SCRIPT_MESSAGES_KEY, &showScriptMessages);
if (showScriptMessages) {
if (settings.debug.show_script_messages) {
debugPrint("\n");
debugPrint(string);
}

View File

@ -22,7 +22,6 @@
#include "draw.h"
#include "file_utils.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_movie.h"
#include "game_sound.h"
@ -45,6 +44,7 @@
#include "queue.h"
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "skill.h"
#include "stat.h"
#include "svga.h"
@ -195,10 +195,7 @@ static int _map_backup_count = -1;
static int _automap_db_flag = 0;
// 0x5193CC
static char* _patches = NULL;
// 0x5193D0
static char _emgpath[] = "\\FALLOUT\\CD\\DATA\\SAVEGAME";
static const char* _patches = NULL;
// 0x5193EC
static SaveGameHandler* _master_save_list[LOAD_SAVE_HANDLER_COUNT] = {
@ -328,11 +325,7 @@ void _InitLoadSave()
{
_quick_done = false;
_slot_cursor = 0;
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &_patches)) {
debugPrint("\nLOADSAVE: Error reading patches config variable! Using default.\n");
_patches = _emgpath;
}
_patches = settings.system.master_patches_path.c_str();
_MapDirErase("MAPS\\", "SAV");
_MapDirErase(PROTO_DIR_NAME "\\" CRITTERS_DIR_NAME "\\", PROTO_FILE_EXT);
@ -354,11 +347,7 @@ int lsgSaveGame(int mode)
MessageListItem messageListItem;
_ls_error_code = 0;
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &_patches)) {
debugPrint("\nLOADSAVE: Error reading patches config variable! Using default.\n");
_patches = _emgpath;
}
_patches = settings.system.master_patches_path.c_str();
if (mode == LOAD_SAVE_MODE_QUICK && _quick_done) {
sprintf(_gmpath, "%s\\%s%.2d\\", "SAVEGAME", "SLOT", _slot_cursor + 1);
@ -761,11 +750,7 @@ int lsgLoadGame(int mode)
};
_ls_error_code = 0;
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &_patches)) {
debugPrint("\nLOADSAVE: Error reading patches config variable! Using default.\n");
_patches = _emgpath;
}
_patches = settings.system.master_patches_path.c_str();
if (mode == LOAD_SAVE_MODE_QUICK && _quick_done) {
int quickSaveWindowX = (screenGetWidth() - LS_WINDOW_WIDTH) / 2;

View File

@ -16,7 +16,6 @@
#include "endgame.h"
#include "fps_limiter.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_movie.h"
#include "game_sound.h"
@ -33,6 +32,7 @@
#include "random.h"
#include "scripts.h"
#include "selfrun.h"
#include "settings.h"
#include "sfall_config.h"
#include "svga.h"
#include "text_font.h"
@ -625,9 +625,7 @@ static void showDeath()
const char* deathFileName = endgameDeathEndingGetFileName();
int subtitles = 0;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_SUBTITLES_KEY, &subtitles);
if (subtitles != 0) {
if (settings.preferences.subtitles) {
char text[512];
if (_mainDeathGrabTextFile(deathFileName, text) == 0) {
debugPrint("\n((ShowDeath)): %s\n", text);
@ -716,14 +714,8 @@ static int _mainDeathGrabTextFile(const char* fileName, char* dest)
return -1;
}
char* language = NULL;
if (!configGetString(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_KEY, &language)) {
debugPrint("MAIN: Error grabing language for ending. Defaulting to english.\n");
language = _aEnglish_2;
}
char path[COMPAT_MAX_PATH];
sprintf(path, "text\\%s\\cuts\\%s%s", language, p + 1, ".TXT");
sprintf(path, "text\\%s\\cuts\\%s%s", settings.system.language.c_str(), p + 1, ".TXT");
File* stream = fileOpen(path, "rt");
if (stream == NULL) {

View File

@ -17,7 +17,6 @@
#include "draw.h"
#include "elevator.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_movie.h"
#include "game_sound.h"
@ -36,6 +35,7 @@
#include "queue.h"
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "svga.h"
#include "text_object.h"
#include "tile.h"
@ -282,9 +282,7 @@ void isoExit()
// 0x481FB4
void _map_init()
{
char* executable;
configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, "executable", &executable);
if (compat_stricmp(executable, "mapper") == 0) {
if (compat_stricmp(settings.system.executable.c_str(), "mapper") == 0) {
_map_scroll_refresh = isoWindowRefreshRectMapper;
}
@ -1284,14 +1282,11 @@ static int _map_save()
char temp[80];
temp[0] = '\0';
char* masterPatchesPath;
if (configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &masterPatchesPath)) {
strcat(temp, masterPatchesPath);
compat_mkdir(temp);
strcat(temp, settings.system.master_patches_path.c_str());
compat_mkdir(temp);
strcat(temp, "\\MAPS");
compat_mkdir(temp);
}
strcat(temp, "\\MAPS");
compat_mkdir(temp);
int rc = -1;
if (gMapHeader.name[0] != '\0') {
@ -1466,13 +1461,7 @@ static void mapMakeMapsDirectory()
{
char path[COMPAT_MAX_PATH];
char* masterPatchesPath;
if (configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &masterPatchesPath)) {
strcpy(path, masterPatchesPath);
} else {
strcpy(path, "DATA");
}
strcpy(path, settings.system.master_patches_path.c_str());
compat_mkdir(path);
strcat(path, "\\MAPS");

View File

@ -6,11 +6,11 @@
#include <string.h>
#include "debug.h"
#include "game_config.h"
#include "memory.h"
#include "platform_compat.h"
#include "proto_types.h"
#include "random.h"
#include "settings.h"
#include "sfall_config.h"
namespace fallout {
@ -177,7 +177,6 @@ bool messageListFree(MessageList* messageList)
// 0x484AA4
bool messageListLoad(MessageList* messageList, const char* path)
{
char* language;
char localized_path[COMPAT_MAX_PATH];
File* file_ptr;
char num[1024];
@ -197,17 +196,13 @@ bool messageListLoad(MessageList* messageList, const char* path)
return false;
}
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, &language)) {
return false;
}
sprintf(localized_path, "%s\\%s\\%s", "text", language, path);
sprintf(localized_path, "%s\\%s\\%s", "text", settings.system.language.c_str(), path);
file_ptr = fileOpen(localized_path, "rt");
// SFALL: Fallback to english if requested localization does not exist.
if (file_ptr == NULL) {
if (compat_stricmp(language, ENGLISH) != 0) {
if (compat_stricmp(settings.system.language.c_str(), ENGLISH) != 0) {
sprintf(localized_path, "%s\\%s\\%s", "text", ENGLISH, path);
file_ptr = fileOpen(localized_path, "rt");
}
@ -298,8 +293,6 @@ bool messageListGetItem(MessageList* msg, MessageListItem* entry)
// 0x484CB8
bool _message_make_path(char* dest, const char* path)
{
char* language;
if (dest == NULL) {
return false;
}
@ -308,11 +301,7 @@ bool _message_make_path(char* dest, const char* path)
return false;
}
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, &language)) {
return false;
}
sprintf(dest, "%s\\%s\\%s", "text", language, path);
sprintf(dest, "%s\\%s\\%s", "text", settings.system.language.c_str(), path);
return true;
}
@ -532,9 +521,7 @@ bool messageListFilterBadwords(MessageList* messageList)
return true;
}
int languageFilter = 0;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_FILTER_KEY, &languageFilter);
if (languageFilter != 1) {
if (!settings.preferences.language_filter) {
return true;
}

View File

@ -8,7 +8,6 @@
#include "db.h"
#include "debug.h"
#include "draw.h"
#include "game_config.h"
#include "geometry.h"
#include "input.h"
#include "memory_manager.h"

View File

@ -11,7 +11,6 @@
#include "debug.h"
#include "draw.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "item.h"
#include "light.h"
@ -21,6 +20,7 @@
#include "proto.h"
#include "proto_instance.h"
#include "scripts.h"
#include "settings.h"
#include "svga.h"
#include "text_object.h"
#include "tile.h"
@ -470,14 +470,9 @@ static int objectLoadAllInternal(File* stream)
return -1;
}
bool fixMapInventory;
if (!configGetBool(&gGameConfig, GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_FIX_MAP_INVENTORY_KEY, &fixMapInventory)) {
fixMapInventory = false;
}
bool fixMapInventory = settings.mapper.fix_map_inventory;
if (!configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, &gViolenceLevel)) {
gViolenceLevel = VIOLENCE_LEVEL_MAXIMUM_BLOOD;
}
gViolenceLevel = settings.preferences.violence_level;
int objectCount;
if (fileReadInt32(stream, &objectCount) == -1) {
@ -5164,9 +5159,7 @@ void _obj_fix_violence_settings(int* fid)
bool shouldResetViolenceLevel = false;
if (gViolenceLevel == -1) {
if (!configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, &gViolenceLevel)) {
gViolenceLevel = VIOLENCE_LEVEL_MAXIMUM_BLOOD;
}
gViolenceLevel = settings.preferences.violence_level;
shouldResetViolenceLevel = true;
}

View File

@ -14,7 +14,6 @@
#include "debug.h"
#include "draw.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_sound.h"
#include "geometry.h"
@ -27,6 +26,7 @@
#include "mouse.h"
#include "platform_compat.h"
#include "scripts.h"
#include "settings.h"
#include "svga.h"
#include "text_font.h"
#include "text_object.h"
@ -895,26 +895,26 @@ static void _SetSystemPrefs()
{
preferencesSetDefaults(false);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_GAME_DIFFICULTY_KEY, &gPreferencesGameDifficulty1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_DIFFICULTY_KEY, &gPreferencesCombatDifficulty1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, &gPreferencesViolenceLevel1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TARGET_HIGHLIGHT_KEY, &gPreferencesTargetHighlight1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_MESSAGES_KEY, &gPreferencesCombatMessages1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_LOOKS_KEY, &gPreferencesCombatLooks1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_TAUNTS_KEY, &gPreferencesCombatTaunts1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_FILTER_KEY, &gPreferencesLanguageFilter1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_RUNNING_KEY, &gPreferencesRunning1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_SUBTITLES_KEY, &gPreferencesSubtitles1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_ITEM_HIGHLIGHT_KEY, &gPreferencesItemHighlight1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_SPEED_KEY, &gPreferencesCombatSpeed1);
configGetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TEXT_BASE_DELAY_KEY, &gPreferencesTextBaseDelay1);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_PLAYER_SPEEDUP_KEY, &gPreferencesPlayerSpeedup1);
configGetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MASTER_VOLUME_KEY, &gPreferencesMasterVolume1);
configGetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_VOLUME_KEY, &gPreferencesMusicVolume1);
configGetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SNDFX_VOLUME_KEY, &gPreferencesSoundEffectsVolume1);
configGetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SPEECH_VOLUME_KEY, &gPreferencesSpeechVolume1);
configGetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_BRIGHTNESS_KEY, &gPreferencesBrightness1);
configGetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_MOUSE_SENSITIVITY_KEY, &gPreferencesMouseSensitivity1);
gPreferencesGameDifficulty1 = settings.preferences.game_difficulty;
gPreferencesCombatDifficulty1 = settings.preferences.combat_difficulty;
gPreferencesViolenceLevel1 = settings.preferences.violence_level;
gPreferencesTargetHighlight1 = settings.preferences.target_highlight;
gPreferencesCombatMessages1 = settings.preferences.combat_messages;
gPreferencesCombatLooks1 = settings.preferences.combat_looks;
gPreferencesCombatTaunts1 = settings.preferences.combat_taunts;
gPreferencesLanguageFilter1 = settings.preferences.language_filter;
gPreferencesRunning1 = settings.preferences.running;
gPreferencesSubtitles1 = settings.preferences.subtitles;
gPreferencesItemHighlight1 = settings.preferences.item_highlight;
gPreferencesCombatSpeed1 = settings.preferences.combat_speed;
gPreferencesTextBaseDelay1 = settings.preferences.text_base_delay;
gPreferencesPlayerSpeedup1 = settings.preferences.player_speedup;
gPreferencesMasterVolume1 = settings.sound.master_volume;
gPreferencesMusicVolume1 = settings.sound.music_volume;
gPreferencesSoundEffectsVolume1 = settings.sound.sndfx_volume;
gPreferencesSpeechVolume1 = settings.sound.speech_volume;
gPreferencesBrightness1 = settings.preferences.brightness;
gPreferencesMouseSensitivity1 = settings.preferences.mouse_sensitivity;
_JustUpdate_();
}
@ -1284,19 +1284,19 @@ static void _UpdateThing(int index)
// 0x492CB0
int _SavePrefs(bool save)
{
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_GAME_DIFFICULTY_KEY, gPreferencesGameDifficulty1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_DIFFICULTY_KEY, gPreferencesCombatDifficulty1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, gPreferencesViolenceLevel1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TARGET_HIGHLIGHT_KEY, gPreferencesTargetHighlight1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_MESSAGES_KEY, gPreferencesCombatMessages1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_LOOKS_KEY, gPreferencesCombatLooks1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_TAUNTS_KEY, gPreferencesCombatTaunts1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_FILTER_KEY, gPreferencesLanguageFilter1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_RUNNING_KEY, gPreferencesRunning1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_SUBTITLES_KEY, gPreferencesSubtitles1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_ITEM_HIGHLIGHT_KEY, gPreferencesItemHighlight1);
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_SPEED_KEY, gPreferencesCombatSpeed1);
configSetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TEXT_BASE_DELAY_KEY, gPreferencesTextBaseDelay1);
settings.preferences.game_difficulty = gPreferencesGameDifficulty1;
settings.preferences.combat_difficulty = gPreferencesCombatDifficulty1;
settings.preferences.violence_level = gPreferencesViolenceLevel1;
settings.preferences.target_highlight = gPreferencesTargetHighlight1;
settings.preferences.combat_messages = gPreferencesCombatMessages1;
settings.preferences.combat_looks = gPreferencesCombatLooks1;
settings.preferences.combat_taunts = gPreferencesCombatTaunts1;
settings.preferences.language_filter = gPreferencesLanguageFilter1;
settings.preferences.running = gPreferencesRunning1;
settings.preferences.subtitles = gPreferencesSubtitles1;
settings.preferences.item_highlight = gPreferencesItemHighlight1;
settings.preferences.combat_speed = gPreferencesCombatSpeed1;
settings.preferences.text_base_delay = gPreferencesTextBaseDelay1;
double textLineDelay = (gPreferencesTextBaseDelay1 + dbl_50C2D0) * dbl_50C2D8 * dbl_50C2E0;
if (textLineDelay >= 0.0) {
@ -1304,22 +1304,22 @@ int _SavePrefs(bool save)
textLineDelay = 2.0;
}
configSetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TEXT_LINE_DELAY_KEY, textLineDelay);
settings.preferences.text_line_delay = textLineDelay;
} else {
configSetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TEXT_LINE_DELAY_KEY, 0.0);
settings.preferences.text_line_delay = 0.0;
}
configSetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_PLAYER_SPEEDUP_KEY, gPreferencesPlayerSpeedup1);
configSetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MASTER_VOLUME_KEY, gPreferencesMasterVolume1);
configSetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_VOLUME_KEY, gPreferencesMusicVolume1);
configSetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SNDFX_VOLUME_KEY, gPreferencesSoundEffectsVolume1);
configSetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SPEECH_VOLUME_KEY, gPreferencesSpeechVolume1);
settings.preferences.player_speedup = gPreferencesPlayerSpeedup1;
settings.sound.master_volume = gPreferencesMasterVolume1;
settings.sound.music_volume = gPreferencesMusicVolume1;
settings.sound.sndfx_volume = gPreferencesSoundEffectsVolume1;
settings.sound.speech_volume = gPreferencesSpeechVolume1;
configSetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_BRIGHTNESS_KEY, gPreferencesBrightness1);
configSetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_MOUSE_SENSITIVITY_KEY, gPreferencesMouseSensitivity1);
settings.preferences.brightness = gPreferencesBrightness1;
settings.preferences.mouse_sensitivity = gPreferencesMouseSensitivity1;
if (save) {
gameConfigSave();
settingsSave();
}
return 0;
@ -1415,8 +1415,7 @@ err:
// 0x4928E4
void brightnessIncrease()
{
gPreferencesBrightness1 = 1.0;
configGetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_BRIGHTNESS_KEY, &gPreferencesBrightness1);
gPreferencesBrightness1 = settings.preferences.brightness;
if (gPreferencesBrightness1 < dbl_50C168) {
gPreferencesBrightness1 += dbl_50C170;
@ -1431,17 +1430,16 @@ void brightnessIncrease()
colorSetBrightness(gPreferencesBrightness1);
configSetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_BRIGHTNESS_KEY, gPreferencesBrightness1);
settings.preferences.brightness = gPreferencesBrightness1;
gameConfigSave();
settingsSave();
}
}
// 0x4929C8
void brightnessDecrease()
{
gPreferencesBrightness1 = 1.0;
configGetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_BRIGHTNESS_KEY, &gPreferencesBrightness1);
gPreferencesBrightness1 = settings.preferences.brightness;
if (gPreferencesBrightness1 > 1.0) {
gPreferencesBrightness1 += dbl_50C178;
@ -1456,9 +1454,9 @@ void brightnessDecrease()
colorSetBrightness(gPreferencesBrightness1);
configSetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_BRIGHTNESS_KEY, gPreferencesBrightness1);
settings.preferences.brightness = gPreferencesBrightness1;
gameConfigSave();
settingsSave();
}
}

View File

@ -4,7 +4,6 @@
#include "debug.h"
#include "game.h"
#include "game_config.h"
#include "memory.h"
#include "message.h"
#include "object.h"

View File

@ -15,7 +15,6 @@
#include "debug.h"
#include "draw.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_movie.h"
#include "game_sound.h"
@ -33,6 +32,7 @@
#include "queue.h"
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "stat.h"
#include "svga.h"
#include "text_font.h"
@ -695,10 +695,7 @@ static int pipboyWindowInit(int intent)
// 0x497828
static void pipboyWindowFree()
{
bool showScriptMessages = false;
configGetBool(&gGameConfig, GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_SHOW_SCRIPT_MESSAGES_KEY, &showScriptMessages);
if (showScriptMessages) {
if (settings.debug.show_script_messages) {
debugPrint("\nScript <Map Update>");
}

View File

@ -11,13 +11,13 @@
#include "debug.h"
#include "dialog.h"
#include "game.h"
#include "game_config.h"
#include "game_movie.h"
#include "interface.h"
#include "map.h"
#include "memory.h"
#include "object.h"
#include "perk.h"
#include "settings.h"
#include "skill.h"
#include "stat.h"
#include "trait.h"
@ -1060,17 +1060,12 @@ int protoGetDataMember(int pid, int member, ProtoDataMemberValue* value)
// 0x4A0390
int protoInit()
{
char* master_patches;
size_t len;
MessageListItem messageListItem;
char path[COMPAT_MAX_PATH];
int i;
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &master_patches)) {
return -1;
}
sprintf(path, "%s\\proto", master_patches);
sprintf(path, "%s\\proto", settings.system.master_patches_path.c_str());
len = strlen(path);
compat_mkdir(path);

View File

@ -4,11 +4,11 @@
#include "db.h"
#include "game.h"
#include "game_config.h"
#include "input.h"
#include "kb.h"
#include "mouse.h"
#include "platform_compat.h"
#include "settings.h"
#include "svga.h"
#include "vcr.h"
@ -216,11 +216,8 @@ int selfrunWriteData(const char* path, SelfrunData* selfrunData)
return -1;
}
char* masterPatches;
configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &masterPatches);
char selfrunDirectoryPath[COMPAT_MAX_PATH];
sprintf(selfrunDirectoryPath, "%s\\%s", masterPatches, "selfrun\\");
sprintf(selfrunDirectoryPath, "%s\\%s", settings.system.master_patches_path.c_str(), "selfrun\\");
compat_mkdir(selfrunDirectoryPath);

244
src/settings.cc Normal file
View File

@ -0,0 +1,244 @@
#include "settings.h"
namespace fallout {
static void settingsFromConfig();
static void settingsToConfig();
static void settingsRead(const char* section, const char* key, std::string& value);
static void settingsRead(const char* section, const char* key, int& value);
static void settingsRead(const char* section, const char* key, bool& value);
static void settingsRead(const char* section, const char* key, double& value);
static void settingsWrite(const char* section, const char* key, std::string& value);
static void settingsWrite(const char* section, const char* key, int& value);
static void settingsWrite(const char* section, const char* key, bool& value);
static void settingsWrite(const char* section, const char* key, double& value);
Settings settings;
bool settingsInit(bool isMapper, int argc, char** argv)
{
if (!gameConfigInit(isMapper, argc, argv)) {
return false;
}
settingsFromConfig();
return true;
}
bool settingsSave()
{
settingsToConfig();
return gameConfigSave();
}
bool settingsExit(bool shouldSave)
{
if (shouldSave) {
settingsToConfig();
}
return gameConfigExit(shouldSave);
}
static void settingsFromConfig()
{
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_EXECUTABLE_KEY, settings.system.executable);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_DAT_KEY, settings.system.master_dat_path);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, settings.system.master_patches_path);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CRITTER_DAT_KEY, settings.system.critter_dat_path);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CRITTER_PATCHES_KEY, settings.system.critter_patches_path);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, settings.system.language);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_SCROLL_LOCK_KEY, settings.system.scroll_lock);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_INTERRUPT_WALK_KEY, settings.system.interrupt_walk);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_ART_CACHE_SIZE_KEY, settings.system.art_cache_size);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_COLOR_CYCLING_KEY, settings.system.color_cycling);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CYCLE_SPEED_FACTOR_KEY, settings.system.cycle_speed_factor);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_HASHING_KEY, settings.system.hashing);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_SPLASH_KEY, settings.system.splash);
settingsRead(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_FREE_SPACE_KEY, settings.system.free_space);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_GAME_DIFFICULTY_KEY, settings.preferences.game_difficulty);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_DIFFICULTY_KEY, settings.preferences.combat_difficulty);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, settings.preferences.violence_level);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TARGET_HIGHLIGHT_KEY, settings.preferences.target_highlight);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_ITEM_HIGHLIGHT_KEY, settings.preferences.item_highlight);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_LOOKS_KEY, settings.preferences.combat_looks);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_MESSAGES_KEY, settings.preferences.combat_messages);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_TAUNTS_KEY, settings.preferences.combat_taunts);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_FILTER_KEY, settings.preferences.language_filter);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_RUNNING_KEY, settings.preferences.running);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_SUBTITLES_KEY, settings.preferences.subtitles);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_SPEED_KEY, settings.preferences.combat_speed);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_PLAYER_SPEED_KEY, settings.preferences.player_speedup);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TEXT_BASE_DELAY_KEY, settings.preferences.text_base_delay);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TEXT_LINE_DELAY_KEY, settings.preferences.text_line_delay);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_BRIGHTNESS_KEY, settings.preferences.brightness);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_MOUSE_SENSITIVITY_KEY, settings.preferences.mouse_sensitivity);
settingsRead(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_RUNNING_BURNING_GUY_KEY, settings.preferences.running_burning_guy);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_INITIALIZE_KEY, settings.sound.initialize);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_DEBUG_KEY, settings.sound.debug);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_DEBUG_SFXC_KEY, settings.sound.debug_sfxc);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_DEVICE_KEY, settings.sound.device);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_PORT_KEY, settings.sound.port);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_IRQ_KEY, settings.sound.irq);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_DMA_KEY, settings.sound.dma);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SOUNDS_KEY, settings.sound.sounds);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_KEY, settings.sound.music);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SPEECH_KEY, settings.sound.speech);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MASTER_VOLUME_KEY, settings.sound.master_volume);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_VOLUME_KEY, settings.sound.music_volume);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SNDFX_VOLUME_KEY, settings.sound.sndfx_volume);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SPEECH_VOLUME_KEY, settings.sound.speech_volume);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_CACHE_SIZE_KEY, settings.sound.cache_size);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_PATH1_KEY, settings.sound.music_path1);
settingsRead(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_PATH2_KEY, settings.sound.music_path2);
settingsRead(GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_MODE_KEY, settings.debug.mode);
settingsRead(GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_SHOW_TILE_NUM_KEY, settings.debug.show_tile_num);
settingsRead(GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_SHOW_SCRIPT_MESSAGES_KEY, settings.debug.show_script_messages);
settingsRead(GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_SHOW_LOAD_INFO_KEY, settings.debug.show_load_info);
settingsRead(GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_OUTPUT_MAP_DATA_INFO_KEY, settings.debug.output_map_data_info);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_OVERRIDE_LIBRARIAN_KEY, settings.mapper.override_librarian);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_LIBRARIAN_KEY, settings.mapper.librarian);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_USE_ART_NOT_PROTOS_KEY, settings.mapper.user_art_not_protos);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_REBUILD_PROTOS_KEY, settings.mapper.rebuild_protos);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_FIX_MAP_OBJECTS_KEY, settings.mapper.fix_map_objects);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_FIX_MAP_INVENTORY_KEY, settings.mapper.fix_map_inventory);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_IGNORE_REBUILD_ERRORS_KEY, settings.mapper.rebuild_protos);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_SHOW_PID_NUMBERS_KEY, settings.mapper.show_pid_numbers);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_SAVE_TEXT_MAPS_KEY, settings.mapper.save_text_maps);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_RUN_MAPPER_AS_GAME_KEY, settings.mapper.run_mapper_as_game);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_DEFAULT_F8_AS_GAME_KEY, settings.mapper.default_f8_as_game);
settingsRead(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_SORT_SCRIPT_LIST_KEY, settings.mapper.sort_script_list);
}
static void settingsToConfig()
{
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_EXECUTABLE_KEY, settings.system.executable);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_DAT_KEY, settings.system.master_dat_path);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, settings.system.master_patches_path);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CRITTER_DAT_KEY, settings.system.critter_dat_path);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CRITTER_PATCHES_KEY, settings.system.critter_patches_path);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, settings.system.language);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_SCROLL_LOCK_KEY, settings.system.scroll_lock);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_INTERRUPT_WALK_KEY, settings.system.interrupt_walk);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_ART_CACHE_SIZE_KEY, settings.system.art_cache_size);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_COLOR_CYCLING_KEY, settings.system.color_cycling);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CYCLE_SPEED_FACTOR_KEY, settings.system.cycle_speed_factor);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_HASHING_KEY, settings.system.hashing);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_SPLASH_KEY, settings.system.splash);
settingsWrite(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_FREE_SPACE_KEY, settings.system.free_space);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_GAME_DIFFICULTY_KEY, settings.preferences.game_difficulty);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_DIFFICULTY_KEY, settings.preferences.combat_difficulty);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, settings.preferences.violence_level);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TARGET_HIGHLIGHT_KEY, settings.preferences.target_highlight);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_ITEM_HIGHLIGHT_KEY, settings.preferences.item_highlight);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_LOOKS_KEY, settings.preferences.combat_looks);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_MESSAGES_KEY, settings.preferences.combat_messages);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_TAUNTS_KEY, settings.preferences.combat_taunts);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_FILTER_KEY, settings.preferences.language_filter);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_RUNNING_KEY, settings.preferences.running);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_SUBTITLES_KEY, settings.preferences.subtitles);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_COMBAT_SPEED_KEY, settings.preferences.combat_speed);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_PLAYER_SPEED_KEY, settings.preferences.player_speedup);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TEXT_BASE_DELAY_KEY, settings.preferences.text_base_delay);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TEXT_LINE_DELAY_KEY, settings.preferences.text_line_delay);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_BRIGHTNESS_KEY, settings.preferences.brightness);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_MOUSE_SENSITIVITY_KEY, settings.preferences.mouse_sensitivity);
settingsWrite(GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_RUNNING_BURNING_GUY_KEY, settings.preferences.running_burning_guy);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_INITIALIZE_KEY, settings.sound.initialize);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_DEBUG_KEY, settings.sound.debug);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_DEBUG_SFXC_KEY, settings.sound.debug_sfxc);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_DEVICE_KEY, settings.sound.device);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_PORT_KEY, settings.sound.port);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_IRQ_KEY, settings.sound.irq);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_DMA_KEY, settings.sound.dma);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SOUNDS_KEY, settings.sound.sounds);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_KEY, settings.sound.music);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SPEECH_KEY, settings.sound.speech);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MASTER_VOLUME_KEY, settings.sound.master_volume);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_VOLUME_KEY, settings.sound.music_volume);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SNDFX_VOLUME_KEY, settings.sound.sndfx_volume);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_SPEECH_VOLUME_KEY, settings.sound.speech_volume);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_CACHE_SIZE_KEY, settings.sound.cache_size);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_PATH1_KEY, settings.sound.music_path1);
settingsWrite(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_PATH2_KEY, settings.sound.music_path2);
settingsWrite(GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_MODE_KEY, settings.debug.mode);
settingsWrite(GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_SHOW_TILE_NUM_KEY, settings.debug.show_tile_num);
settingsWrite(GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_SHOW_SCRIPT_MESSAGES_KEY, settings.debug.show_script_messages);
settingsWrite(GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_SHOW_LOAD_INFO_KEY, settings.debug.show_load_info);
settingsWrite(GAME_CONFIG_DEBUG_KEY, GAME_CONFIG_OUTPUT_MAP_DATA_INFO_KEY, settings.debug.output_map_data_info);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_OVERRIDE_LIBRARIAN_KEY, settings.mapper.override_librarian);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_LIBRARIAN_KEY, settings.mapper.librarian);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_USE_ART_NOT_PROTOS_KEY, settings.mapper.user_art_not_protos);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_REBUILD_PROTOS_KEY, settings.mapper.rebuild_protos);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_FIX_MAP_OBJECTS_KEY, settings.mapper.fix_map_objects);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_FIX_MAP_INVENTORY_KEY, settings.mapper.fix_map_inventory);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_IGNORE_REBUILD_ERRORS_KEY, settings.mapper.rebuild_protos);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_SHOW_PID_NUMBERS_KEY, settings.mapper.show_pid_numbers);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_SAVE_TEXT_MAPS_KEY, settings.mapper.save_text_maps);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_RUN_MAPPER_AS_GAME_KEY, settings.mapper.run_mapper_as_game);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_DEFAULT_F8_AS_GAME_KEY, settings.mapper.default_f8_as_game);
settingsWrite(GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_SORT_SCRIPT_LIST_KEY, settings.mapper.sort_script_list);
}
static void settingsRead(const char* section, const char* key, std::string& value)
{
char* v;
if (configGetString(&gGameConfig, section, key, &v)) {
value = v;
}
}
static void settingsRead(const char* section, const char* key, int& value)
{
int v;
if (configGetInt(&gGameConfig, section, key, &v)) {
value = v;
}
}
static void settingsRead(const char* section, const char* key, bool& value)
{
bool v;
if (configGetBool(&gGameConfig, section, key, &v)) {
value = v;
}
}
static void settingsRead(const char* section, const char* key, double& value)
{
double v;
if (configGetDouble(&gGameConfig, section, key, &v)) {
value = v;
}
}
static void settingsWrite(const char* section, const char* key, std::string& value)
{
configSetString(&gGameConfig, section, key, value.c_str());
}
static void settingsWrite(const char* section, const char* key, int& value)
{
configSetInt(&gGameConfig, section, key, value);
}
static void settingsWrite(const char* section, const char* key, bool& value)
{
configSetBool(&gGameConfig, section, key, value);
}
static void settingsWrite(const char* section, const char* key, double& value)
{
configSetDouble(&gGameConfig, section, key, value);
}
} // namespace fallout

108
src/settings.h Normal file
View File

@ -0,0 +1,108 @@
#ifndef FALLOUT_SETTINGS_H_
#define FALLOUT_SETTINGS_H_
#include <string>
#include "game_config.h"
namespace fallout {
struct SystemSettings {
std::string executable = "game";
std::string master_dat_path = "master.dat";
std::string master_patches_path = "data";
std::string critter_dat_path = "critter.dat";
std::string critter_patches_path = "data";
std::string language = ENGLISH;
int scroll_lock = 0;
bool interrupt_walk = true;
int art_cache_size = 8;
bool color_cycling = true;
int cycle_speed_factor = 1;
bool hashing = true;
int splash = 0;
int free_space = 20480;
int times_run = 0;
};
struct PreferencesSettings {
int game_difficulty = GAME_DIFFICULTY_NORMAL;
int combat_difficulty = COMBAT_DIFFICULTY_NORMAL;
int violence_level = VIOLENCE_LEVEL_MAXIMUM_BLOOD;
int target_highlight = TARGET_HIGHLIGHT_TARGETING_ONLY;
bool item_highlight = true;
bool combat_looks = false;
bool combat_messages = true;
bool combat_taunts = true;
bool language_filter = false;
bool running = false;
bool subtitles = false;
int combat_speed = 0;
bool player_speedup = false;
double text_base_delay = 3.5;
double text_line_delay = 1.399994;
double brightness = 1.0;
double mouse_sensitivity = 1.0;
bool running_burning_guy = true;
};
struct SoundSettings {
bool initialize = true;
bool debug = false;
bool debug_sfxc = true;
int device = -1;
int port = -1;
int irq = -1;
int dma = -1;
bool sounds = true;
bool music = true;
bool speech = true;
int master_volume = 22281;
int music_volume = 22281;
int sndfx_volume = 22281;
int speech_volume = 22281;
int cache_size = 448;
std::string music_path1 = "sound\\music\\";
std::string music_path2 = "sound\\music\\";
};
struct DebugSettings {
std::string mode = "environment";
bool show_tile_num = false;
bool show_script_messages = false;
bool show_load_info = false;
bool output_map_data_info = false;
};
struct MapperSettings {
bool override_librarian = false;
bool librarian = false;
bool user_art_not_protos = false;
bool rebuild_protos = false;
bool fix_map_objects = false;
bool fix_map_inventory = false;
bool ignore_rebuild_errors = false;
bool show_pid_numbers = false;
bool save_text_maps = false;
bool run_mapper_as_game = false;
bool default_f8_as_game = true;
bool sort_script_list = false;
};
struct Settings {
SystemSettings system;
PreferencesSettings preferences;
SoundSettings sound;
DebugSettings debug;
MapperSettings mapper;
};
extern Settings settings;
bool settingsInit(bool isMapper, int argc, char** argv);
bool settingsSave();
bool settingsExit(bool shouldSave);
} // namespace fallout
#endif /* FALLOUT_SETTINGS_H_ */

View File

@ -11,7 +11,6 @@
#include "debug.h"
#include "display_monitor.h"
#include "game.h"
#include "game_config.h"
#include "interface.h"
#include "item.h"
#include "message.h"
@ -24,6 +23,7 @@
#include "proto.h"
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "stat.h"
#include "trait.h"
@ -1125,8 +1125,7 @@ int skillGetGameDifficultyModifier(int skill)
case SKILL_GAMBLING:
case SKILL_OUTDOORSMAN:
if (1) {
int gameDifficulty = GAME_DIFFICULTY_NORMAL;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_GAME_DIFFICULTY_KEY, &gameDifficulty);
int gameDifficulty = settings.preferences.game_difficulty;
if (gameDifficulty == GAME_DIFFICULTY_HARD) {
return -10;

View File

@ -8,8 +8,8 @@
#include "cache.h"
#include "db.h"
#include "game_config.h"
#include "memory.h"
#include "settings.h"
#include "sound_decoder.h"
#include "sound_effects_list.h"
@ -73,9 +73,7 @@ static int _sfxc_files_open = 0;
// 0x4A8FC0
int soundEffectsCacheInit(int cacheSize, const char* effectsPath)
{
if (!configGetInt(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_DEBUG_SFXC_KEY, &gSoundEffectsCacheDebugLevel)) {
gSoundEffectsCacheDebugLevel = 1;
}
gSoundEffectsCacheDebugLevel = settings.sound.debug_sfxc;
if (cacheSize <= SOUND_EFFECTS_CACHE_MIN_SIZE) {
return -1;

View File

@ -4,10 +4,10 @@
#include "debug.h"
#include "draw.h"
#include "game_config.h"
#include "input.h"
#include "memory.h"
#include "object.h"
#include "settings.h"
#include "svga.h"
#include "text_font.h"
#include "tile.h"
@ -82,18 +82,8 @@ int textObjectsInit(unsigned char* windowBuffer, int width, int height)
tickersAdd(textObjectsTicker);
double textBaseDelay;
if (!configGetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TEXT_BASE_DELAY_KEY, &textBaseDelay)) {
textBaseDelay = 3.5;
}
double textLineDelay;
if (!configGetDouble(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_TEXT_LINE_DELAY_KEY, &textLineDelay)) {
textLineDelay = 1.399993896484375;
}
gTextObjectsBaseDelay = (unsigned int)(textBaseDelay * 1000.0);
gTextObjectsLineDelay = (unsigned int)(textLineDelay * 1000.0);
gTextObjectsBaseDelay = (unsigned int)(settings.preferences.text_base_delay * 1000.0);
gTextObjectsLineDelay = (unsigned int)(settings.preferences.text_line_delay * 1000.0);
gTextObjectsEnabled = true;
gTextObjectsInitialized = true;

View File

@ -9,12 +9,12 @@
#include "config.h"
#include "debug.h"
#include "draw.h"
#include "game_config.h"
#include "game_mouse.h"
#include "light.h"
#include "map.h"
#include "object.h"
#include "platform_compat.h"
#include "settings.h"
#include "svga.h"
namespace fallout {
@ -444,9 +444,7 @@ int tileInit(TileData** a1, int squareGridWidth, int squareGridHeight, int hexGr
tileSetCenter(hexGridWidth * (hexGridHeight / 2) + hexGridWidth / 2, 2);
char* executable;
configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_EXECUTABLE_KEY, &executable);
if (compat_stricmp(executable, "mapper") == 0) {
if (compat_stricmp(settings.system.executable.c_str(), "mapper") == 0) {
gTileWindowRefreshElevationProc = tileRefreshMapper;
}

View File

@ -20,7 +20,6 @@
#include "display_monitor.h"
#include "draw.h"
#include "game.h"
#include "game_config.h"
#include "game_mouse.h"
#include "game_movie.h"
#include "game_sound.h"
@ -37,6 +36,7 @@
#include "queue.h"
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "sfall_config.h"
#include "skill.h"
#include "stat.h"
@ -3336,17 +3336,14 @@ static int wmRndEncounterOccurred()
int frequency = wmFreqValues[wmGenData.currentSubtile->encounterChance[dayPart]];
if (frequency > 0 && frequency < 100) {
int gameDifficulty = GAME_DIFFICULTY_NORMAL;
if (configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_GAME_DIFFICULTY_KEY, &gameDifficulty)) {
int modifier = frequency / 15;
switch (gameDifficulty) {
case GAME_DIFFICULTY_EASY:
frequency -= modifier;
break;
case GAME_DIFFICULTY_HARD:
frequency += modifier;
break;
}
int modifier = frequency / 15;
switch (settings.preferences.game_difficulty) {
case GAME_DIFFICULTY_EASY:
frequency -= modifier;
break;
case GAME_DIFFICULTY_HARD:
frequency += modifier;
break;
}
}
@ -3552,22 +3549,19 @@ static int wmRndEncounterPick()
v2++;
}
int gameDifficulty;
if (configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_GAME_DIFFICULTY_KEY, &gameDifficulty)) {
switch (gameDifficulty) {
case GAME_DIFFICULTY_EASY:
v2 += 5;
if (v2 > totalChance) {
v2 = totalChance;
}
break;
case GAME_DIFFICULTY_HARD:
v2 -= 5;
if (v2 < 0) {
v2 = 0;
}
break;
switch (settings.preferences.game_difficulty) {
case GAME_DIFFICULTY_EASY:
v2 += 5;
if (v2 > totalChance) {
v2 = totalChance;
}
break;
case GAME_DIFFICULTY_HARD:
v2 -= 5;
if (v2 < 0) {
v2 = 0;
}
break;
}
int index;
@ -3627,14 +3621,13 @@ int wmSetupRandomEncounter()
getmsg(&wmMsgFile, &messageListItem, 3000 + 50 * wmGenData.encounterTableId + wmGenData.encounterEntryId));
displayMonitorAddMessage(formattedText);
int gameDifficulty;
int gameDifficulty = settings.preferences.game_difficulty;
switch (encounterTableEntry->scenery) {
case ENCOUNTER_SCENERY_TYPE_NONE:
case ENCOUNTER_SCENERY_TYPE_LIGHT:
case ENCOUNTER_SCENERY_TYPE_NORMAL:
case ENCOUNTER_SCENERY_TYPE_HEAVY:
debugPrint("\nwmSetupRandomEncounter: Scenery Type: %s", wmSceneryStrs[encounterTableEntry->scenery]);
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_GAME_DIFFICULTY_KEY, &gameDifficulty);
break;
default:
debugPrint("\nERROR: wmSetupRandomEncounter: invalid Scenery Type!");