From ba1020ef70440c7eb7e5b53aae9a443508e8907e Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Sun, 11 Aug 2024 20:32:16 +0300 Subject: [PATCH 1/2] Fix compilation on Windows SetUnhandledExceptionFilter requires WINAPI macros on RecordExceptionInfo() declaration, otherwise it fails to compile on x86 arch. --- ddebug/debug.h | 9 +++++---- ddebug/windebug.cpp | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ddebug/debug.h b/ddebug/debug.h index 2c0e6a957..988c73228 100644 --- a/ddebug/debug.h +++ b/ddebug/debug.h @@ -180,10 +180,11 @@ void ddio_InternalKeyClose(); #else #define debug_break() #endif + #if defined(WIN32) -// We forward declare PEXCEPTION_POINTERS so that the function -// prototype doesn't needlessly require windows.h. -typedef struct _EXCEPTION_POINTERS EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; -long __cdecl RecordExceptionInfo(PEXCEPTION_POINTERS data); + +#include + +long WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data); #endif #endif diff --git a/ddebug/windebug.cpp b/ddebug/windebug.cpp index 1e27cda18..a3bccfbaa 100644 --- a/ddebug/windebug.cpp +++ b/ddebug/windebug.cpp @@ -325,8 +325,7 @@ void dump_text_to_clipboard(char *text) { DumpTextToClipboard(text); } /////////////////////////////////////////////////////////////////////////////// #pragma comment(lib, "DbgHelp.lib") - -long __cdecl RecordExceptionInfo(PEXCEPTION_POINTERS data) { +long WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data) { static bool BeenHere = false; if (BeenHere) // Going recursive! That must mean this routine crashed! return EXCEPTION_CONTINUE_SEARCH; From f888a101aba2e2630f5f6b24c68b41716335a0ac Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Mon, 12 Aug 2024 01:43:05 +0300 Subject: [PATCH 2/2] Fix crash in Release mode for new pilot During start of new game with new pilot (never played) game tries to inject to play level1.mve before training mission right in the middle of update UI frame. At same time, if game previously found mainmenu.mve, it will be looped in main menu screen. Since buffers for MVE playback already allocated fo mainmenu.mve, trying to start another movie will lead to crash. Removed movie injection from playing, now new pilot will see this sequence: New game -> Training mission -> level1.mve cutscene -> Level 1 Removed RELEASE #ifdef's on this part of code as this definitely masked issue until we caught it in preparation of release build. --- Descent3/Mission.cpp | 11 +++-------- Descent3/init.cpp | 3 --- Descent3/init.h | 5 +++++ Descent3/menu.cpp | 30 ++++++++++-------------------- Descent3/mmItem.h | 7 +++++-- 5 files changed, 23 insertions(+), 33 deletions(-) diff --git a/Descent3/Mission.cpp b/Descent3/Mission.cpp index b36c9f8f8..8706865b1 100644 --- a/Descent3/Mission.cpp +++ b/Descent3/Mission.cpp @@ -1635,20 +1635,15 @@ bool DoMissionBriefing(int level) { return ret; } extern bool FirstGame; -bool Skip_next_movie = false; + // --------------------------------------------------------------------------- // play movie void DoMissionMovie(const char *movie) { - char temppath[_MAX_PATH]; if (PROGRAM(windowed)) { mprintf(0, "Skipping movie...can't do in windowed mode!\n"); return; } - // Don't play this movie the first time through. This is a horrible hack. - if (Skip_next_movie) { - Skip_next_movie = false; - return; - } + #ifdef D3_FAST return; #endif @@ -1657,8 +1652,8 @@ void DoMissionMovie(const char *movie) { ddio_MakePath(mpath, LocalD3Dir, "movies", movie, NULL); PlayMovie(mpath); } - // PlayMovie(movie); } + /////////////////////////////////////////////////////////////////////////////// // Script Management for Missions and Levels /////////////////////////////////////////////////////////////////////////////// diff --git a/Descent3/init.cpp b/Descent3/init.cpp index 92a18cd42..6bb665eb5 100644 --- a/Descent3/init.cpp +++ b/Descent3/init.cpp @@ -1117,9 +1117,6 @@ void PreInitD3Systems() { #endif } -/* - Save game variables to the registry -*/ void SaveGameSettings() { char tempbuffer[TEMPBUFFERSIZE]; int tempint; diff --git a/Descent3/init.h b/Descent3/init.h index f7cc89af4..535d0457f 100644 --- a/Descent3/init.h +++ b/Descent3/init.h @@ -98,4 +98,9 @@ void RestartD3(); void InitMessage(const char *c, float progress = -1); +/** + * Save game variables to the registry + */ +void SaveGameSettings(); + #endif diff --git a/Descent3/menu.cpp b/Descent3/menu.cpp index 3e9119ba9..c0e45a07a 100644 --- a/Descent3/menu.cpp +++ b/Descent3/menu.cpp @@ -658,12 +658,12 @@ #include "menu.h" #include "mmItem.h" #include "game.h" -#include "gamesequence.h" #include "Mission.h" #include "multi_ui.h" #include "ctlconfig.h" #include "config.h" #include "gamesave.h" +#include "gamesequence.h" #include "demofile.h" #include "pilot.h" #include "LoadLevel.h" @@ -671,6 +671,8 @@ #include "mem.h" #include "args.h" #include "cinematics.h" +#include "multi_dll_mgr.h" +#include "newui_core.h" #ifdef _WIN32 #define USE_DIRECTPLAY @@ -681,9 +683,6 @@ #else bool Directplay_lobby_launched_game = false; #endif -#include "multi_dll_mgr.h" -#include "d3music.h" -#include "newui_core.h" #define IDV_QUIT 0xff // Menu Item Defines @@ -702,8 +701,7 @@ bool MenuLoadLevel(void); #endif // for command line joining of games bool Auto_connected = false; -// externed from init.cpp -extern void SaveGameSettings(); + // runs command line options. bool ProcessCommandLine(); // new game selection @@ -715,7 +713,6 @@ extern bool Demo_looping; bool FirstGame = false; int MainMenu() { - extern void ShowStaticScreen(char *bitmap_filename, bool timed = false, float delay_time = 0.0f); mmInterface main_menu; bool exit_game = false; bool exit_menu = false; @@ -1127,15 +1124,16 @@ static inline int generate_mission_listbox(newuiListBox *lb, int n_maxfiles, cha } return c; } -extern bool Skip_next_movie; + #define OEM_TRAINING_FILE "training.mn3" #define OEM_MISSION_FILE "d3oem.mn3" + bool MenuNewGame() { newuiTiledWindow menu; newuiSheet *select_sheet; newuiListBox *msn_lb; - char **filelist = NULL; - int n_missions, i, res; //,k + char **filelist = nullptr; + int n_missions, i, res; bool found = false; bool do_menu = true, load_mission = false, retval = true; #ifdef DEMO @@ -1150,18 +1148,10 @@ bool MenuNewGame() { return false; } #else -#ifdef RELEASE if ((!FindArg("-mission")) && (!FirstGame) && (-1 == Current_pilot.find_mission_data(TRAINING_MISSION_NAME))) { FirstGame = true; - char moviepath[_MAX_PATH]; - ddio_MakePath(moviepath, LocalD3Dir, "movies", "level1.mve", nullptr); - if (cfexist(moviepath)) { - PlayMovie(moviepath); - } - Skip_next_movie = true; - if (LoadMission("training.mn3")) { CurrentPilotUpdateMissionStatus(true); // go into game mode. @@ -1190,7 +1180,7 @@ bool MenuNewGame() { return false; } } -#endif + // create menu. menu.Create(TXT_MENUNEWGAME, 0, 0, 448, 384); @@ -1333,7 +1323,7 @@ bool MenuNewGame() { goto redo_newgame_menu; } else { Current_mission.cur_level = start_level; - // pull out the ship permssions and use them + // pull out the ship permissions and use them Players[0].ship_permissions = GetPilotShipPermissions(&Current_pilot, Current_mission.name); } } diff --git a/Descent3/mmItem.h b/Descent3/mmItem.h index 9909fb832..55d5e0f22 100644 --- a/Descent3/mmItem.h +++ b/Descent3/mmItem.h @@ -68,9 +68,12 @@ */ #ifndef MMITEM_H #define MMITEM_H + +#include "cinematics.h" +#include "gamefont.h" #include "newui.h" #include "psclass.h" -#include "gamefont.h" + #if ((!defined(OEM)) && (!defined(DEMO))) #define MOVIE_MENU #endif @@ -176,7 +179,7 @@ class mmItem : public UIGadget { virtual void OnSelect(); }; // Main Menu Interface Object -struct tCinematic; + class mmInterface : public UIWindow { int m_nmenu_items; // number of menu items available. mmItem m_menuitems[N_MMENU_ITEMS]; // main menu items