Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 07-21-2011, 10:38 AM
image
Demi-God
 
Join Date: Jan 2002
Posts: 1,290
Default 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;
}
__________________
www.eq2emu.com
EQ2Emu Developer
Former EQEMu Developer / GuildWars / Zek Seasons Servers
Member of the "I hate devn00b" club.
Reply With Quote
  #2  
Old 07-21-2011, 11:04 AM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,447
Default

Quote:
Originally Posted by image View Post
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 07:25 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3