diff --git a/src/game.cc b/src/game.cc index add04ff..aae3a83 100644 --- a/src/game.cc +++ b/src/game.cc @@ -891,6 +891,24 @@ int gameSetGlobalVar(int var, int value) return -1; } + // SFALL: Display karma changes. + if (var == GVAR_PLAYER_REPUTATION) { + bool shouldDisplayKarmaChanges = false; + configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_DISPLAY_KARMA_CHANGES_KEY, &shouldDisplayKarmaChanges); + if (shouldDisplayKarmaChanges) { + int diff = value - gGameGlobalVars[var]; + if (diff != 0) { + char formattedMessage[80]; + if (diff > 0) { + sprintf(formattedMessage, "You gained %d karma.", diff); + } else { + sprintf(formattedMessage, "You lost %d karma.", -diff); + } + displayMonitorAddMessage(formattedMessage); + } + } + } + gGameGlobalVars[var] = value; return 0; diff --git a/src/sfall_config.cc b/src/sfall_config.cc index 3e82246..8de82ea 100644 --- a/src/sfall_config.cc +++ b/src/sfall_config.cc @@ -29,6 +29,7 @@ bool sfallConfigInit(int argc, char** argv) configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_MAIN_MENU_FONT_COLOR, 0); configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_SKIP_OPENING_MOVIES_KEY, 0); configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_STARTING_MAP_KEY, ""); + configSetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_DISPLAY_KARMA_CHANGES_KEY, false); char path[COMPAT_MAX_PATH]; char* executable = argv[0]; diff --git a/src/sfall_config.h b/src/sfall_config.h index be583be..4c576cf 100644 --- a/src/sfall_config.h +++ b/src/sfall_config.h @@ -15,6 +15,7 @@ #define SFALL_CONFIG_MAIN_MENU_FONT_COLOR "MainMenuFontColour" #define SFALL_CONFIG_SKIP_OPENING_MOVIES_KEY "SkipOpeningMovies" #define SFALL_CONFIG_STARTING_MAP_KEY "StartingMap" +#define SFALL_CONFIG_DISPLAY_KARMA_CHANGES_KEY "DisplayKarmaChanges" extern bool gSfallConfigInitialized; extern Config gSfallConfig;