Skip to content

Commit

Permalink
config: add new game plus unlock (LostArtefacts#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
walkawayy authored and rr- committed Sep 9, 2023
1 parent fbfa543 commit a4d1baa
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- added the triggered music tracks to the savegame so one shot tracks don't replay on load (#371)
- added forward/backward input detection in line with TR2+ for jump-twists (#931)
- added an option to restore the mummy in City of Khamoon room 25, similar to the PS1 version (#886)
- added a flag indicating if new game plus is unlocked to the player config which allows the player to select new game plus or not when making a new game (#966)
- changed the installer to always overwrite all essential files such as the gameflow and injections (#904)
- changed the data injection system to warn when it detects invalid or missing files, rather than preventing levels from loading (#918)
- changed the gameflow to detect and skip over legacy sequence types, rather than preventing the game from starting (#882)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo
- added the "Story so far..." option in the select level menu to view cutscenes and FMVs
- added graphics effects, lava emitters, flame emitters, and waterfalls to the savegame so they now persist on load
- added an option to restore the mummy in City of Khamoon room 25, similar to the PS version
- added a flag indicating if new game plus is unlocked to the player config which allows the player to select new game plus or not when making a new game
- fixed keys and items not working when drawing guns immediately after using them
- fixed counting the secret in The Great Pyramid
- fixed running out of ammo forcing Lara to equip pistols even if she doesn't carry them
Expand Down
4 changes: 4 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ bool Config_ReadFromJSON(const char *cfg_data)
READ_FLOAT(ui.bar_scale, DEFAULT_UI_SCALE);
CLAMP(g_Config.ui.bar_scale, MIN_BAR_SCALE, MAX_BAR_SCALE);

READ_BOOL(profile.new_game_plus_unlock, false);

char layout_name[50];
for (INPUT_LAYOUT layout = INPUT_LAYOUT_CUSTOM_1;
layout < INPUT_LAYOUT_NUMBER_OF; layout++) {
Expand Down Expand Up @@ -441,6 +443,8 @@ bool Config_Write(void)
WRITE_FLOAT(ui.text_scale);
WRITE_FLOAT(ui.bar_scale);

WRITE_BOOL(profile.new_game_plus_unlock);

char layout_name[20];
for (INPUT_LAYOUT layout = INPUT_LAYOUT_CUSTOM_1;
layout < INPUT_LAYOUT_NUMBER_OF; layout++) {
Expand Down
4 changes: 4 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ typedef struct {
UI_STYLE menu_style;
} ui;

struct {
bool new_game_plus_unlock;
} profile;

int32_t sound_volume;
int32_t music_volume;

Expand Down
3 changes: 2 additions & 1 deletion src/game/game/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ int32_t Game_Stop(void)
Savegame_PersistGameToCurrentInfo(g_CurrentLevel);

if (g_CurrentLevel == g_GameFlow.last_level_num) {
g_GameInfo.bonus_flag = GBF_NGPLUS;
g_Config.profile.new_game_plus_unlock = true;
Config_Write();
} else {
Savegame_CarryCurrentInfoToNextLevel(
g_CurrentLevel, g_CurrentLevel + 1);
Expand Down
3 changes: 2 additions & 1 deletion src/game/option/option_passport.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ void Option_Passport(INVENTORY_ITEM *inv_item)
if (g_InvMode == INV_TITLE_MODE
|| (g_CurrentLevel == g_GameFlow.gym_level_num
&& g_InvMode != INV_DEATH_MODE)) {
if (g_Config.enable_game_modes) {
if (g_Config.enable_game_modes
|| g_Config.profile.new_game_plus_unlock) {
Option_PassportInitNewGameRequester();
m_PassportMode = PASSPORT_MODE_NEW_GAME;
g_Input = (INPUT_STATE) { 0 };
Expand Down
5 changes: 5 additions & 0 deletions src/game/savegame/savegame.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ static void Savegame_LoadPostprocess(void)
g_MusicTrackFlags[MX_BALDY_SPEECH] |= IF_ONESHOT;
}
}

if (g_GameInfo.bonus_flag) {
g_Config.profile.new_game_plus_unlock = true;
}

LOT_ClearLOT(&g_Lara.LOT);
}

Expand Down
2 changes: 0 additions & 2 deletions src/game/savegame/savegame_bson.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ static bool Savegame_BSON_LoadMisc(
return false;
}
game_info->bonus_flag = json_object_get_int(misc_obj, "bonus_flag", 0);
LOG_DEBUG("Load bonus_flag: %d", game_info->bonus_flag);
return true;
}

Expand Down Expand Up @@ -930,7 +929,6 @@ static struct json_object_s *Savegame_BSON_DumpMisc(GAME_INFO *game_info)
assert(game_info);
struct json_object_s *misc_obj = json_object_new();
json_object_append_int(misc_obj, "bonus_flag", game_info->bonus_flag);
LOG_DEBUG("Dump bonus_flag: %d", game_info->bonus_flag);
return misc_obj;
}

Expand Down

0 comments on commit a4d1baa

Please sign in to comment.