From 810fdf3ccac7aec22200ada95cd893ac85a48163 Mon Sep 17 00:00:00 2001 From: Derision Date: Fri, 15 Mar 2013 19:37:29 +0000 Subject: [PATCH] Resurrection - Fix for RoF + fixed a couple of memory leaks. --- changelog.txt | 3 +++ common/patches/RoF.cpp | 37 ++++++++++++++++++++++++++++++++++++ common/patches/RoF_ops.h | 2 ++ common/patches/RoF_structs.h | 31 ++++++++++++++++-------------- zone/PlayerCorpse.cpp | 2 +- zone/client_packet.cpp | 7 +++---- 6 files changed, 63 insertions(+), 19 deletions(-) diff --git a/changelog.txt b/changelog.txt index 071d940b4..5a91b9e74 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 03/15/2013 == +Derision: RoF: Added ENCODE for Resurrect_struct (Accepting a rez should now work). +Derision: Fixed a couple of memory leaks in Rez code. == 03/14/2013 == JJ: (NatedogEZ) Fix for hate list random never selecting last member of hate list. diff --git a/common/patches/RoF.cpp b/common/patches/RoF.cpp index 97cfd927a..0f5bcaa3f 100644 --- a/common/patches/RoF.cpp +++ b/common/patches/RoF.cpp @@ -3987,6 +3987,24 @@ ENCODE(OP_BeginCast) FINISH_ENCODE(); } +ENCODE(OP_RezzRequest) +{ + SETUP_DIRECT_ENCODE(Resurrect_Struct, structs::Resurrect_Struct); + + OUT(zone_id); + OUT(instance_id); + OUT(y); + OUT(x); + OUT(z); + OUT_str(your_name); + OUT_str(rezzer_name); + OUT(spellid); + OUT_str(corpse_name); + OUT(action); + + FINISH_ENCODE(); +} + DECODE(OP_BuffRemoveRequest) { // This is to cater for the fact that short buff box buffs start at 30 as opposed to 25 in prior clients. @@ -4777,6 +4795,25 @@ DECODE(OP_GuildStatus) FINISH_DIRECT_DECODE(); } +DECODE(OP_RezzAnswer) +{ + DECODE_LENGTH_EXACT(structs::Resurrect_Struct); + SETUP_DIRECT_DECODE(Resurrect_Struct, structs::Resurrect_Struct); + + IN(zone_id); + IN(instance_id); + IN(y); + IN(x); + IN(z); + memcpy(emu->your_name, eq->your_name, sizeof(emu->your_name)); + memcpy(emu->rezzer_name, eq->rezzer_name, sizeof(emu->rezzer_name)); + IN(spellid); + memcpy(emu->corpse_name, eq->corpse_name, sizeof(emu->corpse_name)); + IN(action); + + FINISH_DIRECT_DECODE(); +} + uint32 NextItemInstSerialNumber = 1; uint32 MaxInstances = 2000000000; diff --git a/common/patches/RoF_ops.h b/common/patches/RoF_ops.h index 159607a72..9e3a91c7e 100644 --- a/common/patches/RoF_ops.h +++ b/common/patches/RoF_ops.h @@ -100,6 +100,7 @@ E(OP_MercenaryDataResponse) E(OP_GuildMemberUpdate) E(OP_GMLastName) E(OP_BeginCast) +E(OP_RezzRequest) //list of packets we need to decode on the way in: D(OP_SetServerFilter) D(OP_CharacterCreate) @@ -156,5 +157,6 @@ D(OP_GuildRemove) D(OP_GuildStatus) D(OP_Trader) D(OP_GMLastName) +D(OP_RezzAnswer) #undef E #undef D diff --git a/common/patches/RoF_structs.h b/common/patches/RoF_structs.h index df428ffdf..f3565d2ce 100644 --- a/common/patches/RoF_structs.h +++ b/common/patches/RoF_structs.h @@ -2792,20 +2792,23 @@ struct Underworld_Struct { float z; }; -struct Resurrect_Struct { - uint32 unknown00; - uint16 zone_id; - uint16 instance_id; - float y; - float x; - float z; - char your_name[64]; - uint32 unknown88; - char rezzer_name[64]; - uint32 spellid; - char corpse_name[64]; - uint32 action; -/* 228 */ +struct Resurrect_Struct +{ +/*000*/ uint32 unknown000; +/*004*/ uint16 zone_id; +/*006*/ uint16 instance_id; +/*008*/ float y; +/*012*/ float x; +/*016*/ float z; +/*020*/ uint32 unknown020; +/*024*/ char your_name[64]; +/*088*/ uint32 unknown088; +/*092*/ char rezzer_name[64]; +/*156*/ uint32 spellid; +/*160*/ char corpse_name[64]; +/*224*/ uint32 action; +/*228*/ uint32 unknown228; +/*232*/ }; struct SetRunMode_Struct { diff --git a/zone/PlayerCorpse.cpp b/zone/PlayerCorpse.cpp index 82da1a827..9140a5914 100644 --- a/zone/PlayerCorpse.cpp +++ b/zone/PlayerCorpse.cpp @@ -1578,9 +1578,9 @@ uint32 ZoneDatabase::UpdatePlayerCorpse(uint32 dbid, uint32 charid, const char* } if(rezzed){ if (!RunQuery(query, MakeAnyLenString(&query, "update player_corpses set rezzed = 1 WHERE id=%d",dbid), errbuf)) { - safe_delete_array(query); cerr << "Error in UpdatePlayerCorpse/Rezzed query: " << errbuf << endl; } + safe_delete_array(query); } return dbid; } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 302a72ddc..6369af127 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4768,10 +4768,8 @@ void Client::Handle_OP_InstillDoubt(const EQApplicationPacket *app) void Client::Handle_OP_RezzAnswer(const EQApplicationPacket *app) { - if (app->size != sizeof(Resurrect_Struct)) { - LogFile->write(EQEMuLog::Error, "Wrong size: OP_RezzAnswer, size=%i, expected %i", app->size, sizeof(Resurrect_Struct)); - return; - } + VERIFY_PACKET_LENGTH(OP_RezzAnswer, app, Resurrect_Struct); + const Resurrect_Struct* ra = (const Resurrect_Struct*) app->pBuffer; _log(SPELLS__REZ, "Received OP_RezzAnswer from client. Pendingrezzexp is %i, action is %s", @@ -4788,6 +4786,7 @@ void Client::Handle_OP_RezzAnswer(const EQApplicationPacket *app) // the rezzed corpse is in to mark the corpse as rezzed. outapp->SetOpcode(OP_RezzComplete); worldserver.RezzPlayer(outapp, 0, 0, OP_RezzComplete); + safe_delete(outapp); } return; }