zaela-Server/zone/perl_hateentry.cpp

140 lines
3.5 KiB
C++
Raw Permalink Normal View History

2013-05-09 10:44:08 -04:00
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2009 EQEMu Development Team (http://eqemulator.net)
2013-02-16 16:14:39 -08:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
2013-05-09 10:44:08 -04:00
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
2013-02-16 16:14:39 -08:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
2013-05-09 10:44:08 -04:00
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2013-02-16 16:14:39 -08:00
*/
2013-02-20 13:54:26 -08:00
#include "../common/features.h"
2013-02-16 16:14:39 -08:00
#include "client.h"
2013-02-16 16:14:39 -08:00
#ifdef EMBPERL_XS_CLASSES
#include "../common/global_define.h"
2013-02-16 16:14:39 -08:00
#include "embperl.h"
#ifdef seed
#undef seed
#endif
2013-02-16 16:14:39 -08:00
#include "../common/linked_list.h"
#include "hate_list.h"
#ifdef THIS /* this macro seems to leak out on some systems */
2013-02-16 16:14:39 -08:00
#undef THIS
#endif
XS(XS_HateEntry_GetEnt); /* prototype to pass -Wmissing-prototypes */
XS(XS_HateEntry_GetEnt) {
2013-02-16 16:14:39 -08:00
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: HateEntry::GetData(THIS)");
{
struct_HateList *THIS;
Mob *RETVAL;
2013-02-16 16:14:39 -08:00
if (sv_derived_from(ST(0), "HateEntry")) {
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(struct_HateList *, tmp);
} else
2013-02-16 16:14:39 -08:00
Perl_croak(aTHX_ "THIS is not of type tHateEntry");
if (THIS == nullptr)
2013-05-04 18:06:58 -07:00
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
2013-02-16 16:14:39 -08:00
RETVAL = THIS->entity_on_hatelist;
2013-02-16 16:14:39 -08:00
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "Mob", (void *) RETVAL);
2013-02-16 16:14:39 -08:00
}
XSRETURN(1);
}
XS(XS_HateEntry_GetHate); /* prototype to pass -Wmissing-prototypes */
XS(XS_HateEntry_GetHate) {
2013-02-16 16:14:39 -08:00
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: HateEntry::GetHate(THIS)");
{
struct_HateList *THIS;
2013-02-16 16:14:39 -08:00
int32 RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "HateEntry")) {
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(struct_HateList *, tmp);
} else
2013-02-16 16:14:39 -08:00
Perl_croak(aTHX_ "THIS is not of type tHateEntry");
if (THIS == nullptr)
2013-05-04 18:06:58 -07:00
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
2013-02-16 16:14:39 -08:00
RETVAL = THIS->stored_hate_amount;
XSprePUSH;
PUSHi((IV) RETVAL);
2013-02-16 16:14:39 -08:00
}
XSRETURN(1);
}
XS(XS_HateEntry_GetDamage); /* prototype to pass -Wmissing-prototypes */
XS(XS_HateEntry_GetDamage) {
2013-02-16 16:14:39 -08:00
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: HateEntry::GetDamage(THIS)");
{
struct_HateList *THIS;
2013-02-16 16:14:39 -08:00
int32 RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "HateEntry")) {
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(struct_HateList *, tmp);
} else
2013-02-16 16:14:39 -08:00
Perl_croak(aTHX_ "THIS is not of type tHateEntry");
if (THIS == nullptr)
2013-05-04 18:06:58 -07:00
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
2013-02-16 16:14:39 -08:00
RETVAL = THIS->hatelist_damage;
XSprePUSH;
PUSHi((IV) RETVAL);
2013-02-16 16:14:39 -08:00
}
XSRETURN(1);
}
#ifdef __cplusplus
extern "C"
#endif
XS(boot_HateEntry);
XS(boot_HateEntry) {
2013-02-16 16:14:39 -08:00
dXSARGS;
char file[256];
strncpy(file, __FILE__, 256);
file[255] = 0;
if (items != 1)
2013-02-16 16:14:39 -08:00
fprintf(stderr, "boot_quest does not take any arguments.");
char buf[128];
//add the strcpy stuff to get rid of const warnings....
XS_VERSION_BOOTCHECK;
2013-02-16 16:14:39 -08:00
newXSproto(strcpy(buf, "GetEnt"), XS_HateEntry_GetEnt, file, "$");
newXSproto(strcpy(buf, "GetDamage"), XS_HateEntry_GetDamage, file, "$");
newXSproto(strcpy(buf, "GetHate"), XS_HateEntry_GetHate, file, "$");
2013-02-16 16:14:39 -08:00
XSRETURN_YES;
}
2013-05-04 18:06:58 -07:00
#endif //EMBPERL_XS_CLASSES
2013-05-09 10:44:08 -04:00