mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-04 14:05:32 +02:00
Read fileInt fully before loading it with Marshal
This commit is contained in:
parent
d08c07b42a
commit
6b50662b46
2 changed files with 13 additions and 26 deletions
|
@ -86,7 +86,6 @@ 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)*
|
* 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.
|
* Some Win32API calls don't play nicely with SDL. Building with the `fix_essentials` option will attempt to fix this.
|
||||||
* Sockets.
|
* Sockets.
|
||||||
* 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
|
* Movie playback
|
||||||
* wma audio files
|
* wma audio files
|
||||||
* Creating Bitmaps with sizes greater than the OpenGL texture size limit (around 8192 on modern cards)^
|
* Creating Bitmaps with sizes greater than the OpenGL texture size limit (around 8192 on modern cards)^
|
||||||
|
|
|
@ -151,10 +151,21 @@ kernelLoadDataInt(const char *filename, bool rubyExc)
|
||||||
|
|
||||||
VALUE port = fileIntForPath(filename, rubyExc);
|
VALUE port = fileIntForPath(filename, rubyExc);
|
||||||
|
|
||||||
|
// RGSS checks to see if a file is in the RGSSAD,
|
||||||
|
// and if it is, just passes a char* and the length
|
||||||
|
// of the file to rb_str_new and gives that back to
|
||||||
|
// Marshal. I haven't checked if the whole archive
|
||||||
|
// is kept decrypted in memory (probably, if the
|
||||||
|
// file is always locked), but either way, dumping
|
||||||
|
// the file to a string is much faster than faking
|
||||||
|
// the IO. Seems to cause a bit of startup lag,
|
||||||
|
// but that's no doubt fixable
|
||||||
|
|
||||||
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
||||||
|
|
||||||
// FIXME need to catch exceptions here with begin rescue
|
// FIXME need to catch exceptions here with begin rescue
|
||||||
VALUE result = rb_funcall2(marsh, rb_intern("load"), 1, &port);
|
VALUE data = fileIntRead(0, 0, port);
|
||||||
|
VALUE result = rb_funcall2(marsh, rb_intern("load"), 1, &data);
|
||||||
|
|
||||||
rb_funcall2(port, rb_intern("close"), 0, NULL);
|
rb_funcall2(port, rb_intern("close"), 0, NULL);
|
||||||
|
|
||||||
|
@ -168,29 +179,6 @@ RB_METHOD(kernelLoadData)
|
||||||
VALUE filename;
|
VALUE filename;
|
||||||
rb_get_args(argc, argv, "S", &filename RB_ARG_END);
|
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("start_with?"),
|
|
||||||
1,
|
|
||||||
rb_str_new2("Graphics"));
|
|
||||||
|
|
||||||
if (isGraphicsFile == Qtrue)
|
|
||||||
{
|
|
||||||
VALUE f = rb_file_open_str(filename, "rb");
|
|
||||||
VALUE ret = rb_funcall(f, rb_intern("read"), 0);
|
|
||||||
rb_funcall(f, rb_intern("close"), 0);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return kernelLoadDataInt(RSTRING_PTR(filename), true);
|
return kernelLoadDataInt(RSTRING_PTR(filename), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue