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/platform_compat.h"
"src/pointer_registry.cc" "src/pointer_registry.cc"
"src/pointer_registry.h" "src/pointer_registry.h"
"src/settings.cc"
"src/settings.h"
"src/sfall_config.cc" "src/sfall_config.cc"
"src/sfall_config.h" "src/sfall_config.h"
) )

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,16 +5,15 @@
#include <windows.h> #include <windows.h>
#endif #endif
#include "game_config.h"
#include "platform_compat.h" #include "platform_compat.h"
#include "settings.h"
namespace fallout { namespace fallout {
// 0x440DD0 // 0x440DD0
void runElectronicRegistration() void runElectronicRegistration()
{ {
int timesRun = 0; int timesRun = settings.system.times_run;
configGetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_TIMES_RUN_KEY, &timesRun);
if (timesRun > 0 && timesRun < 5) { if (timesRun > 0 && timesRun < 5) {
#ifdef _WIN32 #ifdef _WIN32
char path[COMPAT_MAX_PATH]; char path[COMPAT_MAX_PATH];
@ -40,10 +39,10 @@ void runElectronicRegistration()
} }
#endif #endif
configSetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_TIMES_RUN_KEY, timesRun + 1); settings.system.times_run = timesRun + 1;
} else { } else {
if (timesRun == 0) { 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 "debug.h"
#include "draw.h" #include "draw.h"
#include "game.h" #include "game.h"
#include "game_config.h"
#include "game_mouse.h" #include "game_mouse.h"
#include "game_movie.h" #include "game_movie.h"
#include "game_sound.h" #include "game_sound.h"
@ -28,6 +27,7 @@
#include "pipboy.h" #include "pipboy.h"
#include "platform_compat.h" #include "platform_compat.h"
#include "random.h" #include "random.h"
#include "settings.h"
#include "stat.h" #include "stat.h"
#include "svga.h" #include "svga.h"
#include "text_font.h" #include "text_font.h"
@ -84,9 +84,6 @@ static int endgameEndingInit();
static void endgameEndingFree(); static void endgameEndingFree();
static int endgameDeathEndingValidate(int* percentage); static int endgameDeathEndingValidate(int* percentage);
// 0x50B00C
char _aEnglish_2[] = ENGLISH;
// The number of lines in current subtitles file. // The number of lines in current subtitles file.
// //
// It's used as a length for two arrays: // It's used as a length for two arrays:
@ -559,19 +556,12 @@ static int endgameEndingSlideshowWindowInit()
speechSetEndCallback(_endgame_voiceover_callback); speechSetEndCallback(_endgame_voiceover_callback);
gEndgameEndingSubtitlesEnabled = false; gEndgameEndingSubtitlesEnabled = settings.preferences.subtitles;
configGetBool(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_SUBTITLES_KEY, &gEndgameEndingSubtitlesEnabled);
if (!gEndgameEndingSubtitlesEnabled) { if (!gEndgameEndingSubtitlesEnabled) {
return 0; return 0;
} }
char* language; sprintf(gEndgameEndingSubtitlesLocalizedPath, "text\\%s\\cuts\\", settings.system.language.c_str());
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_LANGUAGE_KEY, &language)) {
gEndgameEndingSubtitlesEnabled = false;
return 0;
}
sprintf(gEndgameEndingSubtitlesLocalizedPath, "text\\%s\\cuts\\", language);
gEndgameEndingSubtitles = (char**)internal_malloc(sizeof(*gEndgameEndingSubtitles) * ENDGAME_ENDING_MAX_SUBTITLES); gEndgameEndingSubtitles = (char**)internal_malloc(sizeof(*gEndgameEndingSubtitles) * ENDGAME_ENDING_MAX_SUBTITLES);
if (gEndgameEndingSubtitles == NULL) { if (gEndgameEndingSubtitles == NULL) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,6 @@
#include "endgame.h" #include "endgame.h"
#include "fps_limiter.h" #include "fps_limiter.h"
#include "game.h" #include "game.h"
#include "game_config.h"
#include "game_mouse.h" #include "game_mouse.h"
#include "game_movie.h" #include "game_movie.h"
#include "game_sound.h" #include "game_sound.h"
@ -33,6 +32,7 @@
#include "random.h" #include "random.h"
#include "scripts.h" #include "scripts.h"
#include "selfrun.h" #include "selfrun.h"
#include "settings.h"
#include "sfall_config.h" #include "sfall_config.h"
#include "svga.h" #include "svga.h"
#include "text_font.h" #include "text_font.h"
@ -625,9 +625,7 @@ static void showDeath()
const char* deathFileName = endgameDeathEndingGetFileName(); const char* deathFileName = endgameDeathEndingGetFileName();
int subtitles = 0; if (settings.preferences.subtitles) {
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_SUBTITLES_KEY, &subtitles);
if (subtitles != 0) {
char text[512]; char text[512];
if (_mainDeathGrabTextFile(deathFileName, text) == 0) { if (_mainDeathGrabTextFile(deathFileName, text) == 0) {
debugPrint("\n((ShowDeath)): %s\n", text); debugPrint("\n((ShowDeath)): %s\n", text);
@ -716,14 +714,8 @@ static int _mainDeathGrabTextFile(const char* fileName, char* dest)
return -1; 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]; 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"); File* stream = fileOpen(path, "rt");
if (stream == NULL) { if (stream == NULL) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,11 +4,11 @@
#include "db.h" #include "db.h"
#include "game.h" #include "game.h"
#include "game_config.h"
#include "input.h" #include "input.h"
#include "kb.h" #include "kb.h"
#include "mouse.h" #include "mouse.h"
#include "platform_compat.h" #include "platform_compat.h"
#include "settings.h"
#include "svga.h" #include "svga.h"
#include "vcr.h" #include "vcr.h"
@ -216,11 +216,8 @@ int selfrunWriteData(const char* path, SelfrunData* selfrunData)
return -1; return -1;
} }
char* masterPatches;
configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &masterPatches);
char selfrunDirectoryPath[COMPAT_MAX_PATH]; 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); 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 "debug.h"
#include "display_monitor.h" #include "display_monitor.h"
#include "game.h" #include "game.h"
#include "game_config.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "message.h" #include "message.h"
@ -24,6 +23,7 @@
#include "proto.h" #include "proto.h"
#include "random.h" #include "random.h"
#include "scripts.h" #include "scripts.h"
#include "settings.h"
#include "stat.h" #include "stat.h"
#include "trait.h" #include "trait.h"
@ -1125,8 +1125,7 @@ int skillGetGameDifficultyModifier(int skill)
case SKILL_GAMBLING: case SKILL_GAMBLING:
case SKILL_OUTDOORSMAN: case SKILL_OUTDOORSMAN:
if (1) { if (1) {
int gameDifficulty = GAME_DIFFICULTY_NORMAL; int gameDifficulty = settings.preferences.game_difficulty;
configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_GAME_DIFFICULTY_KEY, &gameDifficulty);
if (gameDifficulty == GAME_DIFFICULTY_HARD) { if (gameDifficulty == GAME_DIFFICULTY_HARD) {
return -10; return -10;

View File

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

View File

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

View File

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

View File

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