This function required more of a rewrite
New Code:
Code:
void Client::Handle_OP_RequestDuel(const EQApplicationPacket *app)
{
if(app->size != sizeof(Duel_Struct))
return;
EQApplicationPacket* outapp = app->Copy();
Duel_Struct* ds = (Duel_Struct*) outapp->pBuffer;
int32 duel = ds->duel_initiator;
ds->duel_initiator = ds->duel_target;
ds->duel_target = duel;
Client* entity = entity_list.GetClientByID(ds->duel_target);
// Kings & Bandits - null checks for duels
if ( !entity )
{
LogFile->write(EQEMuLog::Debug, "Handle_OP_RequestDuel had a bad entity passed by %s.", GetName());
return;
}
// Kings & Bandits - duelrequest - check if they are already planning to duel someone and ignore it, if we are the duel target jump down below and just delete the outapp
else if((entity->CastToClient()->GetDuelTarget() != 0 && entity->CastToClient()->GetDuelTarget() != this->GetID())) {
Message_StringID(10,DUEL_CONSIDERING,entity->GetName());
return;
}
else if ( entity->CastToClient()->IsDueling() )
{
Message_StringID(10,DUEL_INPROGRESS,entity->GetName());
}
else if(IsDueling()) {
Message_StringID(10,DUEL_INPROGRESS);
return;
}
if(GetID() != ds->duel_target && entity->IsClient() && GetDuelTarget() == 0 && !IsDueling() && !entity->CastToClient()->IsDueling() && entity->CastToClient()->GetDuelTarget() == 0) {
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
safe_delete(outapp);
return;
}
Old Code:
Code:
void Client::Handle_OP_RequestDuel(const EQApplicationPacket *app)
{
if(app->size != sizeof(Duel_Struct))
return;
EQApplicationPacket* outapp = app->Copy();
Duel_Struct* ds = (Duel_Struct*) outapp->pBuffer;
int32 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)) {
Message_StringID(10,DUEL_CONSIDERING,entity->GetName());
return;
}
if(IsDueling()) {
Message_StringID(10,DUEL_INPROGRESS);
return;
}
if(GetID() != ds->duel_target && entity->IsClient() && GetDuelTarget() == 0 && !IsDueling() && !entity->CastToClient()->IsDueling() && entity->CastToClient()->GetDuelTarget() == 0) {
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
safe_delete(outapp);
return;
}