Make getPrivateDataCheck more accurate

This commit is contained in:
Inori 2019-08-01 01:14:49 -04:00
parent 46ba5b378a
commit 7d66ea6fd5

View file

@ -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