[Scummvm-cvs-logs] SF.net SVN: scummvm: [31819] scummvm/trunk/engines/kyra
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Fri May 2 17:08:46 CEST 2008
Revision: 31819
http://scummvm.svn.sourceforge.net/scummvm/?rev=31819&view=rev
Author: lordhoto
Date: 2008-05-02 08:08:45 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Moved common kyra2/kyra3 item to KyraEngine_v2.
Modified Paths:
--------------
scummvm/trunk/engines/kyra/items_hof.cpp
scummvm/trunk/engines/kyra/items_mr.cpp
scummvm/trunk/engines/kyra/kyra_hof.cpp
scummvm/trunk/engines/kyra/kyra_mr.cpp
scummvm/trunk/engines/kyra/kyra_mr.h
scummvm/trunk/engines/kyra/kyra_v2.cpp
scummvm/trunk/engines/kyra/kyra_v2.h
scummvm/trunk/engines/kyra/module.mk
scummvm/trunk/engines/kyra/saveload.cpp
scummvm/trunk/engines/kyra/saveload_hof.cpp
scummvm/trunk/engines/kyra/saveload_mr.cpp
Added Paths:
-----------
scummvm/trunk/engines/kyra/items_v2.cpp
Modified: scummvm/trunk/engines/kyra/items_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items_hof.cpp 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/items_hof.cpp 2008-05-02 15:08:45 UTC (rev 31819)
@@ -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 @@
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 @@
_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 @@
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 @@
_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
Modified: scummvm/trunk/engines/kyra/items_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items_mr.cpp 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/items_mr.cpp 2008-05-02 15:08:45 UTC (rev 31819)
@@ -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 @@
}
}
-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 @@
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 @@
_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 @@
_itemList[freeItemSlot].x = x;
_itemList[freeItemSlot].y = y;
_itemList[freeItemSlot].id = item;
- _itemList[freeItemSlot].unk8 = 1;
_itemList[freeItemSlot].sceneId = sceneId;
return true;
}
Added: scummvm/trunk/engines/kyra/items_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items_v2.cpp (rev 0)
+++ scummvm/trunk/engines/kyra/items_v2.cpp 2008-05-02 15:08:45 UTC (rev 31819)
@@ -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
+
Property changes on: scummvm/trunk/engines/kyra/items_v2.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Modified: scummvm/trunk/engines/kyra/kyra_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_hof.cpp 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/kyra_hof.cpp 2008-05-02 15:08:45 UTC (rev 31819)
@@ -352,8 +352,7 @@
}
_gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)];
- _itemList = new Item[30];
- memset(_itemList, 0, sizeof(Item)*30);
+ initItemList(30);
loadButtonShapes();
resetItemList();
_loadedZTable = 1;
Modified: scummvm/trunk/engines/kyra/kyra_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.cpp 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/kyra_mr.cpp 2008-05-02 15:08:45 UTC (rev 31819)
@@ -57,7 +57,6 @@
memset(_sceneShapes, 0, sizeof(_sceneShapes));
memset(_sceneAnimMovie, 0, sizeof(_sceneAnimMovie));
_gfxBackUpRect = 0;
- _itemList = 0;
_malcolmShapes = 0;
_paletteOverlay = 0;
_sceneList = 0;
@@ -162,7 +161,6 @@
delete _sceneAnimMovie[i];
delete [] _gfxBackUpRect;
- delete [] _itemList;
delete [] _paletteOverlay;
delete [] _sceneList;
@@ -591,7 +589,7 @@
musicUpdate(0);
updateMalcolmShapes();
_gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)];
- _itemList = new Item[50];
+ initItemList(50);
resetItemList();
loadShadowShape();
Modified: scummvm/trunk/engines/kyra/kyra_mr.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.h 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/kyra_mr.h 2008-05-02 15:08:45 UTC (rev 31819)
@@ -261,27 +261,11 @@
// 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,15 +293,9 @@
int getItemCommandStringInv(uint16 item);
// -> hand item
+ void setItemMouseCursor();
void setMouseCursor(uint16 item);
- void setHandItem(uint16 item);
- void removeHandItem();
- void setItemMouseCursor();
-
- int _itemInHand;
- int _handItemSet;
-
// shapes
void initMouseShapes();
Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp 2008-05-02 15:08:45 UTC (rev 31819)
@@ -34,6 +34,9 @@
_lastProcessedSceneScript = 0;
_specialSceneScriptRunFlag = false;
+
+ _itemList = 0;
+ _itemListSize = 0;
}
KyraEngine_v2::~KyraEngine_v2() {
@@ -42,6 +45,8 @@
i->_value = 0;
}
_gameShapes.clear();
+
+ delete [] _itemList;
}
void KyraEngine_v2::updateInput() {
Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/kyra_v2.h 2008-05-02 15:08:45 UTC (rev 31819)
@@ -205,6 +205,36 @@
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
Modified: scummvm/trunk/engines/kyra/module.mk
===================================================================
--- scummvm/trunk/engines/kyra/module.mk 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/module.mk 2008-05-02 15:08:45 UTC (rev 31819)
@@ -12,6 +12,7 @@
gui_v2.o \
gui_v3.o \
items_v1.o \
+ items_v2.o \
items_hof.o \
items_mr.o \
kyra.o \
Modified: scummvm/trunk/engines/kyra/saveload.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload.cpp 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/saveload.cpp 2008-05-02 15:08:45 UTC (rev 31819)
@@ -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)
Modified: scummvm/trunk/engines/kyra/saveload_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload_hof.cpp 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/saveload_hof.cpp 2008-05-02 15:08:45 UTC (rev 31819)
@@ -92,7 +92,6 @@
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 @@
_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) {
Modified: scummvm/trunk/engines/kyra/saveload_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload_mr.cpp 2008-05-02 14:48:19 UTC (rev 31818)
+++ scummvm/trunk/engines/kyra/saveload_mr.cpp 2008-05-02 15:08:45 UTC (rev 31819)
@@ -79,7 +79,6 @@
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 @@
_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) {
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