don't allow players to pick up items if they are too far away
This commit is contained in:
@@ -37,6 +37,14 @@ struct VectorXZF {
|
|||||||
inline double norm2() const {
|
inline double norm2() const {
|
||||||
return ((this->x * this->x) + (this->z * this->z));
|
return ((this->x * this->x) + (this->z * this->z));
|
||||||
}
|
}
|
||||||
|
inline double dist(const VectorXZF& other) const {
|
||||||
|
return sqrt(this->dist2(other));
|
||||||
|
}
|
||||||
|
inline double dist2(const VectorXZF& other) const {
|
||||||
|
double x = this->x - other.x;
|
||||||
|
double z = this->z - other.z;
|
||||||
|
return ((x * x) + (z * z));
|
||||||
|
}
|
||||||
|
|
||||||
inline VectorXZF rotate_y(double angle) const {
|
inline VectorXZF rotate_y(double angle) const {
|
||||||
double s = sin(angle);
|
double s = sin(angle);
|
||||||
|
|||||||
@@ -2264,6 +2264,15 @@ static asio::awaitable<void> on_pick_up_item_generic(
|
|||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Figure out what the actual max range is; 30 is an overestimate
|
||||||
|
double dist2 = fi->pos.dist2(c->pos);
|
||||||
|
if (dist2 > 900.0) {
|
||||||
|
l->log.warning_f("Player {} requests to pick up {:08X}, but it is too far away (dist2={})",
|
||||||
|
client_id, item_id, dist2);
|
||||||
|
l->add_item(floor, fi);
|
||||||
|
co_return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
p->add_item(fi->data, *s->item_stack_limits(c->version()));
|
p->add_item(fi->data, *s->item_stack_limits(c->version()));
|
||||||
} catch (const out_of_range&) {
|
} catch (const out_of_range&) {
|
||||||
|
|||||||
Reference in New Issue
Block a user