[Scummvm-git-logs] scummvm master -> 0008fab4f50efc6ec81f35555b421c1a07ad567c
bluegr
bluegr at gmail.com
Mon Mar 25 10:42:58 CET 2019
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:
0008fab4f5 SCI: Fix Mac icon bar crash on restart (KQ6, FPFP)
Commit: 0008fab4f50efc6ec81f35555b421c1a07ad567c
https://github.com/scummvm/scummvm/commit/0008fab4f50efc6ec81f35555b421c1a07ad567c
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2019-03-25T11:42:54+02:00
Commit Message:
SCI: Fix Mac icon bar crash on restart (KQ6, FPFP)
Add support for reinitializing the mac icon bar when restarting.
Restarting runs the game's init script which calls KPlatform again.
Prior to this, restarting these games would fail an assertion.
Changed paths:
engines/sci/engine/kmisc.cpp
engines/sci/graphics/maciconbar.cpp
engines/sci/graphics/maciconbar.h
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index e02590a..848cf18 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -503,8 +503,7 @@ reg_t kIconBar(EngineState *s, int argc, reg_t *argv) {
switch (argv[0].toUint16()) {
case 0: // InitIconBar
- for (int i = 0; i < argv[1].toUint16(); i++)
- g_sci->_gfxMacIconBar->addIcon(argv[i + 2]);
+ g_sci->_gfxMacIconBar->initIcons(argv[1].toUint16(), &argv[2]);
break;
case 1: // DisposeIconBar
warning("kIconBar(Dispose)");
diff --git a/engines/sci/graphics/maciconbar.cpp b/engines/sci/graphics/maciconbar.cpp
index c5c2fb9..9b645e4 100644
--- a/engines/sci/graphics/maciconbar.cpp
+++ b/engines/sci/graphics/maciconbar.cpp
@@ -49,6 +49,23 @@ GfxMacIconBar::GfxMacIconBar() {
}
GfxMacIconBar::~GfxMacIconBar() {
+ freeIcons();
+}
+
+void GfxMacIconBar::initIcons(uint16 count, reg_t *objs) {
+ // free icons and reset state in case game is restarting
+ freeIcons();
+ _iconBarItems.clear();
+ _lastX = 0;
+ _inventoryIcon = 0;
+ _allDisabled = true;
+
+ for (uint16 i = 0; i < count; i++) {
+ addIcon(objs[i]);
+ }
+}
+
+void GfxMacIconBar::freeIcons() {
if (_inventoryIcon) {
_inventoryIcon->free();
delete _inventoryIcon;
diff --git a/engines/sci/graphics/maciconbar.h b/engines/sci/graphics/maciconbar.h
index 86cbc74..21d28df 100644
--- a/engines/sci/graphics/maciconbar.h
+++ b/engines/sci/graphics/maciconbar.h
@@ -38,7 +38,7 @@ public:
GfxMacIconBar();
~GfxMacIconBar();
- void addIcon(reg_t obj);
+ void initIcons(uint16 count, reg_t *objs);
void drawIcons();
void setIconEnabled(int16 index, bool enabled);
void setInventoryIcon(int16 icon);
@@ -63,6 +63,8 @@ private:
Graphics::Surface *createImage(uint32 iconIndex, bool isSelected);
void remapColors(Graphics::Surface *surf, const byte *palette);
+ void freeIcons();
+ void addIcon(reg_t obj);
void drawIcon(uint16 index, bool selected);
void drawSelectedImage(uint16 index);
bool isIconEnabled(uint16 index) const;
More information about the Scummvm-git-logs
mailing list