HYPNO: fix timer usage during bus puzzle (hard) in spider

This commit is contained in:
neuromancer 2022-06-18 10:00:03 +02:00
parent 20e8482b3d
commit 8186f29f77
9 changed files with 33 additions and 12 deletions

View File

@ -93,6 +93,8 @@ void HypnoEngine::runTimer(Timer *a) {
return; // Do not start another timer
uint32 delay = a->delay / 1000;
if (a->flag == "vus0")
_keepTimerDuringScenes = true;
debugC(1, kHypnoDebugScene, "Starting timer with %d secons", delay);
if (delay == 0 || !startCountdown(delay))

View File

@ -140,11 +140,13 @@ public:
class Timer : public Action {
public:
Timer(uint32 delay_) {
Timer(uint32 delay_, Common::String flag_) {
type = TimerAction;
delay = delay_;
flag = flag_;
}
uint32 delay;
Common::String flag;
};
class Palette : public Action {

View File

@ -1334,11 +1334,11 @@ yyreduce:
case 11: /* line: TIMETOK NUM mflag */
#line 148 "engines/hypno/grammar_mis.y"
{
Timer *a = new Timer((yyvsp[-1].i));
Timer *a = new Timer((yyvsp[-1].i), (yyvsp[0].s));
Hotspots *cur = stack->back();
Hotspot *hot = &cur->back();
hot->actions.push_back(a);
debugC(1, kHypnoDebugParser, "TIME %d", (yyvsp[-1].i)); }
debugC(1, kHypnoDebugParser, "TIME %d %s", (yyvsp[-1].i), (yyvsp[0].s)); }
#line 1343 "engines/hypno/grammar_mis.cpp"
break;

View File

@ -146,11 +146,11 @@ line: MENUTOK mflag mflag mflag {
hot->actions.push_back(a);
debugC(1, kHypnoDebugParser, "ESC SUBMENU"); }
| TIMETOK NUM mflag {
Timer *a = new Timer($2);
Timer *a = new Timer($2, $3);
Hotspots *cur = stack->back();
Hotspot *hot = &cur->back();
hot->actions.push_back(a);
debugC(1, kHypnoDebugParser, "TIME %d", $2); }
debugC(1, kHypnoDebugParser, "TIME %d %s", $2, $3); }
| SWPTTOK NUM {
SwapPointer *a = new SwapPointer($2);
Hotspots *cur = stack->back();

View File

@ -57,7 +57,8 @@ HypnoEngine::HypnoEngine(OSystem *syst, const ADGameDescription *gd)
_defaultCursor(""), _defaultCursorIdx(0), _skipDefeatVideo(false),
_background(nullptr), _masks(nullptr), _musicRate(0), _musicStereo(false),
_additionalVideo(nullptr), _ammo(0), _maxAmmo(0), _skipNextVideo(false),
_doNotStopSounds(false), _screenW(0), _screenH(0) { // Every games initializes its own resolution
_doNotStopSounds(false), _screenW(0), _screenH(0), // Every games initializes its own resolution
_keepTimerDuringScenes(false) {
_rnd = new Common::RandomSource("hypno");
_checkpoint = "";
@ -622,6 +623,7 @@ bool HypnoEngine::startCountdown(uint32 delay) {
void HypnoEngine::removeTimers() {
_timerStarted = false;
_keepTimerDuringScenes = false;
g_system->getTimerManager()->removeTimerProc(&alarmCallback);
g_system->getTimerManager()->removeTimerProc(&countdownCallback);
}

View File

@ -354,6 +354,7 @@ public:
// Timers
int32 _countdown;
bool _timerStarted;
bool _keepTimerDuringScenes;
bool startAlarm(uint32, Common::String *);
bool startCountdown(uint32);
void removeTimers();

View File

@ -277,7 +277,6 @@ void HypnoEngine::runTransition(Transition *trans) {
void HypnoEngine::runScene(Scene *scene) {
changeScreenMode(scene->resolution);
_refreshConversation = false;
_timerStarted = false;
Common::Event event;
Common::Point mousePos;
Common::List<uint32> videosToRemove;
@ -298,7 +297,8 @@ void HypnoEngine::runScene(Scene *scene) {
if (lastCountdown == _countdown) {
} else if (_countdown > 0) {
uint32 c = 251; // red
runMenu(stack.back());
if (stack.size() > 0)
runMenu(stack.back());
uint32 minutes = _countdown / 60;
uint32 seconds = _countdown % 60;
drawString("console", Common::String::format("TIME: %d:%d", minutes, seconds), 80, 10, 60, c);
@ -306,8 +306,10 @@ void HypnoEngine::runScene(Scene *scene) {
} else {
assert(!scene->levelIfLose.empty());
_nextLevel = scene->levelIfLose;
debugC(1, kHypnoDebugScene, "Finishing level and jumping to %s", _nextLevel.c_str());
debugC(1, kHypnoDebugScene, "Finishing level with timeout and jumping to %s", _nextLevel.c_str());
resetSceneState();
removeTimers();
_defaultCursorIdx = 0;
continue;
}
lastCountdown = _countdown;
@ -557,7 +559,8 @@ void HypnoEngine::runScene(Scene *scene) {
_escapeSequentialVideoToPlay.clear();
_conversation.clear();
removeTimers();
if (!_keepTimerDuringScenes)
removeTimers();
}
void HypnoEngine::showConversation() { error("Function \"%s\" not implemented", __FUNCTION__); }

View File

@ -240,6 +240,7 @@ void SpiderEngine::checkMixture(Code *code) {
}
}
_nextLevel = "<after_bus_hard>";
removeTimers();
}
void SpiderEngine::runNote(Code *code) {

View File

@ -324,9 +324,19 @@ void SpiderEngine::loadAssetsFullGame() {
loadSceneLevel("bushard2.mi_", "", prefix);
sc = (Scene *) _levels["bushard2.mi_"];
sc->levelIfLose = "<over_bus>";
Escape *escape = new Escape();
Hotspots *hs = sc->hots[1].smenu;
Hotspots *hs = &sc->hots;
Timer *tm = new Timer(600000, "vus0");
Actions ac = (*hs)[0].actions;
(*hs)[0].actions.clear();
(*hs)[0].actions.push_back(tm);
for (int i = 0; i < int(ac.size()); i++)
(*hs)[0].actions.push_back(ac[i]);
hs = sc->hots[1].smenu;
(*hs)[1].actions.push_back(escape);
cl = new ChangeLevel("<check_mixture>");
@ -965,7 +975,7 @@ void SpiderEngine::loadAssetsFullGame() {
Transition *over_bus = new Transition("tryagain.mi_");
over_bus->intros.push_back("spider/cine/blcs002s.smk");
over_bus->intros.push_back("spider/cine/apt04as.smk");
over_bus->intros.push_back("spider/cine/apts04as.smk");
_levels["<over_bus>"] = over_bus;
Transition *over_octo1 = new Transition("tryagain.mi_");