[API] mob->SpellEffect small perl fix (#1820)

* Update perl_mob.cpp

* Update perl_mob.cpp
This commit is contained in:
KayenEQ 2021-11-24 12:48:23 -05:00 committed by GitHub
parent 1a2897c423
commit 6ff7f7aa53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4877,6 +4877,7 @@ XS(XS_Mob_SpellEffect) {
Client *client = nullptr;
uint32 caster_id = 0;
uint32 target_id = 0;
bool nullclient = false;
VALIDATE_THIS_IS_MOB;
if (items > 2) { duration = (uint32) SvUV(ST(2)); }
if (items > 3) { finish_delay = (uint32) SvUV(ST(3)); }
@ -4885,18 +4886,26 @@ XS(XS_Mob_SpellEffect) {
if (items > 6) { perm_effect = (bool) SvTRUE(ST(6)); }
if (items > 7) {
if (sv_derived_from(ST(7), "Client")) {
IV tmp = SvIV((SV *) SvRV(ST(7)));
IV tmp = SvIV((SV *)SvRV(ST(7)));
client = INT2PTR(Client *, tmp);
} else
Perl_croak(aTHX_ "client is not of type Client");
if (client == nullptr)
Perl_croak(aTHX_ "client is nullptr, avoiding crash.");
}
else {
nullclient = true;
}
if (client == nullptr) {
nullclient = true;
}
}
if (items > 8) { caster_id = (uint32)SvUV(ST(8)); }
if (items > 9) { target_id = (uint32)SvUV(ST(9)); }
if (nullclient) {
THIS->SendSpellEffect(effect, duration, finish_delay, zone_wide, unk20, perm_effect, 0, caster_id, target_id);
}
else {
THIS->SendSpellEffect(effect, duration, finish_delay, zone_wide, unk20, perm_effect, client, caster_id, target_id);
}
THIS->SendSpellEffect(effect, duration, finish_delay, zone_wide, unk20, perm_effect, client, caster_id, target_id);
}
XSRETURN_EMPTY;
}