From 3ff3512c64fd3e5245b45506203a8d5083598a88 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 11:36:31 +0200 Subject: DM: Add initialization related to F0435_STARTEND_LoadGame_CPSF --- engines/dm/champion.cpp | 4 ++++ engines/dm/champion.h | 10 +++++++++- engines/dm/dm.cpp | 20 ++++++++++++++++---- engines/dm/dm.h | 6 ++++++ engines/dm/loadsave.cpp | 37 +++++++++++++++++++++++++++++++++++++ engines/dm/loadsave.h | 25 +++++++++++++++++++++++++ engines/dm/module.mk | 3 ++- 7 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 engines/dm/loadsave.cpp create mode 100644 engines/dm/loadsave.h (limited to 'engines') diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b3a4ad5c73..0e0d5e8eea 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -5,4 +5,8 @@ namespace DM { ChampionMan::ChampionMan(DMEngine *vm): _vm(vm) {} +ChampionIndex ChampionMan::getIndexInCell(int16 mapX, int16 mapY, ViewCell cell) { + return kChampionNone; +} + } \ No newline at end of file diff --git a/engines/dm/champion.h b/engines/dm/champion.h index ab6d4916ec..36f1689b7a 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -6,9 +6,12 @@ namespace DM { -enum ChampionIndice { +enum ChampionIndex { kChampionNone = -1, // @ CM1_CHAMPION_NONE kChampionFirst = 0, // @ C00_CHAMPION_FIRST + kChampionSecond = 1, + kChampionThird = 2, + kChampionFourth = 3, kChmpionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY kChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY }; @@ -242,7 +245,12 @@ class ChampionMan { DMEngine *_vm; Champion champions[4]; public: + uint16 _partChampionCount; + bool _partyDead; // @ G0303_B_PartyDead + Thing _leaderHand; + ChampionMan(DMEngine *vm); + ChampionIndex getIndexInCell(int16 mapX, int16 mapY, ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell }; } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 7875c5c45d..77d7ed012a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -16,6 +16,8 @@ #include "dungeonman.h" #include "eventman.h" #include "menus.h" +#include "champion.h" +#include "loadsave.h" namespace DM { @@ -41,10 +43,12 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { // register random source _rnd = new Common::RandomSource("quux"); - _displayMan = nullptr; _dungeonMan = nullptr; + _displayMan = nullptr; _eventMan = nullptr; _menuMan = nullptr; + _championMan = nullptr; + _loadsaveMan = nullptr; _stopWaitingForPlayerInput = false; _gameTimeTicking = false; @@ -61,6 +65,8 @@ DMEngine::~DMEngine() { delete _dungeonMan; delete _eventMan; delete _menuMan; + delete _championMan; + delete _loadsaveMan; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -74,14 +80,15 @@ Common::Error DMEngine::run() { _dungeonMan = new DungeonMan(this); _eventMan = new EventManager(this); _menuMan = new MenuMan(this); + _championMan = new ChampionMan(this); + _loadsaveMan = new LoadsaveMan(this); _displayMan->setUpScreens(320, 200); _displayMan->loadGraphics(); _dungeonMan->loadDungeonFile(); - int16 dummyMapIndex = 0; - _dungeonMan->setCurrentMapAndPartyMap(dummyMapIndex); + _dungeonMan->setCurrentMapAndPartyMap(0); _displayMan->loadCurrentMapGraphics(); @@ -90,13 +97,15 @@ Common::Error DMEngine::run() { _eventMan->initMouse(); _eventMan->showMouse(true); + _loadsaveMan->loadgame(); + startGame(); while (true) { _stopWaitingForPlayerInput = false; //do { - _eventMan->processInput(); + _eventMan->processInput(); _eventMan->processCommandQueue(); //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); @@ -117,8 +126,11 @@ void DMEngine::startGame() { _eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface; _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; + _menuMan->drawMovementArrows(); _gameTimeTicking = true; + + // MISSING CODE: Lot of stuff } } // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h index de37d3fceb..67d968a7f9 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -13,6 +13,8 @@ class DisplayMan; class DungeonMan; class EventManager; class MenuMan; +class ChampionMan; +class LoadsaveMan; enum direction { @@ -92,8 +94,12 @@ public: DungeonMan *_dungeonMan; EventManager *_eventMan; MenuMan *_menuMan; + ChampionMan *_championMan; + LoadsaveMan *_loadsaveMan; bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput bool _gameTimeTicking; // @ G0301_B_GameTimeTicking + bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed + uint32 _gameId; // @ G0525_l_GameID, probably useless here }; class Console : public GUI::Debugger { diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp new file mode 100644 index 0000000000..cd522fa508 --- /dev/null +++ b/engines/dm/loadsave.cpp @@ -0,0 +1,37 @@ +#include "loadsave.h" +#include "dungeonman.h" +#include "champion.h" + + + +namespace DM { + +LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {} + + +LoadgameResponse LoadsaveMan::loadgame() { + bool newGame = _vm->_dungeonMan->_messages.newGame; + ChampionMan &cm = *_vm->_championMan; + + if (newGame) { + _vm->_restartGameAllowed = false; + cm._partChampionCount = 0; + cm._leaderHand = Thing::thingNone; + _vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); + } else { + assert(false); + // MISSING CODE: load game + } + + + if (newGame) { + warning("MISSING CODE: Timline init, Group init"); + } else { + assert(false); + // MISSING CODE: load game + } + cm._partyDead = false; + return kLoadgameSuccess; +} + +} \ No newline at end of file diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h new file mode 100644 index 0000000000..857191200f --- /dev/null +++ b/engines/dm/loadsave.h @@ -0,0 +1,25 @@ +#ifndef DM_LOADSAVE_H +#define DM_LOADSAVE_H + +#include "dm.h" + +namespace DM { + +enum LoadgameResponse { + kLoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE + kLoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS +}; + +class LoadsaveMan { + DMEngine *_vm; +public: + LoadsaveMan(DMEngine *vm); + + LoadgameResponse loadgame(); // @ F0435_STARTEND_LoadGame_CPSF + +}; + +} + +#endif + diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 1acf291453..45a6ed528d 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -7,7 +7,8 @@ MODULE_OBJS := \ dungeonman.o \ eventman.o \ menus.o \ - champion.o + champion.o \ + loadsave.o MODULE_DIRS += \ engines/dm -- cgit v1.2.3