[Scummvm-git-logs] scummvm master -> ced08c2c4bde2d03ba610091d4e41a5c2ed22d17
dreammaster
paulfgilbert at gmail.com
Tue Apr 28 05:01:02 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
03afa37139 ULTIMA4: General cleanups
cd45556cb4 ULTIMA4: Move response parts into their own class
ced08c2c4b ULTIMA4: Refactor death code into it's own class
Commit: 03afa37139b9b3b0d751a40660fa91af1952ba43
https://github.com/scummvm/scummvm/commit/03afa37139b9b3b0d751a40660fa91af1952ba43
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-27T22:00:06-07:00
Commit Message:
ULTIMA4: General cleanups
Changed paths:
engines/ultima/ultima4/controllers/game_controller.cpp
engines/ultima/ultima4/controllers/inn_controller.cpp
engines/ultima/ultima4/controllers/intro_controller.cpp
engines/ultima/ultima4/controllers/intro_controller.h
engines/ultima/ultima4/core/config.cpp
engines/ultima/ultima4/core/utils.cpp
engines/ultima/ultima4/game/game.cpp
diff --git a/engines/ultima/ultima4/controllers/game_controller.cpp b/engines/ultima/ultima4/controllers/game_controller.cpp
index c54287f261..f53d6db163 100644
--- a/engines/ultima/ultima4/controllers/game_controller.cpp
+++ b/engines/ultima/ultima4/controllers/game_controller.cpp
@@ -43,8 +43,6 @@
namespace Ultima {
namespace Ultima4 {
-using namespace std;
-
GameController *g_game = nullptr;
static const MouseArea MOUSE_AREAS[] = {
diff --git a/engines/ultima/ultima4/controllers/inn_controller.cpp b/engines/ultima/ultima4/controllers/inn_controller.cpp
index 44c1799e15..8dff192b71 100644
--- a/engines/ultima/ultima4/controllers/inn_controller.cpp
+++ b/engines/ultima/ultima4/controllers/inn_controller.cpp
@@ -29,8 +29,6 @@
namespace Ultima {
namespace Ultima4 {
-void innTimer(void *data);
-
InnController::InnController() {
_map = nullptr;
/*
diff --git a/engines/ultima/ultima4/controllers/intro_controller.cpp b/engines/ultima/ultima4/controllers/intro_controller.cpp
index 943fb0f8a8..ff5ceee224 100644
--- a/engines/ultima/ultima4/controllers/intro_controller.cpp
+++ b/engines/ultima/ultima4/controllers/intro_controller.cpp
@@ -46,11 +46,6 @@
namespace Ultima {
namespace Ultima4 {
-using namespace std;
-
-Common::String profileName;
-bool useProfile;
-
IntroController *g_intro;
#define INTRO_MAP_HEIGHT 5
@@ -197,7 +192,8 @@ IntroController::IntroController() : Controller(1),
_title(_titles.begin()), // element iterator
_transparentIndex(13), // palette index for transparency
_transparentColor(), // palette color for transparency
- _bSkipTitles(false) {
+ _bSkipTitles(false),
+ _useProfile(false) {
Common::fill(&_questionTree[0], &_questionTree[15], -1);
// initialize menus
@@ -599,8 +595,8 @@ void IntroController::updateScreen() {
drawMap();
drawBeasties();
// display the profile name if a local profile is being used
- if (useProfile)
- g_screen->screenTextAt(40 - profileName.size(), 24, "%s", profileName.c_str());
+ if (_useProfile)
+ g_screen->screenTextAt(40 - _profileName.size(), 24, "%s", _profileName.c_str());
break;
case INTRO_MENU:
diff --git a/engines/ultima/ultima4/controllers/intro_controller.h b/engines/ultima/ultima4/controllers/intro_controller.h
index c58b275cf0..4ba90a9139 100644
--- a/engines/ultima/ultima4/controllers/intro_controller.h
+++ b/engines/ultima/ultima4/controllers/intro_controller.h
@@ -359,6 +359,8 @@ private:
IntroObjectState *_objectStateTable;
bool _justInitiatedNewGame;
+ Common::String _profileName;
+ bool _useProfile;
//
// Title defs, structs, methods, and data members
diff --git a/engines/ultima/ultima4/core/config.cpp b/engines/ultima/ultima4/core/config.cpp
index fff4bb4c69..e21c37ba15 100644
--- a/engines/ultima/ultima4/core/config.cpp
+++ b/engines/ultima/ultima4/core/config.cpp
@@ -27,8 +27,6 @@
namespace Ultima {
namespace Ultima4 {
-using namespace std;
-
Config *Config::_instance;
Config::Config() {
diff --git a/engines/ultima/ultima4/core/utils.cpp b/engines/ultima/ultima4/core/utils.cpp
index 02b65c035c..a6c19a09d7 100644
--- a/engines/ultima/ultima4/core/utils.cpp
+++ b/engines/ultima/ultima4/core/utils.cpp
@@ -50,7 +50,6 @@ int xu4_random(int upperRange) {
}
Common::String &trim(Common::String &val, const Common::String &chars_to_trim) {
- using namespace std;
Common::String::iterator i;
if (val.size()) {
size_t pos;
@@ -63,7 +62,6 @@ Common::String &trim(Common::String &val, const Common::String &chars_to_trim) {
}
Common::String &lowercase(Common::String &val) {
- using namespace std;
Common::String::iterator i;
for (i = val.begin(); i != val.end(); i++)
*i = tolower(*i);
@@ -71,7 +69,6 @@ Common::String &lowercase(Common::String &val) {
}
Common::String &uppercase(Common::String &val) {
- using namespace std;
Common::String::iterator i;
for (i = val.begin(); i != val.end(); i++)
*i = toupper(*i);
diff --git a/engines/ultima/ultima4/game/game.cpp b/engines/ultima/ultima4/game/game.cpp
index f28eb4ffe5..4b0ef2aa9d 100644
--- a/engines/ultima/ultima4/game/game.cpp
+++ b/engines/ultima/ultima4/game/game.cpp
@@ -74,8 +74,6 @@
namespace Ultima {
namespace Ultima4 {
-using namespace std;
-
/*-----------------*/
/* Functions BEGIN */
Commit: cd45556cb4d3ee9eba9fb0d5398d1bcc4f33b3d3
https://github.com/scummvm/scummvm/commit/cd45556cb4d3ee9eba9fb0d5398d1bcc4f33b3d3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-27T22:00:06-07:00
Commit Message:
ULTIMA4: Move response parts into their own class
Changed paths:
engines/ultima/ultima4/conversation/conversation.cpp
engines/ultima/ultima4/conversation/conversation.h
engines/ultima/ultima4/conversation/dialogueloader_hw.cpp
engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
engines/ultima/ultima4/game/person.cpp
engines/ultima/ultima4/ultima4.cpp
engines/ultima/ultima4/ultima4.h
diff --git a/engines/ultima/ultima4/conversation/conversation.cpp b/engines/ultima/ultima4/conversation/conversation.cpp
index a6d1470621..fe61db9c25 100644
--- a/engines/ultima/ultima4/conversation/conversation.cpp
+++ b/engines/ultima/ultima4/conversation/conversation.cpp
@@ -27,20 +27,30 @@
namespace Ultima {
namespace Ultima4 {
-/* Static variable initialization */
-const ResponsePart ResponsePart::NONE("<NONE>", "", true);
-const ResponsePart ResponsePart::ASK("<ASK>", "", true);
-const ResponsePart ResponsePart::END("<END>", "", true);
-const ResponsePart ResponsePart::ATTACK("<ATTACK>", "", true);
-const ResponsePart ResponsePart::BRAGGED("<BRAGGED>", "", true);
-const ResponsePart ResponsePart::HUMBLE("<HUMBLE>", "", true);
-const ResponsePart ResponsePart::ADVANCELEVELS("<ADVANCELEVELS>", "", true);
-const ResponsePart ResponsePart::HEALCONFIRM("<HEALCONFIRM>", "", true);
-const ResponsePart ResponsePart::STARTMUSIC_LB("<STARTMUSIC_LB>", "", true);
-const ResponsePart ResponsePart::STARTMUSIC_HW("<STARTMUSIC_HW>", "", true);
-const ResponsePart ResponsePart::STOPMUSIC("<STOPMUSIC>", "", true);
-const ResponsePart ResponsePart::HAWKWIND("<HAWKWIND>", "", true);
const uint Conversation::BUFFERLEN = 16;
+ResponseParts *g_responseParts;
+
+ResponseParts::ResponseParts() :
+ NONE("<NONE>", "", true),
+ ASK("<ASK>", "", true),
+ END("<END>", "", true),
+ ATTACK("<ATTACK>", "", true),
+ BRAGGED("<BRAGGED>", "", true),
+ HUMBLE("<HUMBLE>", "", true),
+ ADVANCELEVELS("<ADVANCELEVELS>", "", true),
+ HEALCONFIRM("<HEALCONFIRM>", "", true),
+ STARTMUSIC_LB("<STARTMUSIC_LB>", "", true),
+ STARTMUSIC_HW("<STARTMUSIC_HW>", "", true),
+ STOPMUSIC("<STOPMUSIC>", "", true),
+ HAWKWIND("<HAWKWIND>", "", true) {
+ g_responseParts = this;
+}
+
+ResponseParts::~ResponseParts() {
+ g_responseParts = nullptr;
+}
+
+/*-------------------------------------------------------------------*/
Response::Response(const Common::String &response) : _references(0) {
add(response);
@@ -202,12 +212,12 @@ const ResponsePart &Dialogue::getAction() const {
/* Does the person turn away from/attack you? */
if (prob >= _turnAwayProb)
- return ResponsePart::NONE;
+ return g_responseParts->NONE;
else {
if (_attackProb - prob < 0x40)
- return ResponsePart::END;
+ return g_responseParts->END;
else
- return ResponsePart::ATTACK;
+ return g_responseParts->ATTACK;
}
}
diff --git a/engines/ultima/ultima4/conversation/conversation.h b/engines/ultima/ultima4/conversation/conversation.h
index 68c3ebe68f..50376d951e 100644
--- a/engines/ultima/ultima4/conversation/conversation.h
+++ b/engines/ultima/ultima4/conversation/conversation.h
@@ -39,20 +39,6 @@ class Script;
*/
class ResponsePart {
public:
- // the valid command response parts
- static const ResponsePart NONE;
- static const ResponsePart ASK;
- static const ResponsePart END;
- static const ResponsePart ATTACK;
- static const ResponsePart BRAGGED;
- static const ResponsePart HUMBLE;
- static const ResponsePart ADVANCELEVELS;
- static const ResponsePart HEALCONFIRM;
- static const ResponsePart STARTMUSIC_LB;
- static const ResponsePart STARTMUSIC_HW;
- static const ResponsePart STOPMUSIC;
- static const ResponsePart HAWKWIND;
-
ResponsePart(const Common::String &value, const Common::String &arg = "", bool command = false);
operator Common::String() const;
@@ -64,6 +50,30 @@ private:
bool _command;
};
+/**
+ * A list of valid command response parts
+ */
+class ResponseParts {
+public:
+ const ResponsePart NONE;
+ const ResponsePart ASK;
+ const ResponsePart END;
+ const ResponsePart ATTACK;
+ const ResponsePart BRAGGED;
+ const ResponsePart HUMBLE;
+ const ResponsePart ADVANCELEVELS;
+ const ResponsePart HEALCONFIRM;
+ const ResponsePart STARTMUSIC_LB;
+ const ResponsePart STARTMUSIC_HW;
+ const ResponsePart STOPMUSIC;
+ const ResponsePart HAWKWIND;
+
+ ResponseParts();
+ ~ResponseParts();
+};
+
+extern ResponseParts *g_responseParts;
+
/**
* A static response. Each response can be made up of any number of
* ResponseParts, which are either text fragments or commands.
diff --git a/engines/ultima/ultima4/conversation/dialogueloader_hw.cpp b/engines/ultima/ultima4/conversation/dialogueloader_hw.cpp
index 1b633668d0..7f9c37b0d4 100644
--- a/engines/ultima/ultima4/conversation/dialogueloader_hw.cpp
+++ b/engines/ultima/ultima4/conversation/dialogueloader_hw.cpp
@@ -79,8 +79,8 @@ Dialogue *U4HWDialogueLoader::load(void *source) {
}
Response *bye = new Response(hawkwindText[HW_BYE]);
- bye->add(ResponsePart::STOPMUSIC);
- bye->add(ResponsePart::END);
+ bye->add(g_responseParts->STOPMUSIC);
+ bye->add(g_responseParts->END);
dlg->addKeyword("bye", bye);
dlg->addKeyword("", bye);
@@ -132,10 +132,10 @@ Response *hawkwindGetIntro(const DynamicResponse *dynResp) {
intro->add(hawkwindText[HW_SPEAKONLYWITH] + g_context->_party->member(0)->getName() +
hawkwindText[HW_RETURNWHEN] + g_context->_party->member(0)->getName() +
hawkwindText[HW_ISREVIVED]);
- intro->add(ResponsePart::END);
+ intro->add(g_responseParts->END);
} else {
- intro->add(ResponsePart::STARTMUSIC_HW);
- intro->add(ResponsePart::HAWKWIND);
+ intro->add(g_responseParts->STARTMUSIC_HW);
+ intro->add(g_responseParts->HAWKWIND);
intro->add(hawkwindText[HW_WELCOME] + g_context->_party->member(0)->getName() +
hawkwindText[HW_GREETING1] + hawkwindText[HW_GREETING2]);
diff --git a/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp b/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
index f57bfa7d44..1f4355de50 100644
--- a/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
+++ b/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
@@ -79,7 +79,7 @@ Dialogue *U4LBDialogueLoader::load(void *source) {
"of highest Virtue may enter this Chamber, one such as an Avatar!!!\n"));
Response *heal = new Response("\n\n\n\n\n\nHe says: I am\nwell, thank ye.");
- heal->add(ResponsePart::HEALCONFIRM);
+ heal->add(g_responseParts->HEALCONFIRM);
dlg->addKeyword("heal", heal);
Response *bye;
@@ -87,8 +87,8 @@ Dialogue *U4LBDialogueLoader::load(void *source) {
bye = new Response("Lord British says: Fare thee well my friends!");
else
bye = new Response("Lord British says: Fare thee well my friend!");
- bye->add(ResponsePart::STOPMUSIC);
- bye->add(ResponsePart::END);
+ bye->add(g_responseParts->STOPMUSIC);
+ bye->add(g_responseParts->END);
dlg->addKeyword("bye", bye);
dlg->addKeyword("", bye);
@@ -176,7 +176,7 @@ Response *lordBritishGetHelp(const DynamicResponse *resp) {
Response *lordBritishGetIntro(const DynamicResponse *resp) {
Response *intro = new Response("");
- intro->add(ResponsePart::STARTMUSIC_LB);
+ intro->add(g_responseParts->STARTMUSIC_LB);
if (g_ultima->_saveGame->_lbIntro) {
if (g_ultima->_saveGame->_members == 1) {
@@ -197,7 +197,7 @@ Response *lordBritishGetIntro(const DynamicResponse *resp) {
// Lord British automatically adds "What would thou ask of me?"
// Check levels here, just like the original!
- intro->add(ResponsePart::ADVANCELEVELS);
+ intro->add(g_responseParts->ADVANCELEVELS);
}
else {
diff --git a/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp b/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
index a4d08498da..9ac3e9c0f5 100644
--- a/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
+++ b/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
@@ -103,8 +103,8 @@ Dialogue *U4TlkDialogueLoader::load(void *source) {
Response *yes = new Response(strings[8]);
Response *no = new Response(strings[9]);
if (humilityTestQuestion) {
- yes->add(ResponsePart::BRAGGED);
- no->add(ResponsePart::HUMBLE);
+ yes->add(g_responseParts->BRAGGED);
+ no->add(g_responseParts->HUMBLE);
}
dlg->setQuestion(new Dialogue::Question(strings[7], yes, no));
@@ -116,16 +116,16 @@ Dialogue *U4TlkDialogueLoader::load(void *source) {
switch (qtrigger) {
case JOB:
- job->add(ResponsePart::ASK);
+ job->add(g_responseParts->ASK);
break;
case HEALTH:
- health->add(ResponsePart::ASK);
+ health->add(g_responseParts->ASK);
break;
case KEYWORD1:
- kw1->add(ResponsePart::ASK);
+ kw1->add(g_responseParts->ASK);
break;
case KEYWORD2:
- kw2->add(ResponsePart::ASK);
+ kw2->add(g_responseParts->ASK);
break;
case NONE:
default:
@@ -149,7 +149,7 @@ Dialogue *U4TlkDialogueLoader::load(void *source) {
dlg->addKeyword("join", new Response(Common::String("\n") + dlg->getPronoun() + " says: I cannot join thee."));
Response *bye = new Response("\nBye.");
- bye->add(ResponsePart::END);
+ bye->add(g_responseParts->END);
dlg->addKeyword("bye", bye);
dlg->addKeyword("", bye);
diff --git a/engines/ultima/ultima4/game/person.cpp b/engines/ultima/ultima4/game/person.cpp
index 4cd745d4a4..8d975d3796 100644
--- a/engines/ultima/ultima4/game/person.cpp
+++ b/engines/ultima/ultima4/game/person.cpp
@@ -370,28 +370,28 @@ Common::String Person::processResponse(Conversation *cnv, Response *response) {
}
void Person::runCommand(Conversation *cnv, const ResponsePart &command) {
- if (command == ResponsePart::ASK) {
+ if (command == g_responseParts->ASK) {
cnv->_question = _dialogue->getQuestion();
cnv->_state = Conversation::ASK;
- } else if (command == ResponsePart::END) {
+ } else if (command == g_responseParts->END) {
cnv->_state = Conversation::DONE;
- } else if (command == ResponsePart::ATTACK) {
+ } else if (command == g_responseParts->ATTACK) {
cnv->_state = Conversation::ATTACK;
- } else if (command == ResponsePart::BRAGGED) {
+ } else if (command == g_responseParts->BRAGGED) {
g_context->_party->adjustKarma(KA_BRAGGED);
- } else if (command == ResponsePart::HUMBLE) {
+ } else if (command == g_responseParts->HUMBLE) {
g_context->_party->adjustKarma(KA_HUMBLE);
- } else if (command == ResponsePart::ADVANCELEVELS) {
+ } else if (command == g_responseParts->ADVANCELEVELS) {
cnv->_state = Conversation::ADVANCELEVELS;
- } else if (command == ResponsePart::HEALCONFIRM) {
+ } else if (command == g_responseParts->HEALCONFIRM) {
cnv->_state = Conversation::CONFIRMATION;
- } else if (command == ResponsePart::STARTMUSIC_LB) {
+ } else if (command == g_responseParts->STARTMUSIC_LB) {
g_music->lordBritish();
- } else if (command == ResponsePart::STARTMUSIC_HW) {
+ } else if (command == g_responseParts->STARTMUSIC_HW) {
g_music->hawkwind();
- } else if (command == ResponsePart::STOPMUSIC) {
+ } else if (command == g_responseParts->STOPMUSIC) {
g_music->play();
- } else if (command == ResponsePart::HAWKWIND) {
+ } else if (command == g_responseParts->HAWKWIND) {
g_context->_party->adjustKarma(KA_HAWKWIND);
} else {
error("unknown command trigger in dialogue response: %s\n", Common::String(command).c_str());
@@ -406,10 +406,10 @@ Common::String Person::getResponse(Conversation *cnv, const char *inquiry) {
reply = "\n";
/* Does the person take action during the conversation? */
- if (action == ResponsePart::END) {
+ if (action == g_responseParts->END) {
runCommand(cnv, action);
return _dialogue->getPronoun() + " turns away!\n";
- } else if (action == ResponsePart::ATTACK) {
+ } else if (action == g_responseParts->ATTACK) {
runCommand(cnv, action);
return Common::String("\n") + getName() + " says: On guard! Fool!";
}
diff --git a/engines/ultima/ultima4/ultima4.cpp b/engines/ultima/ultima4/ultima4.cpp
index 4b1a7c57cc..d4e305a128 100644
--- a/engines/ultima/ultima4/ultima4.cpp
+++ b/engines/ultima/ultima4/ultima4.cpp
@@ -22,6 +22,7 @@
#include "ultima/ultima4/ultima4.h"
#include "ultima/ultima4/controllers/intro_controller.h"
+#include "ultima/ultima4/conversation/conversation.h"
#include "ultima/ultima4/conversation/dialogueloader.h"
#include "ultima/ultima4/core/config.h"
#include "ultima/ultima4/core/debugger.h"
@@ -57,8 +58,9 @@ Ultima4Engine::Ultima4Engine(OSystem *syst, const Ultima::UltimaGameDescription
Shared::UltimaEngine(syst, gameDesc), _saveSlotToLoad(-1), _armors(nullptr),
_codex(nullptr), _config(nullptr), _context(nullptr), _dialogueLoaders(nullptr),
_game(nullptr), _music(nullptr), _imageLoaders(nullptr), _mapLoaders(nullptr),
- _moongates(nullptr), _saveGame(nullptr), _screen(nullptr), _shrines(nullptr),
- _tileMaps(nullptr), _tileRules(nullptr), _tileSets(nullptr), _weapons(nullptr) {
+ _moongates(nullptr), _responseParts(nullptr), _saveGame(nullptr), _screen(nullptr),
+ _shrines(nullptr), _tileMaps(nullptr), _tileRules(nullptr), _tileSets(nullptr),
+ _weapons(nullptr) {
g_ultima = this;
g_armors = nullptr;
g_codex = nullptr;
@@ -66,6 +68,7 @@ Ultima4Engine::Ultima4Engine(OSystem *syst, const Ultima::UltimaGameDescription
g_game = nullptr;
g_mapLoaders = nullptr;
g_moongates = nullptr;
+ g_responseParts = nullptr;
g_screen = nullptr;
g_shrines = nullptr;
g_tileMaps = nullptr;
@@ -85,6 +88,7 @@ Ultima4Engine::~Ultima4Engine() {
delete _mapLoaders;
delete _moongates;
delete _music;
+ delete _responseParts;
delete _saveGame;
delete _screen;
delete _shrines;
@@ -111,6 +115,7 @@ bool Ultima4Engine::initialize() {
_dialogueLoaders = new DialogueLoaders();
_mapLoaders = new MapLoaders();
_moongates = new Moongates();
+ _responseParts = new ResponseParts();
_screen = new Screen();
_screen->init();
_shrines = new Shrines();
diff --git a/engines/ultima/ultima4/ultima4.h b/engines/ultima/ultima4/ultima4.h
index cd6138e233..0b98e08988 100644
--- a/engines/ultima/ultima4/ultima4.h
+++ b/engines/ultima/ultima4/ultima4.h
@@ -39,6 +39,7 @@ class GameController;
class MapLoaders;
class Moongates;
class Music;
+class ResponseParts;
struct SaveGame;
class Screen;
class Shrines;
@@ -73,6 +74,7 @@ public:
MapLoaders *_mapLoaders;
Moongates *_moongates;
Music *_music;
+ ResponseParts *_responseParts;
SaveGame *_saveGame;
Screen *_screen;
Shrines *_shrines;
Commit: ced08c2c4bde2d03ba610091d4e41a5c2ed22d17
https://github.com/scummvm/scummvm/commit/ced08c2c4bde2d03ba610091d4e41a5c2ed22d17
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-27T22:00:06-07:00
Commit Message:
ULTIMA4: Refactor death code into it's own class
Changed paths:
engines/ultima/ultima4/controllers/combat_controller.cpp
engines/ultima/ultima4/controllers/game_controller.cpp
engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
engines/ultima/ultima4/events/event_handler.cpp
engines/ultima/ultima4/filesys/filesystem.cpp
engines/ultima/ultima4/game/death.cpp
engines/ultima/ultima4/game/death.h
engines/ultima/ultima4/game/game.cpp
engines/ultima/ultima4/ultima4.cpp
engines/ultima/ultima4/ultima4.h
diff --git a/engines/ultima/ultima4/controllers/combat_controller.cpp b/engines/ultima/ultima4/controllers/combat_controller.cpp
index b12e260d3b..2662b6823a 100644
--- a/engines/ultima/ultima4/controllers/combat_controller.cpp
+++ b/engines/ultima/ultima4/controllers/combat_controller.cpp
@@ -318,7 +318,7 @@ void CombatController::end(bool adjustKarma) {
if (_creature)
g_context->_location->_map->removeObject(_creature);
- deathStart(5);
+ g_death->start(5);
}
else {
diff --git a/engines/ultima/ultima4/controllers/game_controller.cpp b/engines/ultima/ultima4/controllers/game_controller.cpp
index f53d6db163..ad1a6e98c3 100644
--- a/engines/ultima/ultima4/controllers/game_controller.cpp
+++ b/engines/ultima/ultima4/controllers/game_controller.cpp
@@ -238,7 +238,7 @@ void GameController::finishTurn() {
break;
if (g_context->_party->isDead()) {
- deathStart(0);
+ g_death->start(0);
return;
} else {
g_screen->screenMessage("Zzzzzz\n");
@@ -262,7 +262,7 @@ void GameController::finishTurn() {
// extra turn after party death and do some things
// that could cause a crash, like Hole up and Camp.
if (g_context->_party->isDead()) {
- deathStart(0);
+ g_death->start(0);
return;
}
}
diff --git a/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp b/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
index 1f4355de50..9d43671a37 100644
--- a/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
+++ b/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
@@ -30,9 +30,6 @@
namespace Ultima {
namespace Ultima4 {
-using Common::String;
-using Std::vector;
-
Response *lordBritishGetHelp(const DynamicResponse *resp);
Response *lordBritishGetIntro(const DynamicResponse *resp);
diff --git a/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp b/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
index 9ac3e9c0f5..392fa80c02 100644
--- a/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
+++ b/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
@@ -28,8 +28,6 @@
namespace Ultima {
namespace Ultima4 {
-using Common::String;
-
/**
* A dialogue loader for standard u4dos .tlk files.
*/
diff --git a/engines/ultima/ultima4/events/event_handler.cpp b/engines/ultima/ultima4/events/event_handler.cpp
index 8bee51a8f6..6724cf0b24 100644
--- a/engines/ultima/ultima4/events/event_handler.cpp
+++ b/engines/ultima/ultima4/events/event_handler.cpp
@@ -35,8 +35,6 @@
namespace Ultima {
namespace Ultima4 {
-using namespace Std;
-
bool EventHandler::_controllerDone = false;
bool EventHandler::_ended = false;
diff --git a/engines/ultima/ultima4/filesys/filesystem.cpp b/engines/ultima/ultima4/filesys/filesystem.cpp
index 97cd37ff32..fae3b96a58 100644
--- a/engines/ultima/ultima4/filesys/filesystem.cpp
+++ b/engines/ultima/ultima4/filesys/filesystem.cpp
@@ -31,10 +31,6 @@ namespace Ultima4 {
const char Path::delim = '/';
-#if !defined(S_IFDIR)
-#define S_IFDIR _S_IFDIR
-#endif
-
Path::Path(const Common::String &p) : path(p) {
uint pos;
bool _exists = false, isDir = false;
diff --git a/engines/ultima/ultima4/game/death.cpp b/engines/ultima/ultima4/game/death.cpp
index eced29991d..363bd3782d 100644
--- a/engines/ultima/ultima4/game/death.cpp
+++ b/engines/ultima/ultima4/game/death.cpp
@@ -42,22 +42,17 @@
namespace Ultima {
namespace Ultima4 {
+Death *g_death;
+
#define REVIVE_WORLD_X 86
#define REVIVE_WORLD_Y 107
#define REVIVE_CASTLE_X 19
#define REVIVE_CASTLE_Y 8
-int timerCount;
-uint timerMsg;
-int deathSequenceRunning = 0;
-
-void deathTimer(void *data);
-void deathRevive();
-
const struct {
- int timeout; /* pause in seconds */
- const char *text; /* text of message */
-} deathMsgs[] = {
+ int _timeout; ///< pause in seconds
+ const char *_text; ///< text of message
+} DEATH_MSGS[] = {
{ 5, "\n\n\nAll is Dark...\n" },
{ 5, "\nBut wait...\n" },
{ 5, "Where am I?...\n" },
@@ -68,9 +63,17 @@ const struct {
{ 5, "\nLord British says: I have pulled thy spirit and some possessions from the void. Be more careful in the future!\n\n\020" }
};
-#define N_MSGS (sizeof(deathMsgs) / sizeof(deathMsgs[0]))
+#define N_MSGS (sizeof(DEATH_MSGS) / sizeof(DEATH_MSGS[0]))
+
+Death::Death() : timerCount(0), timerMsg(0), deathSequenceRunning(false) {
+ g_death = this;
+}
+
+Death::~Death() {
+ g_death = nullptr;
+}
-void deathStart(int delay) {
+void Death::start(int delay) {
if (deathSequenceRunning)
return;
@@ -93,39 +96,37 @@ void deathStart(int delay) {
eventHandler->getTimer()->add(&deathTimer, settings._gameCyclesPerSecond);
}
-void deathTimer(void *data) {
-
- timerCount++;
- if ((timerMsg < N_MSGS) && (timerCount > deathMsgs[timerMsg].timeout)) {
+void Death::deathTimer(void *data) {
+ g_death->timerCount++;
+ if ((g_death->timerMsg < N_MSGS) && (g_death->timerCount > DEATH_MSGS[g_death->timerMsg]._timeout)) {
- g_screen->screenMessage(deathMsgs[timerMsg].text, g_context->_party->member(0)->getName().c_str());
+ g_screen->screenMessage(DEATH_MSGS[g_death->timerMsg]._text, g_context->_party->member(0)->getName().c_str());
g_screen->screenHideCursor();
- timerCount = 0;
- timerMsg++;
+ g_death->timerCount = 0;
+ g_death->timerMsg++;
- if (timerMsg >= N_MSGS) {
+ if (g_death->timerMsg >= N_MSGS) {
eventHandler->getTimer()->remove(&deathTimer);
- deathRevive();
+ g_death->revive();
}
}
}
-void deathRevive() {
+void Death::revive() {
while (!g_context->_location->_map->isWorldMap() && g_context->_location->_prev != nullptr) {
g_game->exitToParentMap();
}
eventHandler->setController(g_game);
- deathSequenceRunning = 0;
+ deathSequenceRunning = false;
gameSetViewMode(VIEW_NORMAL);
- /* Move our world map location to Lord British's Castle */
+ // Move our world map location to Lord British's Castle
g_context->_location->_coords = g_context->_location->_map->_portals[0]->_coords;
- /* Now, move the avatar into the castle and put him
- in front of Lord British */
+ // Now, move the avatar into the castle and put him in front of Lord British
g_game->setMap(mapMgr->get(100), 1, nullptr);
g_context->_location->_coords.x = REVIVE_CASTLE_X;
g_context->_location->_coords.y = REVIVE_CASTLE_Y;
diff --git a/engines/ultima/ultima4/game/death.h b/engines/ultima/ultima4/game/death.h
index 0aca84a39b..98e51defab 100644
--- a/engines/ultima/ultima4/game/death.h
+++ b/engines/ultima/ultima4/game/death.h
@@ -23,10 +23,38 @@
#ifndef ULTIMA4_GAME_DEATH_H
#define ULTIMA4_GAME_DEATH_H
+#include "common/scummsys.h"
+
namespace Ultima {
namespace Ultima4 {
-void deathStart(int delay);
+class Death {
+private:
+ int timerCount;
+ uint timerMsg;
+ bool deathSequenceRunning;
+private:
+ /**
+ * Timer
+ */
+ static void deathTimer(void *data);
+
+ void revive();
+public:
+ /**
+ * Constructor
+ */
+ Death();
+
+ /**
+ * Destructor
+ */
+ ~Death();
+
+ void start(int delay);
+};
+
+extern Death *g_death;
} // End of namespace Ultima4
} // End of namespace Ultima
diff --git a/engines/ultima/ultima4/game/game.cpp b/engines/ultima/ultima4/game/game.cpp
index 4b0ef2aa9d..721f8544b3 100644
--- a/engines/ultima/ultima4/game/game.cpp
+++ b/engines/ultima/ultima4/game/game.cpp
@@ -387,7 +387,7 @@ void gameCheckHullIntegrity() {
}
g_screen->update();
- deathStart(5);
+ g_death->start(5);
}
}
diff --git a/engines/ultima/ultima4/ultima4.cpp b/engines/ultima/ultima4/ultima4.cpp
index d4e305a128..76643f82aa 100644
--- a/engines/ultima/ultima4/ultima4.cpp
+++ b/engines/ultima/ultima4/ultima4.cpp
@@ -33,6 +33,7 @@
#include "ultima/ultima4/game/armor.h"
#include "ultima/ultima4/game/codex.h"
#include "ultima/ultima4/game/context.h"
+#include "ultima/ultima4/game/death.h"
#include "ultima/ultima4/game/game.h"
#include "ultima/ultima4/game/moongate.h"
#include "ultima/ultima4/game/person.h"
@@ -56,15 +57,16 @@ Ultima4Engine *g_ultima;
Ultima4Engine::Ultima4Engine(OSystem *syst, const Ultima::UltimaGameDescription *gameDesc) :
Shared::UltimaEngine(syst, gameDesc), _saveSlotToLoad(-1), _armors(nullptr),
- _codex(nullptr), _config(nullptr), _context(nullptr), _dialogueLoaders(nullptr),
- _game(nullptr), _music(nullptr), _imageLoaders(nullptr), _mapLoaders(nullptr),
- _moongates(nullptr), _responseParts(nullptr), _saveGame(nullptr), _screen(nullptr),
- _shrines(nullptr), _tileMaps(nullptr), _tileRules(nullptr), _tileSets(nullptr),
- _weapons(nullptr) {
+ _codex(nullptr), _config(nullptr), _context(nullptr), _death(nullptr),
+ _dialogueLoaders(nullptr), _game(nullptr), _music(nullptr), _imageLoaders(nullptr),
+ _mapLoaders(nullptr), _moongates(nullptr), _responseParts(nullptr), _saveGame(nullptr),
+ _screen(nullptr), _shrines(nullptr), _tileMaps(nullptr), _tileRules(nullptr),
+ _tileSets(nullptr), _weapons(nullptr) {
g_ultima = this;
g_armors = nullptr;
g_codex = nullptr;
g_context = nullptr;
+ g_death = nullptr;
g_game = nullptr;
g_mapLoaders = nullptr;
g_moongates = nullptr;
@@ -82,6 +84,7 @@ Ultima4Engine::~Ultima4Engine() {
delete _codex;
delete _config;
delete _context;
+ delete _death;
delete _dialogueLoaders;
delete _game;
delete _imageLoaders;
@@ -112,6 +115,7 @@ bool Ultima4Engine::initialize() {
_armors = new Armors();
_codex = new Codex();
_context = new Context();
+ _death = new Death();
_dialogueLoaders = new DialogueLoaders();
_mapLoaders = new MapLoaders();
_moongates = new Moongates();
diff --git a/engines/ultima/ultima4/ultima4.h b/engines/ultima/ultima4/ultima4.h
index 0b98e08988..db9b63acc4 100644
--- a/engines/ultima/ultima4/ultima4.h
+++ b/engines/ultima/ultima4/ultima4.h
@@ -33,6 +33,7 @@ class Armors;
class Codex;
class Config;
class Context;
+class Death;
class DialogueLoaders;
class ImageLoaders;
class GameController;
@@ -68,6 +69,7 @@ public:
Codex *_codex;
Config *_config;
Context *_context;
+ Death *_death;
DialogueLoaders *_dialogueLoaders;
ImageLoaders *_imageLoaders;
GameController *_game;
More information about the Scummvm-git-logs
mailing list