[Scummvm-cvs-logs] SF.net SVN: scummvm:[48731] scummvm/trunk/engines/mohawk

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Mon Apr 19 22:28:37 CEST 2010


Revision: 48731
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48731&view=rev
Author:   mthreepwood
Date:     2010-04-19 20:28:36 +0000 (Mon, 19 Apr 2010)

Log Message:
-----------
Remove use of global constructors in Mohawk.

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/graphics.cpp
    scummvm/trunk/engines/mohawk/graphics.h
    scummvm/trunk/engines/mohawk/riven.cpp
    scummvm/trunk/engines/mohawk/riven.h

Modified: scummvm/trunk/engines/mohawk/graphics.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.cpp	2010-04-19 20:27:34 UTC (rev 48730)
+++ scummvm/trunk/engines/mohawk/graphics.cpp	2010-04-19 20:28:36 UTC (rev 48731)
@@ -613,11 +613,11 @@
 	// bool hasTrapBook = *_vm->matchVarToString("atrapbook") != 0;
 
 	if (!hasCathBook) {
-		drawInventoryImage(101, atrusJournalRectSolo);
+		drawInventoryImage(101, g_atrusJournalRectSolo);
 	} else {
-		drawInventoryImage(101, atrusJournalRect);
-		drawInventoryImage(102, cathJournalRect);
-		drawInventoryImage(100, trapBookRect);
+		drawInventoryImage(101, g_atrusJournalRect);
+		drawInventoryImage(102, g_cathJournalRect);
+		drawInventoryImage(100, g_trapBookRect);
 	}
 
 	_vm->_system->updateScreen();
@@ -648,12 +648,12 @@
 	_vm->_system->unlockScreen();
 }
 
-void RivenGraphics::drawInventoryImage(uint16 id, Common::Rect rect) {
+void RivenGraphics::drawInventoryImage(uint16 id, const Common::Rect *rect) {
 	ImageData *imageData = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, id));
 	Graphics::Surface *surface = imageData->getSurface();
 	delete imageData;
 
-	_vm->_system->copyRectToScreen((byte *)surface->pixels, surface->pitch, rect.left, rect.top, surface->w, surface->h);
+	_vm->_system->copyRectToScreen((byte *)surface->pixels, surface->pitch, rect->left, rect->top, surface->w, surface->h);
 
 	surface->free();
 	delete surface;

Modified: scummvm/trunk/engines/mohawk/graphics.h
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.h	2010-04-19 20:27:34 UTC (rev 48730)
+++ scummvm/trunk/engines/mohawk/graphics.h	2010-04-19 20:28:36 UTC (rev 48731)
@@ -174,7 +174,7 @@
 
 	// Inventory
 	void clearInventoryArea();
-	void drawInventoryImage(uint16 id, Common::Rect rect);
+	void drawInventoryImage(uint16 id, const Common::Rect *rect);
 	bool _inventoryDrawn;
 
 	// Screen Related

Modified: scummvm/trunk/engines/mohawk/riven.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven.cpp	2010-04-19 20:27:34 UTC (rev 48730)
+++ scummvm/trunk/engines/mohawk/riven.cpp	2010-04-19 20:28:36 UTC (rev 48731)
@@ -37,6 +37,11 @@
 
 namespace Mohawk {
 
+Common::Rect *g_atrusJournalRectSolo;
+Common::Rect *g_atrusJournalRect;
+Common::Rect *g_cathJournalRect;
+Common::Rect *g_trapBookRect;
+
 MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescription *gamedesc) : MohawkEngine(syst, gamedesc) {
 	_showHotspots = false;
 	_cardData.hasData = false;
@@ -50,6 +55,11 @@
 	SearchMan.addSubDirectoryMatching(_gameDataDir, "data");
 	SearchMan.addSubDirectoryMatching(_gameDataDir, "exe");
 	SearchMan.addSubDirectoryMatching(_gameDataDir, "assets2");
+
+	g_atrusJournalRectSolo = new Common::Rect(295, 402, 313, 426);
+	g_atrusJournalRect = new Common::Rect(222, 402, 240, 426);
+	g_cathJournalRect = new Common::Rect(291, 408, 311, 419);
+	g_trapBookRect = new Common::Rect(363, 396, 386, 432);
 }
 
 MohawkEngine_Riven::~MohawkEngine_Riven() {
@@ -62,6 +72,10 @@
 	delete _loadDialog;
 	delete _optionsDialog;
 	delete _rnd;
+	delete g_atrusJournalRectSolo;
+	delete g_atrusJournalRect;
+	delete g_cathJournalRect;
+	delete g_trapBookRect;
 	_cardData.scripts.clear();
 }
 
@@ -463,21 +477,21 @@
 
 	// Go to the book if a hotspot contains the mouse
 	if (!hasCathBook) {
-		if (atrusJournalRectSolo.contains(_mousePos)) {
+		if (g_atrusJournalRectSolo->contains(_mousePos)) {
 			_gfx->hideInventory();
 			changeToStack(aspit);
 			changeToCard(5);
 		}
 	} else {
-		if (atrusJournalRect.contains(_mousePos)) {
+		if (g_atrusJournalRect->contains(_mousePos)) {
 			_gfx->hideInventory();
 			changeToStack(aspit);
 			changeToCard(5);
-		} else if (cathJournalRect.contains(_mousePos)) {
+		} else if (g_cathJournalRect->contains(_mousePos)) {
 			_gfx->hideInventory();
 			changeToStack(aspit);
 			changeToCard(6);
-		} else if (trapBookRect.contains(_mousePos)) {
+		} else if (g_trapBookRect->contains(_mousePos)) {
 			_gfx->hideInventory();
 			changeToStack(aspit);
 			changeToCard(7);

Modified: scummvm/trunk/engines/mohawk/riven.h
===================================================================
--- scummvm/trunk/engines/mohawk/riven.h	2010-04-19 20:27:34 UTC (rev 48730)
+++ scummvm/trunk/engines/mohawk/riven.h	2010-04-19 20:28:36 UTC (rev 48731)
@@ -66,11 +66,12 @@
 	StackNames = 5
 };
 
-// Rects for the inventory object positions
-static const Common::Rect atrusJournalRectSolo = Common::Rect(295, 402, 313, 426);
-static const Common::Rect atrusJournalRect = Common::Rect(222, 402, 240, 426);
-static const Common::Rect cathJournalRect = Common::Rect(291, 408, 311, 419);
-static const Common::Rect trapBookRect = Common::Rect(363, 396, 386, 432);
+// Rects for the inventory object positions (initialized in
+// MohawkEngine_Riven's constructor).
+extern Common::Rect *g_atrusJournalRectSolo;
+extern Common::Rect *g_atrusJournalRect;
+extern Common::Rect *g_cathJournalRect;
+extern Common::Rect *g_trapBookRect;
 
 struct RivenHotspot {
 	uint16 blstID;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list