Skip to content

feat: add new NETMSG_DEDIMSG for private comms to game server#2957

Draft
bruno-dasilva wants to merge 1 commit into
masterfrom
bruno/stats-api-1
Draft

feat: add new NETMSG_DEDIMSG for private comms to game server#2957
bruno-dasilva wants to merge 1 commit into
masterfrom
bruno/stats-api-1

Conversation

@bruno-dasilva

@bruno-dasilva bruno-dasilva commented May 3, 2026

Copy link
Copy Markdown
Collaborator

First PR: game packet #2040
Second PR: hook up to autohost #2040
Third PR: usage of game packets with a small engine stats api, local file #2041
Fourth PR: send default engine stats through this API

@bruno-dasilva

bruno-dasilva commented May 3, 2026

Copy link
Copy Markdown
Collaborator Author

NETMSG_PING = 78, // uint8_t playerNum, uint8_t pingTag, float localTime

NETMSG_DEDIMSG = 79, // /* uint16_t messageSize */, uint8_t playerNum, uint16_t header, std::vector<uint8_t> payload

@bruno-dasilva bruno-dasilva May 3, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

im sure there is a better name than dedimsg... but im ironing out use cases right now. open to suggestions

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

HOSTMSG?

*packet << static_cast<uint16_t>(packetSize) << playerNum << header << payload;
return PacketType(packet);
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

xref #2712 (comment)

a universal "freestyle data" packet with a bunch of specifiable traits (whether to leave replay trace, which players or network clients to send to, which "internal" destination eg Lua env, etc), and that LUAMSG is already such relatively universal packet to some extent (with script and mode being ways to choose from a bunch of bundles of traits). I don't know, it sounds reasonable actually but somehow not right, though I can't quite put my finger on it.

This is a possible, more flexible but more complex alternative implementation. LMK what you think.

@sprunk

sprunk commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Looks directionally correct. The name should probably be something along the lines of "secret host message" since this isn't specific to dedi.

Comment on lines +3908 to +3910
* record-type header. The header is engine-encoded little-endian and must be
* in the game-private range 0x1000..0xFFFF; values below 0x1000 are reserved
* for engine use.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what does the header do? what do its numerical values mean? why does the engine reserve 0-4095?

NETMSG_PING = 78, // uint8_t playerNum, uint8_t pingTag, float localTime

NETMSG_DEDIMSG = 79, // /* uint16_t messageSize */, uint8_t playerNum, uint16_t header, std::vector<uint8_t> payload

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

HOSTMSG?

Comment thread rts/Net/GameServer.cpp
Comment on lines +1367 to +1370
if (playerNum != a) {
Message(spring::format(WrongPlayer, msgCode, a, (unsigned)playerNum));
break;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

playerNum is redundant

throw netcode::PackPacketException("[BaseNetProto::SendDediMsg] maximum packet-size exceeded");

PackPacket* packet = new PackPacket(packetSize, NETMSG_DEDIMSG);
*packet << static_cast<uint16_t>(packetSize) << playerNum << header << payload;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

putting packetSize into the packet is probably redundant

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