ULTIMA8: Fix crash after watching Crusader credits and saving game

This commit is contained in:
Matthew Duggan 2021-07-31 16:58:14 +09:00
parent 5ad9352f8e
commit 1afa2eab91
3 changed files with 23 additions and 11 deletions

View File

@ -188,11 +188,7 @@ void CruGame::playDemoScreen() {
}
}
void CruGame::playCredits() {
Process *menuproc = new MainMenuProcess();
Kernel::get_instance()->addProcess(menuproc);
ProcId CruGame::playCreditsNoMenu() {
static const Std::string txt_filename = "static/credits.dat";
static const Std::string bmp_filename = "static/cred.dat";
Common::SeekableReadStream *txtrs = FileSystem::get_instance()->ReadFile(txt_filename);
@ -201,20 +197,29 @@ void CruGame::playCredits() {
if (!txtrs) {
perr << "RemorseGame::playCredits: error opening credits text: "
<< txt_filename << Std::endl;
return;
return 0;
}
if (!bmprs) {
perr << "RemorseGame::playCredits: error opening credits background: "
<< bmp_filename << Std::endl;
return;
return 0;
}
Gump *creditsgump = new CruCreditsGump(txtrs, bmprs);
creditsgump->InitGump(nullptr);
creditsgump->CreateNotifier();
Process *notifyproc = creditsgump->GetNotifyProcess();
return notifyproc->getPid();
}
if (notifyproc) {
menuproc->waitFor(notifyproc);
void CruGame::playCredits() {
Process *menuproc = new MainMenuProcess();
Kernel::get_instance()->addProcess(menuproc);
ProcId creditsnotify = playCreditsNoMenu();
if (creditsnotify) {
menuproc->waitFor(creditsnotify);
}
}

View File

@ -51,6 +51,9 @@ public:
void playCredits() override;
void playQuotes() override { }; // no quotes for Crusader
void playDemoScreen() override;
/** Play credits but without showing a menu at the end - just finish. */
ProcId playCreditsNoMenu();
};
} // End of namespace Ultima8

View File

@ -30,6 +30,7 @@
#include "ultima/ultima8/gumps/widgets/button_widget.h"
#include "ultima/ultima8/gumps/quit_gump.h"
#include "ultima/ultima8/gumps/difficulty_gump.h"
#include "ultima/ultima8/games/cru_game.h"
#include "ultima/ultima8/games/game.h"
#include "ultima/ultima8/world/actors/main_actor.h"
#include "ultima/ultima8/graphics/palette_manager.h"
@ -218,9 +219,12 @@ void CruMenuGump::selectEntry(int entry) {
dlg.runModal();
}
break;
case 5: // Credits
Game::get_instance()->playCredits();
case 5: { // Credits
CruGame *game = dynamic_cast<CruGame *>(Game::get_instance());
assert(game);
game->playCreditsNoMenu();
break;
}
case 6: // Quit
QuitGump::verifyQuit();
break;