EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   Fix for trading with non-targetable NPC's (https://www.eqemulator.org/forums/showthread.php?t=33891)

image 07-21-2011 10:38 AM

Fix for trading with non-targetable NPC's
 
Changes are in bold

client_packet.cpp

Code:

void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app)
{
        // Pass trade request on to recipient
        TradeRequest_Struct* msg = (TradeRequest_Struct*) app->pBuffer;

        if ( msg->from_mob_id != this->GetID() )
                return; // Kings & Bandits - bad!! Someone is trying to cheat! tradereq


        Mob* tradee = entity_list.GetMob(msg->to_mob_id);

        // Client requesting a trade session from an npc/client
        // Trade session not started until OP_TradeRequestAck is sent

        BreakInvis();

        if (tradee && tradee->IsClient()) {
                tradee->CastToClient()->QueuePacket(app);
        }
        else if (tradee) {

                EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeRequestAck, sizeof(TradeRequest_Struct));
                TradeRequest_Struct* acc = (TradeRequest_Struct*) outapp->pBuffer;
                // Kings & Bandits - BodyType fix for non-target trade
                switch(tradee->CastToNPC()->GetBodyType())
                {
                case BT_NoTarget:
                case BT_NoTarget2:
                case BT_Special:
                        {
                                acc->from_mob_id = 0;
                                acc->to_mob_id = msg->from_mob_id;
                                break;
                        }
                default:
                        {
                                //npcs always accept
                                trade->Start(msg->to_mob_id);
                                acc->from_mob_id = msg->to_mob_id;
                                acc->to_mob_id = msg->from_mob_id;
                                break;
                        }
                }


                FastQueuePacket(&outapp);
                safe_delete(outapp);
        }
        return;
}


Secrets 07-21-2011 11:04 AM

Quote:

Originally Posted by image (Post 201629)
Changes are in bold

client_packet.cpp

Code:

void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app)
{
        // Pass trade request on to recipient
        TradeRequest_Struct* msg = (TradeRequest_Struct*) app->pBuffer;

        if ( msg->from_mob_id != this->GetID() )
                return; // Kings & Bandits - bad!! Someone is trying to cheat! tradereq


        Mob* tradee = entity_list.GetMob(msg->to_mob_id);

        // Client requesting a trade session from an npc/client
        // Trade session not started until OP_TradeRequestAck is sent

        BreakInvis();

        if (tradee && tradee->IsClient()) {
                tradee->CastToClient()->QueuePacket(app);
        }
        else if (tradee) {

                EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeRequestAck, sizeof(TradeRequest_Struct));
                TradeRequest_Struct* acc = (TradeRequest_Struct*) outapp->pBuffer;
                // Kings & Bandits - BodyType fix for non-target trade
                switch(tradee->CastToNPC()->GetBodyType())
                {
                case BT_NoTarget:
                case BT_NoTarget2:
                case BT_Special:
                        {
                                acc->from_mob_id = 0;
                                acc->to_mob_id = msg->from_mob_id;
                                break;
                        }
                default:
                        {
                                //npcs always accept
                                trade->Start(msg->to_mob_id);
                                acc->from_mob_id = msg->to_mob_id;
                                acc->to_mob_id = msg->from_mob_id;
                                break;
                        }
                }


                FastQueuePacket(&outapp);
                safe_delete(outapp);
        }
        return;
}


Image, thanks for this and all your other fixes. I will be committing them soonish if no one else gets around to it.


All times are GMT -4. The time now is 01:23 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.