Debian Codegraph @

common/main/state.h

raw
1 /*
2 * Portions of this file are copyright Rebirth contributors and licensed as
3 * described in COPYING.txt.
4 * Portions of this file are copyright Parallax Software and licensed
5 * according to the Parallax license below.
6 * See COPYING.txt for license details.
7
8 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
9 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
10 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
11 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
12 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
13 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
14 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
15 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
16 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
17 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
18 */
19
20 /*
21 *
22 * Prototypes for state saving functions.
23 *
24 */
25
26 #pragma once
27
28 #ifdef DXX_BUILD_DESCENT
29 #if DXX_BUILD_DESCENT == 2
30 #define SECRETB_FILENAME PLAYER_DIRECTORY_STRING("secret.sgb")
31 #define SECRETC_FILENAME PLAYER_DIRECTORY_STRING("secret.sgc")
32 #endif
33 #endif
34
35 #include <cstddef>
36 #include "dsx-ns.h"
37 #include "fwd-window.h"
38 #include "fwd-object.h"
39 #include "game.h"
40 #include "gameplayopt.h"
41
42 extern unsigned state_game_id;
43
44 #ifdef DXX_BUILD_DESCENT
45 #include "fwd-player.h"
46 namespace dsx {
47
48 enum class secret_save : uint8_t
49 {
50 none,
51 #if DXX_BUILD_DESCENT == 2
52 b,
53 c,
54 #endif
55 };
56
57 enum class secret_restore : uint8_t
58 {
59 none,
60 #if DXX_BUILD_DESCENT == 2
61 survived,
62 died,
63 #endif
64 };
65
66 }
67 #endif
68
69 namespace dcx {
70
71 enum class blind_save : bool
72 {
73 no,
74 yes,
75 };
76
77 enum class deny_save_result : bool
78 {
79 allowed,
80 denied,
81 };
82
83 int state_get_game_id(const d_game_unique_state::savegame_file_path &filename);
84
85 }
86
87 #ifdef DXX_BUILD_DESCENT
88 namespace dsx {
89 deny_save_result deny_save_game(fvcobjptr &vcobjptr, const d_level_unique_control_center_state &LevelUniqueControlCenterState);
90 deny_save_result deny_save_game(fvcobjptr &vcobjptr, const d_level_unique_control_center_state &LevelUniqueControlCenterState, const d_game_unique_state &GameUniqueState);
91 void state_poll_autosave_game(d_game_unique_state &GameUniqueState, const d_level_unique_object_state &LevelUniqueObjectState);
92 void state_set_immediate_autosave(d_game_unique_state &GameUniqueState);
93 void state_set_next_autosave(d_game_unique_state &GameUniqueState, std::chrono::steady_clock::time_point now, autosave_interval_type interval);
94 void state_set_next_autosave(d_game_unique_state &GameUniqueState, autosave_interval_type interval);
95 int state_save_all_sub(const char *filename, const char *desc);
96
97 d_game_unique_state::save_slot state_get_save_file(grs_canvas &canvas, d_game_unique_state::savegame_file_path &fname, d_game_unique_state::savegame_description *dsc, blind_save);
98 d_game_unique_state::save_slot state_get_restore_file(grs_canvas &canvas, d_game_unique_state::savegame_file_path &fname, blind_save);
99
100 #if DXX_BUILD_DESCENT == 1
101 int state_restore_all_sub(const char *filename);
102 static inline void set_pos_from_return_segment(void)
103 {
104 }
105 int state_save_all(blind_save b);
106 static inline int state_save_all(secret_save, blind_save b)
107 {
108 return state_save_all(b);
109 }
110 int state_restore_all(int in_game, std::nullptr_t, blind_save);
111 static inline int state_restore_all(int in_game, secret_restore, std::nullptr_t, blind_save blind)
112 {
113 return state_restore_all(in_game, nullptr, blind);
114 }
115 window_event_result StartNewLevelSub(const d_robot_info_array &Robot_info, int level_num, int page_in_textures);
116 // Actually does the work to start new level
117 static inline window_event_result StartNewLevelSub(const d_robot_info_array &Robot_info, int level_num, int page_in_textures, secret_restore)
118 {
119 return StartNewLevelSub(Robot_info, level_num, page_in_textures);
120 }
121 #elif DXX_BUILD_DESCENT == 2
122 int state_restore_all_sub(const d_level_shared_destructible_light_state &LevelSharedDestructibleLightState, secret_restore, const char *filename);
123 void set_pos_from_return_segment(void);
124 int state_save_all(secret_save, blind_save);
125 int state_restore_all(int in_game, secret_restore, const char *filename_override, blind_save);
126 window_event_result StartNewLevelSub(const d_robot_info_array &Robot_info, int level_num, int page_in_textures, secret_restore);
127 #endif
128 }
129 #endif