DM: Add F0141_DUNGEON_GetObjectInfoIndex, getType for Container

This commit is contained in:
Bendegúz Nagy 2016-06-18 23:05:45 +02:00
parent 6b833550b0
commit 7dd90c3daf
2 changed files with 31 additions and 1 deletions

View File

@ -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;
}
}
}

View File

@ -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; // @ ???