Skip to content

Commit

Permalink
DM: Add GroupMan, Group, ActiveGroup, F0196_GROUP_InitializeActiveGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendegúz Nagy committed Aug 26, 2016
1 parent f3d4b85 commit 5bb19fd
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 22 deletions.
6 changes: 5 additions & 1 deletion engines/dm/TODOs/methodtree.txt
Expand Up @@ -9,6 +9,10 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
F0158_DUNGEON_GetWeaponInfo // done
M66_PROJECTILE_ASPECT_ORDINAL // done
F0176_GROUP_GetCreatureOrdinalInCell
F0145_DUNGEON_GetGroupCells
F0147_DUNGEON_GetGroupDirections
GROUP // done
CreatureType
G0017_auc_Graphic562_PaletteChanges_NoChanges
G0075_apuc_PaletteChanges_Projectile
G0077_B_DoNotDrawFluxcagesDuringEndgame
Expand Down Expand Up @@ -40,7 +44,7 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
G0370_ps_Events
G0375_ps_ActiveGroups
OBJECT_ASPECT
GROUP
GROUP // done
ACTIVE_GROUP
CREATURE_INFO
CREATURE_ASPECT
Expand Down
7 changes: 5 additions & 2 deletions engines/dm/dm.cpp
Expand Up @@ -49,6 +49,7 @@
#include "inventory.h"
#include "text.h"
#include "movesens.h"
#include "group.h"

namespace DM {

Expand Down Expand Up @@ -93,7 +94,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
_inventoryMan = nullptr;
_textMan = nullptr;
_movsens = nullptr;

_groupMan = nullptr;
_stopWaitingForPlayerInput = false;
_gameTimeTicking = false;
_restartGameAllowed = false;
Expand Down Expand Up @@ -122,6 +123,7 @@ DMEngine::~DMEngine() {
delete _inventoryMan;
delete _textMan;
delete _movsens;
delete _groupMan;

// clear debug channels
DebugMan.clearAllDebugChannels();
Expand Down Expand Up @@ -203,7 +205,8 @@ Common::Error DMEngine::run() {
_objectMan = new ObjectMan(this);
_inventoryMan = new InventoryMan(this);
_textMan = new TextMan(this);
_movsens = new MovesensMan(this);
_movsens = new MovesensMan(this);
_groupMan = new GroupMan(this);
_displayMan->setUpScreens(320, 200);

initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
Expand Down
2 changes: 2 additions & 0 deletions engines/dm/dm.h
Expand Up @@ -46,6 +46,7 @@ class ObjectMan;
class InventoryMan;
class TextMan;
class MovesensMan;
class GroupMan;


enum direction {
Expand Down Expand Up @@ -161,6 +162,7 @@ class DMEngine : public Engine {
InventoryMan *_inventoryMan;
TextMan *_textMan;
MovesensMan *_movsens;
GroupMan *_groupMan;

bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
Expand Down
2 changes: 1 addition & 1 deletion engines/dm/dungeonman.cpp
Expand Up @@ -1305,7 +1305,7 @@ int16 DungeonMan::getProjectileAspect(Thing thing) {
int16 projAspOrd;
WeaponInfo *weaponInfo;

if ((thingType == thing.getType()) == kExplosionThingType) {
if ((thingType = thing.getType()) == kExplosionThingType) {
if (thing == Thing::_explFireBall)
return -_vm->indexToOrdinal(kProjectileAspectExplosionFireBall);
if (thing == Thing::_explSlime)
Expand Down
17 changes: 0 additions & 17 deletions engines/dm/dungeonman.h
Expand Up @@ -326,23 +326,6 @@ class Sensor {
// some macros missing, i got bored
}; // @ SENSOR

class Group {
Thing _nextThing;
Thing _possessionID;
byte _type;
byte _position;
uint16 _health[4];
uint16 _attributes;
public:
explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _possessionID(rawDat[1]), _type(rawDat[2]),
_position(rawDat[3]), _attributes(rawDat[8]) {
_health[0] = rawDat[4];
_health[1] = rawDat[5];
_health[2] = rawDat[6];
_health[3] = rawDat[7];
}
Thing getNextThing() { return _nextThing; }
}; // @ GROUP

enum WeaponType {
kWeaponTypeTorch = 2, // @ C02_WEAPON_TORCH
Expand Down
54 changes: 54 additions & 0 deletions engines/dm/group.cpp
@@ -0,0 +1,54 @@
/* 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 "group.h"
#include "dungeonman.h"



namespace DM {


GroupMan::GroupMan(DMEngine* vm) : _vm(vm) {
_activeGroups = nullptr;
}

GroupMan::~GroupMan() {
delete[] _activeGroups;
}

void GroupMan::initActiveGroups() {
if (_vm->_dungeonMan->_messages._newGame)
_maxActiveGroupCount = 60;
if (_activeGroups)
delete[] _activeGroups;
_activeGroups = new ActiveGroup[_maxActiveGroupCount];
for (uint16 i = 0; i < _maxActiveGroupCount; ++i)
_activeGroups[i]._groupThingIndex = -1;
}

}
94 changes: 94 additions & 0 deletions engines/dm/group.h
@@ -0,0 +1,94 @@
/* 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/)
*/


#ifndef DM_GROUP_H
#define DM_GROUP_H

#include "dm.h"

namespace DM {

class ActiveGroup {
public:
int _groupThingIndex;
byte _directions;
byte _cells;
byte _lastMoveTime;
byte _delayFleeingFromTarget;
byte _targetMapX;
byte _targetMapY;
byte _priorMapX;
byte _priorMapY;
byte _homeMapX;
byte _homeMapY;
byte _aspect[4];
}; // @ ACTIVE_GROUP


class Group {
public:
Thing _nextThing;
Thing _slot;
byte _type;
byte _cells;
uint16 _health[4];
private:
uint16 _flags;
public:
explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _type(rawDat[2]),
_cells(rawDat[3]), _flags(rawDat[8]) {
_health[0] = rawDat[4];
_health[1] = rawDat[5];
_health[2] = rawDat[6];
_health[3] = rawDat[7];
}

byte &getActiveGroupIndex() { return _cells; }

uint16 getBehaviour() { return _flags & 0xF; }
uint16 getCount() { return (_flags >> 5) & 0x3; }
direction getDir() { return (direction)((_flags >> 8) & 0x3); }
uint16 getDoNotDiscard() { return (_flags >> 10) & 0x1; }
}; // @ GROUP


class GroupMan {
DMEngine *_vm;
public:
uint16 _maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount
ActiveGroup *_activeGroups; // @ G0375_ps_ActiveGroups
GroupMan(DMEngine *vm);
~GroupMan();
void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
};



}

#endif
4 changes: 3 additions & 1 deletion engines/dm/loadsave.cpp
Expand Up @@ -28,6 +28,7 @@
#include "loadsave.h"
#include "dungeonman.h"
#include "champion.h"
#include "group.h"



Expand All @@ -53,7 +54,8 @@ LoadgameResponse LoadsaveMan::loadgame() {


if (newGame) {
warning("MISSING CODE: Timline init, Group init");
warning("MISSING CODE: Timline init");
_vm->_groupMan->initActiveGroups();
} else {
assert(false);
// MISSING CODE: load game
Expand Down
1 change: 1 addition & 0 deletions engines/dm/module.mk
Expand Up @@ -36,6 +36,7 @@ MODULE_OBJS := \
dungeonman.o \
eventman.o \
gfx.o \
group.o \
inventory.o \
loadsave.o \
menus.o \
Expand Down

0 comments on commit 5bb19fd

Please sign in to comment.