Skip to content

Commit

Permalink
DM: Refactor DungeonMan
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendegúz Nagy committed Aug 26, 2016
1 parent 63ff166 commit 46b9b11
Show file tree
Hide file tree
Showing 11 changed files with 256 additions and 270 deletions.
26 changes: 13 additions & 13 deletions engines/dm/champion.cpp
Expand Up @@ -437,7 +437,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
}

void ChampionMan::resetDataToStartGame() {
if (!_vm->_dungeonMan->_messages._g298_newGame) {
if (!_vm->_g298_newGame) {
warning("MISSING CODE: stuff for resetting for loaded games");
assert(false);
}
Expand Down Expand Up @@ -468,20 +468,20 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
champ->_actionIndex = k255_ChampionActionNone;
champ->_enableActionEventIndex = -1;
champ->_hideDamageReceivedIndex = -1;
champ->_dir = dunMan._currMap._g308_partyDir;
champ->_dir = dunMan._g308_partyDir;
ViewCell AL_0_viewCell = k0_ViewCellFronLeft;
while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._g308_partyDir) & 3)) != kM1_ChampionNone)
while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone)
AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._g308_partyDir) & 3);
champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3);
champ->clearAttributes(k0x0400_ChampionAttributeIcon);
champ->_directionMaximumDamageReceived = dunMan._currMap._g308_partyDir;
champ->_directionMaximumDamageReceived = dunMan._g308_partyDir;
champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
int16 AL_0_slotIndex_Red;
for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) {
champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
}
Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._g306_partyPosX, dunMan._currMap._g307_partyPosY);
Thing thing = dunMan.getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY);
while (thing.getType() != k2_TextstringType) {
thing = dunMan.getNextThing(thing);
}
Expand Down Expand Up @@ -557,12 +557,12 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
_vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
}

int16 mapX = _vm->_dungeonMan->_currMap._g306_partyPosX;
int16 mapY = _vm->_dungeonMan->_currMap._g307_partyPosY;
int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
int16 mapY = _vm->_dungeonMan->_g307_partyMapY;

uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._g308_partyDir));
mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._g308_partyDir];
mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._g308_partyDir];
uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir));
mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
thing = dunMan.getSquareFirstThing(mapX, mapY);
AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1;
uint16 slotIndex_Green;
Expand Down Expand Up @@ -850,11 +850,11 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
}

{ // block so goto won't skip AL_0_championIconIndex initialization
int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._g308_partyDir);
int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir);

if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]);
dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._g308_partyDir) * 19, 0,
dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0,
g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
}
}
Expand Down
12 changes: 6 additions & 6 deletions engines/dm/dm.cpp
Expand Up @@ -179,9 +179,9 @@ void DMEngine::startGame() {
_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
warning("MISSING CODE: set primary/secondary keyboard input");

processNewPartyMap(_dungeonMan->_currMap._g309_currPartyMapIndex);
processNewPartyMap(_dungeonMan->_g309_partyMapIndex);

if (!_dungeonMan->_messages._g298_newGame) {
if (!_g298_newGame) {
warning("TODO: loading game");
} else {
_displayMan->_g578_useByteBoxCoordinates = false;
Expand Down Expand Up @@ -233,9 +233,9 @@ Common::Error DMEngine::run() {

void DMEngine::gameloop() {
warning("DUMMY CODE SETTING PARTY POS AND DIRECTION");
_dungeonMan->_currMap._g306_partyPosX = 10;
_dungeonMan->_currMap._g307_partyPosY = 4;
_dungeonMan->_currMap._g308_partyDir = kDirNorth;
_dungeonMan->_g306_partyMapX = 10;
_dungeonMan->_g307_partyMapY = 4;
_dungeonMan->_g308_partyDir = kDirNorth;


warning("DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero");
Expand All @@ -254,7 +254,7 @@ void DMEngine::gameloop() {
if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
Box box(0, 224, 0, 126);
_displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code
_displayMan->drawDungeon(_dungeonMan->_currMap._g308_partyDir, _dungeonMan->_currMap._g306_partyPosX, _dungeonMan->_currMap._g307_partyPosY);
_displayMan->drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
}
// DUMMY CODE: next line
_menuMan->drawMovementArrows();
Expand Down
4 changes: 4 additions & 0 deletions engines/dm/dm.h
Expand Up @@ -168,6 +168,10 @@ class DMEngine : public Engine {
GroupMan *_groupMan;
Timeline *_timeline;


bool _g298_newGame; // @ G0298_B_NewGame
bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested

bool _g321_stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking
bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed
Expand Down

0 comments on commit 46b9b11

Please sign in to comment.