Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Descent3/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void ConfigureDisplayResolutions() {
return;
}

std::set<tVideoResolution, tVideoResolution::tVideoResolutionCompare> resolutions;
std::set<tVideoResolution> resolutions;
for (int d = 0; d < display_count; d++) {
SDL_DisplayID display_id = displays[d];

Expand Down Expand Up @@ -417,7 +417,7 @@ void ConfigureDisplayResolutions() {
if (resolutions_vec.empty()) {
return;
}
std::swap(resolutions_vec, Video_res_list);
Video_res_list = std::move(resolutions_vec);
SDL_free(displays);

// Find the index of the current screen resolution in the list
Expand Down
15 changes: 4 additions & 11 deletions Descent3/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,14 @@ struct tVideoResolution
return ss.str();
}

bool operator==(const tVideoResolution& other) {
bool operator==(const tVideoResolution& other) const {
return other.width == this->width && other.height == this->height;
}

struct tVideoResolutionCompare
bool operator<(const tVideoResolution& other) const
{
bool operator()(const tVideoResolution &lres, const tVideoResolution &rres) const
{
if (lres.width != rres.width)
{
return lres.width < rres.width;
}
return lres.height < rres.height;
}
};
return width != other.width ? width < other.width : height < other.height;
}
};

extern std::vector<tVideoResolution> Video_res_list;
Expand Down
70 changes: 0 additions & 70 deletions Descent3/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2061,12 +2061,9 @@ void DeleteTempFiles() {
*
*/

static int Init_old_screen_mode;
static void (*Init_old_ui_callback)() = NULL;
static bool Init_old_control_mode;
static bool Init_ui_cursor_visible;
static bool Init_was_game_paused = false;
static pilot Init_old_pilot;

// TODO: MTS: Unused in project
void ShutdownD3() {
Expand Down Expand Up @@ -2096,81 +2093,14 @@ void ShutdownD3() {
Sound_system.PauseSounds();
}

SaveControlConfig(&Init_old_pilot);
CloseControls();

// shutdown cinematics.

// shutdown screen.
Init_ui_cursor_visible = ui_IsCursorVisible();
Init_old_screen_mode = GetScreenMode();
Init_old_ui_callback = GetUICallback();
SetScreenMode(SM_NULL);

// shutdown IO
ddio_Close();
}

// TODO: MTS: unused in project
// This function restarts all game systems
void RestartD3() {
ddio_init_info io_info;

if (!Init_systems_init)
return;

LOG_INFO << "Restarting D3...";

if (!FindArg("-windowed")) {
if (Dedicated_server) {
ddio_MouseMode(MOUSE_STANDARD_MODE);
} else {
ddio_MouseMode(MOUSE_EXCLUSIVE_MODE);
}
}

// startup io
io_info.obj = Descent;
if (!ddio_Init(&io_info)) {
Error("I/O initialization failed.");
}

// startup screen.
ddio_KeyFlush();
SetScreenMode(Init_old_screen_mode);
SetUICallback(Init_old_ui_callback);
if (Init_ui_cursor_visible)
ui_ShowCursor();

// startup game systems
InitControls();
LoadControlConfig(&Init_old_pilot);

// resume game sounds and time as needed
if (GetFunctionMode() == GAME_MODE) {
if (!(Game_mode & GM_MULTI)) {
if (!Init_was_game_paused) {
ResumeGame();
} else {
D3MusicResume();
}
}
} else {
Sound_system.ResumeSounds();
D3MusicResume();
}

// resume controller if it was active before alt-tabbing out.
if (Init_old_control_mode) {
ResumeControls();
}

// Restart Force Feedback
ForceRestart();

// startup cinematics.

// startup sound.
// Sound_system.ResumeSounds();
// Sound_system.InitSoundLib(Descent, Sound_mixer, Sound_quality, false);
}
3 changes: 1 addition & 2 deletions Descent3/pilot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,6 @@ void ShipSelectDeleteLogo(newuiListBox *lb);
void ShowPilotPicDialog(pilot *Pilot);

UITextItem *pilot_items = nullptr; // array of UITextItems for use in Pilot listbox
pilot temp; // pilot in use by the listbox
static std::vector<std::string> filelist; // list of pilot filenames
static int filecount; // number of pilot filenames found
void PilotListSelectChangeCallback(int index);
Expand Down Expand Up @@ -825,7 +824,7 @@ struct {
bool initial_call;
bool all_setup;
} PilotChooseDialogInfo;
pilot working_pilot;
static pilot working_pilot;

void PilotListSelectChangeCallback(int index) {
if (!filecount || !PilotChooseDialogInfo.all_setup)
Expand Down
40 changes: 6 additions & 34 deletions Descent3/pilot_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,48 +172,22 @@ extern float Key_ramp_speed;

pilot::~pilot() { clean(false); }

pilot::pilot() {
write_pending = false;
initialize();
pilot::pilot() :
difficulty{DIFFICULTY_ROOKIE},
hud_mode{HUD_COCKPIT},
hud_graphical_stat{STAT_STANDARD}
{
}

pilot::pilot(pilot *copy) {
write_pending = true;
initialize();
}

pilot::pilot(char *fname) {
write_pending = true;
initialize();
}

// initializes all the data (for constructors)
// Two-stage construction (because it references global vars)
void pilot::initialize(void) {
int i;

filename.clear();
name = NULL;
ship_model = mem_strdup("Pyro-GL");
ship_logo = NULL;
audio1_file = NULL;
audio2_file = NULL;
audio3_file = NULL;
audio4_file = NULL;
guidebot_name = mem_strdup("GB");
picture_id = PPIC_INVALID_ID;
difficulty = DIFFICULTY_ROOKIE;
hud_mode = (uint8_t)HUD_COCKPIT;
hud_stat = 0;
hud_graphical_stat = STAT_STANDARD;
game_window_w = Video_res_list[Current_video_resolution_id].width;
game_window_h = Video_res_list[Current_video_resolution_id].height;
num_missions_flown = 0;
mission_data = NULL;
mouselook_control = false;
key_ramping = 0.35f;
lrearview_enabled = false;
rrearview_enabled = false;

bool kiddie_settings = true;

if (Database) {
Expand All @@ -237,8 +211,6 @@ void pilot::initialize(void) {
strcpy(taunts[i], TXT(TXT_TAUNT_TEXT + i));
}

read_controller = READF_MOUSE + READF_JOY;

if (Controller) {
for (i = 0; i < NUM_CONTROLLER_FUNCTIONS; i++) {
Controller->get_controller_function(Controller_needs[i].id, controls[i].type, &controls[i].value,
Expand Down
68 changes: 33 additions & 35 deletions Descent3/pilot_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ class pilot {
public:
~pilot();
pilot();
pilot(pilot *copy);
pilot(char *fname);

// This function guts the data so it's virgin (fresh for reading)
// frees any memory that needs to be freed, etc.
Expand Down Expand Up @@ -235,9 +233,9 @@ class pilot {
void get_mission_data(int index, tMissionData *data);
int find_mission_data(const char *mission_name);

private:
void initialize(void); // initializes all the data (for constructors)
bool write_pending; // data has changed and pilot data is out of sync with file
private:
bool write_pending = false; // data has changed and pilot data is out of sync with file
private:
// internal file access functions
void write_name(CFILE *file);
Expand All @@ -256,7 +254,7 @@ class pilot {

// for the read functions, skip is true if the data should actually
// just be skipped and not processed
int file_version;
int file_version = 0;
void read_name(CFILE *file, bool skip);
void read_ship_info(CFILE *file, bool skip);
void read_custom_multiplayer_data(CFILE *file, bool skip);
Expand All @@ -275,46 +273,46 @@ class pilot {
//--- Pilot data ---//
//--- Try to preserve alignment ---//
std::string filename;// filename location of this pilot
char *name; // name of the pilot (used in the game)
char *ship_logo; // ship logo for multiplayer play (filename)
char *ship_model; // what ship does this pilot fly
char *audio1_file; // audio taunt #1 (filename)
char *audio2_file; // audio taunt #2 (filename)
char *audio3_file; // audio taunt #1 (filename)
char *audio4_file; // audio taunt #2 (filename)
char *guidebot_name; // guidebot name

uint16_t picture_id; // pilot picture image id
char *name = nullptr; // name of the pilot (used in the game)
char *ship_logo = nullptr; // ship logo for multiplayer play (filename)
char *ship_model = nullptr; // what ship does this pilot fly
char *audio1_file = nullptr; // audio taunt #1 (filename)
char *audio2_file = nullptr; // audio taunt #2 (filename)
char *audio3_file = nullptr; // audio taunt #1 (filename)
char *audio4_file = nullptr; // audio taunt #2 (filename)
char *guidebot_name = nullptr; // guidebot name

uint16_t picture_id = PPIC_INVALID_ID; // pilot picture image id
uint8_t difficulty; // difficulty setting for this pilot (DIFFICULTY_*)
uint8_t hud_mode; // hud display mode
bool profanity_filter_on, audiotaunts;
bool profanity_filter_on = false, audiotaunts = true;

uint16_t hud_stat; // hud layout using the STAT mask
uint16_t hud_stat = 0; // hud layout using the STAT mask
uint16_t hud_graphical_stat;

int game_window_w, game_window_h; // game window size
int game_window_w = 0, game_window_h = 0; // game window size

int num_missions_flown; // number of mission's flown
tMissionData *mission_data; // mission data
int num_missions_flown = 0; // number of mission's flown
tMissionData *mission_data = nullptr; // mission data

uint16_t PrimarySelectList[MAX_PRIMARY_WEAPONS];
uint16_t SecondarySelectList[MAX_SECONDARY_WEAPONS];
uint16_t PrimarySelectList[MAX_PRIMARY_WEAPONS]{};
uint16_t SecondarySelectList[MAX_SECONDARY_WEAPONS]{};

tGameToggles gameplay_toggles; // special options in config menu.
tGameToggles gameplay_toggles{}; // special options in config menu.

public:
char taunts[MAX_PILOT_TAUNTS][PILOT_TAUNT_SIZE]; // taunt macros

cntrldata controls[NUM_CONTROLLER_FUNCTIONS]; // controller settings
float mouse_sensitivity[N_MOUSE_AXIS]; // axis sensitivities
float joy_sensitivity[N_JOY_AXIS]; // axis sensitivities
float key_ramping;
char read_controller; // do we read the controller port also (beyond keyboard/mouse)
bool mouselook_control; // mouselook control.
bool lrearview_enabled;
bool rrearview_enabled; // are these small views enabled?

uint8_t ingame_difficulty; // DAJ for optimization
char taunts[MAX_PILOT_TAUNTS][PILOT_TAUNT_SIZE]{}; // taunt macros

cntrldata controls[NUM_CONTROLLER_FUNCTIONS]{}; // controller settings
float mouse_sensitivity[N_MOUSE_AXIS]{}; // axis sensitivities
float joy_sensitivity[N_JOY_AXIS]{}; // axis sensitivities
float key_ramping = 0.35;
char read_controller = READF_MOUSE + READF_JOY; // do we read the controller port also (beyond keyboard/mouse)
bool mouselook_control = false; // mouselook control.
bool lrearview_enabled = false;
bool rrearview_enabled = false; // are these small views enabled?

uint8_t ingame_difficulty = 0; // DAJ for optimization
};

#endif
2 changes: 2 additions & 0 deletions Descent3/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "init.h"
#include "log.h"
#include "config.h"
#include "pilot.h"

#ifdef WIN32
#include "debug.h"
Expand Down Expand Up @@ -222,6 +223,7 @@ int main(int argc, char *argv[]) {
GatherArgs(argv);
bool enable_winconsole = true;
#endif
Current_pilot.initialize();

orig_pwd = std::filesystem::current_path();

Expand Down
Loading