Skip to content

Commit

Permalink
tr1/savegame: support setting save slots to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Nov 25, 2024
1 parent 0ff682b commit efbabb4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 29 deletions.
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr1-4.6...develop) - ××××-××-××
- added ability to disable saves completely by setting the save slot to 0 (#1954)
- fixed invisible walls being present in front of some doors (#1948, regression from 4.6)
- fixed big font scale causing text overlaps in the graphics options (#1946)
- fixed missing FMVs causing the game to go silent (#1931, regression from 4.6)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void Config_Sanitize(void)
CLAMP(
g_Config.rendering.turbo_speed, CLOCK_TURBO_SPEED_MIN,
CLOCK_TURBO_SPEED_MAX);
CLAMPL(g_Config.maximum_save_slots, 1);
CLAMPL(g_Config.maximum_save_slots, 0);
CLAMPL(g_Config.rendering.anisotropy_filter, 1.0);
CLAMP(g_Config.rendering.wireframe_width, 1.0, 100.0);

Expand Down
57 changes: 32 additions & 25 deletions src/tr1/game/option/option_passport.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ static void M_DeterminePages(void)
switch (g_InvMode) {
case INV_TITLE_MODE:
m_PassportStatus.mode = PASSPORT_MODE_BROWSE;
m_PassportStatus.page_available[PAGE_1] = g_SavedGamesCount > 0;
m_PassportStatus.page_available[PAGE_1] =
g_SavedGamesCount > 0 && Savegame_GetSlotCount() > 0;
m_PassportStatus.page_available[PAGE_2] = true;
m_PassportStatus.page_available[PAGE_3] = true;
m_PassportStatus.page_role[PAGE_1] = PASSPORT_MODE_LOAD_GAME;
Expand All @@ -183,28 +184,36 @@ static void M_DeterminePages(void)

case INV_GAME_MODE:
m_PassportStatus.mode = PASSPORT_MODE_BROWSE;
m_PassportStatus.page_available[PAGE_1] = g_SavedGamesCount > 0;
m_PassportStatus.page_available[PAGE_1] =
g_SavedGamesCount > 0 && Savegame_GetSlotCount() > 0;
m_PassportStatus.page_available[PAGE_2] = true;
m_PassportStatus.page_available[PAGE_3] = true;
m_PassportStatus.page_role[PAGE_1] = PASSPORT_MODE_LOAD_GAME;
m_PassportStatus.page_role[PAGE_2] = PASSPORT_MODE_SAVE_GAME;
m_PassportStatus.page_role[PAGE_3] = PASSPORT_MODE_EXIT_TITLE;
if (g_CurrentLevel == g_GameFlow.gym_level_num) {
if (g_CurrentLevel == g_GameFlow.gym_level_num
|| Savegame_GetSlotCount() <= 0) {
m_PassportStatus.page_role[PAGE_2] = PASSPORT_MODE_NEW_GAME;
} else if (g_Config.enable_save_crystals) {
m_PassportStatus.page_role[PAGE_2] = PASSPORT_MODE_RESTART;
}
break;

case INV_LOAD_MODE:
m_PassportStatus.mode = PASSPORT_MODE_LOAD_GAME;
m_PassportStatus.mode = Savegame_GetSlotCount() > 0
? PASSPORT_MODE_LOAD_GAME
: PASSPORT_MODE_RESTART;
m_PassportStatus.page_available[PAGE_1] = true;
m_PassportStatus.page_available[PAGE_2] = false;
m_PassportStatus.page_available[PAGE_3] = false;
m_PassportStatus.page_role[PAGE_1] = PASSPORT_MODE_LOAD_GAME;
m_PassportStatus.page_role[PAGE_1] = m_PassportStatus.mode;
m_PassportStatus.page_role[PAGE_2] = PASSPORT_MODE_UNAVAILABLE;
m_PassportStatus.page_role[PAGE_3] = PASSPORT_MODE_UNAVAILABLE;
M_InitSaveRequester(PAGE_1);
if (m_PassportStatus.mode == PASSPORT_MODE_RESTART) {
M_InitNewGameRequester();
} else {
M_InitSaveRequester(PAGE_1);
}
break;

case INV_SAVE_MODE:
Expand All @@ -215,7 +224,8 @@ static void M_DeterminePages(void)
m_PassportStatus.page_role[PAGE_1] = PASSPORT_MODE_UNAVAILABLE;
m_PassportStatus.page_role[PAGE_2] = PASSPORT_MODE_SAVE_GAME;
m_PassportStatus.page_role[PAGE_3] = PASSPORT_MODE_UNAVAILABLE;
if (g_CurrentLevel == g_GameFlow.gym_level_num) {
if (g_CurrentLevel == g_GameFlow.gym_level_num
|| Savegame_GetSlotCount() <= 0) {
m_PassportStatus.mode = PASSPORT_MODE_BROWSE;
m_PassportStatus.page_role[PAGE_2] = PASSPORT_MODE_NEW_GAME;
} else if (g_Config.enable_save_crystals) {
Expand All @@ -240,7 +250,8 @@ static void M_DeterminePages(void)

case INV_DEATH_MODE:
m_PassportStatus.mode = PASSPORT_MODE_BROWSE;
m_PassportStatus.page_available[PAGE_1] = g_SavedGamesCount > 0;
m_PassportStatus.page_available[PAGE_1] =
g_SavedGamesCount > 0 && Savegame_GetSlotCount() > 0;
m_PassportStatus.page_available[PAGE_2] = true;
m_PassportStatus.page_available[PAGE_3] = true;
m_PassportStatus.page_role[PAGE_1] = PASSPORT_MODE_LOAD_GAME;
Expand All @@ -250,7 +261,8 @@ static void M_DeterminePages(void)

default:
m_PassportStatus.mode = PASSPORT_MODE_BROWSE;
m_PassportStatus.page_available[PAGE_1] = g_SavedGamesCount > 0;
m_PassportStatus.page_available[PAGE_1] =
g_SavedGamesCount > 0 && Savegame_GetSlotCount() > 0;
m_PassportStatus.page_available[PAGE_2] = true;
m_PassportStatus.page_available[PAGE_3] = true;
m_PassportStatus.page_role[PAGE_1] = PASSPORT_MODE_LOAD_GAME;
Expand Down Expand Up @@ -293,14 +305,7 @@ static void M_InitSaveRequester(int16_t page_num)

static void M_RestoreSaveRequester(void)
{
// Reload the savegame requester items in case something cleared them in
// the meantime (for example the player changed the save slot count with a
// console command.)
if (g_SavegameRequester.items_used == 0) {
M_InitSaveRequester(m_PassportStatus.page);
}

CLAMPG(g_SavegameRequester.requested, g_SavegameRequester.items_used - 1);
CLAMP(g_SavegameRequester.requested, 0, g_SavegameRequester.items_used - 1);
}

static void M_InitSelectLevelRequester(void)
Expand Down Expand Up @@ -429,14 +434,16 @@ static void M_LoadGame(void)
} else {
M_ShowSaves(PASSPORT_MODE_LOAD_GAME);
if (m_PassportStatus.mode == PASSPORT_MODE_LOAD_GAME) {
Text_SetPos(
m_Text[TEXT_LEVEL_ARROW_RIGHT], 130,
g_SavegameRequester
.items
[g_SavegameRequester.requested
- g_SavegameRequester.line_offset]
.content->pos.y);
Text_Hide(m_Text[TEXT_LEVEL_ARROW_RIGHT], false);
const REQUESTER_ITEM *const row_item =
&g_SavegameRequester.items
[g_SavegameRequester.requested
- g_SavegameRequester.line_offset];
if (row_item->content != NULL) {
Text_SetPos(
m_Text[TEXT_LEVEL_ARROW_RIGHT], 130,
row_item->content->pos.y);
Text_Hide(m_Text[TEXT_LEVEL_ARROW_RIGHT], false);
}
} else {
Text_Hide(m_Text[TEXT_LEVEL_ARROW_RIGHT], true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/requester.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ int32_t Requester_Display(REQUEST_INFO *req)
}
}

if (req->line_offset) {
if (req->line_offset > 0) {
if (!req->moreup) {
req->moreup = Text_Create(
req->x, line_one_off - req->line_height + 2, "\\{arrow up}");
Expand Down
4 changes: 2 additions & 2 deletions src/tr1/global/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ typedef struct {
uint16_t max_items;
uint16_t requested;
uint16_t vis_lines;
uint16_t line_offset;
uint16_t line_old_offset;
int16_t line_offset;
int16_t line_old_offset;
uint16_t pix_width;
uint16_t line_height;
bool is_blockable;
Expand Down

0 comments on commit efbabb4

Please sign in to comment.