Secrets: Added functionality to Perl/Server for $client->PlayMP3("name of file").

This commit is contained in:
SecretsOTheP
2013-12-24 01:28:32 -05:00
parent bddb03ba3b
commit a7c15ef598
15 changed files with 54 additions and 12 deletions
+27
View File
@@ -5848,6 +5848,32 @@ XS(XS_Client_SilentMessage)
XSRETURN_EMPTY;
}
XS(XS_Client_PlayMP3); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_PlayMP3)
{
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: Client::PlayMP3(THIS, fname)");
{
Client * THIS;
char * fname = nullptr;
if (sv_derived_from(ST(0), "Client")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Client *,tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Mob");
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
if (items > 1) { fname = (char *)SvPV_nolen(ST(1)); }
THIS->PlayMP3(fname);
}
XSRETURN_EMPTY;
}
#ifdef __cplusplus
extern "C"
#endif
@@ -6082,6 +6108,7 @@ XS(boot_Client)
newXSproto(strcpy(buf, "SetThirst"), XS_Client_SetThirst, file, "$$");
newXSproto(strcpy(buf, "SetConsumption"), XS_Client_SetConsumption, file, "$$$");
newXSproto(strcpy(buf, "SilentMessage"), XS_Client_SilentMessage, file, "$$");
newXSproto(strcpy(buf, "PlayMP3"), XS_Client_PlayMP3, file, "$;$");
XSRETURN_YES;
}