Skip to content

Commit

Permalink
Prevent client update while on boat if boat turning (#1343)
Browse files Browse the repository at this point in the history
Co-authored-by: Noudess <noudess@gmail.com>
  • Loading branch information
Paul Coene and noudess authored May 10, 2021
1 parent 0758250 commit b335568
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions zone/client_packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4474,6 +4474,8 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
LogError("Can't find boat for client position offset.");
}
else {
if (boat->turning) return;

// Calculate angle from boat heading to EQ heading
double theta = std::fmod(((boat->GetHeading() * 360.0) / 512.0),360.0);
double thetar = (theta * M_PI) / 180.0;
Expand Down
1 change: 1 addition & 0 deletions zone/mob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Mob::Mob(
AI_Init();
SetMoving(false);
moved = false;
turning = false;
m_RewindLocation = glm::vec3();
m_RelativePosition = glm::vec4();

Expand Down
1 change: 1 addition & 0 deletions zone/mob.h
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,7 @@ class Mob : public Entity {
bool GetWasSpawnedInWater() const;

void SetSpawnedInWater(bool spawned_in_water);
bool turning;

protected:

Expand Down
4 changes: 4 additions & 0 deletions zone/mob_movement_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class RotateToCommand : public IMovementCommand {

if (!m_started) {
m_started = true;
mob->turning = true;
mob->SetMoving(true);

if (dist > 15.0f && rotate_to_speed > 0.0 && rotate_to_speed <= 25.0) { //send basic rotation
Expand All @@ -84,6 +85,7 @@ class RotateToCommand : public IMovementCommand {
mob->SetHeading(to);
mob->SetMoving(false);
mob_movement_manager->SendCommandToClients(mob, 0.0, 0.0, 0.0, 0.0, 0, ClientRangeCloseMedium);
mob->turning = false;
return true;
}

Expand Down Expand Up @@ -1370,7 +1372,9 @@ void MobMovementManager::UpdatePathBoat(Mob *who, float x, float y, float z, Mob
{
auto eiter = _impl->Entries.find(who);
auto &ent = (*eiter);
float to = who->CalculateHeadingToTarget(x, y);

PushRotateTo(ent.second, who, to, mode);
PushSwimTo(ent.second, x, y, z, mode);
PushStopMoving(ent.second);
}
Expand Down

0 comments on commit b335568

Please sign in to comment.