Skip to content

Commit

Permalink
Some small tweaks to reduce the amount of SendPosUpdates() are actual…
Browse files Browse the repository at this point in the history
…ly getting sent out on the wire.
  • Loading branch information
KimLS committed Jul 9, 2015
1 parent 3455d70 commit 753f53b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
14 changes: 9 additions & 5 deletions zone/mob.cpp
Expand Up @@ -1395,19 +1395,23 @@ void Mob::SendPosUpdate(uint8 iSendToSelf) {
MakeSpawnUpdate(spu);

if (iSendToSelf == 2) {
if (this->IsClient())
this->CastToClient()->FastQueuePacket(&app,false);
if (IsClient()) {
CastToClient()->FastQueuePacket(&app,false);
}
}
else
{
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;
}
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++;
}
}
Expand Down
28 changes: 5 additions & 23 deletions zone/waypoints.cpp
Expand Up @@ -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) {
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 angle;

Expand Down Expand Up @@ -656,6 +635,11 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo

else {
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_y = m_Position.y + m_TargetV.y*tar_vector;
Expand Down Expand Up @@ -717,8 +701,6 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
}
else
{
// force an update now
move_tic_count = RuleI(Zone, NPCPositonUpdateTicCount);
SendPosUpdate();
SetAppearance(eaStanding, false);
}
Expand Down

0 comments on commit 753f53b

Please sign in to comment.