Skip to content

Clamp item onto container edge, when placed out of bounds #1426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2025

Conversation

mtwango
Copy link
Member

@mtwango mtwango commented May 20, 2025

Replicating client behaviour, otherwise it will just bounce to random loc in container.

@cbnolok
Copy link
Contributor

cbnolok commented May 22, 2025

Could you use lesser than 0 instead of - 1? Might be more robust

@mtwango
Copy link
Member Author

mtwango commented May 23, 2025

I used -1 because it is explicitly defined in CPointBase::InitPoint(). All other option fall to clamping to edges, but I can change that.

And maybe change that min/max for clamp?

@cbnolok
Copy link
Contributor

cbnolok commented May 23, 2025

Yes i thought so, but it's easy to do a fast change in other parts of the code and cause subtle bugs.
Std clamp is maybe more elegant but absolutely your choice!

- swap min + max to clamp
@mtwango
Copy link
Member Author

mtwango commented May 23, 2025

Updated both.

@cbnolok cbnolok merged commit 37cb1d2 into Sphereserver:dev May 23, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants