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  * Header for playsave.c
23  *
24  */
25 
26 #pragma once
27 
28 #if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
29 #if defined(DXX_BUILD_DESCENT_I)
30 #include "pstypes.h"
31 #include "player.h"
32 #elif defined(DXX_BUILD_DESCENT_II)
33 #include "escort.h"
34 
35 enum class MissileViewMode : uint8_t
36 {
37 	None,
38 	EnabledSelfOnly,
39 	EnabledSelfAndAllies,
40 };
41 
42 enum class cockpit_3d_view : uint8_t
43 {
44 	None,
45 	Escort,
46 	Rear,
47 	Coop,
48 	Marker,
49 };
50 #endif
51 
52 #include "gameplayopt.h"
53 #include <cstdint>
54 
55 #define N_SAVE_SLOTS    10
56 #define GAME_NAME_LEN   25      // +1 for terminating zero = 26
57 
58 #ifdef dsx
59 #if defined(DXX_BUILD_DESCENT_I)
60 namespace dsx {
61 // NOTE: Obsolete structure - only kept for compability of shareware plr file
62 struct saved_game_sw
63 {
64 	char		name[GAME_NAME_LEN+1];		//extra char for terminating zero
65 	struct player_rw sg_player;
66 	int		difficulty_level;		//which level game is played at
67 	int		primary_weapon;		//which weapon selected
68 	int		secondary_weapon;		//which weapon selected
69 	int		cockpit_mode;			//which cockpit mode selected
70 	int		window_w,window_h;	//size of player's window
71 	int		next_level_num;		//which level we're going to
72 	int		auto_leveling_on;		//does player have autoleveling on?
73 } __pack__;
74 
75 void plyr_save_stats();
76 }
77 #endif
78 #endif
79 
80 struct hli
81 {
82 	std::array<char, 9> Shortname;
83 	uint8_t LevelNum;
84 };
85 
86 #if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
87 #include "kconfig.h"
88 #include "multi.h"
89 #include "fwd-weapon.h"
90 #include "d_array.h"
91 
92 namespace dcx {
93 
94 enum class FiringAutoselectMode : uint8_t
95 {
96 	Immediate,
97 	Never,
98 	Delayed,
99 };
100 
101 enum class HudType : uint8_t
102 {
103 	Standard,
104 	Alternate1,
105 	Alternate2,
106 	Hidden,
107 };
108 
109 enum class RespawnPress : uint8_t
110 {
111 	Any,
112 	Fire,
113 };
114 
115 enum MouselookMode : uint8_t
116 {
117 	Singleplayer = 1,
118 	MPCoop = 2,
119 	MPAnarchy = 4,
120 };
121 
122 }
123 
124 namespace dsx {
125 
126 struct player_config : prohibit_void_ptr<player_config>
127 {
128 	ubyte ControlType;
129 	HudType HudMode;
130 	RespawnPress RespawnMode;
131 	uint8_t MouselookFlags;
132 	using primary_weapon_order = std::array<uint8_t, MAX_PRIMARY_WEAPONS + 1>;
133 	using secondary_weapon_order = std::array<uint8_t, MAX_SECONDARY_WEAPONS + 1>;
134 	primary_weapon_order PrimaryOrder;
135 	secondary_weapon_order SecondaryOrder;
136 	struct KeySettings {
137 		enumerated_array<uint8_t, MAX_CONTROLS, dxx_kconfig_ui_kc_keyboard> Keyboard;
138 #if DXX_MAX_JOYSTICKS
139 		enumerated_array<uint8_t, MAX_CONTROLS, dxx_kconfig_ui_kc_joystick> Joystick;
140 #endif
141 		enumerated_array<uint8_t, MAX_CONTROLS, dxx_kconfig_ui_kc_mouse> Mouse;
142 	} KeySettings;
143 	std::array<uint8_t, MAX_DXX_REBIRTH_CONTROLS> KeySettingsRebirth;
144 	Difficulty_level_type DefaultDifficulty;
145 	int AutoLeveling;
146 	uint16_t NHighestLevels;
147 	std::array<hli, MAX_MISSIONS> HighestLevels;
148 	std::array<int, 5> KeyboardSens;
149 	std::array<int, 6> JoystickSens;
150 	std::array<int, 6> JoystickDead;
151 	std::array<int, 6> JoystickLinear;
152 	std::array<int, 6> JoystickSpeed;
153 	ubyte MouseFlightSim;
154 	std::array<int, 6> MouseSens;
155         std::array<int, 6> MouseOverrun;
156 	int MouseFSDead;
157 	int MouseFSIndicator;
158 	std::array<cockpit_mode_t, 2> CockpitMode; // 0 saves the "real" cockpit, 1 also saves letterbox and rear. Used to properly switch between modes and restore the real one.
159 #if defined(DXX_BUILD_DESCENT_II)
160 	enumerated_array<cockpit_3d_view, 2, gauge_inset_window_view> Cockpit3DView = {{{
161 		cockpit_3d_view::None,
162 		cockpit_3d_view::None,
163 	}}};
164 #endif
165 	std::array<ntstring<MAX_MESSAGE_LEN - 1>, 4> NetworkMessageMacro;
166 	int NetlifeKills;
167 	int NetlifeKilled;
168 	ubyte ReticleType;
169 	std::array<int, 4> ReticleRGBA;
170 	int ReticleSize;
171 #if defined(DXX_BUILD_DESCENT_II)
172 	MissileViewMode MissileViewEnabled;
173 	uint8_t ThiefModifierFlags;
174 	int HeadlightActiveDefault;
175 	int GuidedInBigWindow;
176 	ntstring<GUIDEBOT_NAME_LEN> GuidebotName, GuidebotNameReal;
177 	int EscortHotKeys;
178 #endif
179 	int PersistentDebris;
180 	int PRShot;
181 	ubyte NoRedundancy;
182 	ubyte MultiMessages;
183         ubyte MultiPingHud;
184 	ubyte NoRankings;
185 #if defined(DXX_BUILD_DESCENT_I)
186 	ubyte BombGauge;
187 #endif
188 	ubyte AutomapFreeFlight;
189 	FiringAutoselectMode NoFireAutoselect;
190 	ubyte CycleAutoselectOnly;
191 	uint8_t CloakInvulTimer;
192 	union {
193 		/* For now, manage all these choices in a single variable, but
194 		 * give them separate names to make them easier to find.
195 		 */
196 		int AlphaEffects;
197 		int AlphaBlendMineExplosion;
198 		int AlphaBlendMarkers;
199 		int AlphaBlendFireballs;
200 		int AlphaBlendPowerups;
201 		int AlphaBlendLasers;
202 		int AlphaBlendWeapons;
203 		int AlphaBlendEClips;
204 	};
205 	int DynLightColor;
206 	d_sp_gameplay_options SPGameplayOptions;
207 };
208 
209 }
210 #endif
211 
212 extern struct player_config PlayerCfg;
213 
214 #ifndef EZERO
215 #define EZERO 0
216 #endif
217 
218 // Used to save kconfig values to disk.
219 #ifdef dsx
220 namespace dsx {
221 
222 extern const struct player_config::KeySettings DefaultKeySettings;
223 
224 void write_player_file();
225 
226 void new_player_config();
227 
228 int read_player_file();
229 
230 // set a new highest level for player for this mission
231 }
232 #endif
233 void set_highest_level(uint8_t levelnum);
234 
235 // gets the player's highest level from the file for this mission
236 int get_highest_level(void);
237 
238 namespace dsx {
239 struct netgame_info;
240 void read_netgame_profile(struct netgame_info *ng);
241 void write_netgame_profile(struct netgame_info *ng);
242 }
243 
244 #endif
245