[Scummvm-git-logs] scummvm master -> fda732830dec5e96b9d21a6a2372fa197c379309
Strangerke
noreply at scummvm.org
Mon Jan 13 21:39:28 UTC 2025
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:
fda732830d GOT: Remove some useless includes, format remaining code
Commit: fda732830dec5e96b9d21a6a2372fa197c379309
https://github.com/scummvm/scummvm/commit/fda732830dec5e96b9d21a6a2372fa197c379309
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T22:39:21+01:00
Commit Message:
GOT: Remove some useless includes, format remaining code
Changed paths:
engines/got/console.cpp
engines/got/console.h
engines/got/detection.h
engines/got/detection_tables.h
engines/got/events.cpp
engines/got/events.h
engines/got/got.cpp
engines/got/got.h
engines/got/messages.cpp
engines/got/messages.h
engines/got/metaengine.cpp
engines/got/metaengine.h
engines/got/sound.cpp
engines/got/sound.h
engines/got/vars.cpp
engines/got/vars.h
diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index 81f60f43220..acc88eb4692 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -19,136 +19,135 @@
*
*/
+#include "got/console.h"
#include "common/savefile.h"
#include "common/system.h"
-#include "got/console.h"
#include "got/events.h"
-#include "got/vars.h"
#include "got/got.h"
+#include "got/vars.h"
namespace Got {
static const char *SAVE_FILENAMES[3] = {
- "savegam1.got", "savegam1.gt2", "savegam1.gt3"
-};
+ "savegam1.got", "savegam1.gt2", "savegam1.gt3"};
Console::Console() : GUI::Debugger() {
- registerCmd("view", WRAP_METHOD(Console, cmdView));
- registerCmd("sound", WRAP_METHOD(Console, cmdSound));
- registerCmd("music", WRAP_METHOD(Console, cmdMusic));
- registerCmd("load", WRAP_METHOD(Console, cmdLoad));
- registerCmd("save", WRAP_METHOD(Console, cmdSave));
- registerCmd("magic", WRAP_METHOD(Console, cmdMagic));
- registerCmd("freeze", WRAP_METHOD(Console, cmdFreeze));
- registerCmd("level", WRAP_METHOD(Console, cmdLevel));
- registerCmd("flying", WRAP_METHOD(Console, cmdFlying));
+ registerCmd("view", WRAP_METHOD(Console, cmdView));
+ registerCmd("sound", WRAP_METHOD(Console, cmdSound));
+ registerCmd("music", WRAP_METHOD(Console, cmdMusic));
+ registerCmd("load", WRAP_METHOD(Console, cmdLoad));
+ registerCmd("save", WRAP_METHOD(Console, cmdSave));
+ registerCmd("magic", WRAP_METHOD(Console, cmdMagic));
+ registerCmd("freeze", WRAP_METHOD(Console, cmdFreeze));
+ registerCmd("level", WRAP_METHOD(Console, cmdLevel));
+ registerCmd("flying", WRAP_METHOD(Console, cmdFlying));
}
Console::~Console() {
}
bool Console::cmdView(int argc, const char **argv) {
- if (argc != 2) {
- debugPrintf("view <view name>\n");
- return true;
- } else {
- g_events->replaceView(argv[1], true);
- return false;
- }
+ if (argc != 2) {
+ debugPrintf("view <view name>\n");
+ return true;
+ }
+
+ g_events->replaceView(argv[1], true);
+ return false;
}
bool Console::cmdSound(int argc, const char **argv) {
- if (argc == 2)
- _G(sound).play_sound(atoi(argv[1]), true);
- return false;
+ if (argc == 2)
+ _G(sound).play_sound(atoi(argv[1]), true);
+ return false;
}
bool Console::cmdMusic(int argc, const char **argv) {
- if (argc == 2)
- _G(sound).music_play(atoi(argv[1]), true);
- return false;
+ if (argc == 2)
+ _G(sound).music_play(atoi(argv[1]), true);
+ return false;
}
bool Console::cmdLoad(int argc, const char **argv) {
- Common::String filename = SAVE_FILENAMES[_G(area) - 1];
- if (argc == 2)
- filename = argv[1];
-
- Common::InSaveFile *f;
- if ((f = g_system->getSavefileManager()->openForLoading(filename)) == nullptr) {
- debugPrintf("Could not open %s\n", filename.c_str());
- return true;
- } else {
- Common::Serializer s(f, nullptr);
- g_engine->syncGame(s);
- delete f;
- return false;
- }
+ Common::String filename = SAVE_FILENAMES[_G(area) - 1];
+ if (argc == 2)
+ filename = argv[1];
+
+ Common::InSaveFile *f;
+ if ((f = g_system->getSavefileManager()->openForLoading(filename)) == nullptr) {
+ debugPrintf("Could not open %s\n", filename.c_str());
+ return true;
+ }
+
+ Common::Serializer s(f, nullptr);
+ g_engine->syncGame(s);
+ delete f;
+ return false;
}
bool Console::cmdSave(int argc, const char **argv) {
- Common::String filename = SAVE_FILENAMES[_G(area) - 1];
- if (argc == 2)
- filename = argv[1];
+ Common::String filename = SAVE_FILENAMES[_G(area) - 1];
+ if (argc == 2)
+ filename = argv[1];
- Common::OutSaveFile *f;
- if ((f = g_system->getSavefileManager()->openForSaving(filename, false)) == nullptr) {
- debugPrintf("Could not create %s\n", filename.c_str());
+ Common::OutSaveFile *f = g_system->getSavefileManager()->openForSaving(filename, false);
+ if (f == nullptr) {
+ debugPrintf("Could not create %s\n", filename.c_str());
- } else {
- Common::Serializer s(nullptr, f);
- g_engine->syncGame(s);
+ } else {
+ Common::Serializer s(nullptr, f);
+ g_engine->syncGame(s);
- delete f;
+ delete f;
- debugPrintf("Created %s\n", filename.c_str());
- }
+ debugPrintf("Created %s\n", filename.c_str());
+ }
- return true;
+ return true;
}
bool Console::cmdMagic(int argc, const char **argv) {
- _G(thor_info).magic = (argc == 2) ? CLIP(atoi(argv[1]), 0, 150): 150;
+ _G(thor_info).magic = (argc == 2) ? CLIP(atoi(argv[1]), 0, 150) : 150;
- return false;
+ return false;
}
bool Console::cmdFreeze(int argc, const char **argv) {
- if (argc != 2) {
- debugPrintf("freeze ['health', 'magic', 'gems']\n");
- } else if (!strcmp(argv[1], "health")) {
- _G(cheats).freezeHealth = !_G(cheats).freezeHealth;
- debugPrintf("Health is %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
- } else if (!strcmp(argv[1], "magic")) {
- _G(cheats).freezeMagic = !_G(cheats).freezeMagic;
- debugPrintf("Magic is %s\n", _G(cheats).freezeMagic ? "frozen" : "unfrozen");
- } else if (!strcmp(argv[1], "jewels")) {
- _G(cheats).freezeJewels = !_G(cheats).freezeJewels;
- debugPrintf("Jewels are %s\n", _G(cheats).freezeJewels ? "frozen" : "unfrozen");
- } else if (!strcmp(argv[1], "all")) {
- _G(cheats).freezeHealth = _G(cheats).freezeMagic =
- _G(cheats).freezeJewels = !_G(cheats).freezeHealth;
- debugPrintf("All are %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
- }
-
- return true;
+ if (argc != 2) {
+ debugPrintf("freeze ['health', 'magic', 'gems']\n");
+ } else if (!strcmp(argv[1], "health")) {
+ _G(cheats).freezeHealth = !_G(cheats).freezeHealth;
+ debugPrintf("Health is %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
+ } else if (!strcmp(argv[1], "magic")) {
+ _G(cheats).freezeMagic = !_G(cheats).freezeMagic;
+ debugPrintf("Magic is %s\n", _G(cheats).freezeMagic ? "frozen" : "unfrozen");
+ } else if (!strcmp(argv[1], "jewels")) {
+ _G(cheats).freezeJewels = !_G(cheats).freezeJewels;
+ debugPrintf("Jewels are %s\n", _G(cheats).freezeJewels ? "frozen" : "unfrozen");
+ } else if (!strcmp(argv[1], "all")) {
+ _G(cheats).freezeHealth = _G(cheats).freezeMagic =
+ _G(cheats).freezeJewels = !_G(cheats).freezeHealth;
+ debugPrintf("All are %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
+ }
+
+ return true;
}
bool Console::cmdLevel(int argc, const char **argv) {
- if (argc != 2) {
- debugPrintf("Current level = %d\n", _G(current_level));
- return true;
- } else {
- _G(new_level) = atoi(argv[1]);
- _G(warp_flag) = true;
- return false;
- }
+ if (argc != 2) {
+ debugPrintf("Current level = %d\n", _G(current_level));
+ return true;
+ }
+
+ _G(new_level) = atoi(argv[1]);
+ _G(warp_flag) = true;
+ return false;
}
bool Console::cmdFlying(int argc, const char **argv) {
- _G(thor)->flying = !_G(thor)->flying;
- debugPrintf("Flying is %s\n", _G(thor)->flying ? "on" : "off");
- return true;
+ _G(thor)->flying = !_G(thor)->flying;
+ debugPrintf("Flying is %s\n", _G(thor)->flying ? "on" : "off");
+ return true;
}
} // namespace Got
diff --git a/engines/got/console.h b/engines/got/console.h
index b05391ca81c..1b61d8d76e6 100644
--- a/engines/got/console.h
+++ b/engines/got/console.h
@@ -29,19 +29,19 @@ namespace Got {
class Console : public GUI::Debugger {
private:
- bool cmdView(int argc, const char **argv);
- bool cmdSound(int argc, const char **argv);
- bool cmdMusic(int argc, const char **argv);
- bool cmdLoad(int argc, const char **argv);
- bool cmdSave(int argc, const char **argv);
- bool cmdMagic(int argc, const char **argv);
- bool cmdFreeze(int argc, const char **argv);
- bool cmdLevel(int argc, const char **argv);
- bool cmdFlying(int argc, const char **argv);
+ bool cmdView(int argc, const char **argv);
+ bool cmdSound(int argc, const char **argv);
+ bool cmdMusic(int argc, const char **argv);
+ bool cmdLoad(int argc, const char **argv);
+ bool cmdSave(int argc, const char **argv);
+ bool cmdMagic(int argc, const char **argv);
+ bool cmdFreeze(int argc, const char **argv);
+ bool cmdLevel(int argc, const char **argv);
+ bool cmdFlying(int argc, const char **argv);
public:
- Console();
- ~Console() override;
+ Console();
+ ~Console() override;
};
} // End of namespace Got
diff --git a/engines/got/detection.h b/engines/got/detection.h
index 5d6b5a47773..b9238d19804 100644
--- a/engines/got/detection.h
+++ b/engines/got/detection.h
@@ -27,11 +27,11 @@
namespace Got {
enum GotDebugChannels {
- kDebugGraphics = 1,
- kDebugPath,
- kDebugScan,
- kDebugFilePath,
- kDebugScript,
+ kDebugGraphics = 1,
+ kDebugPath,
+ kDebugScan,
+ kDebugFilePath,
+ kDebugScript,
};
extern const PlainGameDescriptor gotGames[];
@@ -43,27 +43,27 @@ extern const ADGameDescription gameDescriptions[];
} // End of namespace Got
class GotMetaEngineDetection : public AdvancedMetaEngineDetection<ADGameDescription> {
- static const DebugChannelDef debugFlagList[];
+ static const DebugChannelDef debugFlagList[];
public:
- GotMetaEngineDetection();
- ~GotMetaEngineDetection() override {}
+ GotMetaEngineDetection();
+ ~GotMetaEngineDetection() override {}
- const char *getName() const override {
- return "got";
- }
+ const char *getName() const override {
+ return "got";
+ }
- const char *getEngineName() const override {
- return "Got";
- }
+ const char *getEngineName() const override {
+ return "Got";
+ }
- const char *getOriginalCopyright() const override {
- return "Got (C)";
- }
+ const char *getOriginalCopyright() const override {
+ return "Got (C)";
+ }
- const DebugChannelDef *getDebugChannels() const override {
- return debugFlagList;
- }
+ const DebugChannelDef *getDebugChannels() const override {
+ return debugFlagList;
+ }
};
#endif // GOT_DETECTION_H
diff --git a/engines/got/detection_tables.h b/engines/got/detection_tables.h
index 6ab15d33ce7..ad5c10ad4cd 100644
--- a/engines/got/detection_tables.h
+++ b/engines/got/detection_tables.h
@@ -22,49 +22,48 @@
namespace Got {
const PlainGameDescriptor gotGames[] = {
- { "got", "God of Thunder" },
- { 0, 0 }
+ {"got", "God of Thunder"},
+ {nullptr, nullptr}
};
const ADGameDescription gameDescriptions[] = {
- {
- "got",
- "v1.0:143",
- AD_ENTRY1s("gotres.dat", "0fe859bcfd06772be0885bf510c2877d", 739732),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NOSPEECH)
- },
- {
- "got",
- "v1.0:143 Shareware",
- AD_ENTRY1s("gotres.dat", "c316221a3b9d12a838faef55fde2f34c", 482738),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_UNSTABLE | ADGF_DEMO,
- GUIO1(GUIO_NOSPEECH)
- },
- {
- "got",
- "v1.1:144",
- AD_ENTRY1s("gotres.dat", "747ed508ffa3808156a4eb080e9859f8", 739710),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NOSPEECH)
- },
- {
- "got",
- "v1.1:144 Shareware",
- AD_ENTRY1s("gotres.dat", "c443aa09450566ee32998c3ebb15cbaa", 485858),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_UNSTABLE | ADGF_DEMO,
- GUIO1(GUIO_NOSPEECH)
- },
+ {
+ "got",
+ "v1.0:143",
+ AD_ENTRY1s("gotres.dat", "0fe859bcfd06772be0885bf510c2877d", 739732),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NOSPEECH)
+ },
+ {
+ "got",
+ "v1.0:143 Shareware",
+ AD_ENTRY1s("gotres.dat", "c316221a3b9d12a838faef55fde2f34c", 482738),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_UNSTABLE | ADGF_DEMO,
+ GUIO1(GUIO_NOSPEECH)
+ },
+ {
+ "got",
+ "v1.1:144",
+ AD_ENTRY1s("gotres.dat", "747ed508ffa3808156a4eb080e9859f8", 739710),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NOSPEECH)
+ },
+ {
+ "got",
+ "v1.1:144 Shareware",
+ AD_ENTRY1s("gotres.dat", "c443aa09450566ee32998c3ebb15cbaa", 485858),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_UNSTABLE | ADGF_DEMO,
+ GUIO1(GUIO_NOSPEECH)
+ },
- AD_TABLE_END_MARKER
-};
+ AD_TABLE_END_MARKER};
} // End of namespace Got
diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index a35feecc97c..35463e04d8b 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -32,14 +32,10 @@ Events *g_events;
// Index and RGB63 values used for palette animation
// like water effects and gems sparkling
-static const uint16 PAL_CLR1[] = {
- 0xf300, 0x003b, 0xf000, 0x003b, 0xf100, 0x003b, 0xf200, 0x003b};
-static const uint16 PAL_SET1[] = {
- 0xf027, 0x273f, 0xf127, 0x273f, 0xf227, 0x273f, 0xf327, 0x273f};
-static const uint16 PAL_CLR2[] = {
- 0xf73b, 0x0000, 0xf43b, 0x0000, 0xf53b, 0x0000, 0xf63b, 0x0000};
-static const uint16 PAL_SET2[] = {
- 0xf43f, 0x2727, 0xf53f, 0x2727, 0xf63f, 0x2727, 0xf73f, 0x2727};
+static const uint16 PAL_CLR1[] = {0xf300, 0x003b, 0xf000, 0x003b, 0xf100, 0x003b, 0xf200, 0x003b};
+static const uint16 PAL_SET1[] = {0xf027, 0x273f, 0xf127, 0x273f, 0xf227, 0x273f, 0xf327, 0x273f};
+static const uint16 PAL_CLR2[] = {0xf73b, 0x0000, 0xf43b, 0x0000, 0xf53b, 0x0000, 0xf63b, 0x0000};
+static const uint16 PAL_SET2[] = {0xf43f, 0x2727, 0xf53f, 0x2727, 0xf63f, 0x2727, 0xf73f, 0x2727};
Events::Events() : UIElement("Root", nullptr) {
g_events = this;
@@ -72,9 +68,9 @@ void Events::runGame() {
e.type == Common::EVENT_RETURN_TO_LAUNCHER) {
_views.clear();
break;
- } else {
- processEvent(e);
}
+
+ processEvent(e);
}
if (_views.empty())
@@ -109,8 +105,7 @@ void Events::nextFrame() {
_G(rand2) = getRandomNumber(99);
_G(pge) = _G(pge) ^ 1;
_G(shot_ok) = true;
- _G(magic_cnt)
- ++;
+ _G(magic_cnt++);
// In demo mode, handle the next key
if (_G(demo) && focusedView()->getName() == "Game") {
@@ -400,8 +395,7 @@ UIElement::UIElement(const Common::String &name) : _name(name), _parent(g_engine
g_engine->_children.push_back(this);
}
-UIElement::UIElement(const Common::String &name, UIElement *uiParent) : _name(name), _parent(uiParent),
- _bounds(_innerBounds) {
+UIElement::UIElement(const Common::String &name, UIElement *uiParent) : _name(name), _parent(uiParent), _bounds(_innerBounds) {
if (_parent)
_parent->_children.push_back(this);
}
diff --git a/engines/got/events.h b/engines/got/events.h
index a5c164acb09..d7cd9c00e61 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -24,9 +24,9 @@
#include "common/array.h"
#include "common/stack.h"
-#include "graphics/screen.h"
-#include "got/messages.h"
#include "got/gfx/gfx_surface.h"
+#include "got/messages.h"
+#include "graphics/screen.h"
namespace Got {
@@ -43,230 +43,239 @@ class Events;
*/
struct Bounds {
private:
- Common::Rect _bounds;
- Common::Rect &_innerBounds;
- int _borderSize = 0;
+ Common::Rect _bounds;
+ Common::Rect &_innerBounds;
+ int _borderSize = 0;
+
public:
- const int16 &left;
- const int16 ⊤
- const int16 &right;
- const int16 ⊥
+ const int16 &left;
+ const int16 ⊤
+ const int16 &right;
+ const int16 ⊥
+
public:
- Bounds(Common::Rect &innerBounds);
- operator const Common::Rect &() const {
- return _bounds;
- }
- Bounds &operator=(const Common::Rect &r);
- void setBorderSize(size_t borderSize);
- size_t borderSize() const {
- return _borderSize;
- }
- int16 width() const {
- return _bounds.width();
- }
- int16 height() const {
- return _bounds.height();
- }
+ Bounds(Common::Rect &innerBounds);
+ operator const Common::Rect &() const {
+ return _bounds;
+ }
+ Bounds &operator=(const Common::Rect &r);
+ void setBorderSize(size_t borderSize);
+ size_t borderSize() const {
+ return _borderSize;
+ }
+ int16 width() const {
+ return _bounds.width();
+ }
+ int16 height() const {
+ return _bounds.height();
+ }
};
/**
* User interface element
*/
class UIElement {
- friend class Events;
+ friend class Events;
+
private:
- int _timeoutCtr = 0;
+ int _timeoutCtr = 0;
+
protected:
- UIElement *_parent;
- Common::Array<UIElement *> _children;
- Common::Rect _innerBounds;
- Bounds _bounds;
- bool _needsRedraw = true;
- Common::String _name;
+ UIElement *_parent;
+ Common::Array<UIElement *> _children;
+ Common::Rect _innerBounds;
+ Bounds _bounds;
+ bool _needsRedraw = true;
+ Common::String _name;
+
protected:
- /**
+ /**
* Set a delay countdown in seconds, after which timeout() is called
*/
- void delaySeconds(uint seconds);
+ void delaySeconds(uint seconds);
- /**
+ /**
* Set a delay countdown in frames, after which timeout() is called
*/
- void delayFrames(uint frames);
+ void delayFrames(uint frames);
- /**
+ /**
* Returns true if a delay is active
*/
- bool isDelayActive() const {
- return _timeoutCtr != 0;
- }
+ bool isDelayActive() const {
+ return _timeoutCtr != 0;
+ }
- /**
+ /**
* Cancels any active delay
*/
- void cancelDelay() {
- _timeoutCtr = 0;
- }
+ void cancelDelay() {
+ _timeoutCtr = 0;
+ }
- /**
+ /**
* Called when an active timeout countdown expired
*/
- virtual void timeout();
+ virtual void timeout();
private:
- /**
+ /**
* Outer method for doing drawing
*
*/
- void drawElements();
+ void drawElements();
- /**
+ /**
* Finds a view globally
*/
- static UIElement *findViewGlobally(const Common::String &name);
+ static UIElement *findViewGlobally(const Common::String &name);
+
public:
- UIElement(const Common::String &name, UIElement *uiParent);
- UIElement(const Common::String &name);
- virtual ~UIElement() {}
+ UIElement(const Common::String &name, UIElement *uiParent);
+ UIElement(const Common::String &name);
+ virtual ~UIElement() {}
- /**
+ /**
* Returns true if the elements needs to be redrawn
*/
- bool needsRedraw() const {
- return _needsRedraw;
- }
+ bool needsRedraw() const {
+ return _needsRedraw;
+ }
- /**
+ /**
* Sets that the element needs to be redrawn
*/
- void redraw();
+ void redraw();
- /**
+ /**
* Focuses the element as the current view
*/
- void focus();
+ void focus();
- /**
+ /**
* Closes the current view. The view must have been added
* via addView, so there's a remaining view afterwards
*/
- virtual void close();
+ virtual void close();
- /*
+ /*
* Returns true if the view is focused
*/
- bool isFocused() const;
+ bool isFocused() const;
- /**
+ /**
* Sets the focus to a new view
*/
- void replaceView(UIElement *ui, bool replaceAllViews = false, bool fadeOutIn = false);
- void replaceView(const Common::String &name, bool replaceAllViews = false, bool fadeOutIn = false);
+ void replaceView(UIElement *ui, bool replaceAllViews = false, bool fadeOutIn = false);
+ void replaceView(const Common::String &name, bool replaceAllViews = false, bool fadeOutIn = false);
- /**
+ /**
* Adds a focused view to the view stack without replacing current one
*/
- void addView(UIElement *ui);
- void addView(const Common::String &name);
- void addView();
- void open() {
- addView();
- }
+ void addView(UIElement *ui);
+ void addView(const Common::String &name);
+ void addView();
+ void open() {
+ addView();
+ }
- /**
+ /**
* Returns a random number
*/
- int getRandomNumber(int minNumber, int maxNumber);
- int getRandomNumber(int maxNumber);
+ int getRandomNumber(int minNumber, int maxNumber);
+ int getRandomNumber(int maxNumber);
- /**
+ /**
* Sets the element's bounds
*/
- virtual void setBounds(const Common::Rect &r) {
- _bounds = r;
- }
+ virtual void setBounds(const Common::Rect &r) {
+ _bounds = r;
+ }
- /**
+ /**
* Gets the element's bounds
*/
- Common::Rect getBounds() const {
- return _bounds;
- }
+ Common::Rect getBounds() const {
+ return _bounds;
+ }
- /**
+ /**
* Gets a view's name
*/
- const Common::String &getName() const {
- return _name;
- }
+ const Common::String &getName() const {
+ return _name;
+ }
- /**
+ /**
* Returns a surface for drawing the element
*/
- Gfx::GfxSurface getSurface(bool innerBounds = false) const;
+ Gfx::GfxSurface getSurface(bool innerBounds = false) const;
- /**
+ /**
* Clear the surface
*/
- virtual void clearSurface();
+ virtual void clearSurface();
- /**
+ /**
* Draws the element
*/
- virtual void draw();
+ virtual void draw();
- /**
+ /**
* Called for game frame ticks
*/
- virtual bool tick();
+ virtual bool tick();
- /**
+ /**
* Find a view by name
*/
- virtual UIElement *findView(const Common::String &name);
+ virtual UIElement *findView(const Common::String &name);
- /**
+ /**
* Handles events
*/
- // Mouse move only has a minimal implementation for performance reasons
+ // Mouse move only has a minimal implementation for performance reasons
protected:
- virtual bool msgMouseMove(const MouseMoveMessage &msg) {
- return false;
- }
+ virtual bool msgMouseMove(const MouseMoveMessage &msg) {
+ return false;
+ }
+
public:
- bool send(const MouseMoveMessage &msg) {
- return msgMouseMove(msg);
- }
-
-#define MESSAGE(NAME) \
- protected: \
- virtual bool msg##NAME(const NAME##Message &e) { \
- for (Common::Array<UIElement *>::iterator it = _children.begin(); \
- it != _children.end(); ++it) { \
- if ((*it)->msg##NAME(e)) return true; \
- } \
- return false; \
- } \
- public: \
- bool send(const Common::String &viewName, const NAME##Message &msg) { \
- UIElement *view = UIElement::findViewGlobally(viewName); \
- assert(view); \
- return view->msg##NAME(msg); \
- } \
- bool send(const NAME##Message &msg) { \
- return msg##NAME(msg); \
- } \
-
- MESSAGE(Focus);
- MESSAGE(Unfocus);
- MESSAGE(MouseEnter);
- MESSAGE(MouseLeave);
- MESSAGE(Keypress);
- MESSAGE(MouseDown);
- MESSAGE(MouseUp);
- MESSAGE(Action);
- MESSAGE(Game);
- MESSAGE(Value);
+ bool send(const MouseMoveMessage &msg) {
+ return msgMouseMove(msg);
+ }
+
+#define MESSAGE(NAME) \
+protected: \
+ virtual bool msg##NAME(const NAME##Message &e) { \
+ for (Common::Array<UIElement *>::iterator it = _children.begin(); \
+ it != _children.end(); ++it) { \
+ if ((*it)->msg##NAME(e)) \
+ return true; \
+ } \
+ return false; \
+ } \
+ \
+public: \
+ bool send(const Common::String &viewName, const NAME##Message &msg) { \
+ UIElement *view = UIElement::findViewGlobally(viewName); \
+ assert(view); \
+ return view->msg##NAME(msg); \
+ } \
+ bool send(const NAME##Message &msg) { \
+ return msg##NAME(msg); \
+ }
+
+ MESSAGE(Focus);
+ MESSAGE(Unfocus);
+ MESSAGE(MouseEnter);
+ MESSAGE(MouseLeave);
+ MESSAGE(Keypress);
+ MESSAGE(MouseDown);
+ MESSAGE(MouseUp);
+ MESSAGE(Action);
+ MESSAGE(Game);
+ MESSAGE(Value);
#undef MESSAGE
};
@@ -279,162 +288,161 @@ public:
*/
class Events : public UIElement {
private:
- Graphics::Screen *_screen = nullptr;
- Common::Stack<UIElement *> _views;
- int _palLoop = 0;
- int _palCnt1 = 0;
- int _palCnt2 = 0;
+ Graphics::Screen *_screen = nullptr;
+ Common::Stack<UIElement *> _views;
+ int _palLoop = 0;
+ int _palCnt1 = 0;
+ int _palCnt2 = 0;
- void nextFrame();
- int actionToKeyFlag(int action) const;
- void rotatePalette();
+ void nextFrame();
+ int actionToKeyFlag(int action) const;
+ void rotatePalette();
- /**
+ /**
* Process an event
*/
- void processEvent(Common::Event &ev);
+ void processEvent(Common::Event &ev);
- /**
+ /**
* Process a demo event
*/
- void processDemoEvent(byte ev);
+ void processDemoEvent(byte ev);
protected:
- /**
+ /**
* Returns true if the game should quit
*/
- virtual bool shouldQuit() const = 0;
+ virtual bool shouldQuit() const = 0;
- /**
+ /**
* Overrides events we want to only go to the focused view
*/
-#define MESSAGE(NAME) \
- bool msg##NAME(const NAME##Message &e) override { \
- return !_views.empty() ? focusedView()->msg##NAME(e) : false; \
- }
- MESSAGE(Action);
- MESSAGE(Focus);
- MESSAGE(Unfocus);
- MESSAGE(MouseEnter);
- MESSAGE(MouseLeave);
- MESSAGE(Keypress);
- MESSAGE(MouseDown);
- MESSAGE(MouseUp);
- MESSAGE(MouseMove);
+#define MESSAGE(NAME) \
+ bool msg##NAME(const NAME##Message &e) override { \
+ return !_views.empty() ? focusedView()->msg##NAME(e) : false; \
+ }
+ MESSAGE(Action);
+ MESSAGE(Focus);
+ MESSAGE(Unfocus);
+ MESSAGE(MouseEnter);
+ MESSAGE(MouseLeave);
+ MESSAGE(Keypress);
+ MESSAGE(MouseDown);
+ MESSAGE(MouseUp);
+ MESSAGE(MouseMove);
#undef MESSAGE
public:
- Events();
- virtual ~Events();
+ Events();
+ virtual ~Events();
- virtual bool isDemo() const = 0;
+ virtual bool isDemo() const = 0;
- /**
+ /**
* Main game loop
*/
- void runGame();
+ void runGame();
- /**
+ /**
* Sets the focus to a new view
*/
- void replaceView(UIElement *ui, bool replaceAllViews = false, bool fadeOutIn = false);
- void replaceView(const Common::String &name, bool replaceAllViews = false, bool fadeOutIn = false);
+ void replaceView(UIElement *ui, bool replaceAllViews = false, bool fadeOutIn = false);
+ void replaceView(const Common::String &name, bool replaceAllViews = false, bool fadeOutIn = false);
- /**
+ /**
* Adds a focused view to the view stack without replacing current one
*/
- void addView(UIElement *ui);
- void addView(const Common::String &name);
+ void addView(UIElement *ui);
+ void addView(const Common::String &name);
- /**
+ /**
* Clears the view list
*/
- void clearViews();
+ void clearViews();
- /**
+ /**
* Pops a view from the view stack
*/
- void popView();
+ void popView();
- /**
+ /**
* Redraws the views in order. This is used in rare cases
* where a view draws outside it's defined area, and needs
* to restore whether the background was before
*/
- void redrawViews();
+ void redrawViews();
- /**
+ /**
* Returns the currently focused view, if any
*/
- UIElement *focusedView() const {
- return _views.empty() ? nullptr : _views.top();
- }
+ UIElement *focusedView() const {
+ return _views.empty() ? nullptr : _views.top();
+ }
- /**
+ /**
* Returns the view prior to the current view, if any
*/
- UIElement *priorView() const {
- return _views.size() < 2 ? nullptr :
- _views[_views.size() - 2];
- }
+ UIElement *priorView() const {
+ return _views.size() < 2 ? nullptr : _views[_views.size() - 2];
+ }
- /**
+ /**
* Returns the first view in the stack
*/
- UIElement *firstView() const {
- return _views.empty() ? nullptr : _views[0];
- }
+ UIElement *firstView() const {
+ return _views.empty() ? nullptr : _views[0];
+ }
- /**
+ /**
* Returns true if a view of a given name is present
* at all in the visible view stack
*/
- bool isPresent(const Common::String &name) const;
+ bool isPresent(const Common::String &name) const;
- /**
+ /**
* Returns true if combat is active
*/
- bool isInCombat() const {
- return isPresent("Combat");
- }
+ bool isInCombat() const {
+ return isPresent("Combat");
+ }
- /**
+ /**
* Returns the underlying screen
*/
- Graphics::Screen *getScreen() const {
- return _screen;
- }
+ Graphics::Screen *getScreen() const {
+ return _screen;
+ }
- /**
+ /**
* Draws the focused view
*/
- void drawElements() {
- if (!_views.empty())
- focusedView()->drawElements();
- }
+ void drawElements() {
+ if (!_views.empty())
+ focusedView()->drawElements();
+ }
- /**
+ /**
* Add a keypress to the event queue
*/
- void addKeypress(const Common::KeyCode kc);
+ void addKeypress(const Common::KeyCode kc);
- /**
+ /**
* Events manager doesn't have any intrinsic drawing
*/
- void draw() override {}
+ void draw() override {}
- /**
+ /**
* Called once every game frame
*/
- bool tick() override {
- return !_views.empty() ? focusedView()->tick() : false;
- }
+ bool tick() override {
+ return !_views.empty() ? focusedView()->tick() : false;
+ }
- /**
+ /**
* Calling the close method for g_events closes the active view
*/
- void close() override {
- focusedView()->close();
- }
+ void close() override {
+ focusedView()->close();
+ }
};
extern Events *g_events;
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index d974531854a..afbf296cc01 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -19,16 +19,14 @@
*
*/
-#include "common/scummsys.h"
+#include "got/got.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/events.h"
+#include "common/scummsys.h"
#include "common/system.h"
#include "common/translation.h"
#include "engines/util.h"
-#include "graphics/paletteman.h"
-#include "got/got.h"
-#include "got/detection.h"
#include "got/console.h"
#include "got/game/init.h"
#include "got/game/main.h"
@@ -36,6 +34,7 @@
#include "got/gfx/image.h"
#include "got/utils/res_archive.h"
#include "got/views/game_content.h"
+#include "graphics/paletteman.h"
namespace Got {
@@ -44,201 +43,202 @@ namespace Got {
GotEngine *g_engine;
GotEngine::GotEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst),
- _gameDescription(gameDesc), _randomSource("Got") {
- g_engine = this;
+ _gameDescription(gameDesc), _randomSource("Got") {
+ g_engine = this;
}
GotEngine::~GotEngine() {
- _mixer->stopAll();
+ _mixer->stopAll();
}
uint32 GotEngine::getFeatures() const {
- return _gameDescription->flags;
+ return _gameDescription->flags;
}
bool GotEngine::isDemo() const {
- return (_gameDescription->flags & ADGF_DEMO) != 0;
+ return (_gameDescription->flags & ADGF_DEMO) != 0;
}
Common::String GotEngine::getGameId() const {
- return _gameDescription->gameId;
+ return _gameDescription->gameId;
}
Common::Error GotEngine::run() {
- // Initialize 320x240 paletted graphics mode. Note that the original
- // main menu/dialogs ran at 320x200, but the game ran at 320x240.
- initGraphics(320, 240);
+ // Initialize 320x240 paletted graphics mode. Note that the original
+ // main menu/dialogs ran at 320x200, but the game ran at 320x240.
+ initGraphics(320, 240);
- // Set the engine's debugger console
- setDebugger(new Console());
+ // Set the engine's debugger console
+ setDebugger(new Console());
- // Initialize resources and variables
- resInit();
- _vars.load();
+ // Initialize resources and variables
+ resInit();
+ _vars.load();
- // General initialization
- if (_G(demo))
- initialize_game();
- syncSoundSettings();
+ // General initialization
+ if (_G(demo))
+ initialize_game();
+ syncSoundSettings();
- runGame();
+ runGame();
- return Common::kNoError;
+ return Common::kNoError;
}
Common::Error GotEngine::saveGameStream(Common::WriteStream *stream, bool isAutosave) {
- stream->writeByte(SAVEGAME_VERSION);
- Common::Serializer s(nullptr, stream);
- s.setVersion(SAVEGAME_VERSION);
+ stream->writeByte(SAVEGAME_VERSION);
+ Common::Serializer s(nullptr, stream);
+ s.setVersion(SAVEGAME_VERSION);
- return syncGame(s);
+ return syncGame(s);
}
Common::Error GotEngine::loadGameStream(Common::SeekableReadStream *stream) {
- byte version = stream->readByte();
- if (version != SAVEGAME_VERSION)
- error("Invalid savegame version");
+ byte version = stream->readByte();
+ if (version != SAVEGAME_VERSION)
+ error("Invalid savegame version");
- Common::Serializer s(stream, nullptr);
- s.setVersion(version);
+ Common::Serializer s(stream, nullptr);
+ s.setVersion(version);
- return syncGame(s);
+ return syncGame(s);
}
-
Common::Error GotEngine::syncGame(Common::Serializer &s) {
- char title[32];
- Common::fill(title, title + 32, 0);
- Common::strcpy_s(title, _G(playerName).c_str());
- s.syncBytes((byte *)title, 32);
- if (s.isLoading())
- _G(playerName) = title;
+ char title[32];
+ Common::fill(title, title + 32, 0);
+ Common::strcpy_s(title, _G(playerName).c_str());
+ s.syncBytes((byte *)title, 32);
+ if (s.isLoading())
+ _G(playerName) = title;
- _G(setup).sync(s);
+ _G(setup).sync(s);
- if (s.isLoading()) {
- // For savegames loaded directly from the ScummVM launcher,
- // take care of initializing game defaults before rest of loading
- if (!firstView() || firstView()->getName() != "Game")
- initialize_game();
+ if (s.isLoading()) {
+ // For savegames loaded directly from the ScummVM launcher,
+ // take care of initializing game defaults before rest of loading
+ if (!firstView() || firstView()->getName() != "Game")
+ initialize_game();
- int area = _G(setup).area;
- if (area == 0)
- area = 1;
+ int area = _G(setup).area;
+ if (area == 0)
+ area = 1;
- g_vars->setArea(area);
- }
+ g_vars->setArea(area);
+ }
- _G(thor_info).sync(s);
- _G(sd_data).sync(s);
+ _G(thor_info).sync(s);
+ _G(sd_data).sync(s);
- if (s.isLoading())
- savegameLoaded();
+ if (s.isLoading())
+ savegameLoaded();
- return Common::kNoError;
+ return Common::kNoError;
}
void GotEngine::savegameLoaded() {
- _G(current_area) = _G(thor_info).last_screen;
-
- _G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
- _G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
- if (_G(thor)->x < 1) _G(thor)->x = 1;
- if (_G(thor)->y < 0) _G(thor)->y = 0;
- _G(thor)->dir = _G(thor_info).last_dir;
- _G(thor)->last_dir = _G(thor_info).last_dir;
- _G(thor)->health = _G(thor_info).last_health;
- _G(thor)->num_moves = 1;
- _G(thor)->vunerable = 60;
- _G(thor)->show = 60;
- _G(thor)->speed_count = 6;
- load_new_thor();
-
- g_vars->resetEndgameFlags();
-
- if (!_G(music_flag))
- _G(setup).music = 0;
- if (!_G(sound_flag))
- _G(setup).dig_sound = 0;
- if (_G(setup).music == 1) {
- if (GAME1 == 1 && _G(current_area) == 59) {
- music_play(5, true);
- } else {
- music_play(_G(level_type), true);
- }
- } else {
- _G(setup).music = 1;
- music_pause();
- _G(setup).music = 0;
- }
-
- _G(game_over) = _G(setup).game_over != 0;
- _G(slow_mode) = _G(setup).speed != 0;
-
- g_events->replaceView("Game", true);
- setup_load();
+ _G(current_area) = _G(thor_info).last_screen;
+
+ _G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
+ _G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
+ if (_G(thor)->x < 1)
+ _G(thor)->x = 1;
+ if (_G(thor)->y < 0)
+ _G(thor)->y = 0;
+ _G(thor)->dir = _G(thor_info).last_dir;
+ _G(thor)->last_dir = _G(thor_info).last_dir;
+ _G(thor)->health = _G(thor_info).last_health;
+ _G(thor)->num_moves = 1;
+ _G(thor)->vunerable = 60;
+ _G(thor)->show = 60;
+ _G(thor)->speed_count = 6;
+ load_new_thor();
+
+ g_vars->resetEndgameFlags();
+
+ if (!_G(music_flag))
+ _G(setup).music = 0;
+ if (!_G(sound_flag))
+ _G(setup).dig_sound = 0;
+ if (_G(setup).music == 1) {
+ if (GAME1 == 1 && _G(current_area) == 59) {
+ music_play(5, true);
+ } else {
+ music_play(_G(level_type), true);
+ }
+ } else {
+ _G(setup).music = 1;
+ music_pause();
+ _G(setup).music = 0;
+ }
+
+ _G(game_over) = _G(setup).game_over != 0;
+ _G(slow_mode) = _G(setup).speed != 0;
+
+ g_events->replaceView("Game", true);
+ setup_load();
}
bool GotEngine::canLoadGameStateCurrently(Common::U32String *msg) {
- if (_G(demo)) {
- *msg = _("Savegames are not available in demo mode");
- return false;
- }
+ if (_G(demo)) {
+ *msg = _("Savegames are not available in demo mode");
+ return false;
+ }
- // Only allow if not in the middle of area transition, dying, etc.
- return _G(gameMode) == MODE_NORMAL;
+ // Only allow if not in the middle of area transition, dying, etc.
+ return _G(gameMode) == MODE_NORMAL;
}
bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
- if (_G(demo)) {
- *msg = _("Savegames are not available in demo mode");
- return false;
- }
+ if (_G(demo)) {
+ *msg = _("Savegames are not available in demo mode");
+ return false;
+ }
- // Don't allowing saving when not in-game
- if (!firstView() || firstView()->getName() != "Game" || _G(game_over))
- return false;
+ // Don't allowing saving when not in-game
+ if (!firstView() || firstView()->getName() != "Game" || _G(game_over))
+ return false;
- // Only allow if not in the middle of area transition, dying, etc.
- return _G(gameMode) == MODE_NORMAL;
+ // Only allow if not in the middle of area transition, dying, etc.
+ return _G(gameMode) == MODE_NORMAL;
}
void GotEngine::syncSoundSettings() {
- Engine::syncSoundSettings();
+ Engine::syncSoundSettings();
- bool allSoundIsMuted = ConfMan.getBool("mute");
+ bool allSoundIsMuted = ConfMan.getBool("mute");
- _mixer->muteSoundType(Audio::Mixer::kSFXSoundType,
- ConfMan.getBool("sfx_mute") || allSoundIsMuted);
- _mixer->muteSoundType(Audio::Mixer::kMusicSoundType,
- ConfMan.getBool("music_mute") || allSoundIsMuted);
+ _mixer->muteSoundType(Audio::Mixer::kSFXSoundType,
+ ConfMan.getBool("sfx_mute") || allSoundIsMuted);
+ _mixer->muteSoundType(Audio::Mixer::kMusicSoundType,
+ ConfMan.getBool("music_mute") || allSoundIsMuted);
}
void GotEngine::pauseEngineIntern(bool pause) {
- g_vars->clearKeyFlags();
- if (_G(gameMode) == MODE_LIGHTNING)
- _G(gameMode) = MODE_NORMAL;
-
- if (_G(tornado_used)) {
- _G(tornado_used) = false;
- actor_destroyed(&_G(actor)[2]);
- }
-
- if (_G(shield_on)) {
- _G(actor)[2].dead = 2;
- _G(actor)[2].used = 0;
- _G(shield_on) = false;
- }
-
- _G(lightning_used) = false;
- _G(thunder_flag) = 0;
- _G(hourglass_flag) = 0;
-
- Engine::pauseEngineIntern(pause);
+ g_vars->clearKeyFlags();
+ if (_G(gameMode) == MODE_LIGHTNING)
+ _G(gameMode) = MODE_NORMAL;
+
+ if (_G(tornado_used)) {
+ _G(tornado_used) = false;
+ actor_destroyed(&_G(actor[2]));
+ }
+
+ if (_G(shield_on)) {
+ _G(actor[2]).dead = 2;
+ _G(actor[2]).used = 0;
+ _G(shield_on) = false;
+ }
+
+ _G(lightning_used) = false;
+ _G(thunder_flag) = 0;
+ _G(hourglass_flag) = 0;
+
+ Engine::pauseEngineIntern(pause);
}
Common::String GotEngine::getHighScoresSaveName() const {
- return Common::String::format("%s-scores.dat", _targetName.c_str());
+ return Common::String::format("%s-scores.dat", _targetName.c_str());
}
} // End of namespace Got
diff --git a/engines/got/got.h b/engines/got/got.h
index 69db3332eed..b2023980360 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -22,19 +22,13 @@
#ifndef GOT_H
#define GOT_H
-#include "common/scummsys.h"
-#include "common/system.h"
#include "common/error.h"
-#include "common/fs.h"
-#include "common/hash-str.h"
#include "common/random.h"
+#include "common/scummsys.h"
#include "common/serializer.h"
+#include "common/system.h"
#include "common/util.h"
#include "engines/engine.h"
-#include "engines/savestate.h"
-#include "graphics/screen.h"
-
-#include "got/detection.h"
#include "got/events.h"
#include "got/vars.h"
@@ -44,67 +38,66 @@ struct GotGameDescription;
class GotEngine : public Engine, public Events {
private:
- const ADGameDescription *_gameDescription;
- Common::RandomSource _randomSource;
+ const ADGameDescription *_gameDescription;
+ Common::RandomSource _randomSource;
- void savegameLoaded();
+ void savegameLoaded();
protected:
- // Engine APIs
- Common::Error run() override;
+ // Engine APIs
+ Common::Error run() override;
- /**
+ /**
* Returns true if the game should quit
*/
- bool shouldQuit() const override {
- return Engine::shouldQuit();
- }
+ bool shouldQuit() const override {
+ return Engine::shouldQuit();
+ }
public:
- Vars _vars;
+ Vars _vars;
public:
- GotEngine(OSystem *syst, const ADGameDescription *gameDesc);
- ~GotEngine() override;
+ GotEngine(OSystem *syst, const ADGameDescription *gameDesc);
+ ~GotEngine() override;
- uint32 getFeatures() const;
- bool isDemo() const override;
+ uint32 getFeatures() const;
+ bool isDemo() const override;
- /**
+ /**
* Returns the game Id
*/
- Common::String getGameId() const;
+ Common::String getGameId() const;
- /**
+ /**
* Gets a random number
*/
- uint32 getRandomNumber(uint maxNum) {
- return _randomSource.getRandomNumber(maxNum);
- }
+ uint32 getRandomNumber(uint maxNum) {
+ return _randomSource.getRandomNumber(maxNum);
+ }
- bool hasFeature(EngineFeature f) const override {
- return
- (f == kSupportsLoadingDuringRuntime) ||
- (f == kSupportsSavingDuringRuntime) ||
- (f == kSupportsReturnToLauncher);
- };
+ bool hasFeature(EngineFeature f) const override {
+ return (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime) ||
+ (f == kSupportsReturnToLauncher);
+ };
- bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
- bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
+ bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
+ bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
- /**
+ /**
* Uses a serializer to allow implementing savegame
* loading and saving using a single method
*/
- Common::Error syncGame(Common::Serializer &s);
+ Common::Error syncGame(Common::Serializer &s);
- Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
- Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
+ Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
+ Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
- void syncSoundSettings() override;
- void pauseEngineIntern(bool pause) override;
+ void syncSoundSettings() override;
+ void pauseEngineIntern(bool pause) override;
- Common::String getHighScoresSaveName() const;
+ Common::String getHighScoresSaveName() const;
};
extern GotEngine *g_engine;
diff --git a/engines/got/messages.cpp b/engines/got/messages.cpp
index 53b0ed06c45..a1bccd889c5 100644
--- a/engines/got/messages.cpp
+++ b/engines/got/messages.cpp
@@ -24,20 +24,20 @@
namespace Got {
MouseMessage::MouseMessage(Common::EventType type,
- const Common::Point &pos) : Message(), _pos(pos) {
- switch (type) {
- case Common::EVENT_RBUTTONDOWN:
- case Common::EVENT_RBUTTONUP:
- _button = MB_RIGHT;
- break;
- case Common::EVENT_MBUTTONDOWN:
- case Common::EVENT_MBUTTONUP:
- _button = MB_MIDDLE;
- break;
- default:
- _button = MB_LEFT;
- break;
- }
+ const Common::Point &pos) : Message(), _pos(pos) {
+ switch (type) {
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONUP:
+ _button = MB_RIGHT;
+ break;
+ case Common::EVENT_MBUTTONDOWN:
+ case Common::EVENT_MBUTTONUP:
+ _button = MB_MIDDLE;
+ break;
+ default:
+ _button = MB_LEFT;
+ break;
+ }
}
} // namespace Got
diff --git a/engines/got/messages.h b/engines/got/messages.h
index bf8c3268b0a..20f107d295f 100644
--- a/engines/got/messages.h
+++ b/engines/got/messages.h
@@ -22,7 +22,6 @@
#ifndef GOT_MESSAGES_H
#define GOT_MESSAGES_H
-#include "common/array.h"
#include "common/events.h"
#include "common/str.h"
@@ -33,10 +32,10 @@ class UIElement;
struct Message {};
struct FocusMessage : public Message {
- UIElement *_priorView = nullptr;
- FocusMessage() : Message() {}
- FocusMessage(UIElement *priorView) : Message(),
- _priorView(priorView) {}
+ UIElement *_priorView = nullptr;
+ FocusMessage() : Message() {}
+ FocusMessage(UIElement *priorView) : Message(),
+ _priorView(priorView) {}
};
struct UnfocusMessage : public Message {};
@@ -44,66 +43,56 @@ struct MouseEnterMessage : public Message {};
struct MouseLeaveMessage : public Message {};
struct KeypressMessage : public Message, public Common::KeyState {
- KeypressMessage() : Message() {}
- KeypressMessage(const Common::KeyState &ks) :
- Message(), Common::KeyState(ks) {}
+ KeypressMessage() : Message() {}
+ KeypressMessage(const Common::KeyState &ks) : Message(), Common::KeyState(ks) {}
};
struct MouseMessage : public Message {
- enum Button { MB_LEFT, MB_RIGHT, MB_MIDDLE };
- Button _button;
- Common::Point _pos;
-
- MouseMessage() : Message(), _button(MB_LEFT) {}
- MouseMessage(Button btn, const Common::Point &pos) :
- Message(), _button(btn), _pos(pos) {}
- MouseMessage(Common::EventType type, const Common::Point &pos);
+ enum Button { MB_LEFT,
+ MB_RIGHT,
+ MB_MIDDLE };
+ Button _button;
+ Common::Point _pos;
+
+ MouseMessage() : Message(), _button(MB_LEFT) {}
+ MouseMessage(Button btn, const Common::Point &pos) : Message(), _button(btn), _pos(pos) {}
+ MouseMessage(Common::EventType type, const Common::Point &pos);
};
struct MouseDownMessage : public MouseMessage {
- MouseDownMessage() : MouseMessage() {}
- MouseDownMessage(Button btn, const Common::Point &pos) :
- MouseMessage(btn, pos) {}
- MouseDownMessage(Common::EventType type, const Common::Point &pos) :
- MouseMessage(type, pos) {}
+ MouseDownMessage() : MouseMessage() {}
+ MouseDownMessage(Button btn, const Common::Point &pos) : MouseMessage(btn, pos) {}
+ MouseDownMessage(Common::EventType type, const Common::Point &pos) : MouseMessage(type, pos) {}
};
struct MouseUpMessage : public MouseMessage {
- MouseUpMessage() : MouseMessage() {}
- MouseUpMessage(Button btn, const Common::Point &pos) :
- MouseMessage(btn, pos) {}
- MouseUpMessage(Common::EventType type, const Common::Point &pos) :
- MouseMessage(type, pos) {}
+ MouseUpMessage() : MouseMessage() {}
+ MouseUpMessage(Button btn, const Common::Point &pos) : MouseMessage(btn, pos) {}
+ MouseUpMessage(Common::EventType type, const Common::Point &pos) : MouseMessage(type, pos) {}
};
typedef MouseMessage MouseMoveMessage;
struct GameMessage : public Message {
- Common::String _name;
- int _value;
- Common::String _stringValue;
-
- GameMessage() : Message(), _value(-1) {}
- GameMessage(const Common::String &name) : Message(),
- _name(name), _value(-1) {}
- GameMessage(const Common::String &name, int value) : Message(),
- _name(name), _value(value) {}
- GameMessage(const Common::String &name, const Common::String &value) :
- Message(), _name(name), _stringValue(value), _value(0) {}
+ Common::String _name;
+ int _value;
+ Common::String _stringValue;
+
+ GameMessage() : Message(), _value(-1) {}
+ GameMessage(const Common::String &name) : Message(), _name(name), _value(-1) {}
+ GameMessage(const Common::String &name, int value) : Message(), _name(name), _value(value) {}
+ GameMessage(const Common::String &name, const Common::String &value) : Message(), _name(name), _stringValue(value), _value(0) {}
};
struct ValueMessage : public Message {
- int _value;
+ int _value;
- ValueMessage() : Message(), _value(0) {}
- ValueMessage(int value) : Message(),
- _value(value) {}
+ ValueMessage() : Message(), _value(0) {}
+ ValueMessage(int value) : Message(), _value(value) {}
};
struct ActionMessage : public Message {
- int _action;
- ActionMessage() : Message(), _action(0) {
- }
- ActionMessage(int action) : Message(),
- _action(action) {
- }
+ int _action;
+
+ ActionMessage() : Message(), _action(0) {}
+ ActionMessage(int action) : Message(), _action(action) {}
};
} // namespace Got
diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
index 9c4c38bb647..835b2fb3eb1 100644
--- a/engines/got/metaengine.cpp
+++ b/engines/got/metaengine.cpp
@@ -22,7 +22,6 @@
#include "common/translation.h"
#include "backends/keymapper/action.h"
#include "backends/keymapper/keymapper.h"
-#include "backends/keymapper/standard-actions.h"
#include "got/metaengine.h"
#include "got/detection.h"
#include "got/got.h"
diff --git a/engines/got/metaengine.h b/engines/got/metaengine.h
index b2f67f7a41e..ff901f3cda2 100644
--- a/engines/got/metaengine.h
+++ b/engines/got/metaengine.h
@@ -27,29 +27,36 @@
namespace Got {
enum KeybindingAction {
- KEYBIND_NONE, KEYBIND_UP, KEYBIND_DOWN, KEYBIND_LEFT, KEYBIND_RIGHT,
- KEYBIND_SELECT, KEYBIND_FIRE, KEYBIND_MAGIC, KEYBIND_ESCAPE,
- KEYBIND_THOR_DIES
+ KEYBIND_NONE,
+ KEYBIND_UP,
+ KEYBIND_DOWN,
+ KEYBIND_LEFT,
+ KEYBIND_RIGHT,
+ KEYBIND_SELECT,
+ KEYBIND_FIRE,
+ KEYBIND_MAGIC,
+ KEYBIND_ESCAPE,
+ KEYBIND_THOR_DIES
};
} // namespace Got
class GotMetaEngine : public AdvancedMetaEngine<ADGameDescription> {
public:
- const char *getName() const override;
+ const char *getName() const override;
- Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
+ Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
- /**
+ /**
* Determine whether the engine supports the specified MetaEngine feature.
*
* Used by e.g. the launcher to determine whether to enable the Load button.
*/
- bool hasFeature(MetaEngineFeature f) const override;
+ bool hasFeature(MetaEngineFeature f) const override;
- const ADExtraGuiOptionsMap *getAdvancedExtraGuiOptions() const override;
+ const ADExtraGuiOptionsMap *getAdvancedExtraGuiOptions() const override;
- Common::Array<Common::Keymap *> initKeymaps(const char *target) const override;
+ Common::Array<Common::Keymap *> initKeymaps(const char *target) const override;
};
#endif // GOT_METAENGINE_H
diff --git a/engines/got/sound.cpp b/engines/got/sound.cpp
index c83f8ebe8e2..a7179f37673 100644
--- a/engines/got/sound.cpp
+++ b/engines/got/sound.cpp
@@ -19,91 +19,91 @@
*
*/
-#include "common/memstream.h"
+#include "got/sound.h"
#include "audio/decoders/raw.h"
#include "audio/decoders/voc.h"
-#include "got/sound.h"
+#include "common/memstream.h"
#include "got/got.h"
#include "got/utils/file.h"
namespace Got {
-static const byte SOUND_PRIORITY[] = { 1,2,3,3,3,1,4,4,4,5,4,3,1,2,2,5,1,3,1 };
+static const byte SOUND_PRIORITY[] = {1, 2, 3, 3, 3, 1, 4, 4, 4, 5, 4, 3, 1, 2, 2, 5, 1, 3, 1};
void Sound::load() {
- File f("DIGSOUND");
+ File f("DIGSOUND");
- // Load index
- for (int i = 0; i < 16; ++i)
- _digiSounds[i].load(&f);
+ // Load index
+ for (int i = 0; i < 16; ++i)
+ _digiSounds[i].load(&f);
- // Allocate memory and load sound data
- _soundData = new byte[f.size() - 16 * 8];
- f.read(_soundData, f.size() - 16 * 8);
+ // Allocate memory and load sound data
+ _soundData = new byte[f.size() - 16 * 8];
+ f.read(_soundData, f.size() - 16 * 8);
}
void Sound::play_sound(int index, bool priority_override) {
- if (index >= NUM_SOUNDS)
- return;
-
- // If a sound is playing, stop it unless there is a priority override
- if (sound_playing()) {
- if (!priority_override && _currentPriority < SOUND_PRIORITY[index])
- return;
-
- g_engine->_mixer->stopHandle(_soundHandle);
- }
-
- // Play the new sound
- Common::MemoryReadStream *stream = new Common::MemoryReadStream(
- _soundData + _digiSounds[index].offset, _digiSounds[index].length);
- Audio::AudioStream *audioStream = Audio::makeVOCStream(stream, Audio::FLAG_UNSIGNED,
- DisposeAfterUse::YES);
- g_engine->_mixer->playStream(Audio::Mixer::kSFXSoundType,
- &_soundHandle, audioStream);
+ if (index >= NUM_SOUNDS)
+ return;
+
+ // If a sound is playing, stop it unless there is a priority override
+ if (sound_playing()) {
+ if (!priority_override && _currentPriority < SOUND_PRIORITY[index])
+ return;
+
+ g_engine->_mixer->stopHandle(_soundHandle);
+ }
+
+ // Play the new sound
+ Common::MemoryReadStream *stream = new Common::MemoryReadStream(
+ _soundData + _digiSounds[index].offset, _digiSounds[index].length);
+ Audio::AudioStream *audioStream = Audio::makeVOCStream(stream, Audio::FLAG_UNSIGNED,
+ DisposeAfterUse::YES);
+ g_engine->_mixer->playStream(Audio::Mixer::kSFXSoundType,
+ &_soundHandle, audioStream);
}
void Sound::play_sound(const Gfx::GraphicChunk &src) {
- if (sound_playing())
- g_engine->_mixer->stopHandle(_soundHandle);
-
- // Play the new sound
- Common::MemoryReadStream *stream = new Common::MemoryReadStream(
- src._data, src._uncompressedSize);
- Audio::AudioStream *audioStream = Audio::makeVOCStream(stream, Audio::FLAG_UNSIGNED,
- DisposeAfterUse::YES);
- g_engine->_mixer->playStream(Audio::Mixer::kSFXSoundType,
- &_soundHandle, audioStream);
+ if (sound_playing())
+ g_engine->_mixer->stopHandle(_soundHandle);
+
+ // Play the new sound
+ Common::MemoryReadStream *stream = new Common::MemoryReadStream(
+ src._data, src._uncompressedSize);
+ Audio::AudioStream *audioStream = Audio::makeVOCStream(stream, Audio::FLAG_UNSIGNED,
+ DisposeAfterUse::YES);
+ g_engine->_mixer->playStream(Audio::Mixer::kSFXSoundType,
+ &_soundHandle, audioStream);
}
bool Sound::sound_playing() const {
- return g_engine->_mixer->isSoundHandleActive(_soundHandle);
+ return g_engine->_mixer->isSoundHandleActive(_soundHandle);
}
void Sound::music_play(const char *name, bool override) {
- if (name != _currentMusic || override) {
- g_engine->_mixer->stopHandle(_musicHandle);
- _currentMusic = name;
+ if (name != _currentMusic || override) {
+ g_engine->_mixer->stopHandle(_musicHandle);
+ _currentMusic = name;
- File file(name);
+ File file(name);
#ifdef TODO
- // FIXME: Completely wrong. Don't know music format yet
- // Open it up for access
- Common::SeekableReadStream *f = file.readStream(file.size());
- Audio::AudioStream *audioStream = Audio::makeRawStream(
- f, 11025, 0, DisposeAfterUse::YES);
- g_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType,
- &_musicHandle, audioStream);
+ // FIXME: Completely wrong. Don't know music format yet
+ // Open it up for access
+ Common::SeekableReadStream *f = file.readStream(file.size());
+ Audio::AudioStream *audioStream = Audio::makeRawStream(
+ f, 11025, 0, DisposeAfterUse::YES);
+ g_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType,
+ &_musicHandle, audioStream);
#else
- warning("TODO: play_music %s", name);
-
- // The following is a dump of the music data in the hopes
- // it will help someone write a decoder for ScummVM based on it.
- // After an unknown header that doesn't seem to be used, the
- // music seems to be a set of pauses followed by what I think
- // are single byte combinations of frequency and duration that
- /*
+ warning("TODO: play_music %s", name);
+
+ // The following is a dump of the music data in the hopes
+ // it will help someone write a decoder for ScummVM based on it.
+ // After an unknown header that doesn't seem to be used, the
+ // music seems to be a set of pauses followed by what I think
+ // are single byte combinations of frequency and duration that
+ /*
Following is a dump of the "play note" method, in case it's useful:
MU_playNote proc far
@@ -143,172 +143,171 @@ void Sound::music_play(const char *name, bool override) {
MU_playNote endp
*/
- int hdrCount = file.readUint16LE();
- file.skip((hdrCount - 1) * 2);
+ int hdrCount = file.readUint16LE();
+ file.skip((hdrCount - 1) * 2);
- while (!file.eos()) {
- int pause = file.readByte();
- if (pause & 0x80)
- pause = ((pause & 0x7f) << 8) | file.readByte();
+ while (!file.eos()) {
+ int pause = file.readByte();
+ if (pause & 0x80)
+ pause = ((pause & 0x7f) << 8) | file.readByte();
- int freq = file.readByte();
- int duration = file.readByte();
- if (freq == 0 && duration == 0) {
- debug(1, "End of song");
- break;
- }
+ int freq = file.readByte();
+ int duration = file.readByte();
+ if (freq == 0 && duration == 0) {
+ debug(1, "End of song");
+ break;
+ }
- debug(1, "Pause %d, freq %d, duration %d", pause, freq, duration);
- }
+ debug(1, "Pause %d, freq %d, duration %d", pause, freq, duration);
+ }
#endif
- }
+ }
}
void Sound::music_pause() {
- g_engine->_mixer->pauseHandle(_musicHandle, true);
+ g_engine->_mixer->pauseHandle(_musicHandle, true);
}
void Sound::music_resume() {
- g_engine->_mixer->pauseHandle(_musicHandle, false);
+ g_engine->_mixer->pauseHandle(_musicHandle, false);
}
void Sound::music_stop() {
- music_pause();
- _currentMusic = nullptr;
+ music_pause();
+ _currentMusic = nullptr;
}
bool Sound::music_is_on() const {
- return g_engine->_mixer->isSoundHandleActive(_musicHandle);
+ return g_engine->_mixer->isSoundHandleActive(_musicHandle);
}
const char *Sound::getMusicName(int num) const {
- const char *name = nullptr;
-
- switch (_G(area)) {
- case 1:
- switch (num) {
- case 0:
- name = "SONG1";
- break;
- case 1:
- name = "SONG2";
- break;
- case 2:
- name = "SONG3";
- break;
- case 3:
- name = "SONG4";
- break;
- case 4:
- name = "WINSONG";
- break;
- case 5:
- name = "BOSSSONG";
- break;
- default:
- break;
- }
- break;
-
- case 2:
- switch (num) {
- case 0:
- name = "SONG21";
- break;
- case 1:
- name = "SONG22";
- break;
- case 2:
- name = "SONG23";
- break;
- case 3:
- name = "SONG24";
- break;
- case 4:
- name = "SONG35";
- break;
- case 5:
- name = "SONG25";
- break;
- case 6:
- name = "WINSONG";
- break;
- case 7:
- name = "BOSSSONG";
- break;
- default:
- break;
- }
- break;
-
- case 3:
- switch (num) {
- case 0:
- name = "SONG31";
- break;
- case 1:
- name = "SONG32";
- break;
- case 2:
- name = "SONG33";
- break;
- case 3:
- name = "SONG34";
- break;
- case 4:
- name = "SONG35";
- break;
- case 5:
- name = "SONG36";
- break;
- case 6:
- name = "WINSONG";
- break;
- case 7:
- name = "BOSSSONG";
- break;
- default:
- break;
- }
- break;
-
- default:
- break;
- }
-
- if (!name)
- error("Invalid music");
-
- return name;
+ const char *name = nullptr;
+
+ switch (_G(area)) {
+ case 1:
+ switch (num) {
+ case 0:
+ name = "SONG1";
+ break;
+ case 1:
+ name = "SONG2";
+ break;
+ case 2:
+ name = "SONG3";
+ break;
+ case 3:
+ name = "SONG4";
+ break;
+ case 4:
+ name = "WINSONG";
+ break;
+ case 5:
+ name = "BOSSSONG";
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case 2:
+ switch (num) {
+ case 0:
+ name = "SONG21";
+ break;
+ case 1:
+ name = "SONG22";
+ break;
+ case 2:
+ name = "SONG23";
+ break;
+ case 3:
+ name = "SONG24";
+ break;
+ case 4:
+ name = "SONG35";
+ break;
+ case 5:
+ name = "SONG25";
+ break;
+ case 6:
+ name = "WINSONG";
+ break;
+ case 7:
+ name = "BOSSSONG";
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case 3:
+ switch (num) {
+ case 0:
+ name = "SONG31";
+ break;
+ case 1:
+ name = "SONG32";
+ break;
+ case 2:
+ name = "SONG33";
+ break;
+ case 3:
+ name = "SONG34";
+ break;
+ case 4:
+ name = "SONG35";
+ break;
+ case 5:
+ name = "SONG36";
+ break;
+ case 6:
+ name = "WINSONG";
+ break;
+ case 7:
+ name = "BOSSSONG";
+ break;
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (!name)
+ error("Invalid music");
+
+ return name;
}
void play_sound(int index, bool priority_override) {
- _G(sound).play_sound(index, priority_override);
+ _G(sound).play_sound(index, priority_override);
}
void play_sound(const Gfx::GraphicChunk &src) {
- _G(sound).play_sound(src);
+ _G(sound).play_sound(src);
}
-
bool sound_playing() {
- return _G(sound).sound_playing();
+ return _G(sound).sound_playing();
}
void music_play(int num, bool override) {
- _G(sound).music_play(num, override);
+ _G(sound).music_play(num, override);
}
void music_play(const char *name, bool override) {
- _G(sound).music_play(name, override);
+ _G(sound).music_play(name, override);
}
void music_pause() {
- _G(sound).music_pause();
+ _G(sound).music_pause();
}
void music_resume() {
- _G(sound).music_resume();
+ _G(sound).music_resume();
}
} // namespace Got
diff --git a/engines/got/sound.h b/engines/got/sound.h
index 80cd9e8a01a..2acee0f3565 100644
--- a/engines/got/sound.h
+++ b/engines/got/sound.h
@@ -29,59 +29,59 @@
namespace Got {
enum {
- OW,
- GULP,
- SWISH,
- YAH,
- ELECTRIC,
- THUNDER,
- DOOR,
- FALL,
- ANGEL,
- WOOP,
- DEAD,
- BRAAPP,
- WIND,
- PUNCH1,
- CLANG,
- EXPLODE,
- BOSS11,
- BOSS12,
- BOSS13,
+ OW,
+ GULP,
+ SWISH,
+ YAH,
+ ELECTRIC,
+ THUNDER,
+ DOOR,
+ FALL,
+ ANGEL,
+ WOOP,
+ DEAD,
+ BRAAPP,
+ WIND,
+ PUNCH1,
+ CLANG,
+ EXPLODE,
+ BOSS11,
+ BOSS12,
+ BOSS13,
};
-#define NUM_SOUNDS 19
+#define NUM_SOUNDS 19
class Sound {
private:
- byte *_soundData = nullptr;
- HEADER _digiSounds[NUM_SOUNDS];
- Audio::SoundHandle _soundHandle;
- int _currentPriority = 0;
+ byte *_soundData = nullptr;
+ HEADER _digiSounds[NUM_SOUNDS];
+ Audio::SoundHandle _soundHandle;
+ int _currentPriority = 0;
- const char *_currentMusic = nullptr;
- Audio::SoundHandle _musicHandle;
+ const char *_currentMusic = nullptr;
+ Audio::SoundHandle _musicHandle;
- const char *getMusicName(int num) const;
+ const char *getMusicName(int num) const;
public:
- ~Sound() {
- delete[] _soundData;
- }
- void load();
+ ~Sound() {
+ delete[] _soundData;
+ }
+ void load();
- void play_sound(int index, bool priority_override);
- void play_sound(const Gfx::GraphicChunk &src);
- bool sound_playing() const;
+ void play_sound(int index, bool priority_override);
+ void play_sound(const Gfx::GraphicChunk &src);
+ bool sound_playing() const;
- void music_play(int num, bool override) {
- music_play(getMusicName(num), override);
- }
- void music_play(const char *name, bool override);
- void music_pause();
- void music_resume();
- void music_stop();
- bool music_is_on() const;
+ void music_play(int num, bool override) {
+ music_play(getMusicName(num), override);
+ }
+ void music_play(const char *name, bool override);
+ void music_pause();
+ void music_resume();
+ void music_stop();
+ bool music_is_on() const;
};
extern void play_sound(int index, bool priority_override);
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index a8858454a79..8e6a2b6b802 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -19,107 +19,106 @@
*
*/
+#include "got/vars.h"
#include "common/algorithm.h"
#include "common/config-manager.h"
-#include "got/vars.h"
#include "got/gfx/palette.h"
-#include "got/utils/file.h"
#include "got/got.h"
+#include "got/utils/file.h"
namespace Got {
Vars *g_vars;
-Vars::Vars() :
- _hampic("HAMPIC", 262, false),
- _odin("ODINPIC", 262, false),
- _objects("OBJECTS", 262, false),
- _status("STATUS", -1, false) {
- g_vars = this;
+Vars::Vars() : _hampic("HAMPIC", 262, false),
+ _odin("ODINPIC", 262, false),
+ _objects("OBJECTS", 262, false),
+ _status("STATUS", -1, false) {
+ g_vars = this;
}
void Vars::load() {
- _bgPics.load();
- _font.load();
- _gfx.load();
- _hampic.load();
- _objects.load();
- _odin.load();
- _sd_data.load();
- _sound.load();
- _status.load();
- _highScores.load();
-
- _music_flag = !ConfMan.getBool("music_mute");
- _sound_flag = _pcsound_flag = !ConfMan.getBool("sfx_mute");
-
- if (g_engine->isDemo()) {
- _demo = _cheat = true;
- _rdemo = ConfMan.getBool("rdemo");
- }
-
- if (_current_level != 23)
- _story_flag = false;
-
- _setup.music = _music_flag;
- _setup.dig_sound = _sound_flag;
- _setup.pc_sound = _pcsound_flag;
- if (_sound_flag)
- _setup.pc_sound = false;
- _setup.scroll_flag = true;
- _setup.speed = _slow_mode ? 1 : 0;
- _setup.skill = 1;
-
- _tmp_buff = new byte[TMP_SIZE];
-
- res_read("RANDOM", _rnd_array);
-
- Gfx::load_palette();
+ _bgPics.load();
+ _font.load();
+ _gfx.load();
+ _hampic.load();
+ _objects.load();
+ _odin.load();
+ _sd_data.load();
+ _sound.load();
+ _status.load();
+ _highScores.load();
+
+ _music_flag = !ConfMan.getBool("music_mute");
+ _sound_flag = _pcsound_flag = !ConfMan.getBool("sfx_mute");
+
+ if (g_engine->isDemo()) {
+ _demo = _cheat = true;
+ _rdemo = ConfMan.getBool("rdemo");
+ }
+
+ if (_current_level != 23)
+ _story_flag = false;
+
+ _setup.music = _music_flag;
+ _setup.dig_sound = _sound_flag;
+ _setup.pc_sound = _pcsound_flag;
+ if (_sound_flag)
+ _setup.pc_sound = false;
+ _setup.scroll_flag = true;
+ _setup.speed = _slow_mode ? 1 : 0;
+ _setup.skill = 1;
+
+ _tmp_buff = new byte[TMP_SIZE];
+
+ res_read("RANDOM", _rnd_array);
+
+ Gfx::load_palette();
}
Vars::~Vars() {
- g_vars = nullptr;
+ g_vars = nullptr;
- delete[] _tmp_buff;
+ delete[] _tmp_buff;
}
void Vars::setArea(int areaNum) {
- if (areaNum != _area) {
- _area = areaNum;
- _setup.area = areaNum;
- _sd_data.setArea(areaNum);
- _bgPics.setArea(areaNum);
-
- switch (areaNum) {
- case 1:
- _current_level = 23;
- break;
-
- case 2:
- _current_level = 51;
- break;
-
- case 3:
- _current_level = 33;
- break;
-
- default:
- break;
- }
- }
+ if (areaNum != _area) {
+ _area = areaNum;
+ _setup.area = areaNum;
+ _sd_data.setArea(areaNum);
+ _bgPics.setArea(areaNum);
+
+ switch (areaNum) {
+ case 1:
+ _current_level = 23;
+ break;
+
+ case 2:
+ _current_level = 51;
+ break;
+
+ case 3:
+ _current_level = 33;
+ break;
+
+ default:
+ break;
+ }
+ }
}
void Vars::clearKeyFlags() {
- Common::fill(_key_flag, _key_flag + 100, 0);
+ Common::fill(_key_flag, _key_flag + 100, 0);
}
void Vars::resetEndgameFlags() {
- _gameMode = MODE_NORMAL;
- _auto_load = false;
- _end_tile = false;
- _boss_dead = false;
- _game_over = false;
- _boss_intro1 = _boss_intro2 = false;
+ _gameMode = MODE_NORMAL;
+ _auto_load = false;
+ _end_tile = false;
+ _boss_dead = false;
+ _game_over = false;
+ _boss_intro1 = _boss_intro2 = false;
}
} // namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 3c9fc4aef6b..31b616b663f 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -24,19 +24,19 @@
#include "common/events.h"
#include "common/queue.h"
-#include "graphics/screen.h"
#include "got/data/defines.h"
#include "got/data/high_scores.h"
+#include "got/data/level.h"
#include "got/data/sd_data.h"
+#include "got/data/setup.h"
+#include "got/data/thor_info.h"
#include "got/game/script.h"
#include "got/gfx/font.h"
#include "got/gfx/gfx_chunks.h"
#include "got/gfx/gfx_pics.h"
#include "got/metaengine.h"
#include "got/sound.h"
-#include "got/data/level.h"
-#include "got/data/setup.h"
-#include "got/data/thor_info.h"
+#include "graphics/screen.h"
namespace Got {
@@ -50,157 +50,166 @@ class Vars;
extern Vars *g_vars;
enum Key {
- key_none = KEYBIND_NONE,
- key_up = KEYBIND_UP,
- key_down = KEYBIND_DOWN,
- key_left = KEYBIND_LEFT,
- key_right = KEYBIND_RIGHT,
- key_fire = KEYBIND_FIRE,
- key_magic = KEYBIND_MAGIC,
- key_select = KEYBIND_SELECT
+ key_none = KEYBIND_NONE,
+ key_up = KEYBIND_UP,
+ key_down = KEYBIND_DOWN,
+ key_left = KEYBIND_LEFT,
+ key_right = KEYBIND_RIGHT,
+ key_fire = KEYBIND_FIRE,
+ key_magic = KEYBIND_MAGIC,
+ key_select = KEYBIND_SELECT
};
enum GameMode {
- MODE_NORMAL, MODE_AREA_CHANGE, MODE_THUNDER,
- MODE_THOR_DIES, MODE_ADD_SCORE, MODE_LIGHTNING,
- MODE_PAUSE, MODE_SCORE_INV
+ MODE_NORMAL,
+ MODE_AREA_CHANGE,
+ MODE_THUNDER,
+ MODE_THOR_DIES,
+ MODE_ADD_SCORE,
+ MODE_LIGHTNING,
+ MODE_PAUSE,
+ MODE_SCORE_INV
};
enum TransitionDir {
- DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN, DIR_PHASED
+ DIR_LEFT,
+ DIR_RIGHT,
+ DIR_UP,
+ DIR_DOWN,
+ DIR_PHASED
};
struct Cheats {
- bool freezeHealth = false;
- bool freezeMagic = false;
- bool freezeJewels = false;
+ bool freezeHealth = false;
+ bool freezeMagic = false;
+ bool freezeJewels = false;
};
class Vars {
public:
- Vars();
- ~Vars();
-
- void load();
- void setArea(int areaNum);
- void clearKeyFlags();
- void resetEndgameFlags();
-
- Common::String _playerName = "ScummVM";
- Gfx::GfxChunks _gfx;
- Gfx::BgPics _bgPics;
- Gfx::Font _font;
- Gfx::Pics _hampic;
- Gfx::Pics _objects;
- Gfx::Pics _odin;
- Gfx::Pics _status;
- HighScores _highScores;
- SdData _sd_data;
- Sound _sound;
- Scripts _scripts;
- GameMode _gameMode = MODE_NORMAL;
- TransitionDir _transitionDir = DIR_LEFT;
- Cheats _cheats;
- Common::Queue<byte> _demoKeys;
- bool _useItemFlag = false;
- bool _slip_flag = false;
- bool _slipping = false;
- int _slip_cnt = 0;
- bool _boss_intro1 = false, _boss_intro2 = false;
-
- int8 _pge = 0;
- int _exit_flag = 0;
-
- byte _key_flag[100] = {};
- int8 _diag = 0;
- bool _diag_flag = false;
- bool _slow_mode = false, _startup = true;
- bool _shot_ok = false;
- int _thor_x1 = 0, _thor_y1 = 0, _thor_x2 = 0, _thor_y2 = 0, _thor_real_y1 = 0;
- int _thor_pos = 0;
- int _max_shot = 0;
-
- uint _timer_cnt = 0, _vbl_cnt = 0, _magic_cnt = 0, _extra_cnt = 0;
-
- int _ox = 0, _oy = 0, _of = 0;
- byte _object_map[TILES_COUNT] = {};
- byte _object_index[TILES_COUNT] = {};
- int8 _thor_icon1 = 0, _thor_icon2 = 0, _thor_icon3 = 0, _thor_icon4 = 0;
- int8 _level_type = 0;
- int8 _music_current = -1;
- int8 _boss_loaded = 0;
- int8 _apple_drop = 0;
- bool _cheat = false;
- int8 _area = 1;
-
- LEVEL _scrn;
-
- SETUP _setup;
- SETUP _last_setup;
- byte *_tmp_buff = nullptr;
-
- ACTOR _actor[MAX_ACTORS] = {}; //current actors
- ACTOR _enemy[MAX_ENEMIES] = {}; //current enemies
- ACTOR _shot[MAX_ENEMIES] = {}; //current shots
- int8 _enemy_type[MAX_ENEMIES] = {};
- int _etype[MAX_ENEMIES] = {};
-
- ACTOR _magic_item[2] = {};
- byte _magic_pic[2][1024] = {};
- bool _warp_scroll = false;
-
- ACTOR *_thor = nullptr;
- ACTOR *_hammer = nullptr;
- ACTOR _explosion;
- ACTOR _sparkle;
- THOR_INFO _thor_info;
- bool _boss_dead = false;
- byte _endgame = 0;
-
- bool _warp_flag = false;
-
- int8 *_std_sound_start = nullptr;
- int8 *_pcstd_sound_start = nullptr;
- int8 *_std_sound = nullptr;
- int8 *_pcstd_sounds = nullptr;
- byte *_boss_sound[3] = {};
- byte *_boss_pcsound[3] = {};
- long _pcsound_length[NUM_SOUNDS] = {};
- int _rand1 = 0, _rand2 = 0;
+ Vars();
+ ~Vars();
+
+ void load();
+ void setArea(int areaNum);
+ void clearKeyFlags();
+ void resetEndgameFlags();
+
+ Common::String _playerName = "ScummVM";
+ Gfx::GfxChunks _gfx;
+ Gfx::BgPics _bgPics;
+ Gfx::Font _font;
+ Gfx::Pics _hampic;
+ Gfx::Pics _objects;
+ Gfx::Pics _odin;
+ Gfx::Pics _status;
+ HighScores _highScores;
+ SdData _sd_data;
+ Sound _sound;
+ Scripts _scripts;
+ GameMode _gameMode = MODE_NORMAL;
+ TransitionDir _transitionDir = DIR_LEFT;
+ Cheats _cheats;
+ Common::Queue<byte> _demoKeys;
+ bool _useItemFlag = false;
+ bool _slip_flag = false;
+ bool _slipping = false;
+ int _slip_cnt = 0;
+ bool _boss_intro1 = false, _boss_intro2 = false;
+
+ int8 _pge = 0;
+ int _exit_flag = 0;
+
+ byte _key_flag[100] = {};
+ int8 _diag = 0;
+ bool _diag_flag = false;
+ bool _slow_mode = false, _startup = true;
+ bool _shot_ok = false;
+ int _thor_x1 = 0, _thor_y1 = 0, _thor_x2 = 0, _thor_y2 = 0, _thor_real_y1 = 0;
+ int _thor_pos = 0;
+ int _max_shot = 0;
+
+ uint _timer_cnt = 0, _vbl_cnt = 0, _magic_cnt = 0, _extra_cnt = 0;
+
+ int _ox = 0, _oy = 0, _of = 0;
+ byte _object_map[TILES_COUNT] = {};
+ byte _object_index[TILES_COUNT] = {};
+ int8 _thor_icon1 = 0, _thor_icon2 = 0, _thor_icon3 = 0, _thor_icon4 = 0;
+ int8 _level_type = 0;
+ int8 _music_current = -1;
+ int8 _boss_loaded = 0;
+ int8 _apple_drop = 0;
+ bool _cheat = false;
+ int8 _area = 1;
+
+ LEVEL _scrn;
+
+ SETUP _setup;
+ SETUP _last_setup;
+ byte *_tmp_buff = nullptr;
+
+ ACTOR _actor[MAX_ACTORS] = {}; //current actors
+ ACTOR _enemy[MAX_ENEMIES] = {}; //current enemies
+ ACTOR _shot[MAX_ENEMIES] = {}; //current shots
+ int8 _enemy_type[MAX_ENEMIES] = {};
+ int _etype[MAX_ENEMIES] = {};
+
+ ACTOR _magic_item[2] = {};
+ byte _magic_pic[2][1024] = {};
+ bool _warp_scroll = false;
+
+ ACTOR *_thor = nullptr;
+ ACTOR *_hammer = nullptr;
+ ACTOR _explosion;
+ ACTOR _sparkle;
+ THOR_INFO _thor_info;
+ bool _boss_dead = false;
+ byte _endgame = 0;
+
+ bool _warp_flag = false;
+
+ int8 *_std_sound_start = nullptr;
+ int8 *_pcstd_sound_start = nullptr;
+ int8 *_std_sound = nullptr;
+ int8 *_pcstd_sounds = nullptr;
+ byte *_boss_sound[3] = {};
+ byte *_boss_pcsound[3] = {};
+ long _pcsound_length[NUM_SOUNDS] = {};
+ int _rand1 = 0, _rand2 = 0;
int _hourglass_flag = 0, _thunder_flag = 0;
bool _lightning_used = false, _tornado_used = false;
bool _shield_on = false;
bool _apple_flag = false;
bool _bomb_flag = false;
- int _switch_flag = 0;
+ int _switch_flag = 0;
- byte _res_file[16] = {};
- bool _music_flag = false, _sound_flag = false, _pcsound_flag = false;
+ byte _res_file[16] = {};
+ bool _music_flag = false, _sound_flag = false, _pcsound_flag = false;
bool _cash1_inform = false;
bool _cash2_inform = false;
bool _door_inform = false;
bool _magic_inform = false;
bool _carry_inform = false;
- bool _killgg_inform = false;
-
- byte *_pc_sound[NUM_SOUNDS] = {};
- byte *_dig_sound[NUM_SOUNDS] = {};
- bool _boss_active = false;
- bool _story_flag = true;
- int8 *_scr = nullptr;
- bool _demo = false;
- int _rnd_index = 0;
- int _rnd_array[100] = {};
- bool _rdemo = false;
- int8 _test_sdf[80] = {};
- bool _game_over = false;
- char _tempstr[80] = {};
- bool _auto_load = false;
- bool _end_tile = false;
- byte _pbuff[PALETTE_SIZE] = {};
- int _current_level = 23;
- int _new_level = 0;
- int _new_level_tile = 0, _current_area = 0;
+ bool _killgg_inform = false;
+
+ byte *_pc_sound[NUM_SOUNDS] = {};
+ byte *_dig_sound[NUM_SOUNDS] = {};
+ bool _boss_active = false;
+ bool _story_flag = true;
+ int8 *_scr = nullptr;
+ bool _demo = false;
+ int _rnd_index = 0;
+ int _rnd_array[100] = {};
+ bool _rdemo = false;
+ int8 _test_sdf[80] = {};
+ bool _game_over = false;
+ char _tempstr[80] = {};
+ bool _auto_load = false;
+ bool _end_tile = false;
+ byte _pbuff[PALETTE_SIZE] = {};
+ int _current_level = 23;
+ int _new_level = 0;
+ int _new_level_tile = 0, _current_area = 0;
char _sd_header[128] = {};
char _play_speed = 0;
bool _thor_special_flag = false;
More information about the Scummvm-git-logs
mailing list