aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2016-06-29 22:51:40 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commit57ca9afcff6b688d438a7c02096141921f28fc36 (patch)
tree88ef7a71816552f655e3b7affe7fae2037de9be6
parent3f19bcdf6b47bc7227eb91c6eb95fb20335276f6 (diff)
downloadscummvm-rg350-57ca9afcff6b688d438a7c02096141921f28fc36.tar.gz
scummvm-rg350-57ca9afcff6b688d438a7c02096141921f28fc36.tar.bz2
scummvm-rg350-57ca9afcff6b688d438a7c02096141921f28fc36.zip
DM: Move two global arrays to DMEngine
-rw-r--r--engines/dm/champion.cpp4
-rw-r--r--engines/dm/dm.cpp3
-rw-r--r--engines/dm/dm.h10
-rw-r--r--engines/dm/dmglobals.cpp55
-rw-r--r--engines/dm/dungeonman.cpp8
-rw-r--r--engines/dm/eventman.cpp12
-rw-r--r--engines/dm/module.mk1
7 files changed, 74 insertions, 19 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index cce3f558a7..88e03a52d5 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -561,8 +561,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
- mapX += gDirIntoStepCountEast[dunMan._currMap._partyDir];
- mapY += gDirIntoStepCountNorth[dunMan._currMap._partyDir];
+ mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._partyDir];
+ mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._partyDir];
thing = dunMan.getSquareFirstThing(mapX, mapY);
AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
uint16 slotIndex_Green;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 0df836a45a..af0c9d587c 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -52,9 +52,6 @@
namespace DM {
-int8 gDirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
-int8 gDirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
-
void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); }
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 7b68e6d5a3..4bf858422c 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -55,10 +55,6 @@ enum direction {
kDirWest = 3
};
-// TODO: refactor direction into a class
-extern int8 gDirIntoStepCountEast[4];
-extern int8 gDirIntoStepCountNorth[4];
-
void turnDirRight(direction &dir);
void turnDirLeft(direction &dir);
direction returnOppositeDir(direction dir);
@@ -128,6 +124,8 @@ class DMEngine : public Engine {
void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
+ void initArrays();
+
public:
explicit DMEngine(OSystem *syst);
~DMEngine();
@@ -160,6 +158,10 @@ public:
bool _pressingMouth; // @ G0333_B_PressingMouth
bool _stopPressingMouth; // @ G0334_B_StopPressingMouth
bool _highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested
+
+ // TODO: refactor direction into a class
+ int8 _dirIntoStepCountEast[4];
+ int8 _dirIntoStepCountNorth[4];
};
class Console : public GUI::Debugger {
diff --git a/engines/dm/dmglobals.cpp b/engines/dm/dmglobals.cpp
new file mode 100644
index 0000000000..c138453c31
--- /dev/null
+++ b/engines/dm/dmglobals.cpp
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "dm/dm.h"
+#include "gfx.h"
+#include "dungeonman.h"
+#include "eventman.h"
+#include "menus.h"
+#include "champion.h"
+#include "loadsave.h"
+#include "objectman.h"
+#include "inventory.h"
+#include "text.h"
+#include "movesens.h"
+
+namespace DM {
+
+void DMEngine::initArrays() {
+ // G0233_ai_Graphic559_DirectionToStepEastCount
+ _dirIntoStepCountEast[0] = 0; // North
+ _dirIntoStepCountEast[1] = 1; // East
+ _dirIntoStepCountEast[2] = 0; // West
+ _dirIntoStepCountEast[3] = -1; // South
+
+ // G0234_ai_Graphic559_DirectionToStepNorthCount
+ _dirIntoStepCountNorth[0] = -1; // North
+ _dirIntoStepCountNorth[1] = 0; // East
+ _dirIntoStepCountNorth[2] = 1; // West
+ _dirIntoStepCountNorth[3] = 0; // South
+}
+} // End of namespace DM
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 899e7911ad..83c43aac3d 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -360,11 +360,11 @@ CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_Crea
{26, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}};
void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
- posX += gDirIntoStepCountEast[dir] * stepsForward;
- posY += gDirIntoStepCountNorth[dir] * stepsForward;
+ posX += _vm->_dirIntoStepCountEast[dir] * stepsForward;
+ posY += _vm->_dirIntoStepCountNorth[dir] * stepsForward;
turnDirRight(dir);
- posX += gDirIntoStepCountEast[dir] * stepsRight;
- posY += gDirIntoStepCountNorth[dir] * stepsRight;
+ posX += _vm->_dirIntoStepCountEast[dir] * stepsRight;
+ posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight;
}
DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 20c2888aec..f26930c542 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -508,8 +508,8 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
DungeonMan &dunMan = *_vm->_dungeonMan;
CurrMapData &currMap = dunMan._currMap;
- int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir];
- int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir];
+ int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
+ int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
if ((mapX >= 0) && (mapX < currMap._width) && (mapY >= 0) && (mapY < currMap._height)) {
_vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir));
}
@@ -525,8 +525,8 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
return;
if (champMan._leaderEmptyHanded) {
- int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir];
- int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir];
+ int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
+ int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() &&
dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
@@ -627,8 +627,8 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
}
champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
- int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir];
- int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir];
+ int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
+ int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
Thing thing = champ->getSlot((ChampionSlot)slotIndex);
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index d5756c9d5f..28bcaa2a54 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -32,6 +32,7 @@ MODULE_OBJS := \
champion.o \
detection.o \
dm.o \
+ dmglobals.o \
dungeonman.o \
eventman.o \
gfx.o \