From a7c15ef59883efeda13b873e331085fa1eb8808a Mon Sep 17 00:00:00 2001 From: SecretsOTheP Date: Tue, 24 Dec 2013 01:28:32 -0500 Subject: [PATCH] Secrets: Added functionality to Perl/Server for $client->PlayMP3("name of file"). --- changelog.txt | 6 +++++- common/eq_packet_structs.h | 2 +- common/patches/Client62_structs.h | 2 +- common/patches/RoF_structs.h | 2 +- common/patches/SoD_structs.h | 2 +- common/patches/SoF_structs.h | 2 +- common/patches/Titanium_structs.h | 2 +- common/patches/Underfoot_structs.h | 2 +- utils/patches/patch_RoF.conf | 2 +- utils/patches/patch_SoD.conf | 2 +- utils/patches/patch_Titanium.conf | 2 +- utils/patches/patch_Underfoot.conf | 2 +- zone/client.cpp | 10 ++++++++++ zone/client.h | 1 + zone/perl_client.cpp | 27 +++++++++++++++++++++++++++ 15 files changed, 54 insertions(+), 12 deletions(-) diff --git a/changelog.txt b/changelog.txt index 352eab6d0..50faa0054 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,7 +2,11 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- == 12/24/2013 == Secrets (Akkadius): Perl $client->SilentMessage("Message"); addition, this is a pre-req for a Perl plugin I've shared with EQEmu. This function essentially mimics a player speaking with an NPC - which is used in popup window responses - +Secrets: Added functionality to Perl for $client->PlayMP3("name of file"). + Usage varies, but typically you can place an MP3/WAV/XMI in the EQDir//sounds, pfs, s3d, or root client folder and it will play through this Perl function. Example, $client->PlayMP3("combattheme1.mp3") or $client->PlayMP3("TUTBTrade1.mp3") + All clients except Secrets of Faydwer and 6.2 have their opcodes identified for this function. The struct + supported params is the same throughout versions. + Use $client->PlayMP3 with an invalid sound file to stop playback or simply wait for it to end. + == 12/16/2013 == Kayen: Implemented SE_ArcheryDoubleAttack (Chance to do an extra archery attack) Kayen: Implemented SE_ShieldEquipDmgMod (Increase damage in primary hand if shield equiped) diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index a0175a398..63387ef35 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -3483,7 +3483,7 @@ struct MobRename_Struct { }; struct PlayMP3_Struct { - char filename[128]; + char filename[0]; }; //this is for custom title display in the skill window diff --git a/common/patches/Client62_structs.h b/common/patches/Client62_structs.h index ded2078b1..84eacf67e 100644 --- a/common/patches/Client62_structs.h +++ b/common/patches/Client62_structs.h @@ -2665,7 +2665,7 @@ struct MobRename_Struct { }; struct PlayMP3_Struct { - char filename[128]; + char filename[0]; }; //this is for custom title display in the skill window diff --git a/common/patches/RoF_structs.h b/common/patches/RoF_structs.h index cf8f1e804..d3125f97d 100644 --- a/common/patches/RoF_structs.h +++ b/common/patches/RoF_structs.h @@ -3635,7 +3635,7 @@ struct MobRename_Struct { }; struct PlayMP3_Struct { - char filename[128]; + char filename[0]; }; //this is for custom title display in the skill window diff --git a/common/patches/SoD_structs.h b/common/patches/SoD_structs.h index 685e8f77f..e87d90429 100644 --- a/common/patches/SoD_structs.h +++ b/common/patches/SoD_structs.h @@ -3232,7 +3232,7 @@ struct MobRename_Struct { }; struct PlayMP3_Struct { - char filename[128]; + char filename[0]; }; //this is for custom title display in the skill window diff --git a/common/patches/SoF_structs.h b/common/patches/SoF_structs.h index 3f9b6af8f..d02affa65 100644 --- a/common/patches/SoF_structs.h +++ b/common/patches/SoF_structs.h @@ -3095,7 +3095,7 @@ struct MobRename_Struct { }; struct PlayMP3_Struct { - char filename[128]; + char filename[0]; }; //this is for custom title display in the skill window diff --git a/common/patches/Titanium_structs.h b/common/patches/Titanium_structs.h index 0298ca630..a12958c30 100644 --- a/common/patches/Titanium_structs.h +++ b/common/patches/Titanium_structs.h @@ -2724,7 +2724,7 @@ struct MobRename_Struct { }; struct PlayMP3_Struct { - char filename[128]; + char filename[0]; }; //this is for custom title display in the skill window diff --git a/common/patches/Underfoot_structs.h b/common/patches/Underfoot_structs.h index 07d3660a3..941ca583f 100644 --- a/common/patches/Underfoot_structs.h +++ b/common/patches/Underfoot_structs.h @@ -3275,7 +3275,7 @@ struct MobRename_Struct { }; struct PlayMP3_Struct { - char filename[128]; + char filename[0]; }; //this is for custom title display in the skill window diff --git a/utils/patches/patch_RoF.conf b/utils/patches/patch_RoF.conf index 7b0e57920..c4e0b7955 100644 --- a/utils/patches/patch_RoF.conf +++ b/utils/patches/patch_RoF.conf @@ -579,7 +579,7 @@ OP_LoginComplete=0x0000 # discovered opcodes not yet used: OP_PickLockSuccess=0x0000 -OP_PlayMP3=0x0000 +OP_PlayMP3=0x277c OP_ReclaimCrystals=0x0000 OP_DynamicWall=0x0000 OP_OpenDiscordMerchant=0x0000 diff --git a/utils/patches/patch_SoD.conf b/utils/patches/patch_SoD.conf index 0049f56d0..642e0f4ab 100644 --- a/utils/patches/patch_SoD.conf +++ b/utils/patches/patch_SoD.conf @@ -587,7 +587,7 @@ OP_LoginComplete=0x0000 # # discovered opcodes not yet used: OP_PickLockSuccess=0x0000 # -OP_PlayMP3=0x0000 # +OP_PlayMP3=0x82d7 # OP_ReclaimCrystals=0x0000 # OP_DynamicWall=0x0000 # OP_OpenDiscordMerchant=0x0000 # diff --git a/utils/patches/patch_Titanium.conf b/utils/patches/patch_Titanium.conf index 46978d927..93f24e8db 100644 --- a/utils/patches/patch_Titanium.conf +++ b/utils/patches/patch_Titanium.conf @@ -498,7 +498,7 @@ OP_ItemVerifyRequest=0x0000 #Trevius 03/15/09 OP_ItemVerifyReply=0x0000 #Trevius 03/15/09 #discovered opcodes not yet used: -OP_PlayMP3=0x0000 +OP_PlayMP3=0x26ab OP_FriendsWho=0x48fe OP_MoveLogRequest=0x7510 #gone I think OP_MoveLogDisregard=0x0000 #gone I think diff --git a/utils/patches/patch_Underfoot.conf b/utils/patches/patch_Underfoot.conf index b0d0ad017..aadce14ba 100644 --- a/utils/patches/patch_Underfoot.conf +++ b/utils/patches/patch_Underfoot.conf @@ -581,7 +581,7 @@ OP_LoginComplete=0x0000 # # discovered opcodes not yet used: OP_PickLockSuccess=0x0000 # -OP_PlayMP3=0x0000 # +OP_PlayMP3=0x7f72 # OP_ReclaimCrystals=0x0000 # OP_DynamicWall=0x0000 # OP_OpenDiscordMerchant=0x0000 # diff --git a/zone/client.cpp b/zone/client.cpp index 9d2cdbd27..ded5bdc5f 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -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); } \ No newline at end of file diff --git a/zone/client.h b/zone/client.h index b672b114a..edb9c94cc 100644 --- a/zone/client.h +++ b/zone/client.h @@ -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); diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 1ce73eb93..92ecd52ca 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -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; }