mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-08 10:51:11 +00:00
AGS: Fix crash when starting games with multiple plugins
This commit is contained in:
parent
ef860488e1
commit
b38d1c3e6c
@ -297,6 +297,7 @@ Globals::Globals() {
|
||||
// plugins globals
|
||||
_engineExports = new Plugins::Core::EngineExports();
|
||||
_plugins = new Common::Array<EnginePlugin>();
|
||||
_plugins->reserve(MAXPLUGINS);
|
||||
|
||||
// plugin_object_reader.cpp globals
|
||||
_pluginReaders = new PluginObjectReader[MAX_PLUGIN_OBJECT_READERS];
|
||||
|
@ -32,7 +32,7 @@ const char *AGSClipboard::AGS_GetPluginName() {
|
||||
}
|
||||
|
||||
void AGSClipboard::AGS_EngineStartup(IAGSEngine *engine) {
|
||||
AGS_EngineStartup(engine);
|
||||
PluginBase::AGS_EngineStartup(engine);
|
||||
|
||||
SCRIPT_METHOD(Clipboard::PasteText, AGSClipboard::Clipboard_PasteText);
|
||||
SCRIPT_METHOD(Clipboard::CopyText^1, AGSClipboard::Clipboard_CopyText);
|
||||
|
@ -82,7 +82,6 @@ using namespace AGS::Shared::Memory;
|
||||
using namespace AGS::Engine;
|
||||
|
||||
const int PLUGIN_API_VERSION = 25;
|
||||
#define MAXPLUGINS 20
|
||||
|
||||
// On save/restore, the Engine will provide the plugin with a handle. Because we only ever save to one file at a time,
|
||||
// we can reuse the same handle.
|
||||
@ -760,7 +759,9 @@ void pl_stop_plugins() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_GP(plugins).clear();
|
||||
_GP(plugins).reserve(MAXPLUGINS);
|
||||
}
|
||||
|
||||
void pl_startup_plugins() {
|
||||
@ -768,8 +769,10 @@ void pl_startup_plugins() {
|
||||
if (i == 0)
|
||||
_GP(engineExports).AGS_EngineStartup(&_GP(plugins)[0].eiface);
|
||||
|
||||
if (_GP(plugins)[i].available)
|
||||
_GP(plugins)[i]._plugin->AGS_EngineStartup(&_GP(plugins)[i].eiface);
|
||||
if (_GP(plugins)[i].available) {
|
||||
EnginePlugin &ep = _GP(plugins)[i];
|
||||
ep._plugin->AGS_EngineStartup(&ep.eiface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -806,6 +809,7 @@ void pl_run_plugin_init_gfx_hooks(const char *driverName, void *data) {
|
||||
|
||||
Engine::GameInitError pl_register_plugins(const std::vector<Shared::PluginInfo> &infos) {
|
||||
_GP(plugins).clear();
|
||||
_GP(plugins).reserve(MAXPLUGINS);
|
||||
|
||||
for (size_t inf_index = 0; inf_index < infos.size(); ++inf_index) {
|
||||
const Shared::PluginInfo &info = infos[inf_index];
|
||||
|
@ -60,6 +60,8 @@ class BITMAP;
|
||||
typedef int HWND;
|
||||
#endif
|
||||
|
||||
#define MAXPLUGINS 20
|
||||
|
||||
#define AGSIFUNC(type) virtual type
|
||||
|
||||
#define MASK_WALKABLE 1
|
||||
@ -559,26 +561,19 @@ public:
|
||||
};
|
||||
|
||||
struct EnginePlugin {
|
||||
char filename[PLUGIN_FILENAME_MAX + 1];
|
||||
char filename[PLUGIN_FILENAME_MAX + 1] = { 0 };
|
||||
AGS::Engine::Library library;
|
||||
Plugins::PluginBase *_plugin;
|
||||
bool available;
|
||||
char *savedata;
|
||||
int savedatasize;
|
||||
int wantHook;
|
||||
int invalidatedRegion;
|
||||
Plugins::PluginBase *_plugin = nullptr;
|
||||
bool available = false;
|
||||
char *savedata = nullptr;
|
||||
int savedatasize = 0;
|
||||
int wantHook = 0;
|
||||
int invalidatedRegion = 0;
|
||||
bool builtin = false;
|
||||
|
||||
IAGSEngine eiface;
|
||||
bool builtin;
|
||||
|
||||
EnginePlugin() {
|
||||
filename[0] = 0;
|
||||
wantHook = 0;
|
||||
invalidatedRegion = 0;
|
||||
savedata = nullptr;
|
||||
savedatasize = 0;
|
||||
builtin = false;
|
||||
available = false;
|
||||
eiface.version = 0;
|
||||
eiface.pluginId = 0;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ const char *AGSTcpIp::AGS_GetPluginName() {
|
||||
}
|
||||
|
||||
void AGSTcpIp::AGS_EngineStartup(IAGSEngine *engine) {
|
||||
PluginBase::AGS_EngineStartup(engine);
|
||||
}
|
||||
|
||||
} // namespace AGSTcpIp
|
||||
|
Loading…
Reference in New Issue
Block a user