mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-03 21:45:32 +02:00
Make getPrivateDataCheck more accurate
This commit is contained in:
parent
46ba5b378a
commit
7d66ea6fd5
1 changed files with 11 additions and 6 deletions
|
@ -186,13 +186,18 @@ getPrivateDataCheck(VALUE self, const char *type)
|
|||
{
|
||||
#ifndef OLD_RUBY
|
||||
void *obj = Check_TypedStruct(self, &type);
|
||||
#else
|
||||
#else // RGSS1 works in a more permissive way than the above,
|
||||
// See the function at ram:10012AB0 in RGSS104E for an example
|
||||
// This isn't an exact replica, but should have pretty much the same result
|
||||
rb_check_type(self, T_DATA);
|
||||
/* RMXP apparently didn't check for this?
|
||||
const char *ownname = rb_obj_classname(self);
|
||||
if (strcmp(ownname, type))
|
||||
rb_raise(rb_eTypeError, "Type mismatch between %s and %s", ownname, type);
|
||||
*/
|
||||
VALUE otherObj = rb_const_get(rb_cObject, rb_intern(type));
|
||||
const char *ownname, *othername;
|
||||
if (!rb_obj_is_kind_of(self, otherObj))
|
||||
{
|
||||
ownname = rb_obj_classname(self);
|
||||
othername = rb_obj_classname(otherObj);
|
||||
rb_raise(rb_eTypeError, "Can't convert %s into %s", othername, ownname);
|
||||
}
|
||||
void *obj = DATA_PTR(self);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue