mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-05 03:06:38 +00:00
[Bug Fix] Remove possible Duel exploit. (#1911)
* [Duels] Cleanup duel response/request logic. * Fixes and function name cleanup. * Patch file name changes.
This commit is contained in:
+2
-2
@@ -783,9 +783,9 @@ public:
|
||||
|
||||
void GMKill();
|
||||
inline bool IsMedding() const {return medding;}
|
||||
inline uint16 GetDuelTarget() const { return duel_target; }
|
||||
inline uint32 GetDuelTarget() const { return duel_target; }
|
||||
inline bool IsDueling() const { return duelaccepted; }
|
||||
inline void SetDuelTarget(uint16 set_id) { duel_target=set_id; }
|
||||
inline void SetDuelTarget(uint32 set_id) { duel_target = set_id; }
|
||||
inline void SetDueling(bool duel) { duelaccepted = duel; }
|
||||
// use this one instead
|
||||
void MemSpell(uint16 spell_id, int slot, bool update_client = true);
|
||||
|
||||
+61
-18
@@ -194,8 +194,8 @@ void MapOpcodes()
|
||||
ConnectedOpcodes[OP_Disarm] = &Client::Handle_OP_Disarm;
|
||||
ConnectedOpcodes[OP_DisarmTraps] = &Client::Handle_OP_DisarmTraps;
|
||||
ConnectedOpcodes[OP_DoGroupLeadershipAbility] = &Client::Handle_OP_DoGroupLeadershipAbility;
|
||||
ConnectedOpcodes[OP_DuelResponse] = &Client::Handle_OP_DuelResponse;
|
||||
ConnectedOpcodes[OP_DuelResponse2] = &Client::Handle_OP_DuelResponse2;
|
||||
ConnectedOpcodes[OP_DuelDecline] = &Client::Handle_OP_DuelDecline;
|
||||
ConnectedOpcodes[OP_DuelAccept] = &Client::Handle_OP_DuelAccept;
|
||||
ConnectedOpcodes[OP_DumpName] = &Client::Handle_OP_DumpName;
|
||||
ConnectedOpcodes[OP_Dye] = &Client::Handle_OP_Dye;
|
||||
ConnectedOpcodes[OP_DzAddPlayer] = &Client::Handle_OP_DzAddPlayer;
|
||||
@@ -5543,37 +5543,57 @@ void Client::Handle_OP_DoGroupLeadershipAbility(const EQApplicationPacket *app)
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_DuelResponse(const EQApplicationPacket *app)
|
||||
void Client::Handle_OP_DuelDecline(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(DuelResponse_Struct))
|
||||
if (app->size != sizeof(DuelResponse_Struct)) {
|
||||
return;
|
||||
}
|
||||
|
||||
DuelResponse_Struct* ds = (DuelResponse_Struct*)app->pBuffer;
|
||||
if (!ds->target_id || !ds->entity_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity* entity = entity_list.GetID(ds->target_id);
|
||||
Entity* initiator = entity_list.GetID(ds->entity_id);
|
||||
if (!entity->IsClient() || !initiator->IsClient())
|
||||
if (!entity->IsClient() || !initiator->IsClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
entity->CastToClient()->SetDuelTarget(0);
|
||||
entity->CastToClient()->SetDueling(false);
|
||||
initiator->CastToClient()->SetDuelTarget(0);
|
||||
initiator->CastToClient()->SetDueling(false);
|
||||
if (GetID() == initiator->GetID())
|
||||
if (GetID() == initiator->GetID()) {
|
||||
entity->CastToClient()->MessageString(Chat::NPCQuestSay, DUEL_DECLINE, initiator->GetName());
|
||||
else
|
||||
} else {
|
||||
initiator->CastToClient()->MessageString(Chat::NPCQuestSay, DUEL_DECLINE, entity->GetName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void Client::Handle_OP_DuelResponse2(const EQApplicationPacket *app)
|
||||
void Client::Handle_OP_DuelAccept(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(Duel_Struct))
|
||||
if (app->size != sizeof(Duel_Struct)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Duel_Struct* ds = (Duel_Struct*)app->pBuffer;
|
||||
if (!ds->duel_initiator || !ds->duel_target) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity* entity = entity_list.GetID(ds->duel_target);
|
||||
Entity* initiator = entity_list.GetID(ds->duel_initiator);
|
||||
if (!entity || !initiator) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity && initiator && entity == this && initiator->IsClient()) {
|
||||
if (GetDuelTarget() != ds->duel_initiator || IsDueling()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity == this && initiator->IsClient()) {
|
||||
auto outapp = new EQApplicationPacket(OP_RequestDuel, sizeof(Duel_Struct));
|
||||
Duel_Struct* ds2 = (Duel_Struct*)outapp->pBuffer;
|
||||
|
||||
@@ -5581,7 +5601,7 @@ void Client::Handle_OP_DuelResponse2(const EQApplicationPacket *app)
|
||||
ds2->duel_target = entity->GetID();
|
||||
initiator->CastToClient()->QueuePacket(outapp);
|
||||
|
||||
outapp->SetOpcode(OP_DuelResponse2);
|
||||
outapp->SetOpcode(OP_DuelAccept);
|
||||
ds2->duel_initiator = initiator->GetID();
|
||||
|
||||
initiator->CastToClient()->QueuePacket(outapp);
|
||||
@@ -5592,10 +5612,13 @@ void Client::Handle_OP_DuelResponse2(const EQApplicationPacket *app)
|
||||
SetDuelTarget(ds->duel_initiator);
|
||||
safe_delete(outapp);
|
||||
|
||||
if (IsCasting())
|
||||
if (IsCasting()) {
|
||||
InterruptSpell();
|
||||
if (initiator->CastToClient()->IsCasting())
|
||||
}
|
||||
|
||||
if (initiator->CastToClient()->IsCasting()) {
|
||||
initiator->CastToClient()->InterruptSpell();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -12455,34 +12478,54 @@ void Client::Handle_OP_Report(const EQApplicationPacket *app)
|
||||
|
||||
void Client::Handle_OP_RequestDuel(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(Duel_Struct))
|
||||
if (app->size != sizeof(Duel_Struct)) {
|
||||
return;
|
||||
}
|
||||
|
||||
EQApplicationPacket* outapp = app->Copy();
|
||||
Duel_Struct* ds = (Duel_Struct*)outapp->pBuffer;
|
||||
if (!ds->duel_initiator || !ds->duel_target) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 duel = ds->duel_initiator;
|
||||
ds->duel_initiator = ds->duel_target;
|
||||
ds->duel_target = duel;
|
||||
Entity* entity = entity_list.GetID(ds->duel_target);
|
||||
if (GetID() != ds->duel_target && entity->IsClient() && (entity->CastToClient()->IsDueling() && entity->CastToClient()->GetDuelTarget() != 0)) {
|
||||
|
||||
if (
|
||||
GetID() != ds->duel_target &&
|
||||
entity->IsClient() &&
|
||||
entity->CastToClient()->IsDueling() &&
|
||||
entity->CastToClient()->GetDuelTarget()
|
||||
) {
|
||||
MessageString(Chat::NPCQuestSay, DUEL_CONSIDERING, entity->GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsDueling()) {
|
||||
MessageString(Chat::NPCQuestSay, DUEL_INPROGRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetID() != ds->duel_target && entity->IsClient() && GetDuelTarget() == 0 && !IsDueling() && !entity->CastToClient()->IsDueling() && entity->CastToClient()->GetDuelTarget() == 0) {
|
||||
if (
|
||||
GetID() != ds->duel_target &&
|
||||
entity->IsClient() &&
|
||||
!GetDuelTarget() &&
|
||||
!IsDueling() &&
|
||||
!entity->CastToClient()->IsDueling() &&
|
||||
!entity->CastToClient()->GetDuelTarget()
|
||||
) {
|
||||
SetDuelTarget(ds->duel_target);
|
||||
entity->CastToClient()->SetDuelTarget(GetID());
|
||||
ds->duel_target = ds->duel_initiator;
|
||||
entity->CastToClient()->FastQueuePacket(&outapp);
|
||||
entity->CastToClient()->SetDueling(false);
|
||||
SetDueling(false);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@
|
||||
void Handle_OP_Disarm(const EQApplicationPacket *app);
|
||||
void Handle_OP_DisarmTraps(const EQApplicationPacket *app);
|
||||
void Handle_OP_DoGroupLeadershipAbility(const EQApplicationPacket *app);
|
||||
void Handle_OP_DuelResponse(const EQApplicationPacket *app);
|
||||
void Handle_OP_DuelResponse2(const EQApplicationPacket *app);
|
||||
void Handle_OP_DuelDecline(const EQApplicationPacket *app);
|
||||
void Handle_OP_DuelAccept(const EQApplicationPacket *app);
|
||||
void Handle_OP_DumpName(const EQApplicationPacket *app);
|
||||
void Handle_OP_Dye(const EQApplicationPacket *app);
|
||||
void Handle_OP_DzAddPlayer(const EQApplicationPacket *app);
|
||||
|
||||
+2
-2
@@ -582,7 +582,7 @@ luabind::scope lua_register_packet_opcodes() {
|
||||
luabind::value("Logout", static_cast<int>(OP_Logout)),
|
||||
luabind::value("LogoutReply", static_cast<int>(OP_LogoutReply)),
|
||||
luabind::value("PreLogoutReply", static_cast<int>(OP_PreLogoutReply)),
|
||||
luabind::value("DuelResponse2", static_cast<int>(OP_DuelResponse2)),
|
||||
luabind::value("DuelAccept", static_cast<int>(OP_DuelAccept)),
|
||||
luabind::value("InstillDoubt", static_cast<int>(OP_InstillDoubt)),
|
||||
luabind::value("SafeFallSuccess", static_cast<int>(OP_SafeFallSuccess)),
|
||||
luabind::value("DisciplineUpdate", static_cast<int>(OP_DisciplineUpdate)),
|
||||
@@ -659,7 +659,7 @@ luabind::scope lua_register_packet_opcodes() {
|
||||
luabind::value("TraderDelItem", static_cast<int>(OP_TraderDelItem)),
|
||||
luabind::value("AdventureMerchantPurchase", static_cast<int>(OP_AdventureMerchantPurchase)),
|
||||
luabind::value("TestBuff", static_cast<int>(OP_TestBuff)),
|
||||
luabind::value("DuelResponse", static_cast<int>(OP_DuelResponse)),
|
||||
luabind::value("DuelDecline", static_cast<int>(OP_DuelDecline)),
|
||||
luabind::value("RequestDuel", static_cast<int>(OP_RequestDuel)),
|
||||
luabind::value("BazaarInspect", static_cast<int>(OP_BazaarInspect)),
|
||||
luabind::value("ClickDoor", static_cast<int>(OP_ClickDoor)),
|
||||
|
||||
@@ -1753,7 +1753,7 @@ XS(XS_Client_GetDuelTarget) {
|
||||
Perl_croak(aTHX_ "Usage: Client::GetDuelTarget(THIS)"); // @categories Account and Character, Script Utility
|
||||
{
|
||||
Client *THIS;
|
||||
uint16 RETVAL;
|
||||
uint32 RETVAL;
|
||||
dXSTARG;
|
||||
VALIDATE_THIS_IS_CLIENT;
|
||||
RETVAL = THIS->GetDuelTarget();
|
||||
@@ -1786,7 +1786,7 @@ XS(XS_Client_SetDuelTarget) {
|
||||
Perl_croak(aTHX_ "Usage: Client::SetDuelTarget(THIS, set_id)"); // @categories Account and Character
|
||||
{
|
||||
Client *THIS;
|
||||
uint16 set_id = (uint16) SvUV(ST(1));
|
||||
uint32 set_id = (uint32) SvUV(ST(1));
|
||||
VALIDATE_THIS_IS_CLIENT;
|
||||
THIS->SetDuelTarget(set_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user