[Scummvm-git-logs] scummvm master -> b880768235ffbbdb6b6d6cfb15043af5c8d8a49a
sev-
sev at scummvm.org
Fri Mar 5 18:12:19 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b880768235 PRIVATE: Avoid global constructors
Commit: b880768235ffbbdb6b6d6cfb15043af5c8d8a49a
https://github.com/scummvm/scummvm/commit/b880768235ffbbdb6b6d6cfb15043af5c8d8a49a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-03-05T19:12:02+01:00
Commit Message:
PRIVATE: Avoid global constructors
Changed paths:
R engines/private/cursors.h
engines/private/code.cpp
engines/private/cursors.cpp
engines/private/private.cpp
engines/private/private.h
diff --git a/engines/private/code.cpp b/engines/private/code.cpp
index 1b3af9cca4..19ddcb58ad 100644
--- a/engines/private/code.cpp
+++ b/engines/private/code.cpp
@@ -53,7 +53,7 @@
namespace Private {
-Gen::VM *Gen::g_vm = new Gen::VM();
+Gen::VM *Gen::g_vm;
void Gen::VM::run() {
Gen::execute(Gen::g_vm->_prog);
@@ -63,10 +63,10 @@ namespace Settings {
using namespace Gen;
-SettingMaps *g_setts = new SettingMaps();
+SettingMaps *g_setts;
/* initialize setting for code generation */
-void SettingMaps::init() {
+void SettingMaps::init() {
_setting = (Setting *)malloc(sizeof(Setting));
memset((void *)_setting, 0, sizeof(Setting));
diff --git a/engines/private/cursors.cpp b/engines/private/cursors.cpp
index 4094fd9615..3581d4dce7 100644
--- a/engines/private/cursors.cpp
+++ b/engines/private/cursors.cpp
@@ -23,7 +23,6 @@
#include "common/rect.h"
#include "graphics/cursorman.h"
-#include "private/cursors.h"
#include "private/private.h"
namespace Private {
@@ -329,15 +328,12 @@ static struct CursorPointTable {
{ 0, {0, 0} }
};
-static CursorDataMap _cursorData;
-static CursorPointMap _cursorPoints;
-
void PrivateEngine::initCursors() {
for (Private::CursorDataTable *cur = Private::cursorDataTable; cur->name; cur++) {
Common::String name(cur->name);
_cursorData.setVal(name, cur->cursor);
}
-
+
for (Private::CursorPointTable *cur = Private::cursorPointTable; cur->name; cur++) {
Common::String name(cur->name);
Common::Point point = Common::Point(cur->coord[0], cur->coord[1]);
diff --git a/engines/private/cursors.h b/engines/private/cursors.h
deleted file mode 100644
index 682863fde6..0000000000
--- a/engines/private/cursors.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PRIVATE_CURSORS_H
-#define PRIVATE_CURSORS_H
-
-#include "common/hash-str.h"
-#include "common/str.h"
-
-namespace Private {
-
-typedef Common::HashMap<Common::String, const byte *> CursorDataMap;
-typedef Common::HashMap<Common::String, Common::Point> CursorPointMap;
-
-} // End of namespace Private
-
-#endif
diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index 154bdd90ca..154c9bd67c 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -36,7 +36,6 @@
#include "engines/util.h"
#include "image/bmp.h"
-#include "private/cursors.h"
#include "private/private.h"
#include "private/tokens.h"
#include "private/grammar.h"
@@ -149,6 +148,9 @@ Common::Error PrivateEngine::run() {
buf[fileSize] = '\0';
// Initialize stuff
+ Gen::g_vm = new Gen::VM();
+ Settings::g_setts = new Settings::SettingMaps();
+
initFuncs();
initCursors();
parse(buf);
@@ -302,7 +304,7 @@ void PrivateEngine::clearAreas() {
_exits.clear();
_masks.clear();
- if (_loadGameMask.surf)
+ if (_loadGameMask.surf)
_loadGameMask.surf->free();
delete _loadGameMask.surf;
_loadGameMask.clear();
@@ -314,7 +316,7 @@ void PrivateEngine::clearAreas() {
if (_policeRadioArea.surf)
_policeRadioArea.surf->free();
- delete _policeRadioArea.surf;
+ delete _policeRadioArea.surf;
_policeRadioArea.clear();
if (_AMRadioArea.surf)
diff --git a/engines/private/private.h b/engines/private/private.h
index ca34cafdc4..334e5362e2 100644
--- a/engines/private/private.h
+++ b/engines/private/private.h
@@ -140,6 +140,9 @@ typedef Common::Array<DossierInfo> DossierArray;
// hash tables
typedef Common::HashMap<Common::String, bool> PlayedMediaTable;
+typedef Common::HashMap<Common::String, const byte *> CursorDataMap;
+typedef Common::HashMap<Common::String, Common::Point> CursorPointMap;
+
class PrivateEngine : public Engine {
private:
@@ -308,6 +311,9 @@ public:
bool installTimer(uint32, Common::String *);
void removeTimer();
+ // Cursors
+ CursorDataMap _cursorData;
+ CursorPointMap _cursorPoints;
};
extern PrivateEngine *g_private;
More information about the Scummvm-git-logs
mailing list