aboutsummaryrefslogtreecommitdiff
path: root/engines/dm
diff options
context:
space:
mode:
authorStrangerke2016-09-20 22:26:00 +0200
committerStrangerke2016-09-20 22:26:00 +0200
commit58728d2f167074adeaf954115c03c0ee2df75274 (patch)
tree957e989826ffa52324c8d9d0756e85560d6f5432 /engines/dm
parentdd9e43925f59e053697bcd74a6e65013662a6951 (diff)
downloadscummvm-rg350-58728d2f167074adeaf954115c03c0ee2df75274.tar.gz
scummvm-rg350-58728d2f167074adeaf954115c03c0ee2df75274.tar.bz2
scummvm-rg350-58728d2f167074adeaf954115c03c0ee2df75274.zip
DM: Make use of TimeLineEventType
Diffstat (limited to 'engines/dm')
-rw-r--r--engines/dm/group.cpp21
-rw-r--r--engines/dm/group.h3
-rw-r--r--engines/dm/movesens.cpp2
-rw-r--r--engines/dm/movesens.h2
-rw-r--r--engines/dm/timeline.cpp4
-rw-r--r--engines/dm/timeline.h2
6 files changed, 21 insertions, 13 deletions
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 15a1ccaba4..7fd5065dda 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -435,7 +435,8 @@ int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex
if (nextCreatureIndex == creatureIndex)
_vm->_timeline->deleteEvent(eventIndex);
else if (nextCreatureIndex > creatureIndex) {
- curEvent->_type -= 1;
+ int16 curType = curEvent->_type - 1;
+ curEvent->_type = (TimelineEventType)curType;
_vm->_timeline->fixChronology(_vm->_timeline->getIndex(eventIndex));
}
}
@@ -556,7 +557,7 @@ int16 GroupMan::groupGetResistanceAdjustedPoisonAttack(CreatureType creatureType
return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / (poisonResistance + 1);
}
-void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) {
+void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, TimelineEventType eventType, uint16 ticks) {
int16 L0446_i_Multiple = 0;
#define AL0446_i_Direction L0446_i_Multiple
#define AL0446_i_Ticks L0446_i_Multiple
@@ -651,7 +652,8 @@ T0209005_AddEventAndReturn:
For event kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, the reaction time is 1 tick
For event kM2_TMEventTypeCreateReactionEvent30HitByProjectile and kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, the reaction time may be 1 tick or slower: slow moving creatures react more slowly. The more recent is the last creature move, the slower the reaction */
if (eventType < 0) {
- nextEvent._type = eventType + kDMEventTypeUpdateAspectGroup;
+ int16 nextType = eventType + kDMEventTypeUpdateAspectGroup;
+ nextEvent._type = (TimelineEventType)nextType;
if (eventType == kDMEventTypeCreateReactionPartyIsAdjacent) {
AL0446_i_Ticks = 1; /* Retry in 1 tick */
} else {
@@ -681,7 +683,9 @@ T0209005_AddEventAndReturn:
int16 distanceToVisibleParty = 0;
if (eventType <= kDMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */
- switch (eventType = eventType - kDMEventTypeUpdateAspectGroup) {
+ int16 tmpType = eventType - kDMEventTypeUpdateAspectGroup;
+ eventType = (TimelineEventType) tmpType;
+ switch (eventType) {
case kDMEventTypeCreateReactionPartyIsAdjacent: /* This event is used when the party bumps into a group or attacks a group physically (not with a spell). It causes the creature behavior to change to attack if it is not already attacking the party or fleeing from target */
if ((AL0447_i_Behavior != kDMBehaviorAttack) && (AL0447_i_Behavior != kDMBehaviorFlee)) {
groupDeleteEvents(eventMapX, eventMapY);
@@ -709,7 +713,8 @@ T0209005_AddEventAndReturn:
}
}
if (eventType < kDMEventTypeUpdateBehaviourGroup) { /* Process Update Aspect events 32 to 36 */
- nextEvent._type = eventType + 5;
+ int16 nextType = eventType + 5;
+ nextEvent._type = (TimelineEventType)nextType;
if (groupGetDistanceToVisibleParty(curGroup, kDMWholeCreatureGroup, eventMapX, eventMapY)) {
if ((AL0447_i_Behavior != kDMBehaviorAttack) && (AL0447_i_Behavior != kDMBehaviorFlee)) {
if (_vm->getDistance(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, eventMapX, eventMapY) <= 1)
@@ -760,7 +765,8 @@ T0209044_SetBehavior6_Attack:
if (notUpdateBehaviorFl) {
nextEvent._mapTime += MIN((uint16)((creatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks);
}
- nextEvent._type = kDMEventTypeUpdateBehavior0 + AL0447_i_CreatureIndex;
+ int16 nextType = kDMEventTypeUpdateBehavior0 + AL0447_i_CreatureIndex;
+ nextEvent._type = (TimelineEventType)nextType;
addGroupEvent(&nextEvent, getCreatureAspectUpdateTime(activeGroup, AL0447_i_CreatureIndex, false));
}
return;
@@ -1341,7 +1347,8 @@ void GroupMan::setGroupDirection(ActiveGroup *activeGroup, int16 dir, int16 crea
void GroupMan::addGroupEvent(TimelineEvent *event, uint32 time) {
warning("potentially dangerous cast to uint32 below");
if (time < (uint32)_vm->filterTime(event->_mapTime)) {
- event->_type -= 5;
+ int16 tmpType = event->_type - 5;
+ event->_type = (TimelineEventType)tmpType;
event->_Cu._ticks = _vm->filterTime(event->_mapTime) - time;
setTime(event->_mapTime, time);
} else
diff --git a/engines/dm/group.h b/engines/dm/group.h
index a60eb75999..ef34db1e5c 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -30,6 +30,7 @@
#include "dm/dm.h"
#include "dm/sounds.h"
+#include "dm/timeline.h"
namespace DM {
class Champion;
@@ -204,7 +205,7 @@ public:
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(CreatureType creatureType, int16 poisonAttack); // @ F0192_GROUP_GetResistanceAdjustedPoisonAttack
- void processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks); // @ F0209_GROUP_ProcessEvents29to41
+ void processEvents29to41(int16 eventMapX, int16 eventMapY, TimelineEventType eventType, uint16 ticks); // @ F0209_GROUP_ProcessEvents29to41
bool isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY,
uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls); // @ F0202_GROUP_IsMovementPossible
int16 getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX,
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 0051bc21e1..03ae63e34c 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -583,7 +583,7 @@ T0266017_CheckProjectileImpacts:
return false;
}
-void MovesensMan::addEvent(byte type, byte mapX, byte mapY, Cell cell, SensorEffect effect, int32 time) {
+void MovesensMan::addEvent(TimelineEventType type, byte mapX, byte mapY, Cell cell, SensorEffect effect, int32 time) {
TimelineEvent newEvent;
newEvent._mapTime = _vm->setMapAndTime(_vm->_dungeonMan->_currMapIndex, time);
newEvent._type = type;
diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h
index 75bc0737b7..c5a03d09c4 100644
--- a/engines/dm/movesens.h
+++ b/engines/dm/movesens.h
@@ -64,7 +64,7 @@ public:
bool getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY); // @ F0267_MOVE_GetMoveResult_CPSCE
bool isLevitating(Thing thing); // @ F0264_MOVE_IsLevitating
bool moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing); // @ F0266_MOVE_IsKilledByProjectileImpact
- void addEvent(byte type, byte mapX, byte mapY, Cell cell, SensorEffect effect, int32 time); // @ F0268_SENSOR_AddEvent
+ void addEvent(TimelineEventType type, byte mapX, byte mapY, Cell cell, SensorEffect effect, int32 time); // @ F0268_SENSOR_AddEvent
int16 getSound(CreatureType creatureType); // @ F0514_MOVE_GetSound
int16 getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex);// @ F0262_MOVE_GetTeleporterRotatedGroupResult
Thing getTeleporterRotatedProjectileThing(Teleporter *teleporter, Thing projectileThing); // @ F0263_MOVE_GetTeleporterRotatedProjectileThing
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 7be42f2d3f..49839faec4 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -260,7 +260,7 @@ void Timeline::processTimeline() {
TimelineEvent *curEvent = &newEvent;
extractFirstEvent(curEvent);
_vm->_dungeonMan->setCurrentMap(_vm->getMap(newEvent._mapTime));
- uint16 curEventType = newEvent._type;
+ TimelineEventType curEventType = newEvent._type;
if ((curEventType > (kDMEventTypeGroupReactionDangerOnSquare - 1)) && (curEventType < (kDMEventTypeUpdateBehavior3 + 1)))
_vm->_groupMan->processEvents29to41(newEvent._Bu._location._mapX, newEvent._Bu._location._mapY, curEventType, newEvent._Cu._ticks);
else {
@@ -974,7 +974,7 @@ void Timeline::loadEventsPart(Common::InSaveFile *file) {
for (uint16 i = 0; i < _eventMaxCount; ++i) {
TimelineEvent *event = &_events[i];
event->_mapTime = file->readSint32BE();
- event->_type = file->readByte();
+ event->_type = (TimelineEventType)file->readByte();
event->_priority = file->readByte();
event->_Bu._location._mapX = file->readByte();
event->_Bu._location._mapY = file->readByte();
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index ca8f7b4983..e7b4621af0 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -101,7 +101,7 @@ enum TimelineEventType {
class TimelineEvent {
public:
int32 _mapTime;
- byte _type;
+ TimelineEventType _type;
byte _priority; // CHECKME: byte? or int16? Inconsistency in the code
uint16 getTypePriority() { return (_type << 8) + _priority; }