Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::General Support

Support::General Support Post all topics here having to do with errors while trying to connect to an EQEMu server but not about the setup/running of the Server itself.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 02-24-2010, 06:54 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Here is the function that handles the targeting stuff:

client_packet.cpp
Code:
void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app)
{
	if (app->size != sizeof(ClientTarget_Struct)) {
		LogFile->write(EQEMuLog::Error, "OP size error: OP_TargetMouse expected:%i got:%i", sizeof(ClientTarget_Struct), app->size);
		return;
	}

	if(GetTarget())
	{
		GetTarget()->IsTargeted(-1);
	}

	// Locate and cache new target
	ClientTarget_Struct* ct=(ClientTarget_Struct*)app->pBuffer;
	pClientSideTarget = ct->new_target;
	if(!IsAIControlled())
	{
		Mob *new_target = entity_list.GetMob(ct->new_target);
		if(new_target)
		{
			SetTarget(new_target);
		}
		else
		{
			SetTarget(NULL);
			SetHoTT(0);
			return;
		}
	}
	else
	{
		SetTarget(NULL);
		SetHoTT(0);
		return;
	}

	// <Rogean> HoTT
	if (GetTarget() && GetTarget()->GetTarget()) 
		SetHoTT(GetTarget()->GetTarget()->GetID());
	else 
		SetHoTT(0);

	Group *g = GetGroup();

	if(g && g->IsMainAssist(this))
		g->SetGroupTarget(ct->new_target);

	// For /target, send reject or success packet
	if (app->GetOpcode() == OP_TargetCommand) {
		if (GetTarget() && !GetTarget()->CastToMob()->IsInvisible(this) && DistNoRoot(*GetTarget()) <= TARGETING_RANGE*TARGETING_RANGE) {
			if(GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special 
				|| GetTarget()->GetBodyType() == BT_NoTarget)
			{
				//Targeting something we shouldn't with /target
				//but the client allows this without MQ so you don't flag it
				EQApplicationPacket* outapp = new EQApplicationPacket(OP_TargetReject, sizeof(TargetReject_Struct));
				outapp->pBuffer[0] = 0x2f;
				outapp->pBuffer[1] = 0x01;
				outapp->pBuffer[4] = 0x0d;
				if(GetTarget())
				{
					SetTarget(NULL);
				}
				QueuePacket(outapp);
				safe_delete(outapp);
				return;
			}
			
			QueuePacket(app);
			EQApplicationPacket hp_app;
			GetTarget()->IsTargeted(1);
			GetTarget()->CreateHPPacket(&hp_app);
			QueuePacket(&hp_app, false);
		} 
		else 
		{
			EQApplicationPacket* outapp = new EQApplicationPacket(OP_TargetReject, sizeof(TargetReject_Struct));
			outapp->pBuffer[0] = 0x2f;
			outapp->pBuffer[1] = 0x01;
			outapp->pBuffer[4] = 0x0d;
			if(GetTarget())
			{
				SetTarget(NULL);
			}
			QueuePacket(outapp);
			safe_delete(outapp);
		}
	}
	else
	{
		if(GetTarget())
		{
			if(GetGM())
			{
				GetTarget()->IsTargeted(1);
				return;
			}
			else if(GetTarget()->IsClient())
			{
				//make sure this client is in our raid/group
				GetTarget()->IsTargeted(1);
				return;
			}
			else if(GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special 
				|| GetTarget()->GetBodyType() == BT_NoTarget)
			{
				char *hacker_str = NULL;
				MakeAnyLenString(&hacker_str, "%s attempting to target something untargetable, %s bodytype: %i\n",
					GetName(), GetTarget()->GetName(), (int)GetTarget()->GetBodyType());
				database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName());
				safe_delete_array(hacker_str);
				SetTarget((Mob*)NULL);
				return;
			}
			else if(IsPortExempted())
			{
				GetTarget()->IsTargeted(1);
				return;
			}
			else if(IsSenseExempted())
			{
				GetTarget()->IsTargeted(1);
				SetSenseExemption(false);
				return;
			}
			else if(GetBindSightTarget())
			{
				if(GetBindSightTarget()->DistNoRoot(*GetTarget()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
				{
					if(DistNoRoot(*GetTarget()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
					{
						char *hacker_str = NULL;
						MakeAnyLenString(&hacker_str, "%s attempting to target something beyond the clip plane of %.2f units,"
							" from (%.2f, %.2f, %.2f) to %s (%.2f, %.2f, %.2f)", GetName(),
							(zone->newzone_data.maxclip*zone->newzone_data.maxclip),
							GetX(), GetY(), GetZ(), GetTarget()->GetName(), GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ());
						database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName());
						safe_delete_array(hacker_str);
						SetTarget(NULL);
						return;
					}
				}
			}
			else if(DistNoRoot(*GetTarget()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
			{
				char *hacker_str = NULL;
				MakeAnyLenString(&hacker_str, "%s attempting to target something beyond the clip plane of %.2f units,"
					" from (%.2f, %.2f, %.2f) to %s (%.2f, %.2f, %.2f)", GetName(),
					(zone->newzone_data.maxclip*zone->newzone_data.maxclip),
					GetX(), GetY(), GetZ(), GetTarget()->GetName(), GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ());
				database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName());
				safe_delete_array(hacker_str);
				SetTarget(NULL);
				return;
			}

			GetTarget()->IsTargeted(1);
		}
	}
	return;
}
I will try to look through this later and maybe add in a "if(Admin() < 80)" type of check to allow GMs to use /target from any range. Just need to figure out the best place to put that, but it shouldn't be too hard.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
 


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 10:18 AM.


 

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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3