Skip to content
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

Chat fixes #358

Merged
merged 12 commits into from
Aug 30, 2024
Merged

Chat fixes #358

merged 12 commits into from
Aug 30, 2024

Conversation

sorokya
Copy link
Contributor

@sorokya sorokya commented Jun 6, 2024

Closes #352

PM recipient not found doesn't play the SFX

I couldn't replicate this. The SFX played for me

Public and Group chat always shows speech bubble over the main character

This was a bug where we were always overwriting the render character with the main character. Now we always find one in _characterRendererProvider.CharacterRenderers with the matching player id

Admin chat does not play sfx when you send a message, only when you receive one

Added sound effect to chat controller when sending message

Group chat does not play sfx when you are on a different map as the sender

We were only looking at party members in the local map repository instead of the party repository before. Now it shows messages from members no matter where they are in game.

PM tab [x] button doesn't work in resizable display mode

I believe this was a render order bug? Seemed like some kinda z-index kind of thing. Adding the Tab clickable area before the close buttons fixed it. I also adjusted the dimensions a bit to match the gfx.

@ethanmoffat
Copy link
Owner

Closes #352

PM recipient not found doesn't play the SFX

I couldn't replicate this. The SFX played for me

I was having a bunch of issues with PMs, so it might work inconsistently. The chat code was some of the first code I rewrote and it has not aged well.

_otherCharacterEventNotifiers = otherCharacterEventNotifiers;
_chatEventNotifiers = chatEventNotifiers;
}

public override bool HandlePacket(TalkOpenServerPacket packet)
{
return Handle(packet, packet.PlayerId);
}
var member = _partyDataProvider.Members.FirstOrDefault(member => member.CharacterID == packet.PlayerId);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been trying to use optional pattern - OptionalFirst(x => x.CharacterID == packet.PlayerId).MatchSome(x => ...) - instead of linq's XOrDefault methods with comparison to null. More functional and all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share an example of what you would do here? I'm not familiar with that I guess

Copy link
Owner

@ethanmoffat ethanmoffat Jun 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used all over the code base - if you search for OptionalFirst solution-wide you'll see the pattern.

There isn't much more to it than the example I gave. It's exactly like SingleOrDefault in that you pass a predicate to the method that provides a match. The result is an Option<T>, which is sort of like OneOf except it's either "Some" or "None". The chained call MatchSome(x => ...) does the action defined in the predicate when the optional has a value.

It's used as a way to avoid the possibility of NullReferenceException being thrown due to a null value. It's a clear way to mark intent and force the caller to handle the return value regardless of whether there is one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MrDanOak has fixed this now using SingleOrNone and MatchSome :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - if you guys sanity check this one more time to make sure the bugs in 352 are all no longer reproducible then I'm cool with merging this

@ethanmoffat
Copy link
Owner

Can you add some details to the PR description about why the fixes work? You have the "what" in the commit history, but I'd like a clear line between "I changed this" and "this is the effect"

@sorokya
Copy link
Contributor Author

sorokya commented Jun 15, 2024

@ethanmoffat PR description updated and can you show an example of how you'd replace the FirstOrDefault usage?

@sorokya sorokya requested a review from ethanmoffat June 15, 2024 13:55
MrDanOak and others added 6 commits August 24, 2024 22:05
Solution: adjust coordinates (and child control offsets) so chat tabs are *only* the click area (and not the full panel size). Fixes bug where right-clicking would always try to dispatch to the sys tab, which wouldn't have name data for the PM target.
Fixes bug where relogging and attempting to PM a character you'd previously PM'd would not show the chat tab for the PM session.
@ethanmoffat ethanmoffat added this to the Version 1 milestone Aug 28, 2024
@ethanmoffat ethanmoffat merged commit d37ba3e into ethanmoffat:master Aug 30, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chat bugs and inconsistencies
3 participants