aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2008-05-02 15:08:45 +0000
committerJohannes Schickel2008-05-02 15:08:45 +0000
commit7566a12352ff6c5609c8db032a73961d8feffbf9 (patch)
tree3f6bdc939e1df9b9ec2fb7dbafde713366298026
parent52003bc1954d1c2f9c88bb1479e3e0ff24f4e849 (diff)
downloadscummvm-rg350-7566a12352ff6c5609c8db032a73961d8feffbf9.tar.gz
scummvm-rg350-7566a12352ff6c5609c8db032a73961d8feffbf9.tar.bz2
scummvm-rg350-7566a12352ff6c5609c8db032a73961d8feffbf9.zip
Moved common kyra2/kyra3 item to KyraEngine_v2.
svn-id: r31819
-rw-r--r--engines/kyra/items_hof.cpp83
-rw-r--r--engines/kyra/items_mr.cpp78
-rw-r--r--engines/kyra/items_v2.cpp116
-rw-r--r--engines/kyra/kyra_hof.cpp3
-rw-r--r--engines/kyra/kyra_mr.cpp4
-rw-r--r--engines/kyra/kyra_mr.h24
-rw-r--r--engines/kyra/kyra_v2.cpp5
-rw-r--r--engines/kyra/kyra_v2.h30
-rw-r--r--engines/kyra/module.mk1
-rw-r--r--engines/kyra/saveload.cpp2
-rw-r--r--engines/kyra/saveload_hof.cpp4
-rw-r--r--engines/kyra/saveload_mr.cpp4
12 files changed, 170 insertions, 184 deletions
diff --git a/engines/kyra/items_hof.cpp b/engines/kyra/items_hof.cpp
index c20ce5bbb1..da3062fe2c 100644
--- a/engines/kyra/items_hof.cpp
+++ b/engines/kyra/items_hof.cpp
@@ -27,34 +27,6 @@
namespace Kyra {
-int KyraEngine_HoF::findFreeItem() {
- debugC(9, kDebugLevelMain, "KyraEngine_HoF::findFreeItem()");
- for (int i = 0; i < 30; ++i) {
- if (_itemList[i].id == 0xFFFF)
- return i;
- }
- return -1;
-}
-
-int KyraEngine_HoF::countAllItems() {
- debugC(9, kDebugLevelMain, "KyraEngine_HoF::countAllItems()");
- int num = 0;
- for (int i = 0; i < 30; ++i) {
- if (_itemList[i].id != 0xFFFF)
- ++num;
- }
- return num;
-}
-
-int KyraEngine_HoF::findItem(uint16 sceneId, uint16 id) {
- debugC(9, kDebugLevelMain, "KyraEngine_HoF::findItem(%u, %u)", sceneId, id);
- for (int i = 0; i < 30; ++i) {
- if (_itemList[i].id == id && _itemList[i].sceneId == sceneId)
- return i;
- }
- return -1;
-}
-
int KyraEngine_HoF::checkItemCollision(int x, int y) {
debugC(9, kDebugLevelMain, "KyraEngine_HoF::checkItemCollision(%d, %d)", x, y);
int itemPos = -1, yPos = -1;
@@ -86,17 +58,6 @@ int KyraEngine_HoF::checkItemCollision(int x, int y) {
return itemPos;
}
-void KyraEngine_HoF::resetItemList() {
- debugC(9, kDebugLevelMain, "KyraEngine_HoF::resetItemList()");
- for (int i = 0; i < 30; ++i) {
- _itemList[i].id = 0xFFFF;
- _itemList[i].sceneId = 0xFFFF;
- _itemList[i].x = 0;
- _itemList[i].y = 0;
- _itemList[i].unk7 = 0;
- }
-}
-
void KyraEngine_HoF::updateWaterFlasks() {
debugC(9, kDebugLevelMain, "KyraEngine_HoF::updateWaterFlasks()");
for (int i = 22; i < 24; i++) {
@@ -165,7 +126,6 @@ bool KyraEngine_HoF::processItemDrop(uint16 sceneId, uint16 item, int x, int y,
_itemList[freeItemSlot].x = x;
_itemList[freeItemSlot].y = y;
_itemList[freeItemSlot].id = item;
- _itemList[freeItemSlot].unk7 = 1;
_itemList[freeItemSlot].sceneId = sceneId;
return true;
}
@@ -459,6 +419,16 @@ int KyraEngine_HoF::getItemCommandStringInv(uint16 item) {
return pickUpStringIds[stringId];
}
+bool KyraEngine_HoF::itemIsFlask(int item) {
+ debugC(9, kDebugLevelMain, "KyraEngine_HoF::itemIsFlask(%d)", item);
+ for (int i = 0; _flaskTable[i] != -1; ++i) {
+ if (_flaskTable[i] == item)
+ return true;
+ }
+
+ return false;
+}
+
void KyraEngine_HoF::setMouseCursor(uint16 item) {
debugC(9, kDebugLevelMain, "KyraEngine_HoF::setMouseCursor(%u)", item);
int shape = 0;
@@ -474,38 +444,5 @@ void KyraEngine_HoF::setMouseCursor(uint16 item) {
_screen->setMouseCursor(hotX, hotY, getShapePtr(shape));
}
-void KyraEngine_HoF::setHandItem(uint16 item) {
- debugC(9, kDebugLevelMain, "KyraEngine_HoF::setHandItem(%u)", item);
- _screen->hideMouse();
-
- if (item == 0xFFFF) {
- removeHandItem();
- } else {
- setMouseCursor(item);
- _itemInHand = item;
- }
-
- _screen->showMouse();
-}
-
-void KyraEngine_HoF::removeHandItem() {
- debugC(9, kDebugLevelMain, "KyraEngine_HoF::removeHandItem()");
- _screen->hideMouse();
- _screen->setMouseCursor(0, 0, getShapePtr(0));
- _itemInHand = -1;
- _handItemSet = -1;
- _screen->showMouse();
-}
-
-bool KyraEngine_HoF::itemIsFlask(int item) {
- debugC(9, kDebugLevelMain, "KyraEngine_HoF::itemIsFlask(%d)", item);
- for (int i = 0; _flaskTable[i] != -1; ++i) {
- if (_flaskTable[i] == item)
- return true;
- }
-
- return false;
-}
-
} // end of namespace Kyra
diff --git a/engines/kyra/items_mr.cpp b/engines/kyra/items_mr.cpp
index 609d87881e..8ace9f8a3c 100644
--- a/engines/kyra/items_mr.cpp
+++ b/engines/kyra/items_mr.cpp
@@ -28,21 +28,6 @@
namespace Kyra {
-void KyraEngine_MR::resetItem(int index) {
- debugC(9, kDebugLevelMain, "KyraEngine_MR::resetItem(%d)", index);
- _itemList[index].id = 0xFFFF;
- _itemList[index].sceneId = 0xFFFF;
- _itemList[index].x = 0;
- _itemList[index].y = 0;
- _itemList[index].unk8 = 0;
-}
-
-void KyraEngine_MR::resetItemList() {
- debugC(9, kDebugLevelMain, "KyraEngine_MR::resetItemList()");
- for (int i = 0; i < 50; ++i)
- resetItem(i);
-}
-
void KyraEngine_MR::removeTrashItems() {
debugC(9, kDebugLevelMain, "KyraEngine_MR::removeTrashItems()");
for (int i = 0; _trashItemList[i] != 0xFF; ++i) {
@@ -55,15 +40,6 @@ void KyraEngine_MR::removeTrashItems() {
}
}
-int KyraEngine_MR::findFreeItem() {
- debugC(9, kDebugLevelMain, "KyraEngine_MR::findFreeItem()");
- for (int i = 0; i < 50; ++i) {
- if (_itemList[i].id == 0xFFFF)
- return i;
- }
- return -1;
-}
-
int KyraEngine_MR::findFreeInventorySlot() {
debugC(9, kDebugLevelMain, "KyraEngine_MR::findFreeInventorySlot()");
for (int i = 0; i < 10; ++i) {
@@ -73,36 +49,6 @@ int KyraEngine_MR::findFreeInventorySlot() {
return -1;
}
-int KyraEngine_MR::findItem(uint16 sceneId, uint16 id) {
- debugC(9, kDebugLevelMain, "KyraEngine_MR::findItem(%u, %u)", sceneId, id);
- for (int i = 0; i < 50; ++i) {
- if (_itemList[i].id == id && _itemList[i].sceneId == sceneId)
- return i;
- }
- return -1;
-}
-
-int KyraEngine_MR::findItem(uint16 item) {
- debugC(9, kDebugLevelMain, "KyraEngine_MR::findItem(%u)", item);
- for (int i = 0; i < 50; ++i) {
- if (_itemList[i].id == item)
- return i;
- }
- return -1;
-}
-
-int KyraEngine_MR::countAllItems() {
- debugC(9, kDebugLevelMain, "KyraEngine_MR::countAllItems()");
- int count = 0;
-
- for (int i = 0; i < 50; ++i) {
- if (_itemList[i].id != 0xFFFF)
- ++count;
- }
-
- return count;
-}
-
int KyraEngine_MR::checkItemCollision(int x, int y) {
debugC(9, kDebugLevelMain, "KyraEngine_MR::checkItemCollision(%d, %d)", x, y);
int itemIndex = -1;
@@ -158,29 +104,6 @@ void KyraEngine_MR::setItemMouseCursor() {
_screen->setMouseCursor(12, 19, _gameShapes[_itemInHand+248]);
}
-void KyraEngine_MR::setHandItem(uint16 item) {
- debugC(9, kDebugLevelMain, "KyraEngine_MR::setHandItem(%u)", item);
- _screen->hideMouse();
-
- if (item == 0xFFFF) {
- removeHandItem();
- } else {
- setMouseCursor(item);
- _itemInHand = item;
- }
-
- _screen->showMouse();
-}
-
-void KyraEngine_MR::removeHandItem() {
- debugC(9, kDebugLevelMain, "KyraEngine_MR::removeHandItem()");
- _screen->hideMouse();
- _screen->setMouseCursor(0, 0, _gameShapes[0]);
- _itemInHand = -1;
- _handItemSet = -1;
- _screen->showMouse();
-}
-
bool KyraEngine_MR::dropItem(int unk1, uint16 item, int x, int y, int unk2) {
debugC(9, kDebugLevelMain, "KyraEngine_MR::dropItem(%d, %d, %d, %d, %d)", unk1, item, x, y, unk2);
@@ -237,7 +160,6 @@ bool KyraEngine_MR::processItemDrop(uint16 sceneId, uint16 item, int x, int y, i
_itemList[freeItemSlot].x = x;
_itemList[freeItemSlot].y = y;
_itemList[freeItemSlot].id = item;
- _itemList[freeItemSlot].unk8 = 1;
_itemList[freeItemSlot].sceneId = sceneId;
return true;
}
diff --git a/engines/kyra/items_v2.cpp b/engines/kyra/items_v2.cpp
new file mode 100644
index 0000000000..c207a99963
--- /dev/null
+++ b/engines/kyra/items_v2.cpp
@@ -0,0 +1,116 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "kyra/kyra_v2.h"
+#include "kyra/screen_v2.h"
+
+namespace Kyra {
+
+void KyraEngine_v2::initItemList(int size) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v2::initItemList(%d)", size);
+ delete [] _itemList;
+
+ _itemList = new Item[size];
+ _itemListSize = size;
+}
+
+int KyraEngine_v2::findFreeItem() {
+ debugC(9, kDebugLevelMain, "KyraEngine_v2::findFreeItem()");
+ for (int i = 0; i < _itemListSize; ++i) {
+ if (_itemList[i].id == 0xFFFF)
+ return i;
+ }
+ return -1;
+}
+
+int KyraEngine_v2::countAllItems() {
+ debugC(9, kDebugLevelMain, "KyraEngine_v2::countAllItems()");
+ int num = 0;
+ for (int i = 0; i < _itemListSize; ++i) {
+ if (_itemList[i].id != 0xFFFF)
+ ++num;
+ }
+ return num;
+}
+
+int KyraEngine_v2::findItem(uint16 sceneId, uint16 id) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v2::findItem(%u, %u)", sceneId, id);
+ for (int i = 0; i < _itemListSize; ++i) {
+ if (_itemList[i].id == id && _itemList[i].sceneId == sceneId)
+ return i;
+ }
+ return -1;
+}
+
+int KyraEngine_v2::findItem(uint16 item) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v2::findItem(%u)", item);
+ for (int i = 0; i < _itemListSize; ++i) {
+ if (_itemList[i].id == item)
+ return i;
+ }
+ return -1;
+}
+
+void KyraEngine_v2::resetItemList() {
+ debugC(9, kDebugLevelMain, "KyraEngine_v2::resetItemList()");
+ for (int i = 0; i < _itemListSize; ++i)
+ resetItem(i);
+}
+
+void KyraEngine_v2::resetItem(int index) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v2::resetItem(%d)", index);
+ _itemList[index].id = 0xFFFF;
+ _itemList[index].sceneId = 0xFFFF;
+ _itemList[index].x = 0;
+ _itemList[index].y = 0;
+}
+
+void KyraEngine_v2::setHandItem(uint16 item) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v2::setHandItem(%u)", item);
+ Screen *scr = screen();
+ scr->hideMouse();
+
+ if (item == 0xFFFF) {
+ removeHandItem();
+ } else {
+ setMouseCursor(item);
+ _itemInHand = item;
+ }
+
+ scr->showMouse();
+}
+
+void KyraEngine_v2::removeHandItem() {
+ debugC(9, kDebugLevelMain, "KyraEngine_v2::removeHandItem()");
+ Screen *scr = screen();
+ scr->hideMouse();
+ scr->setMouseCursor(0, 0, getShapePtr(0));
+ _itemInHand = -1;
+ _handItemSet = -1;
+ scr->showMouse();
+}
+
+} // end of namesapce Kyra
+
diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp
index e4b7d2b528..0c68de430f 100644
--- a/engines/kyra/kyra_hof.cpp
+++ b/engines/kyra/kyra_hof.cpp
@@ -352,8 +352,7 @@ void KyraEngine_HoF::startup() {
}
_gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)];
- _itemList = new Item[30];
- memset(_itemList, 0, sizeof(Item)*30);
+ initItemList(30);
loadButtonShapes();
resetItemList();
_loadedZTable = 1;
diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp
index a3295f3f38..8193473205 100644
--- a/engines/kyra/kyra_mr.cpp
+++ b/engines/kyra/kyra_mr.cpp
@@ -57,7 +57,6 @@ KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngi
memset(_sceneShapes, 0, sizeof(_sceneShapes));
memset(_sceneAnimMovie, 0, sizeof(_sceneAnimMovie));
_gfxBackUpRect = 0;
- _itemList = 0;
_malcolmShapes = 0;
_paletteOverlay = 0;
_sceneList = 0;
@@ -162,7 +161,6 @@ KyraEngine_MR::~KyraEngine_MR() {
delete _sceneAnimMovie[i];
delete [] _gfxBackUpRect;
- delete [] _itemList;
delete [] _paletteOverlay;
delete [] _sceneList;
@@ -591,7 +589,7 @@ void KyraEngine_MR::startup() {
musicUpdate(0);
updateMalcolmShapes();
_gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)];
- _itemList = new Item[50];
+ initItemList(50);
resetItemList();
loadShadowShape();
diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h
index e166998bc8..36a83e0719 100644
--- a/engines/kyra/kyra_mr.h
+++ b/engines/kyra/kyra_mr.h
@@ -261,27 +261,11 @@ private:
// items
int8 *_itemBuffer1;
int8 *_itemBuffer2;
- struct Item {
- uint16 id;
- uint16 sceneId;
- int16 x, y;
- uint16 unk8;
- };
-
- Item *_itemList;
uint16 _hiddenItems[100];
- void resetItem(int index);
- void resetItemList();
static const uint8 _trashItemList[];
void removeTrashItems();
- int findFreeItem();
- int findItem(uint16 item, uint16 scene);
- int findItem(uint16 item);
-
- int countAllItems();
-
void initItems();
int checkItemCollision(int x, int y);
@@ -309,14 +293,8 @@ private:
int getItemCommandStringInv(uint16 item);
// -> hand item
- void setMouseCursor(uint16 item);
-
- void setHandItem(uint16 item);
- void removeHandItem();
void setItemMouseCursor();
-
- int _itemInHand;
- int _handItemSet;
+ void setMouseCursor(uint16 item);
// shapes
void initMouseShapes();
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 2fefd08888..cc10d2911b 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -34,6 +34,9 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi
_lastProcessedSceneScript = 0;
_specialSceneScriptRunFlag = false;
+
+ _itemList = 0;
+ _itemListSize = 0;
}
KyraEngine_v2::~KyraEngine_v2() {
@@ -42,6 +45,8 @@ KyraEngine_v2::~KyraEngine_v2() {
i->_value = 0;
}
_gameShapes.clear();
+
+ delete [] _itemList;
}
void KyraEngine_v2::updateInput() {
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index 08220123bb..0e44da4934 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -205,6 +205,36 @@ protected:
int _pathfinderPositionTable[400];
int _pathfinderPositionIndexTable[200];
+
+ // items
+ struct Item {
+ uint16 id;
+ uint16 sceneId;
+ int16 x;
+ uint8 y;
+ };
+
+ void initItemList(int size);
+
+ Item *_itemList;
+ int _itemListSize;
+
+ int _itemInHand;
+ int _handItemSet;
+
+ int findFreeItem();
+ int countAllItems();
+
+ int findItem(uint16 sceneId, uint16 id);
+ int findItem(uint16 item);
+
+ void resetItemList();
+ void resetItem(int index);
+
+ virtual void setMouseCursor(uint16 item) = 0;
+
+ void setHandItem(uint16 item);
+ void removeHandItem();
};
} // end of namespace Kyra
diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk
index a45891de46..48bbb6e659 100644
--- a/engines/kyra/module.mk
+++ b/engines/kyra/module.mk
@@ -12,6 +12,7 @@ MODULE_OBJS := \
gui_v2.o \
gui_v3.o \
items_v1.o \
+ items_v2.o \
items_hof.o \
items_mr.o \
kyra.o \
diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp
index c348c622a9..3b78ce579c 100644
--- a/engines/kyra/saveload.cpp
+++ b/engines/kyra/saveload.cpp
@@ -29,7 +29,7 @@
#include "kyra/kyra.h"
-#define CURRENT_SAVE_VERSION 9
+#define CURRENT_SAVE_VERSION 10
#define GF_FLOPPY (1 << 0)
#define GF_TALKIE (1 << 1)
diff --git a/engines/kyra/saveload_hof.cpp b/engines/kyra/saveload_hof.cpp
index 00a54ea916..75abdaa9e2 100644
--- a/engines/kyra/saveload_hof.cpp
+++ b/engines/kyra/saveload_hof.cpp
@@ -92,7 +92,6 @@ void KyraEngine_HoF::saveGame(const char *fileName, const char *saveName) {
out->writeUint16BE(_itemList[i].sceneId);
out->writeSint16BE(_itemList[i].x);
out->writeByte(_itemList[i].y);
- out->writeUint16BE(_itemList[i].unk7);
}
for (int i = 0; i < 72; ++i) {
@@ -228,7 +227,8 @@ void KyraEngine_HoF::loadGame(const char *fileName) {
_itemList[i].sceneId = in.readUint16();
_itemList[i].x = in.readSint16();
_itemList[i].y = in.readByte();
- _itemList[i].unk7 = in.readUint16();
+ if (header.version <= 9)
+ in.readUint16();
}
for (int i = 0; i < 72; ++i) {
diff --git a/engines/kyra/saveload_mr.cpp b/engines/kyra/saveload_mr.cpp
index cab86c3cfe..f8030e69fb 100644
--- a/engines/kyra/saveload_mr.cpp
+++ b/engines/kyra/saveload_mr.cpp
@@ -79,7 +79,6 @@ void KyraEngine_MR::saveGame(const char *fileName, const char *saveName) {
out->writeUint16BE(_itemList[i].sceneId);
out->writeSint16BE(_itemList[i].x);
out->writeSint16BE(_itemList[i].y);
- out->writeUint16BE(_itemList[i].unk8);
}
for (int i = 0; i < 88; ++i) {
@@ -189,7 +188,8 @@ void KyraEngine_MR::loadGame(const char *fileName) {
_itemList[i].sceneId = in.readUint16();
_itemList[i].x = in.readSint16();
_itemList[i].y = in.readSint16();
- _itemList[i].unk8 = in.readUint16();
+ if (header.version <= 9)
+ in.readUint16();
}
for (int i = 0; i < 88; ++i) {