aboutsummaryrefslogtreecommitdiff
path: root/engines/dm
diff options
context:
space:
mode:
authorBendegúz Nagy2016-07-14 20:23:09 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commit247b9210e1280aef243000b954e880054b4cfaa0 (patch)
tree5aa61a2e6814df46b9c1111dbbab09cde892bdb2 /engines/dm
parentd7c7f110c1f63ec91c0837e09e9a614b6eee3cb2 (diff)
downloadscummvm-rg350-247b9210e1280aef243000b954e880054b4cfaa0.tar.gz
scummvm-rg350-247b9210e1280aef243000b954e880054b4cfaa0.tar.bz2
scummvm-rg350-247b9210e1280aef243000b954e880054b4cfaa0.zip
DM: Some refactoring
Diffstat (limited to 'engines/dm')
-rw-r--r--engines/dm/TODOs/todo.txt5
-rw-r--r--engines/dm/champion.cpp48
-rw-r--r--engines/dm/objectman.cpp19
3 files changed, 36 insertions, 36 deletions
diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 71b8aa191b..5dd2caf8bf 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -8,6 +8,11 @@ Bugs:
When object are put on the right side of the current square, they disappear
Drawing door ornaments segfaults when going back to the start
Placing one of the play icons from the top right corner into one of the champions' hands will crash the engine
+ Sometimes putting stuff in the player's hand segfaults
+ Footprints are everywhere
+ Object display is a bit mixed up with regards to which cell is it drawn in
+ Taking the stairs teleports the player to the wrong position
+
Possible bugs:
- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 1590699e64..7b2dc00ce6 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1162,8 +1162,6 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
}
_g415_leaderEmptyHanded = false;
_vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
-
-
_vm->_eventMan->f78_showMouse();
_vm->_objectMan->f34_drawLeaderObjectName(thing);
if (setMousePointer) {
@@ -1262,49 +1260,47 @@ void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
}
void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) {
- uint16 L0903_ui_ChampionIndex;
- uint16 L0904_ui_SlotIndex;
- Thing L0905_T_LeaderHandObject;
- Thing L0906_T_SlotThing;
-
+ uint16 champIndex;
+ uint16 slotIndex;
if (slotBoxIndex < k8_SlotBoxInventoryFirstSlot) {
- if (_vm->_championMan->_g299_candidateChampionOrdinal) {
+ if (_g299_candidateChampionOrdinal) {
return;
}
- L0903_ui_ChampionIndex = slotBoxIndex >> 1;
- if ((L0903_ui_ChampionIndex >= _vm->_championMan->_g305_partyChampionCount) || (_vm->M0_indexToOrdinal(L0903_ui_ChampionIndex) == (int)_vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_vm->_championMan->_gK71_champions[L0903_ui_ChampionIndex]._currHealth) {
+ champIndex = slotBoxIndex >> 1;
+ if ((champIndex >= _g305_partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_gK71_champions[champIndex]._currHealth) {
return;
}
- L0904_ui_SlotIndex = _vm->_championMan->M70_handSlotIndex(slotBoxIndex);
+ slotIndex = M70_handSlotIndex(slotBoxIndex);
} else {
- L0903_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
- L0904_ui_SlotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
+ champIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+ slotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
}
- L0905_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject;
- if (L0904_ui_SlotIndex >= k30_ChampionSlotChest_1) {
- L0906_T_SlotThing = _vm->_inventoryMan->_g425_chestSlots[L0904_ui_SlotIndex - k30_ChampionSlotChest_1];
+ Thing leaderHandObject = _g414_leaderHandObject;
+ Thing slotThing;
+ if (slotIndex >= k30_ChampionSlotChest_1) {
+ slotThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
} else {
- L0906_T_SlotThing = _vm->_championMan->_gK71_champions[L0903_ui_ChampionIndex]._slots[L0904_ui_SlotIndex];
+ slotThing = _gK71_champions[champIndex]._slots[slotIndex];
}
- if ((L0906_T_SlotThing == Thing::_none) && (L0905_T_LeaderHandObject == Thing::_none)) {
+ if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none)) {
return;
}
- if ((L0905_T_LeaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0905_T_LeaderHandObject)]._allowedSlots & g38_slotMasks[L0904_ui_SlotIndex]))) {
+ if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & g38_slotMasks[slotIndex]))) {
return;
}
_vm->_eventMan->f78_showMouse();
- if (L0905_T_LeaderHandObject != Thing::_none) {
+ if (leaderHandObject != Thing::_none) {
f298_getObjectRemovedFromLeaderHand();
}
- if (L0906_T_SlotThing != Thing::_none) {
- f300_getObjectRemovedFromSlot(L0903_ui_ChampionIndex, L0904_ui_SlotIndex);
- f297_putObjectInLeaderHand(L0906_T_SlotThing, false);
+ if (slotThing != Thing::_none) {
+ f300_getObjectRemovedFromSlot(champIndex, slotIndex);
+ f297_putObjectInLeaderHand(slotThing, false);
}
- if (L0905_T_LeaderHandObject != Thing::_none) {
- _vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0903_ui_ChampionIndex, L0905_T_LeaderHandObject, (ChampionSlot)L0904_ui_SlotIndex);
+ if (leaderHandObject != Thing::_none) {
+ f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot) slotIndex);
}
- _vm->_championMan->f292_drawChampionState((ChampionIndex)L0903_ui_ChampionIndex);
+ f292_drawChampionState((ChampionIndex)champIndex);
_vm->_eventMan->f77_hideMouse();
}
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index ea07c582bf..40c650b0f8 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -236,19 +236,18 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
#define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
- IconIndice iconIndex = f33_getIconIndex(thing);
- char *objName;
- char objectNameBuffer[16];
- if (iconIndex == k147_IconIndiceJunkChampionBones) {
+ char* objectName = nullptr;
+ int16 L0007_i_IconIndex = _vm->_objectMan->f33_getIconIndex(thing);
+ if (L0007_i_IconIndex == k147_IconIndiceJunkChampionBones) {
Junk *junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
- strcpy(objectNameBuffer, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
- strcat(objectNameBuffer, _g352_objectNames[iconIndex]);
- objName = objectNameBuffer;
+ char champBonesName[16];
+ strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
+ strcat(champBonesName, _vm->_objectMan->_g352_objectNames[L0007_i_IconIndex]);
+ objectName = champBonesName;
} else {
- objName = _g352_objectNames[iconIndex];
+ objectName = _vm->_objectMan->_g352_objectNames[L0007_i_IconIndex];
}
- _vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, 233, 37,
- k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen);
+ _vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen);
}
IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) {