-
Notifications
You must be signed in to change notification settings - Fork 811
[Tools, py] Fix announce.py and adds native announce command from tools directory #9123
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
base: base
Are you sure you want to change the base?
Conversation
zach2good
left a comment
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.
This is much more complex than it needs to be. You only need to update the layout of the message produced by the existing python script and it'll start working again. You can see the new layout in ipc_stubs, I believe, or somewhere near there.
struct ChatMessageServerMessage
{
uint32 senderId{};
std::string senderName{};
std::string message{};
uint16 zoneId{};
uint8 gmLevel{};
CHAT_MESSAGE_TYPE messageType{ MESSAGE_SYSTEM_1 };
bool skipSender{};
};
struct ChatMessageCustom
{
uint32 recipientId{};
std::string senderName{};
std::string message{};
CHAT_MESSAGE_TYPE messageType{};
}; |
|
I ran into some alpaca issues trying to update the existing script but with what you just sent, I think I know why. Not sure how I missed that when I went digging. Going to make another pass at this with that info. |
|
Ok got it sorted as a python standalone and removed the previous stuff that ultimately isn't needed anymore. I absolutely over-complicated trying to understand the alpaca encoding which took me down the wrong rabbit hole previously. |
| sender = "" | ||
|
|
||
| # alpaca encoding for: | ||
| # Alpaca encoding for ChatMessageServerMessage (ID=12) |
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.
This is now giving conflicting information with 2 lines below
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.
Yep, sorry. That's an artifact from my troubleshooting.
| buffer[idx] = len(sender) | ||
| idx += 1 | ||
| # senderName (std::string) - varint length + UTF-8 data | ||
| sender_bytes = sender.encode('utf-8') |
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 is this utf-8, we aren't using that in the C++ side?
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.
This is my misunderstanding, as i see utf-8 in the db and other places. What character set do i need to use for this specifically, and I'm happy to adjust.
| (ip_int,) = struct.unpack("!I", ip_bytes) | ||
| ipp = ip_int | (port << 32) | ||
| ipp_bytes = struct.pack("!Q", ipp) | ||
| # Convert to host byte order (like ntohl in C++) |
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.
Comment is redundant, it's already called socket.ntohl
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.
(network to host long)
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're right. Will fix that.
I affirm:
What does this pull request do?
Restores the expected behavior of announce.py by sending a system message to all players in all zones. Due to changes in messageType, announce.cpp and accompanying CMakeupdates required to build the new native executable. announce.py was also update for backward compatibility to call the new native exe.
Steps to test these changes
From the server/tools/ directory, use either ./announce "TEST MESSAGE" or python3 announce.py "TEST MESSAGE" to confirm message sent in-game.