Skip to content

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

Merged
cbnolok merged 2 commits intoSphereserver:devfrom
mtwango:container-clamping
May 23, 2025
Merged

Clamp item onto container edge, when placed out of bounds#1426
cbnolok merged 2 commits intoSphereserver:devfrom
mtwango:container-clamping

Conversation

@mtwango
Copy link
Copy Markdown
Member

@mtwango mtwango commented May 20, 2025

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

@cbnolok
Copy link
Copy Markdown
Contributor

cbnolok commented May 22, 2025

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

@mtwango
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

mtwango commented May 23, 2025

Updated both.

@cbnolok cbnolok merged commit 37cb1d2 into Sphereserver:dev May 23, 2025
18 checks passed
@mtwango mtwango deleted the container-clamping branch September 26, 2025 10:04
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