[Scummvm-git-logs] scummvm master -> 51b1381ef9d28c3dddd23efc15c2d9560017ea3b

dreammaster paulfgilbert at gmail.com
Sun Apr 19 03:58:52 UTC 2020


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
130791c308 ULTIMA4: Merge event_scummvm.cpp into event.cpp
51b1381ef9 ULTIMA4: Another compilation fix


Commit: 130791c3083dafcda13eb2a9c3572b5c98c8f87e
    https://github.com/scummvm/scummvm/commit/130791c3083dafcda13eb2a9c3572b5c98c8f87e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-18T20:13:52-07:00

Commit Message:
ULTIMA4: Merge event_scummvm.cpp into event.cpp

Changed paths:
  R engines/ultima/ultima4/events/event_scummvm.cpp
    engines/ultima/module.mk
    engines/ultima/ultima4/events/event.cpp
    engines/ultima/ultima4/events/event.h


diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index 650546f35f..3e64d5067b 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -165,7 +165,6 @@ MODULE_OBJS := \
 	ultima4/core/settings.o \
 	ultima4/core/utils.o \
 	ultima4/events/event.o \
-	ultima4/events/event_scummvm.o \
 	ultima4/events/timed_event_mgr.o \
 	ultima4/filesys/filesystem.o \
 	ultima4/filesys/rle.o \
diff --git a/engines/ultima/ultima4/events/event.cpp b/engines/ultima/ultima4/events/event.cpp
index d1d71c78c5..51a589ac47 100644
--- a/engines/ultima/ultima4/events/event.cpp
+++ b/engines/ultima/ultima4/events/event.cpp
@@ -23,12 +23,14 @@
 #include "ultima/ultima4/events/event.h"
 #include "ultima/ultima4/controllers/wait_controller.h"
 #include "ultima/ultima4/core/settings.h"
+#include "ultima/ultima4/core/utils.h"
 #include "ultima/ultima4/filesys/savegame.h"
 #include "ultima/ultima4/game/context.h"
 #include "ultima/ultima4/game/textview.h"
 #include "ultima/ultima4/gfx/screen.h"
 #include "ultima/ultima4/map/location.h"
 #include "common/events.h"
+#include "common/system.h"
 
 namespace Ultima {
 namespace Ultima4 {
@@ -39,6 +41,10 @@ bool EventHandler::_controllerDone = false;
 bool EventHandler::_ended = false;
 
 EventHandler *EventHandler::_instance = nullptr;
+
+EventHandler::EventHandler() : _timer(settings._eventTimerGranularity), _updateScreen(nullptr) {
+}
+
 EventHandler *EventHandler::getInstance() {
 	if (_instance == nullptr)
 		_instance = new EventHandler();
@@ -58,6 +64,10 @@ void EventHandler::wait_msecs(uint msecs) {
 	EventHandler::sleep(msecs % msecs_per_cycle);
 }
 
+void EventHandler::sleep(uint msec) {
+	g_system->delayMillis(msec);
+}
+
 void EventHandler::wait_cycles(uint cycles) {
 	WaitController waitCtrl(cycles);
 	getInstance()->pushController(&waitCtrl);
@@ -134,5 +144,172 @@ const MouseArea *EventHandler::getMouseAreaSet() const {
 		return nullptr;
 }
 
+void EventHandler::run() {
+	if (_updateScreen)
+		(*_updateScreen)();
+	g_screen->update();
+
+	while (!_ended && !_controllerDone) {
+		Common::Event event;
+		g_system->getEventManager()->pollEvent(event);
+
+		switch (event.type) {
+		case Common::EVENT_KEYDOWN:
+			handleKeyDownEvent(event, getController(), _updateScreen);
+			break;
+
+		case Common::EVENT_LBUTTONDOWN:
+		case Common::EVENT_RBUTTONDOWN:
+		case Common::EVENT_MBUTTONDOWN:
+			handleMouseButtonDownEvent(event, getController(), _updateScreen);
+			break;
+
+		case Common::EVENT_MOUSEMOVE:
+			handleMouseMotionEvent(event);
+			continue;
+
+		case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+			getController()->keybinder((KeybindingAction)event.customType);
+			break;
+
+		case Common::EVENT_QUIT:
+			_ended = true;
+			return;
+
+		default:
+			break;
+		}
+
+		// Brief delay
+		g_system->delayMillis(10);
+
+		// Poll the timer manager
+		_timer.poll();
+	}
+}
+
+void EventHandler::setScreenUpdate(void (*updateScreen)(void)) {
+	_updateScreen = updateScreen;
+}
+
+void EventHandler::pushKeyHandler(KeyHandler kh) {
+	KeyHandler *new_kh = new KeyHandler(kh);
+	KeyHandlerController *khc = new KeyHandlerController(new_kh);
+	pushController(khc);
+}
+
+void EventHandler::popKeyHandler() {
+	if (_controllers.empty())
+		return;
+
+	popController();
+}
+
+KeyHandler *EventHandler::getKeyHandler() const {
+	if (_controllers.empty())
+		return nullptr;
+
+	KeyHandlerController *khc = dynamic_cast<KeyHandlerController *>(_controllers.back());
+	ASSERT(khc != nullptr, "EventHandler::getKeyHandler called when controller wasn't a keyhandler");
+	if (khc == nullptr)
+		return nullptr;
+
+	return khc->getKeyHandler();
+}
+
+void EventHandler::setKeyHandler(KeyHandler kh) {
+	while (popController() != nullptr) {
+	}
+	pushKeyHandler(kh);
+}
+
+const MouseArea *EventHandler::mouseAreaForPoint(int x, int y) {
+	int i;
+	const MouseArea *areas = getMouseAreaSet();
+
+	if (!areas)
+		return nullptr;
+
+	for (i = 0; areas[i]._nPoints != 0; i++) {
+		if (g_screen->screenPointInMouseArea(x, y, &(areas[i]))) {
+			return &(areas[i]);
+		}
+	}
+	return nullptr;
+}
+
+void EventHandler::handleMouseMotionEvent(const Common::Event &event) {
+	if (!settings._mouseOptions._enabled)
+		return;
+
+	const MouseArea *area;
+	area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
+	if (area)
+		g_screen->setMouseCursor(area->_cursor);
+	else
+		g_screen->setMouseCursor(MC_DEFAULT);
+}
+
+void EventHandler::handleMouseButtonDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen) {
+	int button = 0;
+	if (event.type == Common::EVENT_MBUTTONDOWN)
+		button = 1;
+	else if (event.type == Common::EVENT_RBUTTONDOWN)
+		button = 2;
+
+	if (!settings._mouseOptions._enabled)
+		return;
+
+	if (button > 2)
+		button = 0;
+	const MouseArea *area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
+	if (!area || area->_command[button] == 0)
+		return;
+	controller->keyPressed(area->_command[button]);
+	if (updateScreen)
+		(*updateScreen)();
+	g_screen->update();
+}
+
+void EventHandler::handleKeyDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen) {
+	int key;
+	bool processed;
+
+	if (event.kbd.keycode == Common::KEYCODE_UP)
+		key = U4_UP;
+	else if (event.kbd.keycode == Common::KEYCODE_DOWN)
+		key = U4_DOWN;
+	else if (event.kbd.keycode == Common::KEYCODE_LEFT)
+		key = U4_LEFT;
+	else if (event.kbd.keycode == Common::KEYCODE_RIGHT)
+		key = U4_RIGHT;
+	else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE ||
+		event.kbd.keycode == Common::KEYCODE_DELETE)
+		key = U4_BACKSPACE;
+	else {
+		key = event.kbd.ascii;
+		if (!key)
+			return;
+
+		if (event.kbd.flags & Common::KBD_ALT)
+			key += U4_ALT;
+
+		if (event.kbd.flags & Common::KBD_META)
+			key += U4_META;
+	}
+
+	debug(1, "key event: sym = %d, mod = %d; translated = %d",
+		event.kbd.keycode, event.kbd.flags, key);
+
+	/* handle the keypress */
+	processed = controller->notifyKeyPressed(key);
+
+	if (processed) {
+		if (updateScreen)
+			(*updateScreen)();
+		g_screen->update();
+	}
+}
+
 } // End of namespace Ultima4
 } // End of namespace Ultima
diff --git a/engines/ultima/ultima4/events/event.h b/engines/ultima/ultima4/events/event.h
index 00c54cf98b..51f601b4ed 100644
--- a/engines/ultima/ultima4/events/event.h
+++ b/engines/ultima/ultima4/events/event.h
@@ -75,13 +75,23 @@ typedef void(*updateScreenCallback)();
  * A class for handling game events.
  */
 class EventHandler {
-public:
-	/* Typedefs */
 	typedef Common::List<const MouseArea *> MouseAreaList;
-
-	/* Constructors */
+private:
+	static EventHandler *_instance;
+private:
+	void handleMouseMotionEvent(const Common::Event &event);
+	void handleMouseButtonDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen);
+	void handleKeyDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen);
+protected:
+	static bool _controllerDone;
+	static bool _ended;
+	TimedEventMgr _timer;
+	Std::vector<Controller *> _controllers;
+	MouseAreaList _mouseAreaSets;
+	updateScreenCallback _updateScreen;
+public:
 	/**
-	 * Constructs an event handler object.
+	 * Constructor
 	 */
 	EventHandler();
 
@@ -167,17 +177,6 @@ public:
 	const MouseArea *getMouseAreaSet() const;
 
 	const MouseArea *mouseAreaForPoint(int x, int y);
-
-protected:
-	static bool _controllerDone;
-	static bool _ended;
-	TimedEventMgr _timer;
-	Std::vector<Controller *> _controllers;
-	MouseAreaList _mouseAreaSets;
-	updateScreenCallback _updateScreen;
-
-private:
-	static EventHandler *_instance;
 };
 
 } // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/events/event_scummvm.cpp b/engines/ultima/ultima4/events/event_scummvm.cpp
deleted file mode 100644
index 5d90b22d50..0000000000
--- a/engines/ultima/ultima4/events/event_scummvm.cpp
+++ /dev/null
@@ -1,210 +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.
- *
- */
-
-#include "ultima/ultima4/ultima4.h"
-#include "ultima/ultima4/events/event.h"
-#include "ultima/ultima4/game/context.h"
-#include "ultima/ultima4/core/utils.h"
-#include "ultima/ultima4/gfx/screen.h"
-#include "ultima/ultima4/core/settings.h"
-#include "ultima/ultima4/meta_engine.h"
-#include "common/debug.h"
-#include "common/system.h"
-
-namespace Ultima {
-namespace Ultima4 {
-
-EventHandler::EventHandler() : _timer(settings._eventTimerGranularity), _updateScreen(nullptr)  {
-}
-
-static void handleMouseMotionEvent(const Common::Event &event) {
-	if (!settings._mouseOptions._enabled)
-		return;
-
-	const MouseArea *area;
-	area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
-	if (area)
-		g_screen->setMouseCursor(area->_cursor);
-	else
-		g_screen->setMouseCursor(MC_DEFAULT);
-}
-
-static void handleMouseButtonDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen) {
-	int button = 0;
-	if (event.type == Common::EVENT_MBUTTONDOWN)
-		button = 1;
-	else if (event.type == Common::EVENT_RBUTTONDOWN)
-		button = 2;
-
-	if (!settings._mouseOptions._enabled)
-		return;
-
-	if (button > 2)
-		button = 0;
-	const MouseArea *area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
-	if (!area || area->_command[button] == 0)
-		return;
-	controller->keyPressed(area->_command[button]);
-	if (updateScreen)
-		(*updateScreen)();
-	g_screen->update();
-}
-
-static void handleKeyDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen) {
-	int key;
-	bool processed;
-
-	if (event.kbd.keycode == Common::KEYCODE_UP)
-		key = U4_UP;
-	else if (event.kbd.keycode == Common::KEYCODE_DOWN)
-		key = U4_DOWN;
-	else if (event.kbd.keycode == Common::KEYCODE_LEFT)
-		key = U4_LEFT;
-	else if (event.kbd.keycode == Common::KEYCODE_RIGHT)
-		key = U4_RIGHT;
-	else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE ||
-	         event.kbd.keycode == Common::KEYCODE_DELETE)
-		key = U4_BACKSPACE;
-	else {
-		key = event.kbd.ascii;
-		if (!key)
-			return;
-
-		if (event.kbd.flags & Common::KBD_ALT)
-			key += U4_ALT;
-
-		if (event.kbd.flags & Common::KBD_META)
-			key += U4_META;
-	}
-
-	debug(1, "key event: sym = %d, mod = %d; translated = %d",
-		    event.kbd.keycode,  event.kbd.flags,  key);
-
-	/* handle the keypress */
-	processed = controller->notifyKeyPressed(key);
-
-	if (processed) {
-		if (updateScreen)
-			(*updateScreen)();
-		g_screen->update();
-	}
-}
-
-void EventHandler::sleep(uint msec) {
-	g_system->delayMillis(msec);
-}
-
-void EventHandler::run() {
-	if (_updateScreen)
-		(*_updateScreen)();
-	g_screen->update();
-
-	while (!_ended && !_controllerDone) {
-		Common::Event event;
-		g_system->getEventManager()->pollEvent(event);
-
-		switch (event.type) {
-		case Common::EVENT_KEYDOWN:
-			handleKeyDownEvent(event, getController(), _updateScreen);
-			break;
-
-		case Common::EVENT_LBUTTONDOWN:
-		case Common::EVENT_RBUTTONDOWN:
-		case Common::EVENT_MBUTTONDOWN:
-			handleMouseButtonDownEvent(event, getController(), _updateScreen);
-			break;
-
-		case Common::EVENT_MOUSEMOVE:
-			handleMouseMotionEvent(event);
-			continue;
-
-		case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
-			getController()->keybinder((KeybindingAction)event.customType);
-			break;
-
-		case Common::EVENT_QUIT:
-			_ended = true;
-			return;
-
-		default:
-			break;
-		}
-
-		// Brief delay
-		g_system->delayMillis(10);
-
-		// Poll the timer manager
-		_timer.poll();
-	}
-}
-
-void EventHandler::setScreenUpdate(void (*updateScreen)(void)) {
-	this->_updateScreen = updateScreen;
-}
-
-void EventHandler::pushKeyHandler(KeyHandler kh) {
-	KeyHandler *new_kh = new KeyHandler(kh);
-	KeyHandlerController *khc = new KeyHandlerController(new_kh);
-	pushController(khc);
-}
-
-void EventHandler::popKeyHandler() {
-	if (_controllers.empty())
-		return;
-
-	popController();
-}
-
-KeyHandler *EventHandler::getKeyHandler() const {
-	if (_controllers.empty())
-		return nullptr;
-
-	KeyHandlerController *khc = dynamic_cast<KeyHandlerController *>(_controllers.back());
-	ASSERT(khc != nullptr, "EventHandler::getKeyHandler called when controller wasn't a keyhandler");
-	if (khc == nullptr)
-		return nullptr;
-
-	return khc->getKeyHandler();
-}
-
-void EventHandler::setKeyHandler(KeyHandler kh) {
-	while (popController() != nullptr) {}
-	pushKeyHandler(kh);
-}
-
-const MouseArea *EventHandler::mouseAreaForPoint(int x, int y) {
-	int i;
-	const MouseArea *areas = getMouseAreaSet();
-
-	if (!areas)
-		return nullptr;
-
-	for (i = 0; areas[i]._nPoints != 0; i++) {
-		if (g_screen->screenPointInMouseArea(x, y, &(areas[i]))) {
-			return &(areas[i]);
-		}
-	}
-	return nullptr;
-}
-
-} // End of namespace Ultima4
-} // End of namespace Ultima


Commit: 51b1381ef9d28c3dddd23efc15c2d9560017ea3b
    https://github.com/scummvm/scummvm/commit/51b1381ef9d28c3dddd23efc15c2d9560017ea3b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-18T20:58:37-07:00

Commit Message:
ULTIMA4: Another compilation fix

Changed paths:
    engines/ultima/ultima4/map/dungeon.cpp


diff --git a/engines/ultima/ultima4/map/dungeon.cpp b/engines/ultima/ultima4/map/dungeon.cpp
index 3b16bfeae2..0d67dc6c18 100644
--- a/engines/ultima/ultima4/map/dungeon.cpp
+++ b/engines/ultima/ultima4/map/dungeon.cpp
@@ -126,9 +126,9 @@ void dungeonSearch(void) {
 		/* see if there is an item at the current location (stones on altars, etc.) */
 		item = itemAtLocation(dungeon, g_context->_location->_coords);
 		if (item) {
-			if (*item->_isItemInInventory != nullptr && (*item->_isItemInInventory)(item->_data))
+			if (item->_isItemInInventory && (*item->_isItemInInventory)(item->_data)) {
 				g_screen->screenMessage("Nothing Here!\n");
-			else {
+			} else {
 				if (item->_name)
 					g_screen->screenMessage("You find...\n%s!\n", item->_name);
 				(*item->_putItemInInventory)(item->_data);




More information about the Scummvm-git-logs mailing list