mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-12 22:51:11 +00:00
AGS: Beginnings of new Globals class
This commit is contained in:
parent
3d84af6aeb
commit
cf9bbb2bb2
@ -37,6 +37,7 @@
|
||||
#include "ags/lib/std/set.h"
|
||||
#include "ags/shared/ac/common.h"
|
||||
#include "ags/engine/ac/game.h"
|
||||
#include "ags/engine/globals.h"
|
||||
#include "ags/engine/ac/gamesetup.h"
|
||||
#include "ags/engine/ac/gamestate.h"
|
||||
#include "ags/shared/core/def_version.h"
|
||||
@ -328,13 +329,15 @@ AGSEngine *g_vm;
|
||||
|
||||
AGSEngine::AGSEngine(OSystem *syst, const AGSGameDescription *gameDesc) : Engine(syst),
|
||||
_gameDescription(gameDesc), _randomSource("AGS"), _events(nullptr), _music(nullptr),
|
||||
_rawScreen(nullptr), _screen(nullptr), _gfxDriver(nullptr) {
|
||||
_rawScreen(nullptr), _screen(nullptr), _gfxDriver(nullptr),
|
||||
_globals(nullptr) {
|
||||
g_vm = this;
|
||||
DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
|
||||
DebugMan.addDebugChannel(kDebugGraphics, "Graphics", "Graphics debug level");
|
||||
|
||||
_events = new EventsManager();
|
||||
_music = new Music(_mixer);
|
||||
_globals = new ::AGS3::Globals();
|
||||
}
|
||||
|
||||
AGSEngine::~AGSEngine() {
|
||||
@ -342,6 +345,7 @@ AGSEngine::~AGSEngine() {
|
||||
delete _rawScreen;
|
||||
delete _events;
|
||||
delete _music;
|
||||
delete _globals;
|
||||
}
|
||||
|
||||
uint32 AGSEngine::getFeatures() const {
|
||||
|
@ -37,6 +37,10 @@
|
||||
#include "ags/lib/allegro/system.h"
|
||||
#include "ags/engine/util/mutex_std.h"
|
||||
|
||||
namespace AGS3 {
|
||||
class Globals;
|
||||
}
|
||||
|
||||
namespace AGS {
|
||||
|
||||
#define SCREEN_WIDTH 320
|
||||
@ -64,6 +68,7 @@ public:
|
||||
::AGS3::AGS::Engine::Mutex _sMutex;
|
||||
::AGS3::AGS::Engine::Mutex _soundCacheMutex;
|
||||
::AGS3::AGS::Engine::Mutex _mp3Mutex;
|
||||
::AGS3::Globals *_globals;
|
||||
protected:
|
||||
// Engine APIs
|
||||
virtual Common::Error run();
|
||||
|
@ -158,7 +158,6 @@ RoomStruct thisroom;
|
||||
|
||||
volatile int switching_away_from_game = 0;
|
||||
volatile bool switched_away = false;
|
||||
volatile char want_exit = 0, abort_engine = 0;
|
||||
GameDataVersion loaded_game_file_version = kGameVersion_Undefined;
|
||||
int frames_per_second = 40;
|
||||
int displayed_room = -10, starting_room = -1;
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "ags/shared/script/cc_error.h"
|
||||
#include "ags/shared/util/string_utils.h"
|
||||
#include "ags/shared/util/textstreamwriter.h"
|
||||
#include "ags/engine/globals.h"
|
||||
#include "ags/events.h"
|
||||
|
||||
#if AGS_PLATFORM_OS_WINDOWS
|
||||
@ -59,7 +60,6 @@ extern char check_dynamic_sprites_at_exit;
|
||||
extern int displayed_room;
|
||||
extern RoomStruct thisroom;
|
||||
extern char pexbuf[STD_BUFFER_SIZE];
|
||||
extern volatile char want_exit, abort_engine;
|
||||
extern GameSetupStruct game;
|
||||
|
||||
|
||||
@ -471,8 +471,8 @@ int check_for_messages_from_editor() {
|
||||
game_paused_in_debugger = 0;
|
||||
break_on_next_script_step = 1;
|
||||
} else if (strncmp(msgPtr, "EXIT", 4) == 0) {
|
||||
want_exit = 1;
|
||||
abort_engine = 1;
|
||||
_G(want_exit) = 1;
|
||||
_G(abort_engine) = 1;
|
||||
check_dynamic_sprites_at_exit = 0;
|
||||
}
|
||||
|
||||
@ -488,7 +488,7 @@ int check_for_messages_from_editor() {
|
||||
|
||||
bool send_exception_to_editor(const char *qmsg) {
|
||||
#if AGS_PLATFORM_OS_WINDOWS
|
||||
want_exit = 0;
|
||||
_G(want_exit) = 0;
|
||||
// allow the editor to break with the error message
|
||||
if (editor_window_handle != NULL)
|
||||
SetForegroundWindow(editor_window_handle);
|
||||
@ -496,7 +496,7 @@ bool send_exception_to_editor(const char *qmsg) {
|
||||
if (!send_message_to_editor("ERROR", qmsg))
|
||||
return false;
|
||||
|
||||
while ((check_for_messages_from_editor() == 0) && (want_exit == 0)) {
|
||||
while ((check_for_messages_from_editor() == 0) && (_G(want_exit) == 0)) {
|
||||
update_polled_mp3();
|
||||
platform->Delay(10);
|
||||
}
|
||||
|
37
engines/ags/engine/globals.cpp
Normal file
37
engines/ags/engine/globals.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/* 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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ags/engine/globals.h"
|
||||
|
||||
namespace AGS3 {
|
||||
|
||||
Globals *g_globals;
|
||||
|
||||
Globals::Globals() : _want_exit(false), _abort_engine(false) {
|
||||
g_globals = this;
|
||||
}
|
||||
|
||||
Globals::~Globals() {
|
||||
g_globals = nullptr;
|
||||
}
|
||||
|
||||
} // namespace AGS3
|
44
engines/ags/engine/globals.h
Normal file
44
engines/ags/engine/globals.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* 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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AGS_ENGINE_GLOBALS_H
|
||||
#define AGS_ENGINE_GLOBALS_H
|
||||
|
||||
namespace AGS3 {
|
||||
|
||||
class Globals {
|
||||
public:
|
||||
bool _want_exit;
|
||||
bool _abort_engine;
|
||||
|
||||
public:
|
||||
Globals();
|
||||
~Globals();
|
||||
};
|
||||
|
||||
extern Globals *g_globals;
|
||||
|
||||
#define _G(FIELD) (::AGS3::g_globals->_##FIELD)
|
||||
|
||||
} // namespace AGS3
|
||||
|
||||
#endif
|
@ -89,7 +89,6 @@ using namespace AGS::Engine;
|
||||
|
||||
extern char check_dynamic_sprites_at_exit;
|
||||
extern int our_eip;
|
||||
extern volatile char want_exit, abort_engine;
|
||||
extern bool justRunSetup;
|
||||
extern GameSetup usetup;
|
||||
extern GameSetupStruct game;
|
||||
|
@ -66,6 +66,7 @@
|
||||
#include "ags/engine/ac/timer.h"
|
||||
#include "ags/engine/ac/keycode.h"
|
||||
#include "ags/lib/allegro/keyboard.h"
|
||||
#include "ags/engine/globals.h"
|
||||
#include "ags/events.h"
|
||||
|
||||
namespace AGS3 {
|
||||
@ -77,7 +78,6 @@ extern int numAnimButs;
|
||||
extern int mouse_on_iface; // mouse cursor is over this interface
|
||||
extern int ifacepopped;
|
||||
extern int is_text_overlay;
|
||||
extern volatile char want_exit, abort_engine;
|
||||
extern int proper_exit, our_eip;
|
||||
extern int displayed_room, starting_room, in_new_room, new_room_was;
|
||||
extern GameSetupStruct game;
|
||||
@ -124,7 +124,7 @@ unsigned int loopcounter = 0;
|
||||
static unsigned int lastcounter = 0;
|
||||
|
||||
static void ProperExit() {
|
||||
want_exit = 0;
|
||||
_G(want_exit) = 0;
|
||||
proper_exit = 1;
|
||||
quit("||exit!");
|
||||
}
|
||||
@ -737,7 +737,7 @@ void UpdateGameOnce(bool checkControls, IDriverDependantBitmap *extraBitmap, int
|
||||
|
||||
numEventsAtStartOfFunction = numevents;
|
||||
|
||||
if (want_exit) {
|
||||
if (_G(want_exit)) {
|
||||
ProperExit();
|
||||
}
|
||||
|
||||
@ -944,7 +944,7 @@ static void GameLoopUntilEvent(int untilwhat, const void *daaa) {
|
||||
auto cached_user_disabled_for = user_disabled_for;
|
||||
|
||||
SetupLoopParameters(untilwhat, daaa);
|
||||
while (GameTick() == 0 && !abort_engine) {
|
||||
while (GameTick() == 0 && !_G(abort_engine)) {
|
||||
}
|
||||
|
||||
our_eip = 78;
|
||||
@ -992,7 +992,7 @@ void RunGameUntilAborted() {
|
||||
// skip ticks to account for time spent starting game.
|
||||
skipMissedTicks();
|
||||
|
||||
while (!abort_engine) {
|
||||
while (!_G(abort_engine)) {
|
||||
GameTick();
|
||||
|
||||
if (load_new_game) {
|
||||
@ -1003,8 +1003,8 @@ void RunGameUntilAborted() {
|
||||
}
|
||||
|
||||
void update_polled_stuff_if_runtime() {
|
||||
if (want_exit) {
|
||||
want_exit = 0;
|
||||
if (_G(want_exit)) {
|
||||
_G(want_exit) = 0;
|
||||
quit("||exit!");
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,6 @@ using namespace AGS::Shared;
|
||||
using namespace AGS::Engine;
|
||||
|
||||
extern int our_eip, displayed_room;
|
||||
extern volatile char want_exit, abort_engine;
|
||||
extern GameSetupStruct game;
|
||||
extern GameState play;
|
||||
extern const char *loadSaveGameOnStartup;
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "ags/shared/core/assetmanager.h"
|
||||
#include "ags/engine/plugin/plugin_engine.h"
|
||||
#include "ags/engine/media/audio/audio_system.h"
|
||||
#include "ags/engine/globals.h"
|
||||
#include "ags/ags.h"
|
||||
|
||||
namespace AGS3 {
|
||||
@ -67,7 +68,6 @@ extern IAGSEditorDebugger *editor_debugger;
|
||||
extern int need_to_stop_cd;
|
||||
extern int use_cdplayer;
|
||||
extern IGraphicsDriver *gfxDriver;
|
||||
extern volatile char abort_engine;
|
||||
|
||||
bool handledErrorInEditor;
|
||||
|
||||
@ -233,7 +233,7 @@ char quit_message[256] = "\0";
|
||||
// "!|" is a special code used to mean that the player has aborted (Alt+X)
|
||||
void quit(const char *quitmsg) {
|
||||
strncpy(quit_message, quitmsg, 256);
|
||||
abort_engine = true;
|
||||
_G(abort_engine) = true;
|
||||
}
|
||||
|
||||
void quit_free() {
|
||||
|
@ -844,8 +844,6 @@ void update_volume_drop_if_voiceover() {
|
||||
apply_volume_drop_modifier(play.speech_has_voice);
|
||||
}
|
||||
|
||||
extern volatile char want_exit;
|
||||
|
||||
void update_mp3_thread() {
|
||||
if (switching_away_from_game) {
|
||||
return;
|
||||
|
@ -20,8 +20,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//include <cstdio>
|
||||
//include <string.h>
|
||||
#include "ags/shared/ac/common.h"
|
||||
#include "ags/engine/ac/dynobj/cc_dynamicarray.h"
|
||||
#include "ags/engine/ac/dynobj/managedobjectpool.h"
|
||||
@ -45,6 +43,7 @@
|
||||
#include "ags/engine/ac/dynobj/cc_dynamicobject_addr_and_manager.h"
|
||||
#include "ags/shared/util/memory.h"
|
||||
#include "ags/shared/util/string_utils.h" // linux strnicmp definition
|
||||
#include "ags/engine/globals.h"
|
||||
|
||||
namespace AGS3 {
|
||||
|
||||
@ -58,7 +57,6 @@ extern int maxWhileLoops;
|
||||
extern new_line_hook_type new_line_hook;
|
||||
|
||||
extern ScriptString myScriptStringImpl;
|
||||
extern volatile char abort_engine;
|
||||
|
||||
enum ScriptOpArgIsReg {
|
||||
kScOpNoArgIsReg = 0,
|
||||
@ -435,7 +433,7 @@ int ccInstance::Run(int32_t curpc) {
|
||||
FunctionCallStack func_callstack;
|
||||
|
||||
while (1) {
|
||||
if (abort_engine)
|
||||
if (_G(abort_engine))
|
||||
return -1;
|
||||
|
||||
/*
|
||||
|
@ -22,9 +22,9 @@
|
||||
|
||||
#include "ags/events.h"
|
||||
#include "common/system.h"
|
||||
#include "ags/engine/globals.h"
|
||||
|
||||
namespace AGS3 {
|
||||
extern volatile char want_exit, abort_engine;
|
||||
extern char check_dynamic_sprites_at_exit;
|
||||
}
|
||||
|
||||
@ -46,8 +46,8 @@ void EventsManager::pollEvents() {
|
||||
|
||||
while (g_system->getEventManager()->pollEvent(e)) {
|
||||
if (e.type == Common::EVENT_QUIT) {
|
||||
::AGS3::want_exit = 1;
|
||||
::AGS3::abort_engine = 1;
|
||||
_G(want_exit) = true;
|
||||
_G(abort_engine) = true;
|
||||
::AGS3::check_dynamic_sprites_at_exit = 0;
|
||||
|
||||
} else if (e.type == Common::EVENT_KEYDOWN) {
|
||||
|
@ -102,6 +102,7 @@ MODULE_OBJS = \
|
||||
shared/util/textstreamwriter.o \
|
||||
shared/util/version.o \
|
||||
shared/util/wgt2allg.o \
|
||||
engine/globals.o \
|
||||
engine/ac/dynobj/cc_agsdynamicobject.o \
|
||||
engine/ac/dynobj/cc_audiochannel.o \
|
||||
engine/ac/dynobj/cc_audioclip.o \
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "ags/shared/ac/common.h"
|
||||
#include "ags/shared/util/string.h"
|
||||
#include "ags/engine/globals.h"
|
||||
#include "ags/ags.h"
|
||||
|
||||
namespace AGS3 {
|
||||
@ -29,7 +30,6 @@ namespace AGS3 {
|
||||
using namespace AGS::Shared;
|
||||
|
||||
const char *game_file_sig = "Adventure Creator Game File v2";
|
||||
extern volatile char abort_engine;
|
||||
|
||||
void quitprintf(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
@ -37,7 +37,7 @@ void quitprintf(const char *fmt, ...) {
|
||||
String text = String::FromFormatV(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (!abort_engine)
|
||||
if (!_G(abort_engine))
|
||||
::AGS::g_vm->GUIError(text);
|
||||
quit(text);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user