[Scummvm-git-logs] scummvm master -> 97a1b0096a47b6a834c1c524c0293b3bb71c70be

whoozle noreply at scummvm.org
Tue Jul 21 18:57:48 UTC 2026


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

Summary:
6ba7a3578a PHOENIXVR: Fix cursor leak
97a1b0096a PHOENIXVR: Add Sprite_Load/Sprite_Screen


Commit: 6ba7a3578a329fc254d734f6035a5599bb26eb14
    https://github.com/scummvm/scummvm/commit/6ba7a3578a329fc254d734f6035a5599bb26eb14
Author: Vladimir Menshakov (vladimir.menshakov at gmail.com)
Date: 2026-07-21T19:10:40+01:00

Commit Message:
PHOENIXVR: Fix cursor leak

Changed paths:
    engines/phoenixvr/phoenixvr.cpp
    engines/phoenixvr/phoenixvr.h


diff --git a/engines/phoenixvr/phoenixvr.cpp b/engines/phoenixvr/phoenixvr.cpp
index e2d53dac53d..4f50618e437 100644
--- a/engines/phoenixvr/phoenixvr.cpp
+++ b/engines/phoenixvr/phoenixvr.cpp
@@ -354,11 +354,6 @@ void PhoenixVREngine::resetState() {
 
 PhoenixVREngine::~PhoenixVREngine() {
 	_system->lockMouse(false);
-	for (auto it = _cursorCache.begin(); it != _cursorCache.end(); ++it) {
-		auto *s = it->_value;
-		s->free();
-		delete s;
-	}
 	delete _screen;
 }
 
@@ -1238,7 +1233,7 @@ Graphics::ManagedSurface *PhoenixVREngine::loadCursor(const Common::String &path
 		return nullptr;
 	auto it = _cursorCache.find(path);
 	if (it != _cursorCache.end())
-		return it->_value;
+		return it->_value.get();
 	Common::ScopedPtr<Graphics::ManagedSurface> s(loadSurface(path));
 	if (!s) {
 		warning("can't load cursor from %s", path.c_str());
@@ -1247,8 +1242,9 @@ Graphics::ManagedSurface *PhoenixVREngine::loadCursor(const Common::String &path
 	if (w > 0 && h > 0) {
 		s.reset(s->scale(w, h, true));
 	}
-	_cursorCache[path] = s.get();
-	return s.release();
+	auto &cursor = _cursorCache[path];
+	cursor = Common::move(s);
+	return cursor.get();
 }
 
 void PhoenixVREngine::loadCursor(int idx, const Common::String &path, int w, int h) {
diff --git a/engines/phoenixvr/phoenixvr.h b/engines/phoenixvr/phoenixvr.h
index 743e1247eb8..8d5e58de074 100644
--- a/engines/phoenixvr/phoenixvr.h
+++ b/engines/phoenixvr/phoenixvr.h
@@ -338,7 +338,7 @@ private:
 	};
 	Common::Array<PreloadedCursor> _loadedCursors;
 
-	Common::HashMap<Common::String, Graphics::ManagedSurface *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _cursorCache;
+	Common::HashMap<Common::String, Common::ScopedPtr<Graphics::ManagedSurface>, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _cursorCache;
 
 	Common::Array<Common::Array<Common::String>> _cursors;
 	Common::String _defaultCursor[2];


Commit: 97a1b0096a47b6a834c1c524c0293b3bb71c70be
    https://github.com/scummvm/scummvm/commit/97a1b0096a47b6a834c1c524c0293b3bb71c70be
Author: Vladimir Menshakov (vladimir.menshakov at gmail.com)
Date: 2026-07-21T19:56:56+01:00

Commit Message:
PHOENIXVR: Add Sprite_Load/Sprite_Screen

Changed paths:
    engines/phoenixvr/commands_v2.cpp
    engines/phoenixvr/phoenixvr.cpp
    engines/phoenixvr/phoenixvr.h


diff --git a/engines/phoenixvr/commands_v2.cpp b/engines/phoenixvr/commands_v2.cpp
index 817f9b42be9..4449b5dffd7 100644
--- a/engines/phoenixvr/commands_v2.cpp
+++ b/engines/phoenixvr/commands_v2.cpp
@@ -257,28 +257,27 @@ struct Fade : public Command {
 struct Sprite_Load : public Command {
 	Common::String name;
 	Common::String path;
-	Common::String unk;
-	Sprite_Load(const Common::Array<Common::String> &args) : name(args[0]), path(args[1]), unk(args[2]) {}
+	Sprite_Load(const Common::Array<Common::String> &args) : name(args[0]), path(args[1]) {}
 	void exec(ExecutionContext &ctx) const override {
-		warning("sprite load %s %s %s", name.c_str(), path.c_str(), unk.c_str());
+		g_engine->spriteLoad(name, path);
 	}
 };
 
 struct Sprite_Screen : public Command {
 	int index;
 	Common::String name;
-	Common::String x;
-	Common::String y;
+	int x = 0;
+	int y = 0;
 	Sprite_Screen(const Common::Array<Common::String> &args) : index(atoi(args[0].c_str())) {
 		if (args.size() > 1)
 			name = args[1];
 		if (args.size() > 2)
-			x = args[2];
+			x = atoi(args[2].c_str());
 		if (args.size() > 3)
-			y = args[3];
+			y = atoi(args[3].c_str());
 	}
 	void exec(ExecutionContext &ctx) const override {
-		warning("sprite screen %d %s %s %s", index, name.c_str(), x.c_str(), y.c_str());
+		g_engine->spriteScreen(index, name, x, y);
 	}
 };
 
diff --git a/engines/phoenixvr/phoenixvr.cpp b/engines/phoenixvr/phoenixvr.cpp
index 4f50618e437..af5d34f991b 100644
--- a/engines/phoenixvr/phoenixvr.cpp
+++ b/engines/phoenixvr/phoenixvr.cpp
@@ -292,6 +292,7 @@ PhoenixVREngine::PhoenixVREngine(OSystem *syst, const ADGameDescription *gameDes
 																					 _lockKey(13),
 																					 _state(256),
 																					 _loadedCursors(16),
+																					 _sprites(16),
 																					 _fov(kPi2),
 																					 _angleX(0),
 																					 _angleY(-kPi2),
@@ -1208,7 +1209,7 @@ Graphics::ManagedSurface *PhoenixVREngine::loadSurface(const Common::String &pat
 		dec.reset(new Image::PCXDecoder);
 	} else if (filename.hasSuffixIgnoreCase(".gif")) {
 		dec.reset(new Image::GIFDecoder);
-	} else if (filename.hasSuffixIgnoreCase(".cur")) {
+	} else if (filename.hasSuffixIgnoreCase(".cur") || filename.hasSuffixIgnoreCase(".spr")) {
 		dec.reset(new Image::TGADecoder);
 	} else {
 		warning("can't find decoder for %s", filename.c_str());
@@ -1255,6 +1256,19 @@ void PhoenixVREngine::loadCursor(int idx, const Common::String &path, int w, int
 	loadCursor(desc.path, w, h);
 }
 
+void PhoenixVREngine::spriteLoad(const Common::String &name, const Common::String &path) {
+	debug("sprite load %s %s", name.c_str(), path.c_str());
+	_loadedSprites[name].reset(loadSurface(path));
+}
+
+void PhoenixVREngine::spriteScreen(int index, const Common::String &name, int x, int y) {
+	debug("sprite screen %d %s %d %d", index, name.c_str(), x, y);
+	auto &sprite = _sprites[index];
+	sprite.name = name;
+	sprite.x = x;
+	sprite.y = y;
+}
+
 void PhoenixVREngine::scheduleTest(int idx) {
 	debug("schedule test %d for execution", idx);
 	_nextTest = idx;
@@ -1341,8 +1355,25 @@ void PhoenixVREngine::renderTimer() {
 	_screen->simpleBlitFrom(*timerFg, fgSrcRect, fgRect.origin());
 }
 
+void PhoenixVREngine::renderSprites() {
+	if (version() < 2)
+		return;
+
+	for (auto &sprite : _sprites) {
+		if (sprite.name.empty())
+			continue;
+		auto it = _loadedSprites.find(sprite.name);
+		if (it == _loadedSprites.end() || !it->_value)
+			continue;
+
+		auto &src = *it->_value;
+		_screen->copyRectToSurface(src, sprite.x, sprite.y, src.getBounds());
+	}
+}
+
 void PhoenixVREngine::renderVR(float dt) {
 	_vr.render(_screen, _angleX.angle(), _angleY.angle(), _fov, dt, _showRegions ? _regSet.get() : nullptr);
+	renderSprites();
 	paintText(_rolloverText);
 	renderArchiveImages();
 	renderArchiveTexts();
diff --git a/engines/phoenixvr/phoenixvr.h b/engines/phoenixvr/phoenixvr.h
index 8d5e58de074..78cb5237f6c 100644
--- a/engines/phoenixvr/phoenixvr.h
+++ b/engines/phoenixvr/phoenixvr.h
@@ -233,6 +233,9 @@ public:
 	int retrieveState(int index) const;
 	void storeState(int index, int value);
 
+	void spriteLoad(const Common::String &name, const Common::String &path);
+	void spriteScreen(int index, const Common::String &name, int x, int y);
+
 private:
 	struct ArchiveImage {
 		Common::String image;
@@ -275,6 +278,7 @@ private:
 	void renderImageOverlay();
 	void renderTimer();
 	void renderFade(int color);
+	void renderSprites();
 	void resetState();
 	const Graphics::Font *getFont(int size, bool bold) const;
 	Common::Path getSubtitlePath(const Common::String &path) const;
@@ -339,6 +343,13 @@ private:
 	Common::Array<PreloadedCursor> _loadedCursors;
 
 	Common::HashMap<Common::String, Common::ScopedPtr<Graphics::ManagedSurface>, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _cursorCache;
+	Common::HashMap<Common::String, Common::ScopedPtr<Graphics::ManagedSurface>, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _loadedSprites;
+	struct Sprite {
+		Common::String name;
+		int x = 0;
+		int y = 0;
+	};
+	Common::Array<Sprite> _sprites;
 
 	Common::Array<Common::Array<Common::String>> _cursors;
 	Common::String _defaultCursor[2];




More information about the Scummvm-git-logs mailing list