Skip to content

Commit

Permalink
DM: Add F0142_DUNGEON_GetProjectileAspect
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendegúz Nagy committed Aug 26, 2016
1 parent a09ff6a commit f3d4b85
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 57 deletions.
6 changes: 4 additions & 2 deletions engines/dm/TODOs/methodtree.txt
Expand Up @@ -4,8 +4,10 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
FIELD_ASPECT // done
F0114_DUNGEONVIEW_GetExplosionBitmap // done
F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy
F0141_DUNGEON_GetObjectInfoIndex
F0142_DUNGEON_GetProjectileAspect
F0141_DUNGEON_GetObjectInfoIndex // done
F0142_DUNGEON_GetProjectileAspect // done
F0158_DUNGEON_GetWeaponInfo // done
M66_PROJECTILE_ASPECT_ORDINAL // done
F0176_GROUP_GetCreatureOrdinalInCell
G0017_auc_Graphic562_PaletteChanges_NoChanges
G0075_apuc_PaletteChanges_Projectile
Expand Down
22 changes: 11 additions & 11 deletions engines/dm/champion.cpp
Expand Up @@ -368,7 +368,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
ObjectMan &objMan = *_vm->_objectMan;
MenuMan &menuMan = *_vm->_menuMan;

if (thing == Thing::_thingNone)
if (thing == Thing::_none)
return;

Champion *champ = &_champions[champIndex];
Expand Down Expand Up @@ -442,7 +442,7 @@ void ChampionMan::resetDataToStartGame() {
assert(false);
}

_leaderHandObject = Thing::_thingNone;
_leaderHandObject = Thing::_none;
_leaderHandObjectIconIndex = kIconIndiceNone;
_leaderEmptyHanded = true;
}
Expand Down Expand Up @@ -479,7 +479,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
int16 AL_0_slotIndex_Red;
for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) {
champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone);
champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
}
Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
while (thing.getType() != kTextstringType) {
Expand Down Expand Up @@ -566,7 +566,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
thing = dunMan.getSquareFirstThing(mapX, mapY);
AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
uint16 slotIndex_Green;
while (thing != Thing::_thingEndOfList) {
while (thing != Thing::_endOfList) {
ThingType AL_2_thingType = thing.getType();
if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
Expand All @@ -576,24 +576,24 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
goto T0280048;
}
if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_none)) {
slotIndex_Green = kChampionSlotNeck;
} else {
goto T0280046;
}
break;
case kWeaponThingType:
if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) {
if (champ->getSlot(kChampionSlotActionHand) == Thing::_none) {
slotIndex_Green = kChampionSlotActionHand;
} else {
goto T0280046;
}
break;
case kScrollThingType:
case kPotionThingType:
if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) {
if (champ->getSlot(kChampionSlotPouch_1) == Thing::_none) {
slotIndex_Green = kChampionSlotPouch_1;
} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) {
} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_none) {
slotIndex_Green = kChampionSlotPouch_2;
} else {
goto T0280046;
Expand All @@ -602,7 +602,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
case kContainerThingType:
case kJunkThingType:
T0280046:
if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_none)) {
slotIndex_Green = kChampionSlotNeck;
} else {
slotIndex_Green = AL_0_slotIndex_Red++;
Expand All @@ -613,7 +613,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
break;
}
T0280048:
if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) {
goto T0280046;
}
addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
Expand Down Expand Up @@ -937,7 +937,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
}

int16 iconIndex;
if (thing == Thing::_thingNone) {
if (thing == Thing::_none) {
if (slotIndex <= kChampionSlotFeet) {
iconIndex = kIconIndiceReadyHand + (slotIndex << 1);
if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
Expand Down
2 changes: 1 addition & 1 deletion engines/dm/champion.h
Expand Up @@ -400,7 +400,7 @@ class Champion {
void clearWounds() { _wounds = kChampionWoundNone; }
void resetToZero() { // oh boy > . <
for (int16 i = 0; i < 30; ++i)
_slots[i] = Thing::_thingNone;
_slots[i] = Thing::_none;
for (int16 i = 0; i < 20; ++i)
_skills[i].resetToZero();
_attributes = _wounds = 0;
Expand Down
17 changes: 15 additions & 2 deletions engines/dm/dm.h
Expand Up @@ -95,8 +95,21 @@ enum Cell {
class Thing {
uint16 _data;
public:
static const Thing _thingNone;
static const Thing _thingEndOfList;
static const Thing _none; // @ C0xFFFF_THING_NONE
static const Thing _endOfList; // @ C0xFFFE_THING_ENDOFLIST
static const Thing _firstExplosion; // @ C0xFF80_THING_FIRST_EXPLOSION
static const Thing _explFireBall; // @ C0xFF80_THING_EXPLOSION_FIREBALL
static const Thing _explSlime; // @ C0xFF81_THING_EXPLOSION_SLIME
static const Thing _explLightningBolt; // @ C0xFF82_THING_EXPLOSION_LIGHTNING_BOLT
static const Thing _explHarmNonMaterial; // @ C0xFF83_THING_EXPLOSION_HARM_NON_MATERIAL
static const Thing _explOpenDoor; // @ C0xFF84_THING_EXPLOSION_OPEN_DOOR
static const Thing _explPoisonBolt; // @ C0xFF86_THING_EXPLOSION_POISON_BOLT
static const Thing _explPoisonCloud; // @ C0xFF87_THING_EXPLOSION_POISON_CLOUD
static const Thing _explSmoke; // @ C0xFFA8_THING_EXPLOSION_SMOKE
static const Thing _explFluxcage; // @ C0xFFB2_THING_EXPLOSION_FLUXCAGE
static const Thing _explRebirthStep1; // @ C0xFFE4_THING_EXPLOSION_REBIRTH_STEP1
static const Thing _explRebirthStep2; // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2
static const Thing _party; // @ C0xFFFF_THING_PARTY

Thing() : _data(0) {}
explicit Thing(uint16 d) { set(d); }
Expand Down
71 changes: 57 additions & 14 deletions engines/dm/dungeonman.cpp
Expand Up @@ -534,8 +534,21 @@ unsigned char gThingDataWordCount[16] = {
2 /* Explosion */
}; // @ G0235_auc_Graphic559_ThingDataByteCount

const Thing Thing::_thingNone(0);
const Thing Thing::_thingEndOfList(0xFFFE);
const Thing Thing::_none(0); // @ C0xFFFF_THING_NONE
const Thing Thing::_endOfList(0xFFFE); // @ C0xFFFE_THING_ENDOFLIST
const Thing Thing::_firstExplosion(0xFF80); // @ C0xFF80_THING_FIRST_EXPLOSION
const Thing Thing::_explFireBall(0xFF80); // @ C0xFF80_THING_EXPLOSION_FIREBALL
const Thing Thing::_explSlime(0xFF81); // @ C0xFF81_THING_EXPLOSION_SLIME
const Thing Thing::_explLightningBolt(0xFF82); // @ C0xFF82_THING_EXPLOSION_LIGHTNING_BOLT
const Thing Thing::_explHarmNonMaterial(0xFF83); // @ C0xFF83_THING_EXPLOSION_HARM_NON_MATERIAL
const Thing Thing::_explOpenDoor(0xFF84); // @ C0xFF84_THING_EXPLOSION_OPEN_DOOR
const Thing Thing::_explPoisonBolt(0xFF86); // @ C0xFF86_THING_EXPLOSION_POISON_BOLT
const Thing Thing::_explPoisonCloud(0xFF87); // @ C0xFF87_THING_EXPLOSION_POISON_CLOUD
const Thing Thing::_explSmoke(0xFFA8); // @ C0xFFA8_THING_EXPLOSION_SMOKE
const Thing Thing::_explFluxcage(0xFFB2); // @ C0xFFB2_THING_EXPLOSION_FLUXCAGE
const Thing Thing::_explRebirthStep1(0xFFE4); // @ C0xFFE4_THING_EXPLOSION_REBIRTH_STEP1
const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2
const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY

void DungeonMan::loadDungeonFile() {
if (_messages._newGame)
Expand Down Expand Up @@ -627,7 +640,7 @@ void DungeonMan::loadDungeonFile() {
_dunData._squareFirstThings[i].set(dunDataStream.readUint16BE());
if (_messages._newGame)
for (uint16 i = 0; i < 300; ++i)
_dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_thingNone;
_dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;

// TODO: ??? is this - end

Expand Down Expand Up @@ -688,7 +701,7 @@ void DungeonMan::loadDungeonFile() {
if ((thingType == kGroupThingType) || thingType >= kProjectileThingType)
_dunData._eventMaximumCount += _fileHeader._thingCounts[thingType];
for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) {
_dunData._thingsData[thingType][thingCount + i][0] = Thing::_thingNone.toUint16();
_dunData._thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16();
}
}
}
Expand Down Expand Up @@ -797,7 +810,7 @@ int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
int16 index = getSquareFirstThingIndex(mapX, mapY);
if (index == -1)
return Thing::_thingEndOfList;
return Thing::_endOfList;
return _dunData._squareFirstThings[index];
}

Expand Down Expand Up @@ -849,7 +862,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
T0172010_ClosedFakeWall:
setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall);

while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) {
while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) {
int16 sideIndex = (thing.getCell() - dir) & 3;
if (sideIndex) {
if (thing.getType() == kTextstringType) {
Expand All @@ -868,7 +881,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
thing = getNextThing(thing);
}
if (squareIsFakeWall && (_currMap._partyPosX != mapX) && (_currMap._partyPosY != mapY)) {
aspectArray[kFirstGroupOrObjectAspect] = Thing::_thingEndOfList.toUint16();
aspectArray[kFirstGroupOrObjectAspect] = Thing::_endOfList.toUint16();
return;
}
break;
Expand Down Expand Up @@ -897,7 +910,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
T0172029_Teleporter:
footPrintsAllowed = true;
T0172030_Pit:
while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) {
while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) {
if (thing.getType() == kSensorThingType)
aspectArray[kFloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal();
thing = getNextThing(thing);
Expand All @@ -921,7 +934,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
}
footPrintsAllowed = true;
T0172046_Stairs:
while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType))
while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType))
thing = getNextThing(thing);
T0172049_Footprints:
unsigned char scentOrdinal; // see next line comment
Expand Down Expand Up @@ -1178,7 +1191,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
2, 0, 8
};

if (thing == Thing::_thingNone)
if (thing == Thing::_none)
return 0;
switch (thing.getType()) {
case kWeaponThingType:
Expand All @@ -1196,7 +1209,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
uint16 weight = 50;
Container container(getThingData(thing));
Thing slotThing = container.getSlot();
while (slotThing != Thing::_thingEndOfList) {
while (slotThing != Thing::_endOfList) {
weight += getObjectWeight(slotThing);
slotThing = getNextThing(slotThing);
}
Expand Down Expand Up @@ -1240,11 +1253,11 @@ int16 DungeonMan::getObjectInfoIndex(Thing thing) {
}

void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) {
if (thingToLink == Thing::_thingEndOfList)
if (thingToLink == Thing::_endOfList)
return;

uint16 *rawObjPtr = getThingData(thingToLink);
*rawObjPtr = Thing::_thingEndOfList.toUint16();
*rawObjPtr = Thing::_endOfList.toUint16();

if (mapX >= 0) {
Square *squarePtr = (Square*)&_currMap._data[mapX][mapY];
Expand Down Expand Up @@ -1274,12 +1287,42 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map
}

Thing thing = getNextThing(thingInList);
while (thing != Thing::_thingEndOfList) {
while (thing != Thing::_endOfList) {
thing = getNextThing(thing);
thingInList = thing;
}
rawObjPtr = getThingData(thingInList);
*rawObjPtr = thingToLink.toUint16();
}

WeaponInfo* DungeonMan::getWeaponInfo(Thing thing) {
Weapon* weapon = (Weapon*)getThingData(thing);
return &gWeaponInfo[weapon->getType()];
}

int16 DungeonMan::getProjectileAspect(Thing thing) {
ThingType thingType;
int16 projAspOrd;
WeaponInfo *weaponInfo;

if ((thingType == thing.getType()) == kExplosionThingType) {
if (thing == Thing::_explFireBall)
return -_vm->indexToOrdinal(kProjectileAspectExplosionFireBall);
if (thing == Thing::_explSlime)
return -_vm->indexToOrdinal(kProjectileAspectExplosionSlime);
if (thing == Thing::_explLightningBolt)
return -_vm->indexToOrdinal(kProjectileAspectExplosionLightningBolt);
if ((thing == Thing::_explPoisonBolt) || (thing == Thing::_explPoisonCloud))
return -_vm->indexToOrdinal(kProjectileAspectExplosionPoisonBoltCloud);

return -_vm->indexToOrdinal(kProjectileAspectExplosionDefault);
} else if (thingType == kWeaponThingType) {
weaponInfo = getWeaponInfo(thing);
if (projAspOrd = weaponInfo->getProjectileAspectOrdinal())
return -projAspOrd;
}

return gObjectInfo[getObjectInfoIndex(thing)]._objectAspectIndex;
}

}
2 changes: 2 additions & 0 deletions engines/dm/dungeonman.h
Expand Up @@ -671,6 +671,8 @@ class DungeonMan {
uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight
int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex
void linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList
WeaponInfo *getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo
int16 getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect

uint32 _rawDunFileDataSize; // @ probably NONE
byte *_rawDunFileData; // @ ???
Expand Down
2 changes: 1 addition & 1 deletion engines/dm/eventman.cpp
Expand Up @@ -632,7 +632,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane

for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
Thing thing = champ->getSlot((ChampionSlot)slotIndex);
if (thing != Thing::_thingNone) {
if (thing != Thing::_none) {
warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
}
}
Expand Down
2 changes: 1 addition & 1 deletion engines/dm/gfx.cpp
Expand Up @@ -658,7 +658,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
for (int i = 0; i < 18; i++)
_currMapDoorOrnIndices[i] = 0;

_inscriptionThing = Thing::_thingNone;
_inscriptionThing = Thing::_none;
_useByteBoxCoordinates = false;
}

Expand Down

0 comments on commit f3d4b85

Please sign in to comment.