diff options
author | Bendegúz Nagy | 2016-06-19 01:28:28 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 29d832b353c94f2e1096117b34142ded9675f822 (patch) | |
tree | 24805a476fb00a8d20a7fedd81cfc88fce3cb29d | |
parent | 23c1acff1939b8feb4bcbbf04bc44ca00321547d (diff) | |
download | scummvm-rg350-29d832b353c94f2e1096117b34142ded9675f822.tar.gz scummvm-rg350-29d832b353c94f2e1096117b34142ded9675f822.tar.bz2 scummvm-rg350-29d832b353c94f2e1096117b34142ded9675f822.zip |
DM: Add F0033_OBJECT_GetIconIndex and several getters for object types
-rw-r--r-- | engines/dm/dungeonman.h | 9 | ||||
-rw-r--r-- | engines/dm/objectman.cpp | 50 | ||||
-rw-r--r-- | engines/dm/objectman.h | 1 |
3 files changed, 56 insertions, 4 deletions
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 5a7bf24d4b..45130e88e4 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -313,6 +313,8 @@ public: Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {} WeaponType getType() { return (WeaponType)(_desc & 0x7F); } + bool isLit() { return (_desc >> 15) & 1; } + uint16 getChargeCount() { return (_desc >> 10) & 0xF; } Thing getNextThing() { return _nextThing; } }; // @ WEAPON @@ -343,6 +345,7 @@ public: _attributes = attribs; } Thing getNextThing() { return _nextThing; } + uint16 getClosed() { return (_attributes >> 10) & 0x3F; } // ??? dunno why, the original bitfield is 6 bits long }; // @ SCROLL enum PotionType { @@ -574,11 +577,13 @@ class DungeonMan { void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap - Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) - uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing) public: DungeonMan(DMEngine *dmEngine); ~DungeonMan(); + + Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) + uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing) + // TODO: this does stuff other than load the file! void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 04888ee63f..a373e94f1f 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -4,7 +4,7 @@ namespace DM { -ObjectMan::ObjectMan(DMEngine *vm): _vm(vm) {} +ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {} IconIndice ObjectMan::getObjectType(Thing thing) { if (thing == Thing::_thingNone) @@ -17,8 +17,54 @@ IconIndice ObjectMan::getObjectType(Thing thing) { return (IconIndice)objectInfoIndex; } - byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType +int16 ObjectMan::getIconIndex(Thing thing) { + IconIndice iconIndex = getObjectType(thing); + + if ((iconIndex != kIconIndiceNone) && + ((iconIndex < kIconIndiceWeaponDagger) &&(iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error + ((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) || + (iconIndex == kIconIndicePotionEmptyFlask) + ) { + uint16 *rawType = _vm->_dungeonMan->getThingData(thing); + switch (iconIndex) { + case kIconIndiceJunkCompassNorth: + iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._partyDir); + break; + case kIconIndiceWeaponTorchUnlit: { + Weapon weapon(rawType); + if (weapon.isLit()) { + iconIndex = (IconIndice)(iconIndex + gChargeCountToTorchType[weapon.getChargeCount()]); + } + break; + } + case kIconIndiceScrollOpen: + if (Scroll(rawType).getClosed()) { + iconIndex = (IconIndice)(iconIndex + 1); + } + break; + case kIconIndiceJunkWater: + case kIconIndiceJunkIllumuletUnequipped: + case kIconIndiceJunkJewelSymalUnequipped: + if (Junk(rawType).getChargeCount()) { + iconIndex = (IconIndice)(iconIndex + 1); + } + break; + case kIconIndiceWeaponBoltBladeStormEmpty: + case kIconIndiceWeaponFlamittEmpty: + case kIconIndiceWeaponStormringEmpty: + case kIconIndiceWeaponFuryRaBladeEmpty: + case kIconIndiceWeaponEyeOfTimeEmpty: + case kIconIndiceWeaponStaffOfClawsEmpty: + if (Weapon(rawType).getChargeCount()) { + iconIndex = (IconIndice)(iconIndex + 1); + } + break; + } + } + + return iconIndex; +} }
\ No newline at end of file diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index 6421d7c04f..bad5f7c28a 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -9,6 +9,7 @@ class ObjectMan { public: ObjectMan(DMEngine *vm); IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType + int16 getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex }; |