Skip to content

Conversation

@texastoastt
Copy link

I affirm:

  • I understand that if I do not agree to the following points by completing the checkboxes my PR will be ignored.
  • I understand I should leave resolving conversations to the LandSandBoat team so that reviewers won't miss what was said.
  • I have read and understood the Contributing Guide and the Code of Conduct.
  • I have tested my code and the things my code has changed since the last commit in the PR and will test after any later commits.

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.

@texastoastt texastoastt marked this pull request as ready for review January 12, 2026 22:47
Copy link
Contributor

@zach2good zach2good left a 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.

@zach2good
Copy link
Contributor

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{};
};

@texastoastt
Copy link
Author

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.

@texastoastt
Copy link
Author

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.

@zach2good zach2good added the squash Reminder to squash commits before/on merge (you can do this, or maintainers will do this for you) label Jan 13, 2026
@texastoastt texastoastt changed the title [Tools, cpp] Fix announce.py and adds native announce command from tools directory [Tools, py] Fix announce.py and adds native announce command from tools directory Jan 13, 2026
sender = ""

# alpaca encoding for:
# Alpaca encoding for ChatMessageServerMessage (ID=12)
Copy link
Contributor

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

Copy link
Author

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')
Copy link
Contributor

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?

Copy link
Author

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++)
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

(network to host long)

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

squash Reminder to squash commits before/on merge (you can do this, or maintainers will do this for you)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants