mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-04 22:40:05 +00:00
faster player distance check
This commit is contained in:
parent
b94f602537
commit
b43628a19d
@ -10,7 +10,7 @@ randomcharacters=false
|
|||||||
[shard]
|
[shard]
|
||||||
port=8002
|
port=8002
|
||||||
# you'll want to change this one
|
# 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
|
# distance at which other players and NPCs become visible
|
||||||
view=20000
|
view=20000
|
||||||
# little message players see when they enter the game
|
# little message players see when they enter the game
|
||||||
|
@ -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 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);
|
int diffY = abs(pair.second.plr.y - Y);
|
||||||
|
|
||||||
double dist = sqrt(pow(diffX, 2) + pow(diffY, 2));
|
if (diffX < settings::VIEWDISTANCE && diffY < settings::VIEWDISTANCE) {
|
||||||
|
|
||||||
if (dist > settings::VIEWDISTANCE) {
|
|
||||||
noView.push_back(pair.first);
|
|
||||||
} else {
|
|
||||||
yesView.push_back(pair.first);
|
yesView.push_back(pair.first);
|
||||||
|
} else {
|
||||||
|
noView.push_back(pair.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user