Refactor server chat handling by extracting methods#3741
Conversation
…k method to MathUtils
80a5147 to
562d6c6
Compare
|
|
||
| // return true if a value is inside a given range, otherwise false | ||
| template<typename T> | ||
| static inline bool InRange ( T value, T lower, T upper ) |
There was a problem hiding this comment.
The Java/C# programmer in me wants this as an extension to Comparable<T>, so that
(<Comparable<Int>>32).inRange(0, 100)
returns true. Don't know if C++ can do better than what you've got here, though. (What you should do is constraint T somehow, really.)
There was a problem hiding this comment.
Don't know if C++ can do better than what you've got here, though. (What you should do is constraint
Tsomehow, really.)
This function cannot be called from the outside so I think we should be safe here.
The first placed I searched for range validating functions was the Jamulus source code, then Qt docs because I thought there must be something there. Then I wrote this :) If we don't need it and it might cause issues I'm happy to remove it and do the sanity checks locally.
Co-authored-by: Peter L Jones <pljones@users.noreply.github.com>
Co-authored-by: Peter L Jones <pljones@users.noreply.github.com>
Short description of changes
This refactors
CServer::CreateAndSendChatTextForAllConChannelsinto three functions for sending messages.The extracted methods
As it is now possible to call the function to send a message to a channel directly, the channel number needs to be boundary checked.
A function
InRange()was introduced intoutil.hfor that purpose.CHANGELOG: Refactor server chat handling by extracting methods
Context: Fixes an issue?
Not yet ;)
Does this change need documentation? What needs to be documented and how?
No
Status of this Pull Request
Ready for review
What is missing until this pull request can be merged?
Review, Approval
Checklist