From 82efa9dd65601d10ce9caaa7cbb384cf468c3f62 Mon Sep 17 00:00:00 2001 From: Joseph-Eugene Winzer Date: Tue, 29 Aug 2017 01:36:05 +0200 Subject: SUPERNOVA: Simplifies timing code Removing remnants of the original code like _timeAlarmSystem. --- engines/supernova/rooms.cpp | 17 +++++++--------- engines/supernova/state.cpp | 47 +++++++++++++++++---------------------------- engines/supernova/state.h | 4 ---- 3 files changed, 25 insertions(+), 43 deletions(-) (limited to 'engines/supernova') diff --git a/engines/supernova/rooms.cpp b/engines/supernova/rooms.cpp index a767156d0c..0ae152f1f5 100644 --- a/engines/supernova/rooms.cpp +++ b/engines/supernova/rooms.cpp @@ -287,9 +287,8 @@ bool ShipSleepCabin::interact(Action verb, Object &obj1, Object &obj2) { } _gm->_state._arrivalDaysLeft -= _gm->_state._timeSleep; *energyDaysLeft -= _gm->_state._timeSleep; - _gm->_state._timeStarting = _gm->_state._time - ticksToMsec(786520); // 12pm - _gm->_state._timeAlarmSystem = _gm->_state._timeAlarm + _gm->_state._timeStarting; - _gm->_state._alarmOn = (_gm->_state._timeAlarmSystem > _gm->_state._time); + _gm->_state._time = ticksToMsec(786520); // 12pm + _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_state._time); if (*energyDaysLeft == 0) { _gm->turnOff(); room = _gm->_rooms[GENERATOR]; @@ -1655,12 +1654,12 @@ bool ArsanoRoger::interact(Action verb, Object &obj1, Object &obj2) { _vm->removeMessage(); _vm->_menuBrightness = 0; _vm->paletteBrightness(); - _gm->_state._timeStarting -= ticksToMsec(125000); // 2 hours - _gm->_state._timeAlarmSystem -= ticksToMsec(125000); + _gm->_state._time -= ticksToMsec(125000); // 2 hours + _gm->_state._timeAlarm -= ticksToMsec(125000); _gm->_state._eventTime = _gm->_state._time + ticksToMsec(4000); // TODO: implement event calling // _gm->_state.event = &supernova; - _gm->_state._alarmOn = (_gm->_state._timeAlarmSystem > _gm->_state._time); + _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_state._time); setSectionVisible(11, false); setSectionVisible(1, false); _vm->renderRoom(*this); @@ -1966,7 +1965,6 @@ bool ArsanoMeetup3::interact(Action verb, Object &obj1, Object &obj2) { _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(3)); // Discman _gm->changeRoom(CELL); _gm->_newRoom = true; - _gm->_state._benOverlay = 2; _gm->_newOverlay = true; _gm->_state._dream = true; } else @@ -1978,9 +1976,8 @@ bool ArsanoMeetup3::interact(Action verb, Object &obj1, Object &obj2) { void AxacussCell::onEntrance() { if (_gm->_state._dream) { _vm->renderMessage("Du wachst auf und findest dich in|einem geschlossenen Raum wieder."); - _gm->_state._timeStarting = _gm->_state._arrivalDaysLeft - ticksToMsec(500000); - _gm->_state._timeAlarmSystem = _gm->_state._timeAlarm + _gm->_state._timeStarting; - _gm->_state._alarmOn = (_gm->_state._timeAlarmSystem > _gm->_state._arrivalDaysLeft); + _gm->_state._time = ticksToMsec(500000); + _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_state._time); _gm->_state._powerOff = false; _gm->_state._dream = false; } diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp index 5756034a87..f5a6a17c1c 100644 --- a/engines/supernova/state.cpp +++ b/engines/supernova/state.cpp @@ -312,14 +312,13 @@ void GameManager::initState() { _animationEnabled = true; _mouseField = -1; _inventoryScroll = 0; + _oldTime = 0; _timer1 = 0; _animationTimer = 0; - _state._time = 0; + _state._time = ticksToMsec(916364); // 2 pm _state._timeSleep = 0; - _state._timeStarting = ticksToMsec(916364); // 2 pm _state._timeAlarm = ticksToMsec(458182); // 7 am - _state._timeAlarmSystem = _state._timeAlarm + _state._timeStarting; _state._eventTime = 0xffffffff; _state._arrivalDaysLeft = 2840; _state._shipEnergyDaysLeft = 2135; @@ -330,7 +329,6 @@ void GameManager::initState() { _state._coins = 0; _state._shoes = 0; _state._destination = 255; - _state._benOverlay = 0; _state._language = 0; _state._corridorSearch = false; _state._alarmOn = false; @@ -723,19 +721,16 @@ void GameManager::taxi() { } void GameManager::outro() { - _state._benOverlay = 3; -// load_overlay(); // title = 2; _vm->playSoundMod(49); // title = 0; - _state._benOverlay = 0; _vm->paletteFadeOut(); _vm->renderImage(55, 0); _vm->paletteFadeIn(); getInput(); _vm->paletteFadeOut(); // TODO: render info file -// longjmp(termination,1); + // Exit } void GameManager::great(uint number) { @@ -920,10 +915,7 @@ void GameManager::roomBrightness() { } void GameManager::loadTime() { - _state._timeStarting += _state._time; - if (_state._eventTime != 1) - _state._eventTime += _state._time; - _state._timeAlarmSystem = _state._timeAlarm + _state._timeStarting; + // STUB } void GameManager::saveTime() { @@ -944,8 +936,8 @@ void GameManager::errorTemp() { } void GameManager::wait2(int ticks) { - uint end = g_system->getMillis() + ticksToMsec(ticks); - while (g_system->getMillis() < end) { + int32 end = _state._time + ticksToMsec(ticks); + while (_state._time < end) { _vm->updateEvents(); g_system->updateScreen(); g_system->delayMillis(_vm->_delay); @@ -953,22 +945,24 @@ void GameManager::wait2(int ticks) { } void GameManager::setAnimationTimer(int ticks) { - _animationTimer = g_system->getMillis() + ticksToMsec(ticks); + _animationTimer = ticksToMsec(ticks); } void GameManager::handleTime() { - _state._time = g_system->getMillis(); - if (_animationTimer <= _state._time) + int32 delta = g_system->getMillis() - _oldTime; + _state._time += delta; + if (_state._time > 86400000) + _state._time -= 86400000; // 24h wrap around + if (_animationTimer > delta) + _animationTimer -= delta; + else _animationTimer = 0; -} -void GameManager::screenShake() { - // STUB + _oldTime = g_system->getMillis(); } -void GameManager::palette() { +void GameManager::screenShake() { // STUB - // Adjust palette to brightness parameters and make it current } void GameManager::shock() { @@ -1266,9 +1260,6 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) { getInput(); _vm->renderRoom(*_currentRoom); roomBrightness(); - palette(); - showMenu(); - drawMapExits(); _vm->renderMessage("Hmm, irgendwie komme|ich mir verarscht vor."); } else if ((verb == ACTION_LOOK) && (obj1._id == KEYCARD2)) { _vm->renderMessage(obj1._description.c_str()); @@ -1278,7 +1269,7 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) { "Es ist eine Uhr mit extra|lautem Wecker. " "Sie hat einen|Knopf zum Verstellen der Alarmzeit.|" "Uhrzeit: %s Alarmzeit: %s", - timeToString(_state._time + _state._timeStarting).c_str(), + timeToString(_state._time).c_str(), timeToString(_state._timeAlarm).c_str()).c_str()); } else if ((verb == ACTION_PRESS) && (obj1._id == WATCH)) { bool validInput = true; @@ -1289,7 +1280,6 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) { _vm->saveScreen(88, 87, 144, 24); _vm->renderBox(88, 87, 144, 24, kColorWhite35); _vm->renderText("Neue Alarmzeit (hh:mm) :", 91, 90, kColorWhite99); - // TODO: Adjust for msec time instead of ticks do { validInput = true; input.clear(); @@ -1337,8 +1327,7 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) { _vm->restoreScreen(); if (_key.keycode != Common::KEYCODE_ESCAPE) { _state._timeAlarm = (hours * 60 + minutes) * 60 * 1000; - _state._timeAlarmSystem = _state._timeAlarm + _state._timeStarting; - _state._alarmOn = (_state._timeAlarmSystem > _vm->_system->getMillis()); + _state._alarmOn = (_state._timeAlarm > _state._time); } } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, TERMINALSTRIP, WIRE)) { r = _rooms[CABIN_L3]; diff --git a/engines/supernova/state.h b/engines/supernova/state.h index 0f6efc05e7..e50ef3bae2 100644 --- a/engines/supernova/state.h +++ b/engines/supernova/state.h @@ -31,9 +31,7 @@ namespace Supernova { struct GameState { int32 _time; int32 _timeSleep; - int32 _timeStarting; int32 _timeAlarm; - int32 _timeAlarmSystem; int32 _eventTime; int32 _arrivalDaysLeft; int32 _shipEnergyDaysLeft; @@ -43,9 +41,7 @@ struct GameState { int16 _money; byte _coins; byte _shoes; - byte _nameSeen; byte _destination; - byte _benOverlay; byte _language; bool _corridorSearch; bool _alarmOn; -- cgit v1.2.3