[Scummvm-git-logs] scummvm master -> 24435f5bfcaaab0c78f3c1cce89b08e2fb2c8cd3

a-yyg 76591232+a-yyg at users.noreply.github.com
Fri Jul 16 22:40:00 UTC 2021


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:
9a72b42cf9 SAGA2: Properly initialize gToolBase
32ac17817f SAGA2: Move G_BASE to Saga2Engine
24435f5bfc SAGA2: Fix global constructors in panel.cpp


Commit: 9a72b42cf9cefe0cba46c83bae6c7b728d19a9a2
    https://github.com/scummvm/scummvm/commit/9a72b42cf9cefe0cba46c83bae6c7b728d19a9a2
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-17T07:37:18+09:00

Commit Message:
SAGA2: Properly initialize gToolBase

Changed paths:
    engines/saga2/input.h
    engines/saga2/panel.h


diff --git a/engines/saga2/input.h b/engines/saga2/input.h
index 2b43cb5b7a..081be155a7 100644
--- a/engines/saga2/input.h
+++ b/engines/saga2/input.h
@@ -108,6 +108,11 @@ struct gMouseState {
 	Point16         pos;
 	uint8           right,
 	                left;
+
+	gMouseState() {
+		right = 0;
+		left = 0;
+	}
 };
 
 } // end of namespace Saga2
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index f48334d7a6..28dab122c4 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -238,6 +238,18 @@ public:
 	                qualifier;              // qualifier from keyboard
 
 	uint32          timeStamp;              // time of message
+
+	gPanelMessage() {
+		leftButton = 0;
+		rightButton = 0;
+		inPanel = 0;
+		pointerEnter = 0;
+		pointerLeave = 0;
+		doubleClick = 0;
+		key = 0;
+		qualifier = 0;
+		timeStamp = 0;
+	}
 };
 
 /* ===================================================================== *
@@ -488,6 +500,16 @@ class gToolBase {
 public:
 	bool            mouseHintSet;           // true if mouse hint is up.
 
+	gToolBase() {
+		mouseWindow = nullptr;
+		activeWindow = nullptr;
+		mousePanel = nullptr;
+		activePanel = nullptr;
+		leftDrag = 0;
+		rightDrag = 0;
+		lastMouseMoveTime = 0;
+	}
+
 private:
 	void setMsgQ(gPanelMessage &msg_, gPanel *panel) {
 		if (panel == &panel->window)


Commit: 32ac17817fdc7d5eadc7e3462b302a416f79ec8c
    https://github.com/scummvm/scummvm/commit/32ac17817fdc7d5eadc7e3462b302a416f79ec8c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-17T07:37:18+09:00

Commit Message:
SAGA2: Move G_BASE to Saga2Engine

Changed paths:
    engines/saga2/floating.cpp
    engines/saga2/grequest.cpp
    engines/saga2/main.cpp
    engines/saga2/modal.cpp
    engines/saga2/mouseimg.cpp
    engines/saga2/panel.cpp
    engines/saga2/playmode.cpp
    engines/saga2/saga2.cpp
    engines/saga2/saga2.h
    engines/saga2/tilemode.cpp


diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 62af863240..6ee205e0ed 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -52,8 +52,6 @@ void updateWindowSection(const Rect16 &r);
    Imports
  * ===================================================================== */
 
-extern gToolBase    G_BASE;
-
 //  These externs are imported because the window update routines
 //  need to know about the scrolling tile area.
 
@@ -680,7 +678,7 @@ void updateWindowSection(const Rect16 &r) {
 	//  For each window, both background and float, that overlaps
 	//  the clip, draw the window's imagery
 	if (userControlsSetup) {
-		for (Common::List<gWindow *>::iterator it = G_BASE.bottomWindowIterator(); it != G_BASE.topWindowIterator(); --it)
+		for (Common::List<gWindow *>::iterator it = g_vm->_toolBase->bottomWindowIterator(); it != g_vm->_toolBase->topWindowIterator(); --it)
 			(*it)->drawClipped(tempPort, offset, clip);
 	}
 	//  Now, blit the temporary bitmap to the main screen.
@@ -731,7 +729,7 @@ void drawFloatingWindows(gPort &port, const Point16 &offset, const Rect16 &clip)
 		}
 	}
 
-	for (Common::List<gWindow *>::iterator it = G_BASE.bottomWindowIterator(); it != G_BASE.topWindowIterator(); --it) {
+	for (Common::List<gWindow *>::iterator it = g_vm->_toolBase->bottomWindowIterator(); it != g_vm->_toolBase->topWindowIterator(); --it) {
 		dw = (DecoratedWindow *)(*it);
 		if (!dw->isBackdrop())
 			dw->drawClipped(port, offset, clip);
diff --git a/engines/saga2/grequest.cpp b/engines/saga2/grequest.cpp
index b38d39eeea..706a8b9598 100644
--- a/engines/saga2/grequest.cpp
+++ b/engines/saga2/grequest.cpp
@@ -33,7 +33,6 @@ namespace Saga2 {
 
 extern gFont        *mainFont;
 extern vDisplayPage *drawPage;
-extern gToolBase    G_BASE;
 
 const int           maxLines = 16,
                     maxButtons = 16,
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index ea1a40e784..7639045c27 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -54,7 +54,6 @@ namespace Saga2 {
 // enable the following to display event loop processing
 #define DEBUG_LOOP 0
 
-extern gToolBase        G_BASE;
 extern char            *gameTimeStr;
 extern bool             underground;
 extern char             commandLineHelp[];
@@ -294,10 +293,10 @@ void processEventLoop(bool updateScreen) {
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
 		case Common::EVENT_MOUSEMOVE:
-			G_BASE.handleMouse(event, g_system->getMillis());
+			g_vm->_toolBase->handleMouse(event, g_system->getMillis());
 			break;
 		case Common::EVENT_KEYDOWN:
-			G_BASE.handleKeyStroke(event);
+			g_vm->_toolBase->handleKeyStroke(event);
 			break;
 		case Common::EVENT_QUIT:
 			if (verifyUserExit())
@@ -312,7 +311,7 @@ void processEventLoop(bool updateScreen) {
 	debugC(1, kDebugEventLoop, "EventLoop: timer update");
 	//  Handle the timer events
 	//  REM: Causing code corruption in windows for some reason...
-	G_BASE.handleTimerTick(gameTime >> 2);
+	g_vm->_toolBase->handleTimerTick(gameTime >> 2);
 
 	//  Handle updating of the display.
 	debugC(1, kDebugEventLoop, "EventLoop: display update");
diff --git a/engines/saga2/modal.cpp b/engines/saga2/modal.cpp
index 557600ad16..1695f58a5a 100644
--- a/engines/saga2/modal.cpp
+++ b/engines/saga2/modal.cpp
@@ -34,7 +34,6 @@ namespace Saga2 {
 ModalWindow *mWinPtr;
 
 extern gPixelMap    tileDrawMap;
-extern gToolBase    G_BASE;
 
 APPFUNC(cmdModalWindow);
 
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index ba17395112..531ec2da0a 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -346,11 +346,9 @@ void setMouseText(char *text) {
 //  Formatted version of setMouseText, for gTools use...
 
 void setMouseTextF(char *format, ...) {
-	extern gToolBase G_BASE;
-
 	if (format == nullptr) {
 		setMouseText(nullptr);
-		G_BASE.mouseHintSet = true;
+		g_vm->_toolBase->mouseHintSet = true;
 	} else {
 		char        lineBuf[128];
 		va_list     argptr;
@@ -360,7 +358,7 @@ void setMouseTextF(char *format, ...) {
 		va_end(argptr);
 
 		setMouseText(lineBuf);
-		G_BASE.mouseHintSet = true;
+		g_vm->_toolBase->mouseHintSet = true;
 	}
 }
 
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 412b05cebe..8e3d7a08d6 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -46,7 +46,6 @@ extern bool enableUIKeys(bool enabled);
    global dispatcher base
  * ======================================================================= */
 
-gToolBase           G_BASE;
 gDisplayPort        *globalPort;
 gFont               *mainFont;
 
@@ -117,10 +116,10 @@ gPanel::gPanel(gPanelList &list, const StaticRect &box,
 //  Dummy virtual functions
 
 gPanel::~gPanel() {
-	if (this == G_BASE.mousePanel)
-		G_BASE.mousePanel = NULL;
-	if (this == G_BASE.activePanel)
-		G_BASE.activePanel = NULL;
+	if (this == g_vm->_toolBase->mousePanel)
+		g_vm->_toolBase->mousePanel = NULL;
+	if (this == g_vm->_toolBase->activePanel)
+		g_vm->_toolBase->activePanel = NULL;
 }
 void gPanel::draw(void) {}
 void gPanel::drawClipped(gPort &, const Point16 &, const Rect16 &) {}
@@ -152,7 +151,7 @@ void gPanel::ghost(bool b) {
 }
 
 bool gPanel::isActive(void) {
-	return (this == G_BASE.activePanel);
+	return (this == g_vm->_toolBase->activePanel);
 }
 
 void gPanel::notify(enum gEventType type, int32 value) {
@@ -161,8 +160,8 @@ void gPanel::notify(enum gEventType type, int32 value) {
 	ev.panel = this;
 	ev.eventType = type;
 	ev.value = value;
-	ev.mouse.x = G_BASE.pickPos.x - extent.x;
-	ev.mouse.y = G_BASE.pickPos.y - extent.y;
+	ev.mouse.x = g_vm->_toolBase->pickPos.x - extent.x;
+	ev.mouse.y = g_vm->_toolBase->pickPos.y - extent.y;
 	ev.window = &window;
 
 	if (command) command(ev);
@@ -174,11 +173,11 @@ bool gPanel::activate(gEventType) {
 }
 
 void gPanel::deactivate(void) {
-	if (isActive()) G_BASE.activePanel = NULL;
+	if (isActive()) g_vm->_toolBase->activePanel = NULL;
 }
 
 void gPanel::makeActive(void) {
-	G_BASE.setActive(this);
+	g_vm->_toolBase->setActive(this);
 }
 
 void gPanel::invalidate(Rect16 *) {
@@ -435,10 +434,10 @@ bool gWindow::open(void) {
 
 	//  Send a "pointer-leave" message to mouse panel.
 
-	G_BASE.leavePanel();
-	G_BASE.windowList.push_front(this);
-	G_BASE.activeWindow = this;
-	G_BASE.setActive(NULL);
+	g_vm->_toolBase->leavePanel();
+	g_vm->_toolBase->windowList.push_front(this);
+	g_vm->_toolBase->activeWindow = this;
+	g_vm->_toolBase->setActive(NULL);
 
 //	g_vm->_pointer->hide();
 //	if (backSave) backSave->save( *globalPort );
@@ -456,8 +455,8 @@ void gWindow::close(void) {
 	if (!isOpen()) return;
 
 	//  If any panels on this window are active, then deactivate them.
-	if (G_BASE.activePanel && G_BASE.activePanel->getWindow() == this)
-		G_BASE.activePanel->deactivate();
+	if (g_vm->_toolBase->activePanel && g_vm->_toolBase->activePanel->getWindow() == this)
+		g_vm->_toolBase->activePanel->deactivate();
 
 	//  Don't close a window that is being dragged (should never happen,
 	//  but just in case).
@@ -468,10 +467,10 @@ void gWindow::close(void) {
 
 	//  remove this window from the window list.
 
-	G_BASE.windowList.remove(this);
+	g_vm->_toolBase->windowList.remove(this);
 
-	G_BASE.mouseWindow = G_BASE.activeWindow = G_BASE.windowList.front();
-	G_BASE.mousePanel = G_BASE.activePanel = NULL;
+	g_vm->_toolBase->mouseWindow = g_vm->_toolBase->activeWindow = g_vm->_toolBase->windowList.front();
+	g_vm->_toolBase->mousePanel = g_vm->_toolBase->activePanel = NULL;
 }
 
 //  Move the window to the front...
@@ -479,11 +478,11 @@ void gWindow::close(void) {
 void gWindow::toFront(void) {            // re-order the windows
 	if (!isOpen()) return;
 
-	G_BASE.windowList.remove(this);
-	G_BASE.windowList.push_front(this);
+	g_vm->_toolBase->windowList.remove(this);
+	g_vm->_toolBase->windowList.push_front(this);
 
-	G_BASE.activePanel = NULL;
-	G_BASE.activeWindow = this;
+	g_vm->_toolBase->activePanel = NULL;
+	g_vm->_toolBase->activeWindow = this;
 
 	//  redraw the window
 	update(extent);
@@ -526,7 +525,7 @@ void gWindow::setExtent(const Rect16 &r) {
 
 //  insert window into window list
 void gWindow::insert(void) {
-	G_BASE.windowList.push_front(this);
+	g_vm->_toolBase->windowList.push_front(this);
 }
 
 
@@ -597,7 +596,7 @@ void gWindow::setPointer( gPixelMap &map, int x, int y )
     pointerOffset.x = x;
     pointerOffset.y = y;
 
-    if (this == G_BASE.activeWindow)
+    if (this == g_vm->_toolBase->activeWindow)
     {
         g_vm->_pointer->hide();
         g_vm->_pointer->setImage( *pointerImage, pointerOffset.x, pointerOffset.y );
@@ -1091,7 +1090,7 @@ void HandleTimerTick(long tick) {
 
 	if (tick - lastTick > 1) {
 		lastTick = tick;
-		G_BASE.handleTimerTick(tick);
+		g_vm->_toolBase->handleTimerTick(tick);
 	}
 }
 
@@ -1109,11 +1108,11 @@ void cleanupPanels(void) {
 }
 
 int16 leftButtonState(void) {
-	return G_BASE.msg.leftButton;
+	return g_vm->_toolBase->msg.leftButton;
 }
 
 int16 rightButtonState(void) {
-	return G_BASE.msg.rightButton;
+	return g_vm->_toolBase->msg.rightButton;
 }
 
 void LockUI(bool state) {
@@ -1121,7 +1120,7 @@ void LockUI(bool state) {
 		if (lockUINest <= 0) {
 			g_vm->_pointer->hide();
 			enableUIKeys(false);
-			G_BASE.setActive(NULL);
+			g_vm->_toolBase->setActive(NULL);
 		}
 		lockUINest++;
 	} else {
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index c0b7608c14..8959670619 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -49,7 +49,6 @@ extern gPixelMap    tileDrawMap;
 extern gPort        tileDrawPort;
 extern BackWindow   *mainWindow;
 extern SpriteSet    *objectSprites;        // object sprites
-extern gToolBase    G_BASE;
 
 extern APPFUNC(cmdClickSpeech);
 extern PlayerActor  playerList[];           // a list of the players (brothers)
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index ca9896f7c2..c14dbeedb4 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -42,6 +42,7 @@
 #include "saga2/imagcach.h"
 #include "saga2/mouseimg.h"
 #include "saga2/motion.h"
+#include "saga2/panel.h"
 #include "saga2/spelshow.h"
 
 namespace Saga2 {
@@ -83,6 +84,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
 	_activeSpells = new SpellDisplayList(kMaxActiveSpells);
 	_pointer = new gMousePointer(_mainPort);
 	_activeRegionList = new ActiveRegion[kPlayerActors];
+	_toolBase = new gToolBase;
 
 	_edpList = nullptr;
 	_sdpList = nullptr;
@@ -103,6 +105,7 @@ Saga2Engine::~Saga2Engine() {
 	delete _activeSpells;
 	delete _pointer;
 	delete[] _activeRegionList;
+	delete _toolBase;
 }
 
 Common::Error Saga2Engine::run() {
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 8cc6cae234..125f3b488f 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -63,6 +63,7 @@ class DisplayNodeList;
 class SpellDisplayList;
 class gMousePointer;
 class ActiveRegion;
+class gToolBase;
 
 enum {
 	kDebugResources = 1 << 0,
@@ -140,6 +141,7 @@ public:
 	SpellDisplayList *_activeSpells;
 	gMousePointer *_pointer;
 	ActiveRegion *_activeRegionList;
+	gToolBase *_toolBase;
 
 	gDisplayPort _mainPort;
 
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 2a1b22b48d..c319d57d86 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -179,7 +179,6 @@ GameMode            TileMode = {
 
 const int           runThreshhold = 32;
 
-extern gToolBase    G_BASE;
 extern Alarm        frameAlarm;             // 10 fps frame rate
 Alarm               updateAlarm,            // max coord update rate
                     pathFindAlarm;          // mouse click rate for path find
@@ -695,7 +694,7 @@ void TileModeCleanup(void) {
 	delete tileMapControl;
 
 //	This Fixes the mousePanel That's not set up
-	G_BASE.mousePanel = NULL;
+	g_vm->_toolBase->mousePanel = NULL;
 
 	mainWindow->removeDecorations();
 }
@@ -781,7 +780,7 @@ void TileModeHandleTask(void) {
 		}
 
 
-		if (G_BASE.isMousePanel(tileMapControl)) {
+		if (g_vm->_toolBase->isMousePanel(tileMapControl)) {
 			//  If mouse is near edge of screen, then run.
 			runFlag =       lastMousePos.x < runThreshhold
 			                ||  lastMousePos.x >= kTileRectWidth - runThreshhold


Commit: 24435f5bfcaaab0c78f3c1cce89b08e2fb2c8cd3
    https://github.com/scummvm/scummvm/commit/24435f5bfcaaab0c78f3c1cce89b08e2fb2c8cd3
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-17T07:37:18+09:00

Commit Message:
SAGA2: Fix global constructors in panel.cpp

Changed paths:
    engines/saga2/panel.cpp
    engines/saga2/panel.h


diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 8e3d7a08d6..b44f2dd5bc 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -382,9 +382,9 @@ gPanel *gPanelList::keyTest(int16 key) {
 
 //  gWindow static variables
 
-int             gWindow::dragMode;              // current dragging mode
-Rect16          gWindow::dragExtent;            // dragging extent
-Point16         gWindow::dragOffset;            // offset to window origin
+int           gWindow::dragMode = 0;              // current dragging mode
+StaticRect    gWindow::dragExtent = {0, 0, 0, 0};            // dragging extent
+StaticPoint16 gWindow::dragOffset = {0, 0};            // offset to window origin
 
 gWindow::gWindow(const Rect16 &box, uint16 ident, const char saveName[], AppFunc *cmd)
 	: gPanelList(*this, box, NULL, ident, cmd)
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index 28dab122c4..59d8cc6328 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -359,8 +359,8 @@ private:
 	};
 
 	static int      dragMode;               // current dragging mode
-	static Rect16   dragExtent;             // dragging extent
-	static Point16  dragOffset;             // offset to window origin
+	static StaticRect  dragExtent;             // dragging extent
+	static StaticPoint16 dragOffset;             // offset to window origin
 
 	void shadow(void);
 




More information about the Scummvm-git-logs mailing list