diff --git a/README.md b/README.md index 17fdca04..ed67baec 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ If a requested font is not found, no error is generated. Instead, a built-in fon * Win32API calls outside of Windows (Win32API is just an alias to the MiniFFI class, which *does* work with other operating systems, but you can obviously only load libraries made for the platform you're on)* * Some Win32API calls don't play nicely with SDL. Building with the `fix_essentials` option will attempt to fix this. * Sockets. -* Loading data from an archive doesn't work like a real IO, so Ruby doesn't like it when Essentials tries to load files from an archive. Yet. +* The way MKXP handles archives is slower than RMXP's method, so if `fix_essentials` is used, Graphics files will only be checked for outside of encrypted archives. If it didn't, the game would become pretty much unplayable in the overworld and might freeze up completely if your computer is too slow. * Movie playback * wma audio files * Creating Bitmaps with sizes greater than the OpenGL texture size limit (around 8192 on modern cards)^ diff --git a/binding/filesystem-binding.cpp b/binding/filesystem-binding.cpp index 1dbe1441..ea7c88eb 100644 --- a/binding/filesystem-binding.cpp +++ b/binding/filesystem-binding.cpp @@ -165,10 +165,28 @@ RB_METHOD(kernelLoadData) { RB_UNUSED_PARAM; - const char *filename; - rb_get_args(argc, argv, "z", &filename RB_ARG_END); + VALUE filename; + rb_get_args(argc, argv, "S", &filename RB_ARG_END); + +#ifdef USE_ESSENTIALS_FIXES + // Okay seriously holy crap, what are you doing Essentials + + // MKXP's method of processing files in archives is way + // too slow to handle the constant barrage of queries + // SpriteWindow tries to do, and the game becomes pretty + // much unplayable once you get into the overworld, so + // until this can be fixed let's just not open Graphics + // files from archives + VALUE isGraphicsFile = rb_funcall(filename, + rb_intern("include?"), + 1, + rb_str_new2("Graphics/")); + + if (isGraphicsFile == Qtrue) + return rb_file_open_str(filename, "rb"); +#endif - return kernelLoadDataInt(filename, true); + return kernelLoadDataInt(RSTRING_PTR(filename), true); } RB_METHOD(kernelSaveData)