Skip to content

Commit

Permalink
DL: Enforce the use of CreatureType
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Sep 17, 2016
1 parent ffe2c80 commit ea8f3df
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion engines/dm/dungeonman.cpp
Expand Up @@ -1535,7 +1535,7 @@ void DungeonMan::setGroupDirections(Group *group, int16 dir, uint16 mapIndex) {
}

bool DungeonMan::isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
int16 creatureType = ((Group *)getThingData(thing))->_type;
CreatureType creatureType = ((Group *)getThingData(thing))->_type;
Map *map = &_dungeonMaps[mapIndex];
byte *allowedCreatureType = _dungeonMapData[mapIndex][map->_width] + map->_height + 1;
for (int16 L0234_i_Counter = map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) {
Expand Down
21 changes: 11 additions & 10 deletions engines/dm/group.cpp
Expand Up @@ -139,7 +139,7 @@ uint16 GroupMan::getCreatureValue(uint16 groupVal, uint16 creatureIndex) {

void GroupMan::dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, SoundMode soundMode) {
Group *group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
uint16 creatureType = group->_type;
CreatureType creatureType = group->_type;
if ((soundMode != kDMSoundModeDoNotPlaySound) && getFlag(_vm->_dungeonMan->_creatureInfos[creatureType]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
int16 creatureIndex = group->getCount();
uint16 groupCells = getGroupCells(group, _vm->_dungeonMan->_currMapIndex);
Expand Down Expand Up @@ -167,7 +167,7 @@ void GroupMan::dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, So
}
}

void GroupMan::dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, SoundMode soundMode) {
void GroupMan::dropCreatureFixedPossessions(CreatureType creatureType, int16 mapX, int16 mapY, uint16 cell, SoundMode soundMode) {
static uint16 fixedPossessionCreature12Skeleton[3] = { // @ G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton
kDMObjectInfoIndexFirstWeapon + kDMWeaponFalchion,
kDMObjectInfoIndexFirstArmour + kDMArmourWoodenShield,
Expand Down Expand Up @@ -386,7 +386,7 @@ Thing GroupMan::groupGetThing(int16 mapX, int16 mapY) {
}

int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) {
uint16 creatureType = group->_type;
CreatureType creatureType = group->_type;
CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[creatureType];
if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */
return k0_outcomeKilledNoCreaturesInGroup;
Expand Down Expand Up @@ -546,8 +546,8 @@ int16 GroupMan::getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 map
return k0_outcomeKilledNoCreaturesInGroup;
}

int16 GroupMan::groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) {
int16 poisonResistance = _vm->_dungeonMan->_creatureInfos[creatreType].getPoisonResistance();
int16 GroupMan::groupGetResistanceAdjustedPoisonAttack(CreatureType creatureType, int16 poisonAttack) {
int16 poisonResistance = _vm->_dungeonMan->_creatureInfos[creatureType].getPoisonResistance();

if (!poisonAttack || (poisonResistance == kDMImmuneToPoison))
return 0;
Expand Down Expand Up @@ -1246,7 +1246,7 @@ bool GroupMan::isViewPartyBlocked(uint16 mapX, uint16 mapY) {

int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex, bool isAttacking) {
Group *group = &(((Group *)_vm->_dungeonMan->_thingData[kDMThingTypeGroup])[activeGroup->_groupThingIndex]);
uint16 creatureType = group->_type;
CreatureType creatureType = group->_type;
uint16 creatureGraphicInfo = _vm->_dungeonMan->_creatureInfos[creatureType]._graphicInfo;
bool processGroup = (creatureIndex < 0);
if (processGroup) /* If the creature index is negative then all creatures in the group are processed */
Expand Down Expand Up @@ -1415,7 +1415,7 @@ bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16

_vm->_projexpl->_lastCreatureAttackTime = _vm->_gameTime;
ActiveGroup activeGroup = _activeGroups[group->getActiveGroupIndex()];
uint16 creatureType = group->_type;
CreatureType creatureType = group->_type;
CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[creatureType];
uint16 primaryDirectionToParty = _currGroupPrimaryDirToParty;

Expand Down Expand Up @@ -1632,7 +1632,7 @@ int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) {
void GroupMan::dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) {
if (_dropMovingCreatureFixedPossCellCount) {
Group *group = (Group *)_vm->_dungeonMan->getThingData(thing);
int16 creatureType = group->_type;
CreatureType creatureType = group->_type;
while (_dropMovingCreatureFixedPossCellCount) {
dropCreatureFixedPossessions(creatureType, mapX, mapY, _dropMovingCreatureFixedPossessionsCell[--_dropMovingCreatureFixedPossCellCount], kDMSoundModePlayOneTickLater);
}
Expand Down Expand Up @@ -1726,7 +1726,7 @@ void GroupMan::addAllActiveGroups() {
}
}

Thing GroupMan::groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY) {
Thing GroupMan::groupGetGenerated(CreatureType creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY) {
Thing groupThing = _vm->_dungeonMan->getUnusedThing(kDMThingTypeGroup);
if (((_currActiveGroupCount >= (_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex))
|| (groupThing == Thing::_none)) {
Expand All @@ -1745,7 +1745,8 @@ Thing GroupMan::groupGetGenerated(int16 creatureType, int16 healthMultiplier, ui
else
groupCells = k255_CreatureTypeSingleCenteredCreature;

CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type = creatureType];
group->_type = creatureType;
CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
uint16 baseHealth = creatureInfo->_baseHealth;
do {
group->_health[creatureCount] = (baseHealth * healthMultiplier) + _vm->getRandomNumber((baseHealth >> 2) + 1);
Expand Down
12 changes: 6 additions & 6 deletions engines/dm/group.h
Expand Up @@ -118,13 +118,13 @@ class Group {
public:
Thing _nextThing;
Thing _slot;
uint16 _type;
CreatureType _type;
uint16 _cells;
uint16 _health[4];
uint16 _flags;
public:
explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _type(rawDat[2]),
_cells(rawDat[3]), _flags(rawDat[8]) {
explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _cells(rawDat[3]), _flags(rawDat[8]) {
_type = (CreatureType)rawDat[2];
_health[0] = rawDat[4];
_health[1] = rawDat[5];
_health[2] = rawDat[6];
Expand Down Expand Up @@ -194,7 +194,7 @@ class GroupMan {
int16 getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell
uint16 getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE
void dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, SoundMode mode); // @ F0188_GROUP_DropGroupPossessions
void dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell,
void dropCreatureFixedPossessions(CreatureType creatureType, int16 mapX, int16 mapY, uint16 cell,
SoundMode soundMode); // @ F0186_GROUP_DropCreatureFixedPossessions
int16 getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY,
int16 destMapX, int16 destMapY); // @ F0228_GROUP_GetDirectionsWhereDestinationIsVisibleFromSource
Expand All @@ -209,7 +209,7 @@ class GroupMan {
void groupDeleteEvents(int16 mapX, int16 mapY); // @ F0181_GROUP_DeleteEvents
uint16 getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatureVal); // @ F0178_GROUP_GetGroupValueUpdatedWithCreatureValue
int16 getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving); // @ F0191_GROUP_GetDamageAllCreaturesOutcome
int16 groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack); // @ F0192_GROUP_GetResistanceAdjustedPoisonAttack
int16 groupGetResistanceAdjustedPoisonAttack(CreatureType creatureType, int16 poisonAttack); // @ F0192_GROUP_GetResistanceAdjustedPoisonAttack
void processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks); // @ F0209_GROUP_ProcessEvents29to41
bool isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY,
uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls); // @ F0202_GROUP_IsMovementPossible
Expand Down Expand Up @@ -243,7 +243,7 @@ class GroupMan {
void removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup
void removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups
void addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups
Thing groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated
Thing groupGetGenerated(CreatureType creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated
bool isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY); // @ F0223_GROUP_IsSquareACorridorTeleporterPitOrDoor
int16 getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 paryY,
uint16 champCell); // @ F0177_GROUP_GetMeleeTargetCreatureOrdinal
Expand Down
4 changes: 2 additions & 2 deletions engines/dm/projexpl.cpp
Expand Up @@ -163,7 +163,7 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
return false;

curCreatureIndex--;
uint16 curCreatureType = curGroup->_type;
CreatureType curCreatureType = curGroup->_type;
CreatureInfo *curCreatureInfo = &_vm->_dungeonMan->_creatureInfos[curCreatureType];
if ((projectileAssociatedThing == Thing::_explFireBall) && (curCreatureType == kDMCreatureTypeBlackFlame)) {
uint16 *curCreatureHealth = &curGroup->_health[curCreatureIndex];
Expand Down Expand Up @@ -480,7 +480,7 @@ void ProjExpl::processEvent25(TimelineEvent *event) {
Group *group = nullptr;
CreatureInfo *creatureInfo = nullptr;

uint16 creatureType = 0;
CreatureType creatureType;
if (groupThing != Thing::_endOfList) {
group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
creatureType = group->_type;
Expand Down
2 changes: 1 addition & 1 deletion engines/dm/timeline.cpp
Expand Up @@ -734,7 +734,7 @@ void Timeline::processEventSquareCorridor(TimelineEvent *event) {
if (healthMultiplier == 0)
healthMultiplier = _vm->_dungeonMan->_currMap->_difficulty;

_vm->_groupMan->groupGetGenerated(curSensor->getData(), healthMultiplier, creatureCount, (Direction)_vm->getRandomNumber(4), mapX, mapY);
_vm->_groupMan->groupGetGenerated((CreatureType)curSensor->getData(), healthMultiplier, creatureCount, (Direction)_vm->getRandomNumber(4), mapX, mapY);
if (curSensor->getAttrAudibleA())
_vm->_sound->requestPlay(k17_soundBUZZ, mapX, mapY, kDMSoundModePlayIfPrioritized);

Expand Down

0 comments on commit ea8f3df

Please sign in to comment.