Some small tweaks to reduce the amount of SendPosUpdates() are actually getting sent out on the wire.

This commit is contained in:
KimLS 2015-07-08 17:10:33 -07:00
parent 3455d70ca2
commit 753f53be1b
2 changed files with 14 additions and 28 deletions

View File

@ -1395,19 +1395,23 @@ void Mob::SendPosUpdate(uint8 iSendToSelf) {
MakeSpawnUpdate(spu); MakeSpawnUpdate(spu);
if (iSendToSelf == 2) { if (iSendToSelf == 2) {
if (this->IsClient()) if (IsClient()) {
this->CastToClient()->FastQueuePacket(&app,false); CastToClient()->FastQueuePacket(&app,false);
}
} }
else else
{ {
if(move_tic_count == RuleI(Zone, NPCPositonUpdateTicCount)) if(move_tic_count == RuleI(Zone, NPCPositonUpdateTicCount))
{ {
entity_list.QueueClients(this, app, (iSendToSelf==0), false); entity_list.QueueClients(this, app, (iSendToSelf == 0), false);
move_tic_count = 0; move_tic_count = 0;
} }
else else if(move_tic_count % 2 == 0)
{ {
entity_list.QueueCloseClients(this, app, (iSendToSelf==0), 800, nullptr, false); entity_list.QueueCloseClients(this, app, (iSendToSelf == 0), 700, nullptr, false);
move_tic_count++;
}
else {
move_tic_count++; move_tic_count++;
} }
} }

View File

@ -443,31 +443,10 @@ void NPC::NextGuardPosition() {
} }
} }
/*
// we need this for charmed NPCs
void Mob::SaveSpawnSpot() {
spawn_x = x_pos;
spawn_y = y_pos;
spawn_z = z_pos;
spawn_heading = heading;
}*/
/*float Mob::CalculateDistanceToNextWaypoint() {
return CalculateDistance(cur_wp_x, cur_wp_y, cur_wp_z);
}*/
float Mob::CalculateDistance(float x, float y, float z) { float Mob::CalculateDistance(float x, float y, float z) {
return (float)sqrtf( ((m_Position.x-x)*(m_Position.x-x)) + ((m_Position.y-y)*(m_Position.y-y)) + ((m_Position.z-z)*(m_Position.z-z)) ); return (float)sqrtf( ((m_Position.x-x)*(m_Position.x-x)) + ((m_Position.y-y)*(m_Position.y-y)) + ((m_Position.z-z)*(m_Position.z-z)) );
} }
/*
uint8 NPC::CalculateHeadingToNextWaypoint() {
return CalculateHeadingToTarget(cur_wp_x, cur_wp_y);
}
*/
float Mob::CalculateHeadingToTarget(float in_x, float in_y) { float Mob::CalculateHeadingToTarget(float in_x, float in_y) {
float angle; float angle;
@ -656,6 +635,11 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
else { else {
tar_vector/=16.0f; tar_vector/=16.0f;
float dur = Timer::SetCurrentTime() - pLastChange;
if(dur < 1.0f) {
dur = 1.0f;
}
tar_vector = (tar_vector * AImovement_duration) / 100.0f;
float new_x = m_Position.x + m_TargetV.x*tar_vector; float new_x = m_Position.x + m_TargetV.x*tar_vector;
float new_y = m_Position.y + m_TargetV.y*tar_vector; float new_y = m_Position.y + m_TargetV.y*tar_vector;
@ -717,8 +701,6 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
} }
else else
{ {
// force an update now
move_tic_count = RuleI(Zone, NPCPositonUpdateTicCount);
SendPosUpdate(); SendPosUpdate();
SetAppearance(eaStanding, false); SetAppearance(eaStanding, false);
} }