Skip to content

Commit d282d84

Browse files
committed
Remove end_mission(), improve storage handling
1 parent e59212e commit d282d84

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

src/space_merc.c

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ void move_player(const int8_t direction)
5959
g_player->direction == g_mission->entrance_direction &&
6060
direction == g_mission->entrance_direction)
6161
{
62-
end_mission();
62+
g_game_paused = true;
63+
show_window(g_main_menu_window);
64+
if (g_mission->completed)
65+
{
66+
adjust_player_money(g_mission->reward);
67+
}
68+
g_current_narration = MISSION_CONCLUSION_NARRATION;
69+
show_narration();
70+
persist_delete(MISSION_STORAGE_KEY);
71+
persist_write_data(PLAYER_STORAGE_KEY, g_player, sizeof(player_t));
6372
}
6473
else if (occupiable(destination))
6574
{
@@ -284,6 +293,8 @@ void adjust_player_current_hp(const int16_t amount)
284293
g_current_narration = DEATH_NARRATION;
285294
show_narration();
286295
deinit_mission();
296+
persist_delete(MISSION_STORAGE_KEY);
297+
persist_write_data(PLAYER_STORAGE_KEY, g_player, sizeof(player_t));
287298
}
288299
}
289300

@@ -307,30 +318,6 @@ void adjust_player_current_ammo(const int16_t amount)
307318
}
308319
}
309320

310-
/******************************************************************************
311-
Function: end_mission
312-
313-
Description: Called when the player walks into the exit, ending the current
314-
mission. Determines how much reward money to bestow, ensures no
315-
mission data remains in persistent storage, etc.
316-
317-
Inputs: None.
318-
319-
Outputs: None.
320-
******************************************************************************/
321-
void end_mission(void)
322-
{
323-
g_game_paused = true;
324-
show_window(g_main_menu_window);
325-
if (g_mission->completed)
326-
{
327-
adjust_player_money(g_mission->reward);
328-
}
329-
g_current_narration = MISSION_CONCLUSION_NARRATION;
330-
show_narration();
331-
persist_delete(MISSION_STORAGE_KEY);
332-
}
333-
334321
/******************************************************************************
335322
Function: add_new_npc
336323

src/space_merc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ void damage_cell(GPoint cell, const int16_t damage);
301301
bool adjust_player_money(const int32_t amount);
302302
void adjust_player_current_hp(const int16_t amount);
303303
void adjust_player_current_ammo(const int16_t amount);
304-
void end_mission(void);
305304
void add_new_npc(const int8_t npc_type, const GPoint position);
306305
GPoint get_npc_spawn_point(void);
307306
GPoint get_floor_center_point(const int8_t depth, const int8_t position);

0 commit comments

Comments
 (0)