mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
Try to start fixing Essentials
This commit is contained in:
parent
459dfe5d30
commit
9606fa54d2
5 changed files with 54 additions and 26 deletions
|
@ -43,9 +43,6 @@
|
|||
#include <zlib.h>
|
||||
|
||||
#include <SDL_filesystem.h>
|
||||
#ifdef __WIN32__
|
||||
#include <SDL_syswm.h>
|
||||
#endif
|
||||
|
||||
extern const char module_rpg1[];
|
||||
extern const char module_rpg2[];
|
||||
|
@ -519,24 +516,6 @@ static void runRMXPScripts(BacktraceData &btData)
|
|||
fname = newStringUTF8(buf, len);
|
||||
btData.scriptNames.insert(buf, scriptName);
|
||||
|
||||
#ifdef __WIN32__
|
||||
// Quick hacky fix for getting the current window
|
||||
// from Win32API FindWindowEX calls
|
||||
// This will be replaced with a hook to FindWindowEX
|
||||
if(!strcmp(scriptName, "Win32API"))
|
||||
{
|
||||
SDL_SysWMinfo wminfo = {0};
|
||||
SDL_GetWindowWMInfo(shState->sdlWindow(), &wminfo);
|
||||
if (wminfo.info.win.window)
|
||||
{
|
||||
VALUE s = rb_str_new2("@@RGSSWINDOW=");
|
||||
s = rb_str_append(s, rb_inspect(ULONG2NUM((unsigned long)wminfo.info.win.window)));
|
||||
s = rb_str_append(s, rb_str_new2(";return @@RGSSWINDOW"));
|
||||
string = rb_funcall(string, rb_intern("sub"), 2, rb_str_new2("raise \"Can't find RGSS player window\""), s);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int state;
|
||||
evalString(string, fname, &state);
|
||||
if (state)
|
||||
|
|
|
@ -7,6 +7,7 @@ else
|
|||
lib = get_option('ruby_lib')
|
||||
binding_dependencies += compiler.find_library(lib)
|
||||
if host_system == 'windows'
|
||||
binding_dependencies += compiler.find_library('subhook')
|
||||
if lib.endswith('-static')
|
||||
binding_dependencies += compiler.find_library('wsock32')
|
||||
endif
|
||||
|
@ -16,6 +17,10 @@ else
|
|||
add_project_arguments('-DOLD_RUBY', language: 'cpp')
|
||||
endif
|
||||
|
||||
if get_option('fix_essentials') == true
|
||||
add_project_arguments('-DUSE_ESSENTIALS_FIXES', language: 'cpp')
|
||||
endif
|
||||
|
||||
binding_headers = files(
|
||||
'binding-util.h',
|
||||
'binding-types.h',
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
// Most of this was taken from Ruby 1.8's Win32API.c,
|
||||
// Most of the MiniDL class was taken from Ruby 1.8's Win32API.c,
|
||||
// it's just as basic but should work fine for the moment
|
||||
|
||||
#include <ruby/ruby.h>
|
||||
#include <SDL.h>
|
||||
#if defined(__WIN32__) && defined(USE_ESSENTIALS_FIXES)
|
||||
#include <SDL_syswm.h>
|
||||
#include "sharedstate.h"
|
||||
#endif
|
||||
|
||||
#define _T_VOID 0
|
||||
#define _T_NUMBER 1
|
||||
|
@ -39,10 +43,12 @@ MiniDL_initialize(VALUE self, VALUE libname, VALUE func, VALUE imports, VALUE ex
|
|||
}
|
||||
#endif
|
||||
if (!hfunc)
|
||||
rb_raise(rb_eRuntimeError, "Failed to find function %s within %s: %s", RSTRING_PTR(func), RSTRING_PTR(libname), SDL_GetError());
|
||||
rb_raise(rb_eRuntimeError, "Failed to find function %s(A) within %s: %s", RSTRING_PTR(func), RSTRING_PTR(libname), SDL_GetError());
|
||||
|
||||
|
||||
rb_iv_set(self, "_func", OFFT2NUM((unsigned long)hfunc));
|
||||
rb_iv_set(self, "_funcname", func);
|
||||
rb_iv_set(self, "_libname", libname);
|
||||
|
||||
VALUE ary_imports = rb_ary_new();
|
||||
VALUE *entry = RARRAY_PTR(imports);
|
||||
|
@ -176,7 +182,41 @@ MiniDL_call(int argc, VALUE *argv, VALUE self)
|
|||
params[i] = lParam;
|
||||
}
|
||||
|
||||
unsigned long ret = (unsigned long)ApiFunction(param);
|
||||
unsigned long ret;
|
||||
#if defined(__WIN32__) && defined(USE_ESSENTIALS_FIXES)
|
||||
// On Windows, if essentials fixes are enabled, function calls that
|
||||
// do not work with MKXP will be intercepted here so that the code
|
||||
// still has its desired effect
|
||||
|
||||
// Currently though, all this section does is pass dummies because
|
||||
// the Win32API side of Essentials is jank af and I've yet to work
|
||||
// out exactly what I should do here
|
||||
|
||||
SDL_SysWMinfo wm;
|
||||
char *fname = RSTRING_PTR(rb_iv_get(self, "_funcname"));
|
||||
#define func_is(x) !strcmp(fname, x)
|
||||
#define if_func_is(x) if (func_is(x))
|
||||
if (func_is("GetCurrentThreadId") || func_is("GetWindowThreadProcessId"))
|
||||
{
|
||||
ret = 571;
|
||||
}
|
||||
else if_func_is("FindWindowEx")
|
||||
{
|
||||
SDL_GetWindowWMInfo(shState->sdlWindow(), &wm);
|
||||
ret = (unsigned long)wm.info.win.window;
|
||||
}
|
||||
else if_func_is("GetForegroundWindow")
|
||||
{
|
||||
ret = 571;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = (unsigned long)ApiFunction(param);
|
||||
}
|
||||
|
||||
#else
|
||||
ret = (unsigned long)ApiFunction(param);
|
||||
#endif
|
||||
switch (FIX2INT(own_exports))
|
||||
{
|
||||
case _T_NUMBER: case _T_INTEGER:
|
||||
|
@ -190,6 +230,7 @@ MiniDL_call(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MiniDLBindingInit()
|
||||
{
|
||||
|
@ -198,6 +239,7 @@ MiniDLBindingInit()
|
|||
rb_define_method(cMiniDL, "initialize", RUBY_METHOD_FUNC(MiniDL_initialize), 4);
|
||||
rb_define_method(cMiniDL, "call", RUBY_METHOD_FUNC(MiniDL_call), -1);
|
||||
rb_define_alias(cMiniDL, "Call", "call");
|
||||
|
||||
#ifdef __WIN32__
|
||||
rb_define_const(rb_cObject, "Win32API", cMiniDL);
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@ if host_system == 'windows'
|
|||
all_sources += windows_resources
|
||||
include_dirs += include_directories('windows')
|
||||
elif host_system == 'darwin'
|
||||
if meson.get_compiler('cpp').get_id() == 'clang'
|
||||
if compiler.get_id() == 'clang'
|
||||
add_project_arguments(['-std=c++11','-stdlib=libc++'], language: 'cpp')
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
option('shared_fluid', type: 'boolean', value: false, description: 'Dynamically link fluidsynth at build time')
|
||||
option('mri_version', type: 'string', value: '1.8', description: 'Version of MRI to link with')
|
||||
option('workdir_current', type: 'boolean', value: false, description: 'Keep current directory on startup')
|
||||
option('ruby_lib', type: 'string', value: 'ruby', description: 'Name of legacy Ruby library')
|
||||
option('ruby_lib', type: 'string', value: 'ruby', description: 'Name of legacy Ruby library')
|
||||
|
||||
option('fix_essentials', type: 'boolean', value: false, description: 'Try to fix incompatibilities between Essentials and MKXP')
|
Loading…
Add table
Reference in a new issue