Update perl_mob.cpp

This commit is contained in:
Paul Coene 2019-04-24 17:26:17 -04:00 committed by GitHub
parent dfe4bb5b78
commit a402f01514
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1135,28 +1135,28 @@ XS(XS_Mob_ChangeSize) {
XSRETURN_EMPTY; XSRETURN_EMPTY;
} }
+XS(XS_Mob_RandomizeFeatures); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_RandomizeFeatures); /* prototype to pass -Wmissing-prototypes */
+XS(XS_Mob_RandomizeFeatures) { XS(XS_Mob_RandomizeFeatures) {
+ dXSARGS; dXSARGS;
+ if (items < 2 || items > 3) if (items < 2 || items > 3)
+ Perl_croak(aTHX_ "Usage: Mob::RandomizeFeatures(THIS, bool send_illusion, set_variables)"); Perl_croak(aTHX_ "Usage: Mob::RandomizeFeatures(THIS, bool send_illusion, set_variables)");
+ { {
+ Mob *THIS; Mob *THIS;
+ bool send_illusion = (bool) SvNV(ST(1)); bool send_illusion = (bool) SvNV(ST(1));
+ bool set_variables = (bool) SvNV(ST(2)); bool set_variables = (bool) SvNV(ST(2));
+
+ if (sv_derived_from(ST(0), "Mob")) { if (sv_derived_from(ST(0), "Mob")) {
+ IV tmp = SvIV((SV *) SvRV(ST(0))); IV tmp = SvIV((SV *) SvRV(ST(0)));
+ THIS = INT2PTR(Mob *, tmp); THIS = INT2PTR(Mob *, tmp);
+ } else } else
+ Perl_croak(aTHX_ "THIS is not of type Mob"); Perl_croak(aTHX_ "THIS is not of type Mob");
+ if (THIS == nullptr) if (THIS == nullptr)
+ Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
+
+ THIS->RandomizeFeatures(send_illusion, set_variables); THIS->RandomizeFeatures(send_illusion, set_variables);
+ } }
+ XSRETURN_EMPTY; XSRETURN_EMPTY;
+} }
XS(XS_Mob_GMMove); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GMMove); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mob_GMMove) { XS(XS_Mob_GMMove) {