-
Notifications
You must be signed in to change notification settings - Fork 11
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
Private chat mode #1
Conversation
… other. The sender can either pass the player's name with "sayto" or a player's number with "sayto_idx". Alternatively, players can send private messages to the server by passing "server" as a name.
I'm finishing up on these adjustments, if that's everything. I should have a new commit ready very soon. EDIT: Just committed the adjustments, I hope these are okay. One more thing, I added extra code to allow the client to cycle backwards through the player list if they're pressing TAB + SHIFT. Otherwise, it cycles forward with just TAB. |
Yes, I'm done checking and commented on everything I noticed. |
Sorry for overlooking the changes in |
No worries! I'm glad we took a good look in this file to see where things need to be improved for next time. I'll probably have these changes ready for next week, if that's okay. Thanks for the feedback! |
Sure, there's no rush. Have a nice week! |
Thank you, you as well. :) |
I submitted a couple of new commits.
I also added more commits, some of which aren't necessarily related to the private chat:
EDIT: An index of 0 returns the newest chat message, and 2 returns the oldest chat message. |
Sure, will do.
|
I managed to fix it, Torr. |
// [AK] Allows players (or the server) to send private messages to other players. | ||
// | ||
void chat_PrivateMessage( FCommandLine &argv, const ULONG ulReceiver, const bool bServerSelected ) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a separate argument bServerSelected
to encode the server as target instead of just using ulReceiver == MAXPLAYERS
?
BTW: Sorry that this comment only shows up now. I posted it last week but unfortunately using "Start a review" instead of "Add single comment". I just now realized that you couldn't see it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for asking. I added bServerSelected
to ignore all the extra checks required to validate another player being the receiver, if the client explicitly chooses to the server. If the client wants indicates that they want to send a private message to the server using sayto server
or sayto_idx -1
, then it's not necessary to check if the receiver is invalid, a bot, ourselves, etc.
Additionally, if bServerSelected
is true, then the function chat_FindValidReceiver
won't be entered at all. If we did enter that function and there was only one client connected, then the message "There's no other clients to send private messages to. The server will be selected instead." would always appear in the console, even if the client intentionally chose to send a private message to the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also bypass all those checks by using ulReceiver == MAXPLAYERS
instead of bServerSelected
. For instance, you could add const bool bServerSelected = (ulReceiver == MAXPLAYERS);
in the first line of the implementation of chat_PrivateMessage
and keep the rest of chat_PrivateMessage
untouched (except for removing the argument bServerSelected
). Perhaps there is a reason why you don't want to encode the information bServerSelected
in the argument ulReceiver
, but right now I don't see it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, I can change that quickly and resubmit it if you're still around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm still around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I gotta go now. I should be able to add this tomorrow though.
Thanks! Looking all good now, except for the one comment I didn't properly post last week. Sorry for that. |
src/chat.cpp
Outdated
{ | ||
ULONG ulIdx; | ||
FString ChatString; | ||
const bool bServerSelected = ulReceiver; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be const bool bServerSelected = (ulReceiver == MAXPLAYERS);
?
EDIT: Now I'm really gone for today ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I forgot to fix that (really stupid mistake). :(
EDIT: Uploaded the now fixed commit, so sorry about that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I compressed, rebased and added this patch. |
This adds a new chat mode to Zandronum, allowing the player (or the server) to send chat messages privately to another player. Nobody else can see these messages and they won't be logged into the server's chat log, unless the server is sending or receiving a private message.