Skip to content

Commit

Permalink
option_passport: add level selection to the load game menu (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
walkawayy authored May 4, 2022
1 parent da12715 commit 39a7a16
Show file tree
Hide file tree
Showing 20 changed files with 434 additions and 280 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
## [Unreleased](https://github.com/rr-/Tomb1Main/compare/2.7...master)
- added the option to pause sound in the inventory screen (#309)
- added level selection to the load game menu (#197)
- added the ability to pick up multiple items at once with walk to items enabled (#505)
- added the ability to skip pictures during fade animation (#510)
- added a cheat to increase the game speed (#135)
- added a matrix stack overflow error check and message if GetRoomBounds runs infinitely (#506)
- added ability to turn off trex collision (#437)
- changed savegame requestor to remember the user's requested slot number (#514)
- changed the new game requestor's requested to always return to new game
- fixed ghost margins during fade animation on HiDPI screens (#438)
- fixed music rolling over to the main menu if main menu music disabled (#490)
- fixed Unfinished Business gameflow not using basic / detailed stats strings (#497, regression from 2.7)
Expand All @@ -14,6 +16,7 @@
- fixed pushables breaking with flipped rooms when loading a save (#496, regression from 2.6)
- fixed pictures displayed before starting a level causing a black screen (custom levels only)
- fixed underwater caustics animating at 2x speed (#109)
- fixed new game plus infinite ammo carrying over to a loaded game (#535, regression from 2.6)

## [2.7](https://github.com/rr-/Tomb1Main/compare/2.6.4...2.7) - 2022-03-16
- added ability to automatically walk to pickups when nearby (#18)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ Not all options are turned on by default. Refer to `Tomb1Main.json5` for details
- added fade effects to displayed images
- added unobtainable pickups and kills stats support in the gameflow
- added the option to pause sound in the inventory screen
- added level selection to the load game menu
- changed internal game memory limit from 3.5 MB to 16 MB
- changed moveable limit from 256 to 10240
- changed maximum textures from 2048 to 8192
Expand Down
2 changes: 2 additions & 0 deletions bin/cfg/Tomb1Main_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@
"PASSPORT_SELECT_LEVEL": "Select Level",
"PASSPORT_RESTART_LEVEL": "Restart Level",
"PASSPORT_LOCKED_LEVEL": "Level Locked",
"PASSPORT_LEGACY_SELECT_LEVEL_1": "Legacy saves do not",
"PASSPORT_LEGACY_SELECT_LEVEL_2": "support this feature.",
"PASSPORT_SELECT_MODE": "Select Mode",
"PASSPORT_MODE_NEW_GAME": "New Game",
"PASSPORT_MODE_NEW_GAME_PLUS": "New Game+",
Expand Down
2 changes: 2 additions & 0 deletions bin/cfg/Tomb1Main_gameflow_ub.json5
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
"PASSPORT_SELECT_LEVEL": "Select Level",
"PASSPORT_RESTART_LEVEL": "Restart Level",
"PASSPORT_LOCKED_LEVEL": "Level Locked",
"PASSPORT_LEGACY_SELECT_LEVEL_1": "Legacy saves do not",
"PASSPORT_LEGACY_SELECT_LEVEL_2": "support this feature.",
"PASSPORT_SELECT_MODE": "Select Mode",
"PASSPORT_MODE_NEW_GAME": "New Game",
"PASSPORT_MODE_NEW_GAME_PLUS": "New Game+",
Expand Down
2 changes: 1 addition & 1 deletion src/game/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int32_t StartDemo(void)
} while (!g_GameFlow.levels[level_num].demo);
m_DemoLevel = level_num;

s = &g_GameInfo.start[m_DemoLevel];
s = &g_GameInfo.current[m_DemoLevel];
start = *s;
s->flags.available = 1;
s->flags.got_pistols = 1;
Expand Down
84 changes: 61 additions & 23 deletions src/game/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,63 @@ bool StartGame(int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type)
{
g_CurrentLevel = level_num;
g_GameInfo.current_level_type = level_type;
if (level_type == GFL_SAVED) {
// reset start info to the defaults so that we do not do

switch (level_type) {
case GFL_SAVED:
// reset current info to the defaults so that we do not do
// GlobalItemReplace in the inventory initialization routines too early
Savegame_ResetStartInfo(level_num);
} else {
Savegame_InitCurrentInfo();
if (!InitialiseLevel(level_num)) {
return false;
}
if (!Savegame_Load(g_GameInfo.current_save_slot, &g_GameInfo)) {
LOG_ERROR("Failed to load save file!");
return false;
}
break;

case GFL_RESTART:
Savegame_ResetCurrentInfo(level_num);
if (level_num <= g_GameFlow.first_level_num) {
Savegame_InitCurrentInfo();
} else {
// Use previous level's ending info to start current level.
Savegame_CarryCurrentInfoToNextLevel(level_num - 1, level_num);
Savegame_ApplyLogicToCurrentInfo(level_num);
}
InitialiseLevelFlags();
}
if (!InitialiseLevel(level_num)) {
return false;
}
break;

if (!InitialiseLevel(level_num)) {
return false;
}
case GFL_SELECT:
// reset current info to the defaults so that we do not do
// GlobalItemReplace in the inventory initialization routines too early
Savegame_InitCurrentInfo();
Savegame_LoadOnlyResumeInfo(g_GameInfo.current_save_slot, &g_GameInfo);
for (int i = level_num; i < g_GameFlow.level_count; i++) {
Savegame_ResetCurrentInfo(i);
}
if (level_num <= g_GameFlow.first_level_num) {
Savegame_InitCurrentInfo();
} else {
// Use previous level's ending info to start current level.
Savegame_CarryCurrentInfoToNextLevel(level_num - 1, level_num);
Savegame_ApplyLogicToCurrentInfo(level_num);
}
InitialiseLevelFlags();
if (!InitialiseLevel(level_num)) {
return false;
}
break;

if (level_type == GFL_SAVED) {
if (!Savegame_Load(g_GameInfo.current_save_slot, &g_GameInfo)) {
LOG_ERROR("Failed to load save file!");
default:
InitialiseLevelFlags();
if (!InitialiseLevel(level_num)) {
return false;
}
break;
}

// LaraGun() expects request_gun_type to be set only when it
Expand All @@ -59,12 +99,12 @@ int32_t StopGame(void)
if (g_CurrentLevel == g_GameFlow.last_level_num) {
g_GameInfo.bonus_flag = GBF_NGPLUS;
} else {
Savegame_CarryCurrentInfoToStartInfo(
Savegame_CarryCurrentInfoToNextLevel(
g_CurrentLevel, g_CurrentLevel + 1);
Savegame_ApplyLogicToStartInfo(g_CurrentLevel + 1);
Savegame_ApplyLogicToCurrentInfo(g_CurrentLevel + 1);
}

g_GameInfo.start[g_CurrentLevel].flags.available = 0;
g_GameInfo.current[g_CurrentLevel].flags.available = 0;

if (g_LevelComplete) {
return GF_LEVEL_COMPLETE | g_CurrentLevel;
Expand All @@ -74,15 +114,13 @@ int32_t StopGame(void)
return GF_EXIT_TO_TITLE;
}

if (g_InvExtraData[IED_PAGE_NUM] == PASSPORT_PAGE_1) {
return GF_START_SAVED_GAME | g_InvExtraData[IED_SAVEGAME_NUM];
if (g_GameInfo.passport_page == PASSPORT_PAGE_1) {
return GF_START_SAVED_GAME | g_GameInfo.current_save_slot;
} else if (
g_InvExtraData[IED_PAGE_NUM] == PASSPORT_PAGE_1
&& g_InvExtraData[IED_PASSPORT_MODE] == PASSPORT_MODE_SELECT_LEVEL) {
// TODO Placeholder for select level. Do new game.
Savegame_InitStartCurrentInfo();
return GF_START_GAME | g_InvExtraData[IED_LEVEL_NUM];
} else if (g_InvExtraData[IED_PAGE_NUM] == PASSPORT_PAGE_2) {
g_GameInfo.passport_page == PASSPORT_PAGE_1
&& g_GameInfo.passport_mode == PASSPORT_MODE_SELECT_LEVEL) {
return GF_SELECT_GAME | g_GameInfo.select_level_num;
} else if (g_GameInfo.passport_page == PASSPORT_PAGE_2) {
return GF_START_GAME
| (g_InvMode == INV_DEATH_MODE ? g_CurrentLevel
: g_GameFlow.first_level_num);
Expand Down Expand Up @@ -121,7 +159,7 @@ int32_t GameLoop(GAMEFLOW_LEVEL_TYPE level_type)
if (ask_for_save) {
int32_t return_val = Display_Inventory(INV_SAVE_CRYSTAL_MODE);
if (return_val != GF_NOP) {
Savegame_Save(g_InvExtraData[IED_SAVEGAME_NUM], &g_GameInfo);
Savegame_Save(g_GameInfo.current_save_slot, &g_GameInfo);
Settings_Write();
}
ask_for_save = false;
Expand Down
26 changes: 13 additions & 13 deletions src/game/gameflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ static GAME_STRING_ID GameFlow_StringToGameStringID(const char *str)
{ "PASSPORT_SELECT_LEVEL", GS_PASSPORT_SELECT_LEVEL },
{ "PASSPORT_RESTART_LEVEL", GS_PASSPORT_RESTART_LEVEL },
{ "PASSPORT_LOCKED_LEVEL", GS_PASSPORT_LOCKED_LEVEL },
{ "PASSPORT_LEGACY_SELECT_LEVEL_1", GS_PASSPORT_LEGACY_SELECT_LEVEL_1 },
{ "PASSPORT_LEGACY_SELECT_LEVEL_2", GS_PASSPORT_LEGACY_SELECT_LEVEL_2 },
{ "PASSPORT_SELECT_MODE", GS_PASSPORT_SELECT_MODE },
{ "PASSPORT_MODE_NEW_GAME", GS_PASSPORT_MODE_NEW_GAME },
{ "PASSPORT_MODE_NEW_GAME_PLUS", GS_PASSPORT_MODE_NEW_GAME_PLUS },
Expand Down Expand Up @@ -607,7 +609,6 @@ static bool GameFlow_LoadScriptLevels(struct json_object_s *obj)
int32_t level_count = jlvl_arr->length;

g_GameFlow.levels = Memory_Alloc(sizeof(GAMEFLOW_LEVEL) * level_count);
g_GameInfo.start = Memory_Alloc(sizeof(RESUME_INFO) * level_count);
g_GameInfo.current = Memory_Alloc(sizeof(RESUME_INFO) * level_count);

struct json_array_element_s *jlvl_elem = jlvl_arr->start;
Expand Down Expand Up @@ -891,7 +892,6 @@ void GameFlow_Shutdown(void)
Memory_FreePointer(&g_GameFlow.main_menu_background_path);
Memory_FreePointer(&g_GameFlow.savegame_fmt_legacy);
Memory_FreePointer(&g_GameFlow.savegame_fmt_bson);
Memory_FreePointer(&g_GameInfo.start);
Memory_FreePointer(&g_GameInfo.current);

for (int i = 0; i < GS_NUMBER_OF; i++) {
Expand Down Expand Up @@ -1237,13 +1237,13 @@ GameFlow_InterpretSequence(int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type)
give_item_data->object_num, give_item_data->quantity);
if (g_Lara.gun_type == LGT_UNARMED) {
if (Inv_RequestItem(O_GUN_ITEM)) {
g_GameInfo.start[level_num].gun_type = LGT_PISTOLS;
g_GameInfo.current[level_num].gun_type = LGT_PISTOLS;
} else if (Inv_RequestItem(O_SHOTGUN_ITEM)) {
g_GameInfo.start[level_num].gun_type = LGT_SHOTGUN;
g_GameInfo.current[level_num].gun_type = LGT_SHOTGUN;
} else if (Inv_RequestItem(O_MAGNUM_ITEM)) {
g_GameInfo.start[level_num].gun_type = LGT_MAGNUMS;
g_GameInfo.current[level_num].gun_type = LGT_MAGNUMS;
} else if (Inv_RequestItem(O_UZI_ITEM)) {
g_GameInfo.start[level_num].gun_type = LGT_UZIS;
g_GameInfo.current[level_num].gun_type = LGT_UZIS;
}
Lara_InitialiseMeshes(level_num);
}
Expand All @@ -1253,19 +1253,19 @@ GameFlow_InterpretSequence(int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type)
case GFS_REMOVE_GUNS:
if (level_type != GFL_SAVED
&& !(g_GameInfo.bonus_flag & GBF_NGPLUS)) {
g_GameInfo.start[level_num].flags.got_pistols = 0;
g_GameInfo.start[level_num].flags.got_shotgun = 0;
g_GameInfo.start[level_num].flags.got_magnums = 0;
g_GameInfo.start[level_num].flags.got_uzis = 0;
g_GameInfo.start[level_num].gun_type = LGT_UNARMED;
g_GameInfo.start[level_num].gun_status = LGS_ARMLESS;
g_GameInfo.current[level_num].flags.got_pistols = 0;
g_GameInfo.current[level_num].flags.got_shotgun = 0;
g_GameInfo.current[level_num].flags.got_magnums = 0;
g_GameInfo.current[level_num].flags.got_uzis = 0;
g_GameInfo.current[level_num].gun_type = LGT_UNARMED;
g_GameInfo.current[level_num].gun_status = LGS_ARMLESS;
Lara_InitialiseInventory(level_num);
}
break;

case GFS_REMOVE_SCIONS:
if (level_type != GFL_SAVED) {
g_GameInfo.start[level_num].num_scions = 0;
g_GameInfo.current[level_num].num_scions = 0;
Lara_InitialiseInventory(level_num);
}
break;
Expand Down
Loading

0 comments on commit 39a7a16

Please sign in to comment.