[Scummvm-git-logs] scummvm master -> e24230b7b13e60282b73f244fbd8d6692d75535c
bluegr
noreply at scummvm.org
Thu May 7 01:17:29 UTC 2026
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
c5375dd88e MM: MM1: use constexpr to avoid global constructors
e24230b7b1 MM: MM1: move global array to g_globals to avoid global constructor
Commit: c5375dd88e2adf35335922147a2f7bac4868ed06
https://github.com/scummvm/scummvm/commit/c5375dd88e2adf35335922147a2f7bac4868ed06
Author: Michael Kuerbis (michael_kuerbis at web.de)
Date: 2026-05-07T04:17:25+03:00
Commit Message:
MM: MM1: use constexpr to avoid global constructors
Changed paths:
engines/mm/mm1/views/title.cpp
diff --git a/engines/mm/mm1/views/title.cpp b/engines/mm/mm1/views/title.cpp
index 40b602afc19..39211cef572 100644
--- a/engines/mm/mm1/views/title.cpp
+++ b/engines/mm/mm1/views/title.cpp
@@ -36,8 +36,8 @@ namespace Views {
#define SCENE_SECONDS 5
#define TEXT_SCENE_SECONDS 12
-static const Common::Rect START_GAME_BOUNDS(23, 164, 157, 173);
-static const Common::Rect SCENES_BOUNDS(162, 164, 292, 173);
+static constexpr Common::Rect START_GAME_BOUNDS(Common::Point(23, 164), 157 - 23, 173 - 164);
+static constexpr Common::Rect SCENES_BOUNDS(Common::Point(162, 164), 292 - 162, 173 - 164);
Title::Title() : UIElement("Title", g_engine) {
_bounds = Common::Rect(0, 0, SCREEN_W, SCREEN_H);
Commit: e24230b7b13e60282b73f244fbd8d6692d75535c
https://github.com/scummvm/scummvm/commit/e24230b7b13e60282b73f244fbd8d6692d75535c
Author: Michael Kuerbis (michael_kuerbis at web.de)
Date: 2026-05-07T04:17:25+03:00
Commit Message:
MM: MM1: move global array to g_globals to avoid global constructor
Changed paths:
engines/mm/mm1/data/character.h
engines/mm/mm1/globals.cpp
engines/mm/mm1/globals.h
engines/mm/mm1/views_enh/create_characters.cpp
diff --git a/engines/mm/mm1/data/character.h b/engines/mm/mm1/data/character.h
index 3d5b22d8108..a6a1702a934 100644
--- a/engines/mm/mm1/data/character.h
+++ b/engines/mm/mm1/data/character.h
@@ -603,6 +603,12 @@ struct Character : public PrimaryAttributes {
}
};
+struct SuggestedName {
+ CharacterClass _class;
+ Sex _sex;
+ Common::String _name;
+};
+
} // namespace MM1
} // namespace MM
diff --git a/engines/mm/mm1/globals.cpp b/engines/mm/mm1/globals.cpp
index 3ed1332759f..7602c112fa3 100644
--- a/engines/mm/mm1/globals.cpp
+++ b/engines/mm/mm1/globals.cpp
@@ -40,6 +40,7 @@ Globals::Globals() {
Globals::~Globals() {
delete _monsters;
+ delete _suggestedNames;
g_globals = nullptr;
}
diff --git a/engines/mm/mm1/globals.h b/engines/mm/mm1/globals.h
index aa4c85c5809..9c47d491c98 100644
--- a/engines/mm/mm1/globals.h
+++ b/engines/mm/mm1/globals.h
@@ -60,6 +60,7 @@ public:
byte _delay = 5;
int _nonCombatEffectCtr = 0, _combatEffectCtr = 0;
bool _minimapOn = false;
+ Common::Array<SuggestedName> *_suggestedNames = nullptr;
// Console flags
bool _intangible = false;
diff --git a/engines/mm/mm1/views_enh/create_characters.cpp b/engines/mm/mm1/views_enh/create_characters.cpp
index c4d61445529..27109894929 100644
--- a/engines/mm/mm1/views_enh/create_characters.cpp
+++ b/engines/mm/mm1/views_enh/create_characters.cpp
@@ -39,15 +39,6 @@ namespace ViewsEnh {
#define NAME_CANCEL_X 51
#define NAME_CONFIRM_Y 15
-struct SuggestedName {
- CharacterClass _class;
- Sex _sex;
- Common::String _name;
-};
-
-static Common::Array<SuggestedName> g_suggestedNames;
-static bool g_suggestedNamesLoaded = false;
-
static bool openSuggestedNamesFile(Common::File &f, Common::Path &filename) {
filename = Common::Path(NAMES_FILENAME);
if (f.open(filename))
@@ -67,21 +58,21 @@ static void addSuggestedName(CharacterClass classId, Sex sexId,
entry._class = classId;
entry._sex = sexId;
entry._name = name;
- g_suggestedNames.push_back(entry);
+ g_globals->_suggestedNames->push_back(entry);
}
static void loadSuggestedNames() {
- if (g_suggestedNamesLoaded)
+ if (g_globals->_suggestedNames)
return;
+ g_globals->_suggestedNames = new Common::Array<SuggestedName>();
+
Common::File f;
Common::Path filename;
if (!openSuggestedNamesFile(f, filename)) {
warning("MM1: Could not open suggested names file");
- g_suggestedNamesLoaded = true;
return;
}
- g_suggestedNamesLoaded = true;
int invalidLines = 0;
while (!f.eos()) {
@@ -733,20 +724,21 @@ void CreateCharacters::enterFunc(const Common::String &name) {
Common::String CreateCharacters::getSuggestedName() {
loadSuggestedNames();
- if (g_suggestedNames.empty()) {
+ const auto &suggestedNames = *g_globals->_suggestedNames;
+ if (suggestedNames.empty()) {
return "";
}
Common::Array<uint> matches;
- for (uint i = 0; i < g_suggestedNames.size(); ++i) {
- if (g_suggestedNames[i]._class == _newChar._class &&
- g_suggestedNames[i]._sex == _newChar._sex)
+ for (uint i = 0; i < suggestedNames.size(); ++i) {
+ if (suggestedNames[i]._class == _newChar._class &&
+ suggestedNames[i]._sex == _newChar._sex)
matches.push_back(i);
}
if (matches.empty()) {
- for (uint i = 0; i < g_suggestedNames.size(); ++i) {
- if (g_suggestedNames[i]._class == _newChar._class)
+ for (uint i = 0; i < suggestedNames.size(); ++i) {
+ if (suggestedNames[i]._class == _newChar._class)
matches.push_back(i);
}
}
@@ -756,7 +748,7 @@ Common::String CreateCharacters::getSuggestedName() {
}
uint idx = matches.size() == 1 ? matches[0] : matches[g_engine->getRandomNumber(matches.size()) - 1];
- return g_suggestedNames[idx]._name;
+ return suggestedNames[idx]._name;
}
void CreateCharacters::acceptName() {
More information about the Scummvm-git-logs
mailing list