[Scummvm-git-logs] scummvm master -> 66c3be734ca3d79f4e3d91e6fddd3161a623838d
whoozle
noreply at scummvm.org
Sat Jul 18 09:46:54 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
66c3be734c PHOENIXVR: Factor variables out into dedicated class, integrated debugger
Commit: 66c3be734ca3d79f4e3d91e6fddd3161a623838d
https://github.com/scummvm/scummvm/commit/66c3be734ca3d79f4e3d91e6fddd3161a623838d
Author: Vladimir Menshakov (vladimir.menshakov at gmail.com)
Date: 2026-07-18T10:44:14+01:00
Commit Message:
PHOENIXVR: Factor variables out into dedicated class, integrated debugger
Changed paths:
A engines/phoenixvr/variables.cpp
A engines/phoenixvr/variables.h
engines/phoenixvr/console.cpp
engines/phoenixvr/console.h
engines/phoenixvr/module.mk
engines/phoenixvr/phoenixvr.cpp
engines/phoenixvr/phoenixvr.h
diff --git a/engines/phoenixvr/console.cpp b/engines/phoenixvr/console.cpp
index 31a6c48c415..2f7b5e20ed1 100644
--- a/engines/phoenixvr/console.cpp
+++ b/engines/phoenixvr/console.cpp
@@ -27,7 +27,6 @@ namespace PhoenixVR {
Console::Console() : GUI::Debugger() {
registerCmd("warp", WRAP_METHOD(Console, cmdWarp));
registerCmd("script", WRAP_METHOD(Console, cmdScript));
- registerCmd("var", WRAP_METHOD(Console, cmdVar));
registerCmd("stop_all_sounds", WRAP_METHOD(Console, cmdStopAllSounds));
registerCmd("next_level", WRAP_METHOD(Console, cmdNextLevel));
}
@@ -53,22 +52,6 @@ bool Console::cmdScript(int argc, const char **argv) {
return false;
}
-bool Console::cmdVar(int argc, const char **argv) {
- if (argc < 2) {
- debugPrintf("var <name> [value]\n");
- return true;
- }
-
- if (argc >= 3) {
- const int value = atoi(argv[2]);
- g_engine->declareVariable(argv[1]);
- g_engine->setVariable(argv[1], value);
- }
-
- debugPrintf("%s = %d\n", argv[1], g_engine->getVariable(argv[1]));
- return true;
-}
-
bool Console::cmdStopAllSounds(int argc, const char **argv) {
g_engine->stopAllSounds();
return false;
diff --git a/engines/phoenixvr/console.h b/engines/phoenixvr/console.h
index 6ef00d29424..2b2101add95 100644
--- a/engines/phoenixvr/console.h
+++ b/engines/phoenixvr/console.h
@@ -31,13 +31,17 @@ class Console : public GUI::Debugger {
private:
bool cmdWarp(int argc, const char **argv);
bool cmdScript(int argc, const char **argv);
- bool cmdVar(int argc, const char **argv);
bool cmdStopAllSounds(int argc, const char **argv);
bool cmdNextLevel(int argc, const char **argv);
public:
Console();
~Console() override;
+
+ void registerVar(const Common::String &name, int *ptr) {
+ GUI::Debugger::registerVar(name, ptr);
+ }
+ using GUI::Debugger::clearVars;
};
} // End of namespace PhoenixVR
diff --git a/engines/phoenixvr/module.mk b/engines/phoenixvr/module.mk
index 670fa32f23e..57272f53d80 100644
--- a/engines/phoenixvr/module.mk
+++ b/engines/phoenixvr/module.mk
@@ -11,6 +11,7 @@ MODULE_OBJS = \
rectf.o \
region_set.o \
script.o \
+ variables.o \
vr.o
# This module can be built as a plugin
diff --git a/engines/phoenixvr/phoenixvr.cpp b/engines/phoenixvr/phoenixvr.cpp
index 4556fd2de8c..f330c59f30d 100644
--- a/engines/phoenixvr/phoenixvr.cpp
+++ b/engines/phoenixvr/phoenixvr.cpp
@@ -782,27 +782,19 @@ void PhoenixVREngine::hideCursor(const Common::String &wname, int idx) {
}
void PhoenixVREngine::declareVariable(const Common::String &name) {
- if (!_variables.contains(name))
- _variables.setVal(name, 0);
+ _variables.declare(name);
}
bool PhoenixVREngine::hasVariable(const Common::String &name) const {
- return _variables.contains(name);
+ return _variables.declared(name);
}
void PhoenixVREngine::setVariable(const Common::String &name, int value) {
- if (!hasVariable(name)) {
- debug("set %s %d - ignored, variable was not declared", name.c_str(), value);
- return;
- }
- debug("set %s %d", name.c_str(), value);
- _variables.setVal(name, value);
+ _variables.set(name, value);
}
int PhoenixVREngine::getVariable(const Common::String &name) const {
- if (!hasVariable(name))
- warning("get %s - variable was not declared", name.c_str());
- return _variables.getValOrDefault(name, 0);
+ return _variables.get(name);
}
static int8 panToBalance(int pan) {
@@ -1315,10 +1307,11 @@ void PhoenixVREngine::renderImageOverlay() {
void PhoenixVREngine::saveVariables() {
debug("SaveVariable() - saving variable state");
- _variableSnapshot.resize(_variableOrder.size());
- for (uint i = 0, n = _variableOrder.size(); i != n; ++i) {
- _variableSnapshot[i] = _variables.getVal(_variableOrder[i]);
- }
+ auto &values = _variables.values();
+ _variableSnapshot.resize(values.size());
+ uint i = 0;
+ for (auto &var : values)
+ _variableSnapshot[i++] = var;
}
void PhoenixVREngine::loadVariables() {
@@ -1327,10 +1320,11 @@ void PhoenixVREngine::loadVariables() {
debug("skipping, no snapshot");
return;
}
- assert(_variableSnapshot.size() == _variableOrder.size());
- for (uint i = 0, n = _variableOrder.size(); i != n; ++i) {
- _variables.setVal(_variableOrder[i], _variableSnapshot[i]);
- }
+ auto &values = _variables.values();
+ assert(_variableSnapshot.size() == values.size());
+ uint i = 0;
+ for (auto &var : values)
+ var = _variableSnapshot[i++];
_variableSnapshot.clear();
}
@@ -1632,7 +1626,6 @@ Common::Error PhoenixVREngine::run() {
if (var == "*")
break;
declareVariable(var);
- _variableOrder.push_back(Common::move(var));
}
} else
debug("no variables.txt");
diff --git a/engines/phoenixvr/phoenixvr.h b/engines/phoenixvr/phoenixvr.h
index 7e303dd683c..b57186c752d 100644
--- a/engines/phoenixvr/phoenixvr.h
+++ b/engines/phoenixvr/phoenixvr.h
@@ -43,6 +43,7 @@
#include "phoenixvr/detection.h"
#include "phoenixvr/region_set.h"
#include "phoenixvr/script.h"
+#include "phoenixvr/variables.h"
#include "phoenixvr/vr.h"
namespace Common {
@@ -287,9 +288,10 @@ private:
};
Common::Array<Common::String> _lockKey;
- Common::Array<Common::String> _variableOrder;
+
+ Variables _variables;
Common::Array<int> _variableSnapshot;
- Common::HashMap<Common::String, int, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _variables;
+
struct Sound {
Audio::SoundHandle handle;
bool spatial;
@@ -299,6 +301,7 @@ private:
Common::SharedPtr<Video::Subtitles> subtitles;
};
Common::HashMap<Common::String, Sound, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _sounds;
+
struct RandomSound {
Common::String sound;
Audio::Mixer::SoundType type;
diff --git a/engines/phoenixvr/variables.cpp b/engines/phoenixvr/variables.cpp
new file mode 100644
index 00000000000..aad44dc2427
--- /dev/null
+++ b/engines/phoenixvr/variables.cpp
@@ -0,0 +1,63 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "phoenixvr/variables.h"
+#include "common/debug.h"
+#include "phoenixvr/console.h"
+#include "phoenixvr/phoenixvr.h"
+
+namespace PhoenixVR {
+
+void Variables::declare(const Common::String &name) {
+ if (!_variableIndex.contains(name)) {
+ _variableValues.push_back(0);
+ auto *varPtr = &_variableValues.back();
+ _variableIndex.setVal(name, varPtr);
+ static_cast<Console *>(g_engine->getDebugger())->registerVar(name, varPtr);
+ }
+}
+
+int Variables::get(const Common::String &name) const {
+ auto it = _variableIndex.find(name);
+ if (it == _variableIndex.end()) {
+ warning("get %s - variable was not declared", name.c_str());
+ return 0;
+ }
+ return *it->_value;
+}
+
+void Variables::set(const Common::String &name, int value) {
+ auto it = _variableIndex.find(name);
+ if (it == _variableIndex.end()) {
+ debug("set %s %d - ignored, variable was not declared", name.c_str(), value);
+ return;
+ }
+ debug("set %s %d", name.c_str(), value);
+ *it->_value = value;
+}
+
+void Variables::clear() {
+ _variableIndex.clear();
+ _variableValues.clear();
+ static_cast<Console *>(g_engine->getDebugger())->clearVars();
+}
+
+} // namespace PhoenixVR
diff --git a/engines/phoenixvr/variables.h b/engines/phoenixvr/variables.h
new file mode 100644
index 00000000000..b55abe51c91
--- /dev/null
+++ b/engines/phoenixvr/variables.h
@@ -0,0 +1,50 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef PHOENIXVR_VARIABLES_H
+#define PHOENIXVR_VARIABLES_H
+
+#include "common/hash-str.h"
+#include "common/hashmap.h"
+#include "common/list.h"
+
+namespace PhoenixVR {
+
+class Variables {
+ Common::List<int> _variableValues;
+ Common::HashMap<Common::String, int *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _variableIndex;
+
+public:
+ Common::List<int> &values() { return _variableValues; }
+ const Common::List<int> &values() const { return _variableValues; }
+
+ int get(const Common::String &name) const;
+ void set(const Common::String &name, int value);
+ void declare(const Common::String &name);
+ bool declared(const Common::String &name) const {
+ return _variableIndex.contains(name);
+ }
+ void clear();
+};
+
+} // namespace PhoenixVR
+
+#endif
More information about the Scummvm-git-logs
mailing list