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
+10
View File
@@ -8061,4 +8061,14 @@ void Client::SendMarqueeMessage(uint32 type, uint32 priority, uint32 fade_in, ui
strcpy(cms->msg, msg.c_str());
QueuePacket(&outapp);
}
void Client::PlayMP3(const char* fname)
{
std::string filename = fname;
EQApplicationPacket *outapp = new EQApplicationPacket(OP_PlayMP3, filename.length() + 1);
PlayMP3_Struct* buf = (PlayMP3_Struct*)outapp->pBuffer;
strncpy(buf->filename, fname, filename.length());
QueuePacket(outapp);
safe_delete(outapp);
}
+1
View File
@@ -1158,6 +1158,7 @@ public:
void SetAccountFlag(std::string flag, std::string val);
std::string GetAccountFlag(std::string flag); float GetDamageMultiplier(SkillUseTypes);
void Consume(const Item_Struct *item, uint8 type, int16 slot, bool auto_consume);
void PlayMP3(const char* fname);
int mod_client_damage(int damage, SkillUseTypes skillinuse, int hand, const ItemInst* weapon, Mob* other);
bool mod_client_message(char* message, uint8 chan_num);
bool mod_can_increase_skill(SkillUseTypes skillid, Mob* against_who);
+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;
}