Skip to content

Commit

Permalink
The pilot class relied on verify to update internal data. Replicate t…
Browse files Browse the repository at this point in the history
…hat with the new system
  • Loading branch information
InsanityBringer committed Sep 9, 2024
1 parent a47715c commit d5fd48a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ IF (WIN32)
SET(CMAKE_CXX_FLAGS_DEBUG "/Od /EHsc /RTC1 /MTd /MP /W3 /nologo /c /Zi /errorReport:prompt")
SET(CMAKE_CXX_FLAGS_RELEASE "/O2 /FD /EHsc /MT /MP /W3 /nologo /c /Zi /errorReport:prompt")

SET(CMAKE_MODULE_LINKER_FLAGS "/SAFESEH:NO /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC")
SEt(CMAKE_EXE_LINKER_FLAGS_RELEASE " /DEBUG") #[ISB] Generate debug information
set(CMAKE_MODULE_LINKER_FLAGS "/SAFESEH:NO /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/DEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE " /DEBUG") #[ISB] Generate debug information
ADD_DEFINITIONS (-DIS_WINDOWS -D_CRT_SECURE_NO_WARNINGS -DWIN32 -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)


Expand Down
32 changes: 16 additions & 16 deletions Descent3/pilot_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,27 +240,12 @@ void pilot::clean(bool reset)
// It will correct any messed data.
void pilot::verify(void)
{
//[ISB] This isn't needed anymore because I only commit the globals when it's time to choose a pilot.
//The real solution would be to get rid of the duplicated globals holy crap why did they do this and instead have everything read from Current_pilot.
/*int i;
for (i = 0; i < MAX_PRIMARY_WEAPONS; i++)
PrimarySelectList[i] = GetAutoSelectPrimaryWpnIdx(i);
for (i = 0; i < MAX_SECONDARY_WEAPONS; i++)
SecondarySelectList[i] = GetAutoSelectSecondaryWpnIdx(i);
gameplay_toggles.guided_mainview = Game_toggles.guided_mainview;
gameplay_toggles.show_reticle = Game_toggles.show_reticle;
gameplay_toggles.ship_noises = Game_toggles.ship_noises;*/

// kill graphical stat for inventory and reset to text version
if (hud_graphical_stat & STAT_INVENTORY)
{
hud_graphical_stat = hud_graphical_stat & (~STAT_INVENTORY);
hud_stat = hud_stat | STAT_INVENTORY;
}

//key_ramping = Key_ramp_speed;
}

// This function makes the pilot file so it's write pending, meaning that
Expand All @@ -284,7 +269,6 @@ int pilot::flush(bool new_file)
return PLTW_NO_FILENAME; //no filename was given
}


CFILE* file;
char real_filename[_MAX_PATH];

Expand All @@ -301,6 +285,7 @@ int pilot::flush(bool new_file)
try
{
verify();
fetch_state(); //Ensure pilot state is up to date.

file = cfopen(real_filename, "wb");
if (!file)
Expand Down Expand Up @@ -518,6 +503,21 @@ void pilot::commit_state() const
Key_ramp_speed = key_ramping;
}

void pilot::fetch_state()
{
for (int i = 0; i < MAX_PRIMARY_WEAPONS; i++)
PrimarySelectList[i] = GetAutoSelectPrimaryWpnIdx(i);

for (int i = 0; i < MAX_SECONDARY_WEAPONS; i++)
SecondarySelectList[i] = GetAutoSelectSecondaryWpnIdx(i);

gameplay_toggles.guided_mainview = Game_toggles.guided_mainview;
gameplay_toggles.show_reticle = Game_toggles.show_reticle;
gameplay_toggles.ship_noises = Game_toggles.ship_noises;

key_ramping = Key_ramp_speed;
}

void pilot::set_name(char* n)
{
if (name)
Expand Down
3 changes: 3 additions & 0 deletions Descent3/pilot_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class pilot
// Used to work around the problems where merely reading a pilot file would commit global state.
void commit_state() const;

// [ISB] Gets the state from global
void fetch_state();

public:
// data access functions
void set_name(char *name);
Expand Down

0 comments on commit d5fd48a

Please sign in to comment.