Skip to content

Commit

Permalink
DM: Start renaming constants in DungeonMan
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Sep 11, 2016
1 parent 21979d7 commit e413f44
Show file tree
Hide file tree
Showing 13 changed files with 377 additions and 377 deletions.
4 changes: 2 additions & 2 deletions engines/dm/champion.cpp
Expand Up @@ -1476,7 +1476,7 @@ void ChampionMan::championKill(uint16 champIndex) {
L0966_ps_Junk->setDoNotDiscard(true);
L0966_ps_Junk->setChargeCount(champIndex);
curCell = curChampion->_cell;
_vm->_moveSens->getMoveResult(_vm->thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
_vm->_moveSens->getMoveResult(_vm->thingWithNewCell(unusedThing, curCell), kDMMapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
}
curChampion->_symbolStep = 0;
curChampion->_symbols[0] = '\0';
Expand Down Expand Up @@ -1553,7 +1553,7 @@ void ChampionMan::dropAllObjects(uint16 champIndex) {
for (uint16 slotIndex = kDMSlotReadyHand; slotIndex < kDMSlotChest1; slotIndex++) {
Thing curThing = getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
if (curThing != Thing::_none)
_vm->_moveSens->getMoveResult(_vm->thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
_vm->_moveSens->getMoveResult(_vm->thingWithNewCell(curThing, curCell), kDMMapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
}
}

Expand Down
2 changes: 1 addition & 1 deletion engines/dm/console.cpp
Expand Up @@ -184,7 +184,7 @@ bool Console::Cmd_map(int argc, const char** argv) {
debugPrintf("Setting map directly can cause glitches and crashes.\n");
debugPrintf("Map set to %d\n", index);

_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kDMMapXNotOnASquare, 0);
_vm->_newPartyMapIndex = _vm->_dungeonMan->getLocationAfterLevelChange(
_vm->_dungeonMan->_partyMapIndex, index - _vm->_dungeonMan->_partyMapIndex,
&_vm->_dungeonMan->_partyMapX, &_vm->_dungeonMan->_partyMapY);
Expand Down
6 changes: 3 additions & 3 deletions engines/dm/dm.cpp
Expand Up @@ -271,7 +271,7 @@ void DMEngine::initializeGame() {

startGame();
if (_newGameFl)
_moveSens->getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
_moveSens->getMoveResult(Thing::_party, kDMMapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
_eventMan->showMouse();
_eventMan->discardAllInput();
}
Expand Down Expand Up @@ -404,7 +404,7 @@ void DMEngine::gameloop() {

if (_newPartyMapIndex != kDMMapIndexNone) {
processNewPartyMap(_newPartyMapIndex);
_moveSens->getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
_moveSens->getMoveResult(Thing::_party, kDMMapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
_newPartyMapIndex = kDMMapIndexNone;
_eventMan->discardAllInput();
}
Expand Down Expand Up @@ -753,7 +753,7 @@ void DMEngine::drawEntrance() {
_dungeonMan->_currMap = &map;
Square microDungeonSquares[25];
for (uint16 i = 0; i < 25; ++i)
microDungeonSquares[i] = Square(k0_ElementTypeWall, 0);
microDungeonSquares[i] = Square(kDMElementTypeWall, 0);

for (int16 idx = 0; idx < 5; idx++) {
microDungeonCurrentMapData[idx] = (byte*)&microDungeonSquares[idx * 5];
Expand Down
410 changes: 205 additions & 205 deletions engines/dm/dungeonman.cpp

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions engines/dm/dungeonman.h
Expand Up @@ -34,37 +34,37 @@
namespace DM {

/* Object info */
#define k0_ObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL
#define k1_ObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER
#define k2_ObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION
#define k23_ObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON
#define k69_ObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR
#define k127_ObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK
enum ObjectInfoIndexConst {
kDMObjectInfoIndexFirstScroll = 0, // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL
kDMObjectInfoIndexFirstContainer = 1, // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER
kDMObjectInfoIndexFirstPotion = 2, // @ C002_OBJECT_INFO_INDEX_FIRST_POTION
kDMObjectInfoIndexFirstWeapon = 23, // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON
kDMObjectInfoIndexFirstArmour = 69, // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR
kDMObjectInfoIndexFirstJunk = 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK
};

#define kM1_MapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE
#define kDMMapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE

enum ElementType {
kM2_ElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */
kM1_ElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE
k0_ElementTypeWall = 0, // @ C00_ELEMENT_WALL /* Values 0-6 are used as square types and projectile impact types. Values 0-2 and 5-6 are also used for square aspect */
k1_ElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR
k2_ElementTypePit = 2, // @ C02_ELEMENT_PIT
k3_ElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS
// TODO: refactor direction into a class
k4_ElementTypeDoor = 4, // @ C04_ELEMENT_DOOR
k5_ElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER
k6_ElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL
k16_ElementTypeDoorSide = 16, // @ C16_ELEMENT_DOOR_SIDE /* Values 16-19 are only used for square aspect */
k17_ElementTypeDoorFront = 17, // @ C17_ELEMENT_DOOR_FRONT
k18_ElementTypeStairsSide = 18, // @ C18_ELEMENT_STAIRS_SIDE
k19_ElementTypeStaisFront = 19 // @ C19_ELEMENT_STAIRS_FRONT
kDMElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */
kDMElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE
kDMElementTypeWall = 0, // @ C00_ELEMENT_WALL /* Values 0-6 are used as square types and projectile impact types. Values 0-2 and 5-6 are also used for square aspect */
kDMElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR
kDMElementTypePit = 2, // @ C02_ELEMENT_PIT
kDMElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS
kDMElementTypeDoor = 4, // @ C04_ELEMENT_DOOR
kDMElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER
kDMElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL
kDMElementTypeDoorSide = 16, // @ C16_ELEMENT_DOOR_SIDE /* Values 16-19 are only used for square aspect */
kDMElementTypeDoorFront = 17, // @ C17_ELEMENT_DOOR_FRONT
kDMElementTypeStairsSide = 18, // @ C18_ELEMENT_STAIRS_SIDE
kDMElementTypeStairsFront = 19 // @ C19_ELEMENT_STAIRS_FRONT
};


enum ObjectAllowedSlot {
k0x0001_ObjectAllowedSlotMouth = 0x0001, // @ MASK0x0001_MOUTH
k0x0002_ObjectAllowedSlotHead = 0x0002, // @ MASK0x0002_HEAD
k0x0004_ObjectAllowedSlotNeck = 0x0004, // @ MASK0x0004_NECK
kDMMaskMouth = 0x0001, // @ MASK0x0001_MOUTH
kDMMaskHead = 0x0002, // @ MASK0x0002_HEAD
kDMMaskNeck = 0x0004, // @ MASK0x0004_NECK
k0x0008_ObjectAllowedSlotTorso = 0x0008, // @ MASK0x0008_TORSO
k0x0010_ObjectAllowedSlotLegs = 0x0010, // @ MASK0x0010_LEGS
k0x0020_ObjectAllowedSlotFeet = 0x0020, // @ MASK0x0020_FEET
Expand All @@ -75,15 +75,15 @@ enum ObjectAllowedSlot {
k0x0400_ObjectAllowedSlotContainer = 0x0400 // @ MASK0x0400_CONTAINER
};

class ObjectInfo {
class ObjectInfoIndex {
public:
int16 _type;
uint16 _objectAspectIndex;
uint16 _actionSetIndex;
uint16 _allowedSlots;
ObjectInfo(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots)
ObjectInfoIndex(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots)
: _type(type), _objectAspectIndex(objectAspectIndex), _actionSetIndex(actionSetIndex), _allowedSlots(allowedSlots) {}
ObjectInfo() : _type(0), _objectAspectIndex(0), _actionSetIndex(0), _allowedSlots(0) {}
ObjectInfoIndex() : _type(0), _objectAspectIndex(0), _actionSetIndex(0), _allowedSlots(0) {}
bool getAllowedSlot(ObjectAllowedSlot slot) { return _allowedSlots & slot; }
uint16 getAllowedSlots() { return _allowedSlots; }
void setAllowedSlot(ObjectAllowedSlot slot, bool val) {
Expand Down Expand Up @@ -726,7 +726,7 @@ class DungeonMan {
Thing _pileTopObject[5]; // @ G0292_aT_PileTopObject
DoorInfo _currMapDoorInfo[2]; // @ G0275_as_CurrentMapDoorInfo

ObjectInfo _objectInfos[180]; // @ G0237_as_Graphic559_ObjectInfo
ObjectInfoIndex _objectInfos[180]; // @ G0237_as_Graphic559_ObjectInfo
ArmourInfo _armourInfos[58]; // @ G0239_as_Graphic559_ArmourInfo
WeaponInfo _weaponInfos[46]; // @ G0238_as_Graphic559_WeaponInfo
CreatureInfo _creatureInfos[k27_CreatureTypeCount]; // @ G0243_as_Graphic559_CreatureInfo
Expand Down
24 changes: 12 additions & 12 deletions engines/dm/eventman.cpp
Expand Up @@ -993,11 +993,11 @@ void EventManager::commandMoveParty(CommandType cmdType) {
bool isMovementBlocked = false;
SquareType partySquareType = curSquare.getType();
switch (partySquareType){
case k0_ElementTypeWall:
case kDMElementTypeWall:
isMovementBlocked = true;
break;
case k3_ElementTypeStairs: {
_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
case kDMElementTypeStairs: {
_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kDMMapXNotOnASquare, 0);
_vm->_dungeonMan->_partyMapX = partyMapX;
_vm->_dungeonMan->_partyMapY = partyMapY;
byte stairState = curSquare.toByte();
Expand All @@ -1009,7 +1009,7 @@ void EventManager::commandMoveParty(CommandType cmdType) {
isMovementBlocked = (doorState != k0_doorState_OPEN) && (doorState != k1_doorState_FOURTH) && (doorState != k5_doorState_DESTROYED);
}
break;
case k6_ElementTypeFakeWall: {
case kDMElementTypeFakeWall: {
byte wallState = curSquare.toByte();
isMovementBlocked = (!getFlag(wallState, k0x0004_FakeWallOpen) && !getFlag(wallState, k0x0001_FakeWallImaginary));
}
Expand Down Expand Up @@ -1044,7 +1044,7 @@ void EventManager::commandMoveParty(CommandType cmdType) {
}

if (isStairsSquare)
_vm->_moveSens->getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, partyMapX, partyMapY);
_vm->_moveSens->getMoveResult(Thing::_party, kDMMapXNotOnASquare, 0, partyMapX, partyMapY);
else
_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, partyMapX, partyMapY);

Expand All @@ -1069,7 +1069,7 @@ bool EventManager::isLeaderHandObjThrown(int16 posX, int16 posY) {

bool objectThrownFl;
if (posX <= 111) {
if (_vm->_dungeonMan->_squareAheadElement == k17_ElementTypeDoorFront) {
if (_vm->_dungeonMan->_squareAheadElement == kDMElementTypeDoorFront) {
if (posX < 64)
return false;
} else if (posX < 32)
Expand All @@ -1078,7 +1078,7 @@ bool EventManager::isLeaderHandObjThrown(int16 posX, int16 posY) {
// Strangerke: Only present in CSB2.1... But it fixes a bug so we keep it
objectThrownFl = _vm->_championMan->isLeaderHandObjectThrown(k0_sideLeft);
} else {
if (_vm->_dungeonMan->_squareAheadElement == k17_ElementTypeDoorFront) {
if (_vm->_dungeonMan->_squareAheadElement == kDMElementTypeDoorFront) {
if (posX > 163)
return false;
} else if (posX > 191)
Expand Down Expand Up @@ -1163,7 +1163,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
Box(40, 111, 122, 147) /* Back left */
};

if (_vm->_dungeonMan->_squareAheadElement == k17_ElementTypeDoorFront) {
if (_vm->_dungeonMan->_squareAheadElement == kDMElementTypeDoorFront) {
if (_vm->_championMan->_leaderIndex == kDMChampionNone)
return;

Expand Down Expand Up @@ -1197,7 +1197,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
} else {
Thing thingHandObject = _vm->_championMan->_leaderHandObject;
Junk *junkPtr = (Junk*)_vm->_dungeonMan->getThingData(thingHandObject);
if (_vm->_dungeonMan->_squareAheadElement == k0_ElementTypeWall) {
if (_vm->_dungeonMan->_squareAheadElement == kDMElementTypeWall) {
for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k1_ViewCellFrontRight + 1; currViewCell++) {
if (boxObjectPiles[currViewCell].isPointInside(posX, posY)) {
processType80_clickInDungeonViewDropLeaderHandObject(currViewCell);
Expand Down Expand Up @@ -1371,7 +1371,7 @@ void EventManager::processType80_clickInDungeonView_grabLeaderHandObject(uint16

Thing topPileThing = _vm->_dungeonMan->_pileTopObject[viewCell];
if (_vm->_objectMan->getIconIndex(topPileThing) != kDMIconIndiceNone) {
_vm->_moveSens->getMoveResult(topPileThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
_vm->_moveSens->getMoveResult(topPileThing, mapX, mapY, kDMMapXNotOnASquare, 0);
_vm->_championMan->putObjectInLeaderHand(topPileThing, true);
}

Expand All @@ -1393,7 +1393,7 @@ void EventManager::processType80_clickInDungeonViewDropLeaderHandObject(uint16 v

uint16 currCell = _vm->normalizeModulo4(_vm->_dungeonMan->_partyDir + viewCell);
Thing removedThing = _vm->_championMan->getObjectRemovedFromLeaderHand();
_vm->_moveSens->getMoveResult(_vm->thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
_vm->_moveSens->getMoveResult(_vm->thingWithNewCell(removedThing, currCell), kDMMapXNotOnASquare, 0, mapX, mapY);
if (droppingIntoAnAlcove && _vm->_dungeonMan->_isFacingViAltar && (_vm->_objectMan->getIconIndex(removedThing) == kDMIconIndiceJunkChampionBones)) {
Junk *removedJunk = (Junk*)_vm->_dungeonMan->getThingData(removedThing);
TimelineEvent newEvent;
Expand Down Expand Up @@ -1442,7 +1442,7 @@ void EventManager::discardAllInput() {
}

void EventManager::commandTakeStairs(bool stairsGoDown) {
_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kDMMapXNotOnASquare, 0);
_vm->_newPartyMapIndex = _vm->_dungeonMan->getLocationAfterLevelChange(_vm->_dungeonMan->_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_partyMapX, &_vm->_dungeonMan->_partyMapY);
_vm->_dungeonMan->setCurrentMap(_vm->_newPartyMapIndex);
_vm->_championMan->setPartyDirection(_vm->_dungeonMan->getStairsExitDirection(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY));
Expand Down

0 comments on commit e413f44

Please sign in to comment.