From b43628a19dcbb63d3696cbeb073f874be829dc33 Mon Sep 17 00:00:00 2001 From: CPunch Date: Thu, 20 Aug 2020 13:19:03 -0500 Subject: [PATCH] faster player distance check --- config.ini | 2 +- src/PlayerManager.cpp | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/config.ini b/config.ini index 25afe4e..bd72bbc 100644 --- a/config.ini +++ b/config.ini @@ -10,7 +10,7 @@ randomcharacters=false [shard] port=8002 # you'll want to change this one -ip=192.168.0.17 +ip=192.168.1.183 # distance at which other players and NPCs become visible view=20000 # little message players see when they enter the game diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index 4a5b095..021cd57 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -79,12 +79,10 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) { int diffX = abs(pair.second.plr.x - X); // the map is like a grid, X and Y are your position on the map, Z is the height. very different from other games... int diffY = abs(pair.second.plr.y - Y); - double dist = sqrt(pow(diffX, 2) + pow(diffY, 2)); - - if (dist > settings::VIEWDISTANCE) { - noView.push_back(pair.first); - } else { + if (diffX < settings::VIEWDISTANCE && diffY < settings::VIEWDISTANCE) { yesView.push_back(pair.first); + } else { + noView.push_back(pair.first); } }