Skip to content

Implement buddy freechat and menuchat#11

Merged
yungcomputerchair merged 2 commits into
yungcomputerchair:mainfrom
lwcasgc:buddies
Nov 8, 2025
Merged

Implement buddy freechat and menuchat#11
yungcomputerchair merged 2 commits into
yungcomputerchair:mainfrom
lwcasgc:buddies

Conversation

@lwcasgc

@lwcasgc lwcasgc commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@yungcomputerchair yungcomputerchair left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Overall pretty good; the PCID hashmap is awesome and all of the plumbing for cross-shard is there. Just need to add buddy validation, fix the freechat processing, take care of some error handling, and fix the packet name

Comment thread src/bin/shard/chat.rs Outdated
Comment on lines +234 to +239
if !helpers::validate_menuchat_message(&msg) {
return Err(FFError::build(
Severity::Warning,
format!("Invalid menuchat message\n\t{}: '{}'", player, msg),
));
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

For freechat, we don't run validation. Instead we run it through the freechat processor (which does nothing today, but will do things like censor words in the future).

Suggested change
if !helpers::validate_menuchat_message(&msg) {
return Err(FFError::build(
Severity::Warning,
format!("Invalid menuchat message\n\t{}: '{}'", player, msg),
));
}
let msg = helpers::process_freechat_message(msg);

Comment thread src/bin/shard/chat.rs
Comment thread src/bin/shard/chat.rs Outdated
}
}

let login_server = clients.get_login_server().unwrap();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Using unwrap here is very dangerous, because if communication to the login server is lost, this will crash the shard server. We should log a warning and stop if the login server isn't connected.

Suggested change
let login_server = clients.get_login_server().unwrap();
if let Some(login_server) = clients.get_login_server() {
...
} else {
// warn here
}

Comment thread src/bin/shard/chat.rs
Ok(())
}

pub fn send_buddy_menuchat_message(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Most of my comments on the freechat handler apply here too, just not the ones about freechat processing

Comment thread src/bin/shard/login.rs Outdated
buddy_client
.send_packet(P_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, &response_pkt)?;

let login_server = clients.get_login_server().unwrap();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

See earlier comment about avoiding unwrap() on the login server. Yes, the packet came from the login server, but I believe it's possible for the login server to disconnect before the packet starts processing

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I might be guilty of making this assumption in some parts of my code...

Comment thread src/bin/shard/chat.rs Outdated
let response_pkt = sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC {
iFromPCUID: player.get_uid(),
iToPCUID: pkt.iBuddyPCUID,
szFreeChat: pkt.szFreeChat,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Unlike menuchat messages where we fail out if they're invalid, we might modify freechat messages with process_freechat_message, so you should re-encode the modified string here instead of copying from the initial packet

Comment thread src/net/packet.rs Outdated
#[repr(packed(4))]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sP_LS2FE_REP_SEND_BUDDY_FREECHAT {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This packet should definitely be REQ instead of REP since the login server is requesting that the message be sent to the player; you'll need to update in a few spots

@yungcomputerchair yungcomputerchair left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM

@yungcomputerchair
yungcomputerchair merged commit ee7b862 into yungcomputerchair:main Nov 8, 2025
3 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