[Scummvm-git-logs] scummvm master -> 9e33332b8cefb386e398832504414880c134c184

neuromancer neuromancer at users.noreply.github.com
Sun Nov 7 16:39:29 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9e33332b8c HYPNO: refactored level handling to remove duplicated fields


Commit: 9e33332b8cefb386e398832504414880c134c184
    https://github.com/scummvm/scummvm/commit/9e33332b8cefb386e398832504414880c134c184
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2021-11-07T17:39:09+01:00

Commit Message:
HYPNO: refactored level handling to remove duplicated fields

Changed paths:
    engines/hypno/arcade.cpp
    engines/hypno/grammar.h
    engines/hypno/grammar_arc.cpp
    engines/hypno/grammar_arc.y
    engines/hypno/grammar_mis.cpp
    engines/hypno/hypno.cpp
    engines/hypno/hypno.h
    engines/hypno/scene.cpp
    engines/hypno/spider/spider.cpp
    engines/hypno/wet/wet.cpp


diff --git a/engines/hypno/arcade.cpp b/engines/hypno/arcade.cpp
index ef5c59b6e9..300a1f253d 100644
--- a/engines/hypno/arcade.cpp
+++ b/engines/hypno/arcade.cpp
@@ -55,10 +55,9 @@ void HypnoEngine::splitArcadeFile(const Common::String &filename, Common::String
 void HypnoEngine::parseArcadeShooting(const Common::String &prefix, const Common::String &filename, const Common::String &data) {
 	debugC(1, kHypnoDebugParser, "Parsing %s/%s", prefix.c_str(), filename.c_str());
 	parse_arc(data.c_str());
-	Level level;
-	level.arcade = *g_parsedArc;
-	level.arcade.prefix = prefix;
-	_levels[filename] = level;
+	ArcadeShooting *arcade = new ArcadeShooting();
+	*arcade = *g_parsedArc; 
+	_levels[filename] = (Level*) arcade;
 	g_parsedArc->background.clear();
 	g_parsedArc->player.clear();
 	g_parsedArc->shoots.clear();
@@ -95,11 +94,11 @@ void HypnoEngine::loadArcadeLevel(const Common::String &current, const Common::S
 	Common::String arc;
 	Common::String list;
 	splitArcadeFile(arclevel, arc, list);
-	debug("%s", arc.c_str());
+	debugC(1, kHypnoDebugParser, "%s", arc.c_str());
 	parseArcadeShooting("", arclevel, arc);
-	_levels[arclevel].arcade.shootSequence = parseShootList(arclevel, list);
-	_levels[arclevel].arcade.prefix = prefix;
-	_levels[arclevel].arcade.levelIfWin = next + _difficulty + ".mi_";;
+	ArcadeShooting *arcade = (ArcadeShooting *) _levels[arclevel]; 
+	arcade->shootSequence = parseShootList(arclevel, list);
+	arcade->prefix = prefix.c_str();
 }
 
 void HypnoEngine::drawPlayer() { error("Function \"%s\" not implemented", __FUNCTION__); }
@@ -112,21 +111,21 @@ void HypnoEngine::hitPlayer() {
 		_playerFrameIdx = _playerFrameSep;
 }
 
-void HypnoEngine::runArcade(ArcadeShooting &arc) {
-	_arcadeMode = arc.mode;
+void HypnoEngine::runArcade(ArcadeShooting *arc) {
+	_arcadeMode = arc->mode;
 	Common::Point mousePos;
 	Common::List<uint32> shootsToRemove;
-	ShootSequence shootSequence = arc.shootSequence;
+	ShootSequence shootSequence = arc->shootSequence;
 
 	_font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
-	_levelId = arc.id;
-	_shootSound = arc.shootSound;
+	_levelId = arc->id;
+	_shootSound = arc->shootSound;
 	_score = 0;
-	_health = arc.health;
+	_health = arc->health;
 	_maxHealth = _health;
 	_defaultCursor = "arcade";
 	_shoots.clear();
-	_playerFrames = decodeFrames(arc.player);
+	_playerFrames = decodeFrames(arc->player);
 	_playerFrameSep = 0;
 	_playerPosition = 0;
 
@@ -140,14 +139,14 @@ void HypnoEngine::runArcade(ArcadeShooting &arc) {
 	}
 
 	if (_playerFrameSep == (int)_playerFrames.size()) {
-		debugC(1, kHypnoDebugArcade, "No player separator frame found in %s! (size: %d)", arc.player.c_str(), _playerFrames.size());
+		debugC(1, kHypnoDebugArcade, "No player separator frame found in %s! (size: %d)", arc->player.c_str(), _playerFrames.size());
 		//_playerFrameSep = -1;
 	} else 
 		debugC(1, kHypnoDebugArcade, "Separator frame found at %d", _playerFrameSep);
 
 	_playerFrameIdx = -1;
 
-	MVideo background = MVideo(arc.background, Common::Point(0, 0), false, false, false);
+	MVideo background = MVideo(arc->background, Common::Point(0, 0), false, false, false);
 
 	changeCursor("arcade");
 	playVideo(background);
@@ -214,30 +213,30 @@ void HypnoEngine::runArcade(ArcadeShooting &arc) {
 
 		if (_health <= 0) {
 			skipVideo(background);
-			if (!arc.defeatVideos.empty()) {
-				MVideo video(arc.defeatVideos.front(), Common::Point(0, 0), false, false, false);
+			if (!arc->defeatVideos.empty()) {
+				MVideo video(arc->defeatVideos.front(), Common::Point(0, 0), false, false, false);
 				runIntro(video);
 			}
-			_nextLevel = arc.levelIfLose;
+			_nextLevel = arc->levelIfLose;
 			debugC(1, kHypnoDebugArcade, "Losing level and jumping to %s", _nextLevel.c_str());
 			break;
 		}
 
-		if (!arc.transitionVideo.empty() && background.decoder->getCurFrame() >= (int)arc.transitionTime) {
-			debugC(1, kHypnoDebugArcade, "Playing transition %s", arc.transitionVideo.c_str());
-			arc.transitionTime = background.decoder->getFrameCount() + 1;
-			MVideo video(arc.transitionVideo, Common::Point(0, 0), false, false, false);
+		if (!arc->transitionVideo.empty() && background.decoder->getCurFrame() >= (int)arc->transitionTime) {
+			debugC(1, kHypnoDebugArcade, "Playing transition %s", arc->transitionVideo.c_str());
+			arc->transitionTime = background.decoder->getFrameCount() + 1;
+			MVideo video(arc->transitionVideo, Common::Point(0, 0), false, false, false);
 			runIntro(video);
 			skipVideo(background);
 		}
 
 		if (!background.decoder || background.decoder->endOfVideo()) {
 			skipVideo(background);
-			if (!arc.winVideos.empty()) {
-				MVideo video(arc.winVideos.front(), Common::Point(0, 0), false, false, false);
+			if (!arc->winVideos.empty()) {
+				MVideo video(arc->winVideos.front(), Common::Point(0, 0), false, false, false);
 				runIntro(video);
 			}
-			_nextLevel = arc.levelIfWin;
+			_nextLevel = arc->levelIfWin;
 			debugC(1, kHypnoDebugArcade, "Wining level and jumping to %s", _nextLevel.c_str());
 			break;
 		}
@@ -246,13 +245,13 @@ void HypnoEngine::runArcade(ArcadeShooting &arc) {
 			ShootInfo si = shootSequence.front();
 			if ((int)si.timestamp <= background.decoder->getCurFrame()) {
 				shootSequence.pop_front();
-				for (Shoots::iterator it = arc.shoots.begin(); it != arc.shoots.end(); ++it) {
+				for (Shoots::iterator it = arc->shoots.begin(); it != arc->shoots.end(); ++it) {
 					if (it->name == si.name && it->animation != "NONE") {
 						Shoot s = *it;
 						s.video = new MVideo(it->animation, it->position, true, false, false);
 						playVideo(*s.video);
 						_shoots.push_back(s);
-						playSound(_soundPath + arc.enemySound, 1);
+						playSound(_soundPath + arc->enemySound, 1);
 					}
 				}
 			}
@@ -289,8 +288,8 @@ void HypnoEngine::runArcade(ArcadeShooting &arc) {
 		}
 
 		if (_music.empty()) {
-			_music = _soundPath + arc.music;
-			playSound(_music, 1);
+			_music = _soundPath + arc->music;
+			playSound(_music, 0); // music loop forever
 		}
 
 		if (needsUpdate) {
diff --git a/engines/hypno/grammar.h b/engines/hypno/grammar.h
index 290d3bb7a2..a618542108 100644
--- a/engines/hypno/grammar.h
+++ b/engines/hypno/grammar.h
@@ -304,34 +304,37 @@ public:
 typedef Common::List<ShootInfo> ShootSequence;
 typedef Common::Array<Common::String> Sounds;
 
-class Transition {
-public:
-	Common::String level;
-	Filename frameImage;
-	uint32 frameNumber;
-	Filenames intros;
+enum LevelType {
+	TransitionLevel,
+	SceneLevel,
+	ArcadeLevel,
+	CodeLevel
 };
 
-class Code {
+class Level {
 public:
-	Common::String name;
+	virtual ~Level() {} // needed to make Level polymorphic
+	LevelType type;
 	Filenames intros;
-	Common::String levelIfWin;
-	Common::String levelIfLose;
+	Filename prefix;
+	Filename levelIfWin;
+	Filename levelIfLose;
+	Filename music;
 };
 
-class Scene {
+class Scene : public Level {
 public:
-	Filename intro;
-	Common::String prefix;
+	Scene()  {
+		type = SceneLevel;
+	}
 	Hotspots hots;
-	Filename sound;
-	Common::String levelIfWin;
-	Common::String levelIfLose;
 };
 
-class ArcadeShooting {
+class ArcadeShooting : public Level {
 public:
+	ArcadeShooting()  {
+		type = ArcadeLevel;
+	}
 	uint32 id;
 	Common::String mode;
 	Common::String levelIfWin;
@@ -340,8 +343,6 @@ public:
 	uint32 transitionTime;
 	Filenames defeatVideos;
 	Filenames winVideos;
-	Filename intro;
-	Filename prefix;
 	Filename background;
 	Filename player;
 	int health;
@@ -350,18 +351,27 @@ public:
 	Filename shootSound;
 	Filename enemySound;
 	Filename hitSound;
-	Filename music;
 };
 
-class Level {
+class Transition : public Level {
 public:
-	Transition trans;
-	Scene scene;
-	ArcadeShooting arcade;
-	Code code;
+	Transition()  {
+		type = TransitionLevel;
+	}
+	Common::String level;
+	Filename frameImage;
+	uint32 frameNumber;
+};
+
+class Code : public Level {
+public:
+	Code()  {
+		type = CodeLevel;
+	}
+	Common::String name;
 };
 
-typedef Common::HashMap<Filename, Level> Levels;
+typedef Common::HashMap<Filename, Level*> Levels;
 extern Hotspots *g_parsedHots;
 extern ArcadeShooting *g_parsedArc;
 
diff --git a/engines/hypno/grammar_arc.cpp b/engines/hypno/grammar_arc.cpp
index 69bcb4c34b..ca6feb731f 100644
--- a/engines/hypno/grammar_arc.cpp
+++ b/engines/hypno/grammar_arc.cpp
@@ -1476,7 +1476,7 @@ yyreduce:
 #line 116 "engines/hypno/grammar_arc.y" /* yacc.c:1646  */
     {
 		if (Common::String("B0") == (yyvsp[-1].s))
-			g_parsedArc->intro = (yyvsp[0].s);
+			g_parsedArc->intros.push_back((yyvsp[0].s));
 		else if(Common::String("B1") == (yyvsp[-1].s) || Common::String("B2") == (yyvsp[-1].s))
 			g_parsedArc->winVideos.push_back((yyvsp[0].s));
 		else if(Common::String("B3") == (yyvsp[-1].s) || Common::String("B4") == (yyvsp[-1].s))
diff --git a/engines/hypno/grammar_arc.y b/engines/hypno/grammar_arc.y
index 4ae9028807..73484110db 100644
--- a/engines/hypno/grammar_arc.y
+++ b/engines/hypno/grammar_arc.y
@@ -115,7 +115,7 @@ hline: 	CTOK NUM {
 	| QTOK NUM NUM { debugC(1, kHypnoDebugParser, "Q %d %d", $2, $3); }
 	| BNTOK FILENAME {
 		if (Common::String("B0") == $1)
-			g_parsedArc->intro = $2;
+			g_parsedArc->intros.push_back($2);
 		else if(Common::String("B1") == $1 || Common::String("B2") == $1)
 			g_parsedArc->winVideos.push_back($2);
 		else if(Common::String("B3") == $1 || Common::String("B4") == $1)
diff --git a/engines/hypno/grammar_mis.cpp b/engines/hypno/grammar_mis.cpp
index 2c7cea41b8..4a5cf3c45b 100644
--- a/engines/hypno/grammar_mis.cpp
+++ b/engines/hypno/grammar_mis.cpp
@@ -1573,7 +1573,7 @@ yyreduce:
 #line 200 "engines/hypno/grammar_mis.y" /* yacc.c:1646  */
     { 
 		debugC(1, kHypnoDebugParser, "explicit END");
-		g_parsedHots = stack->back(); 
+		g_parsedHots = stack->back();
 		stack->pop_back();
 		smenu_idx->pop_back();
 	}
diff --git a/engines/hypno/hypno.cpp b/engines/hypno/hypno.cpp
index 81b0080f22..a0b313548a 100644
--- a/engines/hypno/hypno.cpp
+++ b/engines/hypno/hypno.cpp
@@ -70,23 +70,23 @@ HypnoEngine::HypnoEngine(OSystem *syst, const ADGameDescription *gd)
 	Hotspot q(MakeMenu, "");
 	Action *a = new Quit();
 	q.actions.push_back(a);
-	Level quit;
+	Scene *quit = new Scene();
 	Hotspots hs;
 	hs.push_back(q);
-	quit.scene.hots = hs;
+	quit->hots = hs;
 	_levels["<quit>"] = quit;
 }
 
 HypnoEngine::~HypnoEngine() {
 	// Deallocate actions
-	for (Levels::iterator it = _levels.begin(); it != _levels.end(); ++it) {
-		Level level = (*it)._value;
-		for (Hotspots::iterator itt = level.scene.hots.begin(); itt != level.scene.hots.end(); ++itt) {
-			Hotspot hot = *itt;
-			for (Actions::iterator ittt = hot.actions.begin(); ittt != hot.actions.end(); ++ittt)
-				delete (*ittt);
-		}
-	}
+	// for (Levels::iterator it = _levels.begin(); it != _levels.end(); ++it) {
+	// 	Level level = (*it)._value;
+	// 	for (Hotspots::iterator itt = level.scene.hots.begin(); itt != level.scene.hots.end(); ++itt) {
+	// 		Hotspot hot = *itt;
+	// 		for (Actions::iterator ittt = hot.actions.begin(); ittt != hot.actions.end(); ++ittt)
+	// 			delete (*ittt);
+	// 	}
+	// }
 
 	delete _rnd;
 	_compositeSurface->free();
@@ -151,43 +151,37 @@ Common::Error HypnoEngine::run() {
 void HypnoEngine::runLevel(Common::String &name) {
 	if (!_levels.contains(name))
 		error("Level %s cannot be found", name.c_str());
+
+	_prefixDir = _levels[name]->prefix;
 	stopSound();
 	_music.clear();
 
+	// Play intros
 	disableCursor();
+	for (Filenames::iterator it = _levels[name]->intros.begin(); it != _levels[name]->intros.end(); ++it) {
+		MVideo v(*it, Common::Point(0, 0), false, true, false);
+		runIntro(v);
+	}
 
-	if (!_levels[name].trans.level.empty()) {
+	if (_levels[name]->type == TransitionLevel) {
 		debugC(1, kHypnoDebugScene, "Executing transition level %s", name.c_str());
-		runTransition(_levels[name].trans);
-
-	} else if (!_levels[name].arcade.background.empty()) {
+		runTransition((Transition *) _levels[name]);
+	} else if (_levels[name]->type == ArcadeLevel) {
 		debugC(1, kHypnoDebugArcade, "Executing arcade level %s", name.c_str());
-		_prefixDir = _levels[name].arcade.prefix;
-		if (!_levels[name].arcade.intro.empty()) {
-			MVideo v(_levels[name].arcade.intro, Common::Point(0, 0), false, true, false);
-			runIntro(v);
-		}
 		changeScreenMode("320x200");
-		runArcade(_levels[name].arcade);
-	} else if (!_levels[name].code.name.empty()) {
+		runArcade((ArcadeShooting *) _levels[name]);
+	} else if (_levels[name]->type == CodeLevel) {
 		debugC(1, kHypnoDebugScene, "Executing hardcoded level %s", name.c_str());
 		//resetSceneState(); // TODO: is this required?
-		if (!_levels[name].arcade.intro.empty()) {
-			MVideo v(_levels[name].arcade.intro, Common::Point(0, 0), false, true, false);
-			runIntro(v);
-		}
 		// Resolution depends on the game
-		runCode(_levels[name].code);
-	} else {
+		runCode((Code *) _levels[name]);
+	} else if (_levels[name]->type == SceneLevel) {
 		debugC(1, kHypnoDebugScene, "Executing scene level %s", name.c_str());
 		resetSceneState();
-		_prefixDir = _levels[name].scene.prefix;
-		if (!_levels[name].scene.intro.empty()) {
-			MVideo v(_levels[name].scene.intro, Common::Point(0, 0), false, true, false);
-			runIntro(v);
-		}
 		changeScreenMode("640x480");
-		runScene(_levels[name].scene);
+		runScene((Scene *) _levels[name]);
+	} else {
+		error("Invalid level %s", name.c_str());
 	}
 }
 
@@ -226,7 +220,7 @@ void HypnoEngine::runIntro(MVideo &video) {
 	}
 }
 
-void HypnoEngine::runCode(Code &code) { error("Function \"%s\" not implemented", __FUNCTION__); }
+void HypnoEngine::runCode(Code *code) { error("Function \"%s\" not implemented", __FUNCTION__); }
 void HypnoEngine::showCredits() { error("Function \"%s\" not implemented", __FUNCTION__); }
 
 void HypnoEngine::loadImage(const Common::String &name, int x, int y, bool transparent, int frameNumber) {
diff --git a/engines/hypno/hypno.h b/engines/hypno/hypno.h
index dd64f1c749..a762aaf415 100644
--- a/engines/hypno/hypno.h
+++ b/engines/hypno/hypno.h
@@ -83,8 +83,12 @@ public:
 	void resetSceneState();
 	bool checkSceneCompleted();
 	void runLevel(Common::String &name);
-	void runScene(Scene &scene);
-	void runArcade(ArcadeShooting &arc);
+	void runScene(Scene *scene);
+	void runArcade(ArcadeShooting *arc);
+	// For some menus and hardcoded puzzles
+	virtual void runCode(Code *code);
+	// Level transitions
+	void runTransition(Transition *trans);
 
 	void restartGame();
 	void clearAreas();
@@ -217,12 +221,6 @@ public:
 	virtual void rightClickedConversation(const Common::Point &mousePos);
 	virtual void leftClickedConversation(const Common::Point &mousePos);
 
-	// For some menus and hardcoded puzzles
-	virtual void runCode(Code &code);
-
-	// Transitions
-	void runTransition(Transition trans);
-
 	// Credits
 	virtual void showCredits();
 
@@ -252,10 +250,10 @@ public:
 	void drawShoot(const Common::Point &target) override;
 	void drawPlayer() override;
 	void drawHealth() override;
-	void runCode(Code &code) override;
+	void runCode(Code *code) override;
 
 private:
-	void runMainMenu(Code &code);
+	void runMainMenu(Code *code);
 };
 
 class SpiderEngine : public HypnoEngine {
@@ -268,14 +266,14 @@ public:
 	void drawShoot(const Common::Point &target) override;
 	void drawPlayer() override;
 	void drawHealth() override;
-	void runCode(Code &code) override;
+	void runCode(Code *code) override;
 
 	void showConversation() override;
 	void rightClickedConversation(const Common::Point &mousePos) override;
 	void leftClickedConversation(const Common::Point &mousePos) override;
 
 private:
-	void runMatrix(Code &code);
+	void runMatrix(Code *code);
 };
 
 class BoyzEngine : public HypnoEngine {
diff --git a/engines/hypno/scene.cpp b/engines/hypno/scene.cpp
index ebf2cab187..18f570f5f0 100644
--- a/engines/hypno/scene.cpp
+++ b/engines/hypno/scene.cpp
@@ -76,10 +76,10 @@ void HypnoEngine::loadSceneLevel(const Common::String &current, const Common::St
 	buf[fileSize] = '\0';
 	debugC(1, kHypnoDebugParser, "%s", buf);
 	parse_mis(buf);
-	Level level;
-	level.scene.prefix = prefix;
-	level.scene.levelIfWin = next;
-	level.scene.hots = *g_parsedHots;
+	Scene *level = new Scene();
+	level->prefix = prefix;
+	level->levelIfWin = next;
+	level->hots = *g_parsedHots;
 	_levels[name] = level;
 	free(buf);
 }
@@ -214,15 +214,10 @@ bool HypnoEngine::hoverHotspot(Common::Point mousePos) {
 	return false;
 }
 
-void HypnoEngine::runTransition(Transition trans) {
-	for (Filenames::iterator it = trans.intros.begin(); it != trans.intros.end(); ++it) {
-		MVideo v(*it, Common::Point(0, 0), false, true, false);
-		runIntro(v);
-	}
-
-	if (!trans.frameImage.empty()) {
-		debugC(1, kHypnoDebugScene, "Rendering %s frame in transaction", trans.frameImage.c_str());
-		Graphics::Surface *frame = decodeFrame(trans.frameImage, trans.frameNumber);
+void HypnoEngine::runTransition(Transition *trans) {
+	if (!trans->frameImage.empty()) {
+		debugC(1, kHypnoDebugScene, "Rendering %s frame in transaction", trans->frameImage.c_str());
+		Graphics::Surface *frame = decodeFrame(trans->frameImage, trans->frameNumber);
 		Graphics::Surface *sframe = frame->scale(_screenW, _screenH);
 		drawImage(*sframe, 0, 0, false);
 		drawScreen();
@@ -230,15 +225,15 @@ void HypnoEngine::runTransition(Transition trans) {
 		delete frame;
 		sframe->free();
 		delete sframe;
-		Common::String *ptr = new Common::String(trans.level);
+		Common::String *ptr = new Common::String(trans->level);
 		if (!installTimer(2 * 1000000, ptr)) // 2 seconds
 			error("Failed to install timer");
 	} else
-		_nextLevel = trans.level;
+		_nextLevel = trans->level;
 }
 
 
-void HypnoEngine::runScene(Scene &scene) {
+void HypnoEngine::runScene(Scene *scene) {
 	_nextLoopingVideoToPlay.clear();
 	_nextParallelVideoToPlay.clear();
 	_nextSequentialVideoToPlay.clear();
@@ -249,9 +244,10 @@ void HypnoEngine::runScene(Scene &scene) {
 	Common::Event event;
 	Common::Point mousePos;
 	Common::List<uint32> videosToRemove;
+	bool enableLoopingVideos = true;
 
 	stack.clear();
-	_nextHotsToAdd = &scene.hots;
+	_nextHotsToAdd = &scene->hots;
 	defaultCursor();
 
 	while (!shouldQuit() && _nextLevel.empty()) {
@@ -322,7 +318,7 @@ void HypnoEngine::runScene(Scene &scene) {
 		}
 
 		if (_refreshConversation && !_conversation.empty() && 
-		    _nextSequentialVideoToPlay.empty() && 
+			_nextSequentialVideoToPlay.empty() && 
 			_nextParallelVideoToPlay.empty() &&
 			_videosPlaying.empty()) {
 			showConversation();
@@ -351,7 +347,7 @@ void HypnoEngine::runScene(Scene &scene) {
 
 			if (it->decoder) {
 				if (it->decoder->endOfVideo()) {
-					if (it->loop) {
+					if (it->loop && enableLoopingVideos) {
 						it->decoder->rewind();
 						it->decoder->start();
 					} else {
@@ -385,8 +381,16 @@ void HypnoEngine::runScene(Scene &scene) {
 			}
 		}
 
-		if (checkSceneCompleted() && _conversation.empty()) {
-			_nextLevel = scene.levelIfWin;
+		if (checkSceneCompleted()) {
+			// Make sure all the videos are played before we finish
+			enableLoopingVideos = false;
+			if (_conversation.empty() && 
+				_videosPlaying.empty() && 
+				_nextSequentialVideoToPlay.empty() && 
+				_nextParallelVideoToPlay.empty()) {
+				debugC(1, kHypnoDebugScene, "Wining level and jumping to %s", scene->levelIfWin.c_str());
+				_nextLevel = scene->levelIfWin;
+			}
 		}
 
 		if (!_videosPlaying.empty() || !_nextSequentialVideoToPlay.empty()) {
@@ -408,9 +412,9 @@ void HypnoEngine::runScene(Scene &scene) {
 			drawScreen();
 		}
 
-		if (_music.empty() && !scene.sound.empty()) {
-			_music = scene.sound;
-			playSound(_music, 1);
+		if (_music.empty() && !scene->music.empty()) {
+			_music = scene->music;
+			playSound(_music, 0);
 		}
 
 		g_system->updateScreen();
diff --git a/engines/hypno/spider/spider.cpp b/engines/hypno/spider/spider.cpp
index 31656fdcbf..1d58d7afe1 100644
--- a/engines/hypno/spider/spider.cpp
+++ b/engines/hypno/spider/spider.cpp
@@ -61,12 +61,10 @@ void SpiderEngine::loadAssetsFullGame() {
 	loadSceneLevel("combmenu.mi_", "", prefix);
 
 	loadSceneLevel("mv0t.mi_", "roof.mi_", prefix);
-	_levels["mv0t.mi_"].scene.intro = "cine/ints001s.smk";
+	_levels["mv0t.mi_"]->intros.push_back("cine/ints001s.smk");
 
 	loadSceneLevel("roof.mi_", "decide1.mi_", prefix);
-
 	loadSceneLevel("decide1.mi_", "", prefix);
-	// _levels["decide1.mi_"].scene.prefix = "spider";
 
 	loadArcadeLevel("c1", "", "spider");
 	loadArcadeLevel("c2", "", "spider");
@@ -78,41 +76,46 @@ void SpiderEngine::loadAssetsFullGame() {
 	loadArcadeLevel("c9", "", "spider");
 
 	// start level
-	Level start;
-	start.trans.level = "mainmenu.mi_";
-	start.trans.intros.push_back("spider/cine/dcine1.smk");
-	start.trans.intros.push_back("spider/cine/dcine2.smk");
+	Transition *start = new Transition();
+	start->level = "mainmenu.mi_";
+	start->intros.push_back("spider/cine/dcine1.smk");
+	start->intros.push_back("spider/cine/dcine2.smk");
 	_levels["<start>"] = start;
 
+	Scene *sc = (Scene *) _levels["mainmenu.mi_"];
 	ChangeLevel *cl = new ChangeLevel("levels.mi_");
-	_levels["mainmenu.mi_"].scene.hots[1].actions.push_back(cl);
+	sc->hots[1].actions.push_back(cl);
 	
 	cl = new ChangeLevel("options.mi_");
-	_levels["mainmenu.mi_"].scene.hots[4].actions.push_back(cl);
+	sc->hots[4].actions.push_back(cl);
 
 	cl = new ChangeLevel("<quit>");
-	_levels["mainmenu.mi_"].scene.hots[5].actions.push_back(cl);
+	sc->hots[5].actions.push_back(cl);
+
+	sc = (Scene *) _levels["options.mi_"]; 
 
 	cl = new ChangeLevel("combmenu.mi_");
-	_levels["options.mi_"].scene.hots[1].actions.push_back(cl);
+	sc->hots[1].actions.push_back(cl);
+
+	sc = (Scene *) _levels["combmenu.mi_"]; 
 
 	cl = new ChangeLevel("options.mi_");
-	_levels["combmenu.mi_"].scene.hots[1].actions.push_back(cl);
+	sc->hots[1].actions.push_back(cl);
 
 	cl = new ChangeLevel("c1.mi_");
-	_levels["combmenu.mi_"].scene.hots[2].actions.push_back(cl);
+	sc->hots[2].actions.push_back(cl);
 
 	cl = new ChangeLevel("c2.mi_");
-	_levels["combmenu.mi_"].scene.hots[3].actions.push_back(cl);
+	sc->hots[3].actions.push_back(cl);
 
 	cl = new ChangeLevel("c5.mi_");
-	_levels["combmenu.mi_"].scene.hots[6].actions.push_back(cl);
+	sc->hots[6].actions.push_back(cl);
 
 	cl = new ChangeLevel("c8.mi_");
-	_levels["combmenu.mi_"].scene.hots[7].actions.push_back(cl);
+	sc->hots[7].actions.push_back(cl);
 	
 	cl = new ChangeLevel("c9.mi_");
-	_levels["combmenu.mi_"].scene.hots[8].actions.push_back(cl);
+	sc->hots[8].actions.push_back(cl);
 }
 
 void SpiderEngine::loadAssetsDemo() {
@@ -128,10 +131,10 @@ void SpiderEngine::loadAssetsDemo() {
 		error("Failed to load any file from missions.lib");
 
 	// start level
-	Level start;
-	start.trans.level = "sixdemo/mis/demo.mis";
-	start.trans.intros.push_back("sixdemo/demo/dcine1.smk");
-	start.trans.intros.push_back("sixdemo/demo/dcine2.smk");
+	Transition *start = new Transition();
+	start->level = "sixdemo/mis/demo.mis";
+	start->intros.push_back("sixdemo/demo/dcine1.smk");
+	start->intros.push_back("sixdemo/demo/dcine2.smk");
 	_levels["<start>"] = start;
 
 	loadArcadeLevel("c1", "sixdemo/mis/demo.mis", "sixdemo");
@@ -143,50 +146,55 @@ void SpiderEngine::loadAssetsDemo() {
 	// Read assets from mis files
 	loadSceneLevel("sixdemo/mis/demo.mis", "", "sixdemo");
 	ChangeLevel *cl = new ChangeLevel("c1.mi_");
-	_levels["sixdemo/mis/demo.mis"].scene.hots[1].actions.push_back(cl);
+
+	Scene *sc = (Scene *) _levels["sixdemo/mis/demo.mis"];
+	sc->hots[1].actions.push_back(cl);
 
 	cl = new ChangeLevel("sixdemo/mis/alley.mis");
-	_levels["sixdemo/mis/demo.mis"].scene.hots[2].actions.push_back(cl);
+	sc->hots[2].actions.push_back(cl);
 
 	cl = new ChangeLevel("sixdemo/puz_matr");
-	_levels["sixdemo/mis/demo.mis"].scene.hots[3].actions.push_back(cl);
+	sc->hots[3].actions.push_back(cl);
 
 	cl = new ChangeLevel("sixdemo/mis/shoctalk.mis");
-	_levels["sixdemo/mis/demo.mis"].scene.hots[4].actions.push_back(cl);
+	sc->hots[4].actions.push_back(cl);
 
 	cl = new ChangeLevel("sixdemo/mis/order.mis");
-	_levels["sixdemo/mis/demo.mis"].scene.hots[5].actions.push_back(cl);
-	_levels["sixdemo/mis/demo.mis"].scene.sound = "demo/sound.lib/menu_mus.raw";
+	sc->hots[5].actions.push_back(cl);
+	sc->music = "demo/sound.lib/menu_mus.raw";
 
 	loadSceneLevel("sixdemo/mis/order.mis", "", "sixdemo");
+	sc = (Scene *) _levels["sixdemo/mis/order.mis"];
 	cl = new ChangeLevel("<quit>");
-	_levels["sixdemo/mis/order.mis"].scene.hots[1].actions.push_back(cl);
+	sc->hots[1].actions.push_back(cl);
 
 	loadSceneLevel("sixdemo/mis/alley.mis", "", "sixdemo");
-	_levels["sixdemo/mis/alley.mis"].scene.intro = "demo/aleyc01s.smk";
-	_levels["sixdemo/mis/alley.mis"].scene.sound = "demo/sound.lib/alleymus.raw";
-	_levels["sixdemo/mis/alley.mis"].scene.levelIfWin = "sixdemo/mis/demo.mis";
-	_levels["sixdemo/mis/alley.mis"].scene.levelIfLose = "sixdemo/mis/demo.mis";
+	sc = (Scene *) _levels["sixdemo/mis/alley.mis"];
+
+	sc->intros.push_back("demo/aleyc01s.smk");
+	sc->music = "demo/sound.lib/alleymus.raw";
+	sc->levelIfWin = "sixdemo/mis/demo.mis";
+	sc->levelIfLose = "sixdemo/mis/demo.mis";
 
 	loadSceneLevel("sixdemo/mis/shoctalk.mis", "", "sixdemo");
 
-	Level matrix;
-	matrix.code.name = "sixdemo/puz_matr";
-	matrix.code.intros.push_back("spiderman/demo/aleyc01s.smk");
-	matrix.code.levelIfWin = "sixdemo/mis/demo.mis";
-	matrix.code.levelIfLose = "sixdemo/mis/demo.mis";
+	Code *matrix = new Code();
+	matrix->name = "sixdemo/puz_matr";
+	matrix->intros.push_back("spiderman/demo/aleyc01s.smk");
+	matrix->levelIfWin = "sixdemo/mis/demo.mis";
+	matrix->levelIfLose = "sixdemo/mis/demo.mis";
 	_levels["sixdemo/puz_matr"] = matrix;
 	_soundPath = "c_misc/sound.lib/";
 }
 
-void SpiderEngine::runCode(Code &code) {
-	if (code.name == "sixdemo/puz_matr")
+void SpiderEngine::runCode(Code *code) {
+	if (code->name == "sixdemo/puz_matr")
 		runMatrix(code);
 	else
 		error("invalid puzzle");
 }
 
-void SpiderEngine::runMatrix(Code &code) {
+void SpiderEngine::runMatrix(Code *code) {
 	changeScreenMode("640x480");
 	Common::Point mousePos;
 	Common::Event event;
@@ -254,7 +262,7 @@ void SpiderEngine::runMatrix(Code &code) {
 
 		if (found) {
 			playSound("sixdemo/demo/sound.lib/matrix_2.raw", 1);
-			_nextLevel = code.levelIfWin;
+			_nextLevel = code->levelIfWin;
 			return;
 		}
 
diff --git a/engines/hypno/wet/wet.cpp b/engines/hypno/wet/wet.cpp
index 386240c47c..d0ece40356 100644
--- a/engines/hypno/wet/wet.cpp
+++ b/engines/hypno/wet/wet.cpp
@@ -69,7 +69,6 @@ void WetEngine::loadAssetsDemoDisc() {
 	if (missions->listMembers(files) == 0)
 		error("Failed to load any files from missions.lib");
 
-	Level start;
 	Hotspot h(MakeMenu, "");
 	Hotspots hs;
 	Ambient *a = new Ambient("movie/selector.smk", Common::Point(0, 0), "/LOOP");
@@ -101,46 +100,47 @@ void WetEngine::loadAssetsDemoDisc() {
 
 	hs.push_back(h);
 
-	start.scene.hots = hs;
+	Scene *start = new Scene();
+	start->hots = hs;
 	_levels["<start>"] = start;
 
-	Level intro;
-	intro.trans.level = "c52.mi_";
-	intro.trans.intros.push_back("movie/nw_logo.smk");
-	intro.trans.intros.push_back("movie/hypnotix.smk");
-	intro.trans.intros.push_back("movie/wetlogo.smk");
-	intro.trans.frameImage = "wetlands/c_misc/c.s";
-	intro.trans.frameNumber = 0;
+	Transition *intro = new Transition();
+	intro->level = "c31.mi_";
+	intro->intros.push_back("movie/nw_logo.smk");
+	intro->intros.push_back("movie/hypnotix.smk");
+	intro->intros.push_back("movie/wetlogo.smk");
+	intro->frameImage = "wetlands/c_misc/c.s";
+	intro->frameNumber = 0;
 	_levels["<intro>"] = intro;
 
-	Level movies;
-	movies.trans.level = "<quit>";
-	movies.trans.intros.push_back("movie/nw_logo.smk");
-	movies.trans.intros.push_back("movie/hypnotix.smk");
-	movies.trans.intros.push_back("movie/wetlogo.smk");
-	movies.trans.intros.push_back("movie/c42e1s.smk");
-	movies.trans.intros.push_back("movie/c23e1s.smk");
-	movies.trans.intros.push_back("movie/c20o1s.smk");
-	movies.trans.intros.push_back("movie/c23d1s.smk");
-	movies.trans.intros.push_back("movie/c40o1s.smk");
-	movies.trans.intros.push_back("movie/c31d1s.smk");
-	movies.trans.intros.push_back("movie/c42d1s.smk");
-	movies.trans.intros.push_back("movie/c44d1s.smk");
-	movies.trans.intros.push_back("movie/c44e1s.smk");
-	movies.trans.intros.push_back("movie/c32d1s.smk");
-	movies.trans.intros.push_back("movie/c22e1s.smk");
-	movies.trans.intros.push_back("movie/c31e1s.smk");
-	movies.trans.intros.push_back("movie/gameover.smk");
-	movies.trans.frameImage = "";
-	movies.trans.frameNumber = 0;
+	Transition *movies = new Transition();
+	movies->level = "<quit>";
+	movies->intros.push_back("movie/nw_logo.smk");
+	movies->intros.push_back("movie/hypnotix.smk");
+	movies->intros.push_back("movie/wetlogo.smk");
+	movies->intros.push_back("movie/c42e1s.smk");
+	movies->intros.push_back("movie/c23e1s.smk");
+	movies->intros.push_back("movie/c20o1s.smk");
+	movies->intros.push_back("movie/c23d1s.smk");
+	movies->intros.push_back("movie/c40o1s.smk");
+	movies->intros.push_back("movie/c31d1s.smk");
+	movies->intros.push_back("movie/c42d1s.smk");
+	movies->intros.push_back("movie/c44d1s.smk");
+	movies->intros.push_back("movie/c44e1s.smk");
+	movies->intros.push_back("movie/c32d1s.smk");
+	movies->intros.push_back("movie/c22e1s.smk");
+	movies->intros.push_back("movie/c31e1s.smk");
+	movies->intros.push_back("movie/gameover.smk");
+	movies->frameImage = "";
+	movies->frameNumber = 0;
 	_levels["<movies>"] = movies;
 
 	loadArcadeLevel("c31", "c52", "wetlands");
 	loadArcadeLevel("c52", "<gameover>", "wetlands");
 
-	Level over;
-	over.trans.level = "<quit>";
-	over.trans.intros.push_back("movie/gameover.smk");
+	Transition *over = new Transition();
+	over->level = "<quit>";
+	over->intros.push_back("movie/gameover.smk");
 	_levels["<gameover>"] = over;
 
 	loadLib("", "wetlands/c_misc/fonts.lib", true);
@@ -154,19 +154,19 @@ void WetEngine::loadAssetsPCW() {
 	if (missions->listMembers(files) == 0)
 		error("Failed to load any files from missions.lib");
 
-	Level intro;
-	intro.trans.level = "c11.mis";
-	intro.trans.intros.push_back("c_misc/nw_logo.smk");
-	intro.trans.intros.push_back("c_misc/h.s");
-	intro.trans.intros.push_back("c_misc/wet.smk");
-	intro.trans.frameImage.clear();
+	Transition *intro = new Transition();
+	intro->level = "c11.mis";
+	intro->intros.push_back("c_misc/nw_logo.smk");
+	intro->intros.push_back("c_misc/h.s");
+	intro->intros.push_back("c_misc/wet.smk");
+	intro->frameImage.clear();
 	_levels["<start>"] = intro;
 
 	loadArcadeLevel("c11", "<gameover>", "");
 
-	Level over;
-	over.trans.level = "<quit>";
-	over.trans.intros.push_back("movie/gameover.smk");
+	Transition *over = new Transition();
+	over->level = "<quit>";
+	over->intros.push_back("movie/gameover.smk");
 	_levels["<gameover>"] = over;
 
 	loadLib("", "c_misc/sound.lib", false);
@@ -179,19 +179,19 @@ void WetEngine::loadAssetsPCG() {
 	if (missions->listMembers(files) == 0)
 		error("Failed to load any files from missions.lib");
 
-	Level intro;
-	intro.trans.level = "c31.mi_";	
-	intro.trans.intros.push_back("nw_logo.smk");
-	intro.trans.intros.push_back("h.s");
-	intro.trans.intros.push_back("wet.smk");
-	intro.trans.frameImage.clear();
+	Transition *intro = new Transition();
+	intro->level = "c31.mi_";	
+	intro->intros.push_back("nw_logo.smk");
+	intro->intros.push_back("h.s");
+	intro->intros.push_back("wet.smk");
+	intro->frameImage.clear();
 	_levels["<start>"] = intro;
 
 	loadArcadeLevel("c31", "<gameover>", "");
 
-	Level over;
-	over.trans.level = "<quit>";
-	over.trans.intros.push_back("gameover.smk");
+	Transition *over = new Transition();
+	over->level = "<quit>";
+	over->intros.push_back("gameover.smk");
 	_levels["<gameover>"] = over;
 
 	loadLib("", "sound.lib", false);
@@ -203,22 +203,22 @@ void WetEngine::loadAssetsFullGame() {
 	if (missions == nullptr || missions->listMembers(files) == 0)
 		error("Failed to load any files from missions.lib");
 
-	Level logos;
-	logos.trans.level = "wetlands/main_menu.mis"; //"c11" + _difficulty + ".mi_";
-	logos.trans.intros.push_back("c_misc/logo.smk");
-	logos.trans.intros.push_back("c_misc/nw_logo.smk");
-	logos.trans.intros.push_back("c_misc/hypnotix.smk");
-	logos.trans.intros.push_back("c_misc/wetlogo.smk");
+	Transition *logos = new Transition();
+	logos->level = "wetlands/main_menu.mis"; //"c11" + _difficulty + ".mi_";
+	logos->intros.push_back("c_misc/logo.smk");
+	logos->intros.push_back("c_misc/nw_logo.smk");
+	logos->intros.push_back("c_misc/hypnotix.smk");
+	logos->intros.push_back("c_misc/wetlogo.smk");
 	_levels["<start>"] = logos;
 
-	Level menu;
-	menu.code.name = "wetlands/main_menu.mis";
+	Code *menu = new Code();
+	menu->name = "wetlands/main_menu.mis";
 	_levels["wetlands/main_menu.mis"] = menu;
-	_levels["wetlands/main_menu.mis"].code.levelIfWin = "<intro>";
+	_levels["wetlands/main_menu.mis"]->levelIfWin = "<intro>";
 
-	Level intro;
-	intro.trans.level = "c11" + _difficulty + ".mi_";
-	intro.trans.intros.push_back("c_misc/intros.smk");
+	Transition *intro = new Transition();
+	intro->level = "c11" + _difficulty + ".mi_";
+	intro->intros.push_back("c_misc/intros.smk");
 	_levels["<intro>"] = intro;
 
 	//loadLevel("c10", "c11", "");
@@ -234,15 +234,15 @@ void WetEngine::showCredits() {
 	runIntro(video);
 }
 
-void WetEngine::runCode(Code &code) {
+void WetEngine::runCode(Code *code) {
 	changeScreenMode("320x200");
-	if (code.name == "wetlands/main_menu.mis")
+	if (code->name == "wetlands/main_menu.mis")
 		runMainMenu(code);
 	else
-		error("invalid hardcoded level: %s", code.name.c_str());
+		error("invalid hardcoded level: %s", code->name.c_str());
 }
 
-void WetEngine::runMainMenu(Code &code) {
+void WetEngine::runMainMenu(Code *code) {
 	Common::Event event;
 	_font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
 	uint32 c = _pixelFormat.RGBToColor(0, 252, 0);
@@ -264,7 +264,7 @@ void WetEngine::runMainMenu(Code &code) {
 				if (event.kbd.keycode == Common::KEYCODE_BACKSPACE)
 					_name.deleteLastChar();
 				else if (event.kbd.keycode == Common::KEYCODE_RETURN && !_name.empty()) {
-					_nextLevel = code.levelIfWin;
+					_nextLevel = code->levelIfWin;
 					return;
 				}
 				else if (Common::isAlnum(event.kbd.keycode)) {




More information about the Scummvm-git-logs mailing list