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.
This commit is contained in:
Azamat H. Hackimov 2024-08-12 01:43:05 +03:00
parent ba1020ef70
commit f888a101ab
5 changed files with 23 additions and 33 deletions

View File

@ -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
///////////////////////////////////////////////////////////////////////////////

View File

@ -1117,9 +1117,6 @@ void PreInitD3Systems() {
#endif
}
/*
Save game variables to the registry
*/
void SaveGameSettings() {
char tempbuffer[TEMPBUFFERSIZE];
int tempint;

View File

@ -98,4 +98,9 @@ void RestartD3();
void InitMessage(const char *c, float progress = -1);
/**
* Save game variables to the registry
*/
void SaveGameSettings();
#endif

View File

@ -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 @@ redo_newgame_menu:
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);
}
}

View File

@ -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 @@ protected:
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