From 7dd90c3daf2d9955ba232c0ed70d1f4b90ba81e9 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 23:05:45 +0200 Subject: DM: Add F0141_DUNGEON_GetObjectInfoIndex, getType for Container --- engines/dm/dungeonman.cpp | 28 ++++++++++++++++++++++++++++ engines/dm/dungeonman.h | 4 +++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 6b577ca3af..93bde021e0 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1036,4 +1036,32 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { return 0; // dummy } +/* Object info */ +#define kObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL +#define kObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER +#define kObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION +#define kObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON +#define kObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR +#define kObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK + +int16 DungeonMan::getObjectInfoIndex(Thing thing) { + uint16 *rawType = getThingData(thing); + switch (thing.getType()) { + case kScrollThingType: + return kObjectInfoIndexFirstScroll; + case kContainerThingType: + return kObjectInfoIndexFirstContainer + Container(rawType).getType(); + case kJunkThingType: + return kObjectInfoIndexFirstJunk + Junk(rawType).getType(); + case kWeaponThingType: + return kObjectInfoIndexFirstWeapon + Weapon(rawType).getType(); + case kArmourThingType: + return kObjectInfoIndexFirstArmour + Armour(rawType).getType(); + case kPotionThingType: + return kObjectInfoIndexFirstPotion + Potion(rawType).getType(); + default: + return -1; + } +} + } \ No newline at end of file diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index aba2872a65..0a68600c1a 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -341,6 +341,7 @@ class Container { public: Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {} + uint16 getType() { return (_type >> 1) & 0x3; } Thing getNextContainedThing() { return _nextContainedThing; } Thing getNextThing() { return _nextThing; } }; // @ CONTAINER @@ -554,7 +555,8 @@ public: void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText - uint16 getObjectWeight(Thing thing);// @ F0140_DUNGEON_GetObjectWeight + uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight + int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? -- cgit v1.2.3