Changeset View
Standalone View
source/network/NetMessages.h
Show All 20 Lines | |||||
*/ | */ | ||||
#ifndef NETMESSAGES_H | #ifndef NETMESSAGES_H | ||||
#define NETMESSAGES_H | #define NETMESSAGES_H | ||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#include "scriptinterface/ScriptVal.h" | #include "scriptinterface/ScriptVal.h" | ||||
#define PS_PROTOCOL_MAGIC 0x5073013f // 'P', 's', 0x01, '?' | #define PS_PROTOCOL_MAGIC 0x5073013f // 'P', 's', 0x01, '?' | ||||
#define PS_PROTOCOL_MAGIC_RESPONSE 0x50630121 // 'P', 'c', 0x01, '!' | #define PS_PROTOCOL_MAGIC_RESPONSE 0x50630121 // 'P', 'c', 0x01, '!' | ||||
#define PS_PROTOCOL_VERSION 0x01010015 // Arbitrary protocol | #define PS_PROTOCOL_VERSION 0x01010015 // Arbitrary protocol | ||||
#define PS_DEFAULT_PORT 0x5073 // 'P', 's' | #define PS_DEFAULT_PORT 0x5073 // 'P', 's' | ||||
// Set when lobby authentication is required. Used in the SrvHandshakeResponseMessage. | |||||
#define PS_REQUIRE_LOBBYAUTH_FLAG 0x1 | |||||
// Defines the list of message types. The order of the list must not change. | // Defines the list of message types. The order of the list must not change. | ||||
elexis: Guess we have to go with a flag instead of a bool because it reuses an existing unused but… | |||||
Not Done Inline ActionsSRVHSRES ? What's that supposed to mean? (PS meant prometheus). Maybe PS_FLAG_LOBBYAUTH? elexis: `SRVHSRES` ? What's that supposed to mean? (PS meant prometheus). Maybe `PS_FLAG_LOBBYAUTH`? | |||||
Not Done Inline ActionsServerHandshakeResponse Imarok: ServerHandshakeResponse | |||||
Done Inline ActionsExactly the reason why we don't use abbreviations in names. It wastes the readers time guessing and often we don't even come to a conclusion what it's supposed to mean! So I'd be for a DUABNKWTSF rule for the coding conventions (dont use abbreviations because noone knows what they stand for). elexis: Exactly the reason why we don't use abbreviations in names. It wastes the readers time guessing… | |||||
Done Inline Actions
I would like a response to this comment. Which one seems better? PS_FLAG_SOMETHING PS_FLAG_ELSE PS_FLAG_LITTLE_BIT_DIFFERENT PS_FLAG_VASTLY_DIFFERENT or PS_SOMETHING_FLAG PS_ELSE_FLAG PS_LITTLE_BIT_DIFFERENT_FLAG PS_VASTLY_DIFFERENT_FLAG Also we have many places where we flags could be used, so probably better to add a prefix like PS_SERVER_FLAG_, PS_NETMESSAGE_FLAG, PS_PROTOCOL_FLAG_ or PS_NETWORK_FLAG_. elexis: > Maybe PS_FLAG_LOBBYAUTH?
> (The flag should come first, so that it's nicely aligned if there… | |||||
// The message types having a negative value are used internally and not sent | // The message types having a negative value are used internally and not sent | ||||
// over the network. The message types used for network communication have | // over the network. The message types used for network communication have | ||||
// positive values. | // positive values. | ||||
enum NetMessageType | enum NetMessageType | ||||
{ | { | ||||
NMT_CONNECT_COMPLETE = -256, | NMT_CONNECT_COMPLETE = -256, | ||||
NMT_CONNECTION_LOST, | NMT_CONNECTION_LOST, | ||||
NMT_INVALID = 0, | NMT_INVALID = 0, | ||||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |
Guess we have to go with a flag instead of a bool because it reuses an existing unused but possibly usable flag field in the handshake message.
The define should still have a comment or better a name that indicates for which packet type its going to be used.