Moved common kyra2/kyra3 item to KyraEngine_v2.
svn-id: r31819
This commit is contained in:
parent
52003bc195
commit
7566a12352
12 changed files with 170 additions and 184 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
116
engines/kyra/items_v2.cpp
Normal file
116
engines/kyra/items_v2.cpp
Normal file
|
@ -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
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue