aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2012-01-14 14:22:23 +0200
committerFilippos Karapetis2012-01-14 14:22:54 +0200
commit20bcb0545e72e784b0369d005314fef39432818c (patch)
treec955cac42aff3b67dc08af8437738845ff8c3d7d /engines
parent96571d9a7e05338ddb93f4b384e017100beebf65 (diff)
downloadscummvm-rg350-20bcb0545e72e784b0369d005314fef39432818c.tar.gz
scummvm-rg350-20bcb0545e72e784b0369d005314fef39432818c.tar.bz2
scummvm-rg350-20bcb0545e72e784b0369d005314fef39432818c.zip
SCI: When deleting a plane, also delete the items in it
This fixes a crash in GK1 day 2, after using the thermostat outside Mosely's office
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/graphics/frameout.cpp18
-rw-r--r--engines/sci/graphics/frameout.h1
2 files changed, 17 insertions, 2 deletions
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 9f150ae507..1402dc9e4d 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -101,7 +101,7 @@ void GfxFrameout::kernelAddPlane(reg_t object) {
}
void GfxFrameout::kernelUpdatePlane(reg_t object) {
- for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); it++) {
+ for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); ++it) {
if (it->object == object) {
// Read some information
it->priority = readSelectorValue(_segMan, object, SELECTOR(priority));
@@ -178,8 +178,10 @@ void GfxFrameout::kernelUpdatePlane(reg_t object) {
}
void GfxFrameout::kernelDeletePlane(reg_t object) {
+ deletePlaneItems(object);
deletePlanePictures(object);
- for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); it++) {
+
+ for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); ++it) {
if (it->object == object) {
_planes.erase(it);
Common::Rect planeRect;
@@ -276,6 +278,18 @@ void GfxFrameout::kernelDeleteScreenItem(reg_t object) {
_screenItems.remove(itemEntry);
}
+void GfxFrameout::deletePlaneItems(reg_t planeObject) {
+ FrameoutList::iterator listIterator = _screenItems.begin();
+
+ while (listIterator != _screenItems.end()) {
+ reg_t itemPlane = readSelector(_segMan, (*listIterator)->object, SELECTOR(plane));
+ if (planeObject == itemPlane)
+ listIterator = _screenItems.erase(listIterator);
+ else
+ ++listIterator;
+ }
+}
+
FrameoutEntry *GfxFrameout::findScreenItem(reg_t object) {
for (FrameoutList::iterator listIterator = _screenItems.begin(); listIterator != _screenItems.end(); listIterator++) {
FrameoutEntry *itemEntry = *listIterator;
diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h
index a4a0a853e4..8c3cc261d5 100644
--- a/engines/sci/graphics/frameout.h
+++ b/engines/sci/graphics/frameout.h
@@ -94,6 +94,7 @@ public:
void kernelAddScreenItem(reg_t object);
void kernelUpdateScreenItem(reg_t object);
void kernelDeleteScreenItem(reg_t object);
+ void deletePlaneItems(reg_t planeObject);
FrameoutEntry *findScreenItem(reg_t object);
int16 kernelGetHighPlanePri();
void kernelAddPicAt(reg_t planeObj, GuiResourceId pictureId, int16 pictureX, int16 pictureY);