2003-11-25 03:11:50 +01:00
|
|
|
#ifndef _AllNetMessages_H
|
|
|
|
#define _AllNetMessages_H
|
|
|
|
|
2005-02-26 16:13:15 +01:00
|
|
|
#include "lib/types.h"
|
2003-11-30 17:36:43 +01:00
|
|
|
#include "CStr.h"
|
2004-11-11 08:09:32 +01:00
|
|
|
#include "scripting/JSSerialization.h"
|
2003-11-25 03:11:50 +01:00
|
|
|
|
2004-03-08 03:03:24 +01:00
|
|
|
enum ENetMessageType
|
2003-11-25 03:11:50 +01:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
All Message Types should be put here. Never change the order of this
|
|
|
|
list.
|
|
|
|
First, all negative types are only for internal/local use and may never
|
|
|
|
be sent over the network.
|
2005-02-21 18:13:31 +01:00
|
|
|
After that, all "real" network messages are listed, giving them a value
|
|
|
|
from 0 and upwards (*unique* value)
|
2003-11-25 03:11:50 +01:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* A special message that contains a PS_RESULT code, used for delivery of
|
|
|
|
* OOB error status messages from a CMessageSocket
|
|
|
|
*/
|
2004-03-08 03:03:24 +01:00
|
|
|
NMT_ERROR=-256,
|
|
|
|
/**
|
|
|
|
* The message socket connect attempt is complete
|
|
|
|
*/
|
|
|
|
NMT_CONNECT_COMPLETE,
|
|
|
|
/**
|
|
|
|
* Close the message socket
|
|
|
|
*/
|
|
|
|
NMT_CLOSE_REQUEST,
|
2003-11-25 03:11:50 +01:00
|
|
|
/**
|
|
|
|
* An invalid message type, representing an uninitialized message.
|
|
|
|
*/
|
|
|
|
NMT_NONE=0,
|
|
|
|
|
2005-02-21 18:13:31 +01:00
|
|
|
/* Handshake Stage */
|
2004-03-08 03:03:24 +01:00
|
|
|
NMT_ServerHandshake,
|
|
|
|
NMT_ClientHandshake,
|
|
|
|
NMT_ServerHandshakeResponse,
|
2005-02-21 18:13:31 +01:00
|
|
|
/* Authentication Stage */
|
2004-03-08 03:03:24 +01:00
|
|
|
NMT_Authenticate,
|
2005-02-21 18:13:31 +01:00
|
|
|
NMT_AuthenticationResult,
|
|
|
|
/* Common Messages, stage 3-5 */
|
2004-08-16 17:19:17 +02:00
|
|
|
NMT_ChatMessage,
|
2005-02-21 18:13:31 +01:00
|
|
|
/* Pre-Game Stage */
|
|
|
|
NMT_ClientConnect,
|
|
|
|
NMT_ClientDisconnect,
|
2004-08-16 17:19:17 +02:00
|
|
|
NMT_SetGameConfig,
|
2005-02-21 18:13:31 +01:00
|
|
|
NMT_AssignPlayerSlot,
|
2005-01-17 05:52:02 +01:00
|
|
|
NMT_SetPlayerConfig,
|
2004-03-08 03:03:24 +01:00
|
|
|
NMT_FilesRequired,
|
|
|
|
NMT_FileRequest,
|
|
|
|
NMT_FileChunk,
|
|
|
|
NMT_FileChunkAck,
|
|
|
|
NMT_FileProgress,
|
2004-08-16 17:19:17 +02:00
|
|
|
NMT_StartGame,
|
2005-02-21 18:13:31 +01:00
|
|
|
/* In-Game Stage */
|
2004-03-08 03:03:24 +01:00
|
|
|
NMT_EndCommandBatch,
|
2004-08-16 17:19:17 +02:00
|
|
|
NMT_COMMAND_FIRST,
|
|
|
|
NMT_GotoCommand=NMT_COMMAND_FIRST,
|
|
|
|
NMT_COMMAND_LAST=NMT_GotoCommand,
|
2005-02-21 18:13:31 +01:00
|
|
|
/* Post-Game Stage */
|
2004-03-08 03:03:24 +01:00
|
|
|
|
2003-11-25 03:11:50 +01:00
|
|
|
/**
|
|
|
|
* One higher than the highest value of any message type
|
|
|
|
*/
|
|
|
|
NMT_LAST // Always put this last in the list
|
|
|
|
};
|
|
|
|
|
2005-02-21 18:13:31 +01:00
|
|
|
/**
|
|
|
|
Only applies to NMT_AuthenticationResult (as of now).
|
|
|
|
*/
|
2004-03-08 03:03:24 +01:00
|
|
|
enum ENetResultCodes
|
|
|
|
{
|
|
|
|
NRC_OK,
|
|
|
|
NRC_PasswordInvalid,
|
|
|
|
NRC_NickTaken,
|
|
|
|
NRC_NickInvalid,
|
|
|
|
};
|
|
|
|
|
|
|
|
// These constants (magic numbers) are highly arbitrary, but have been chosen
|
|
|
|
// such that they should be unlikely to stumble across randomly.
|
|
|
|
|
|
|
|
// in network byte order: 'P', 's', 0x01, '?'
|
|
|
|
#define PS_PROTOCOL_MAGIC 0x5073013f
|
|
|
|
// in network byte order: 'P', 'c', 0x01, '!'
|
|
|
|
#define PS_PROTOCOL_MAGIC_RESPONSE 0x50630121
|
|
|
|
|
|
|
|
// At a later date, there should be a standard for assigning protocol version
|
|
|
|
// numbers. For now, this also highly arbitrary number will hold its place
|
2005-02-21 18:13:31 +01:00
|
|
|
// 1.1.2
|
|
|
|
#define PS_PROTOCOL_VERSION 0x01010002
|
2004-03-08 03:03:24 +01:00
|
|
|
|
2004-08-16 17:19:17 +02:00
|
|
|
// 0x5073 = decimal 20595
|
|
|
|
// The "symbolism" is that the two bytes of the port number in network byte
|
|
|
|
// order is 'P' 's'
|
|
|
|
#define PS_DEFAULT_PORT 0x5073
|
|
|
|
|
|
|
|
// Chat Recipient Constants
|
|
|
|
enum
|
|
|
|
{
|
2005-02-21 18:13:31 +01:00
|
|
|
// Any chat recipients lower than this one is an actual session ID
|
|
|
|
PS_CHAT_RCP_FIRST_SPECIAL=0xfffd,
|
2004-08-16 17:19:17 +02:00
|
|
|
PS_CHAT_RCP_ENEMIES=0xfffd,
|
|
|
|
PS_CHAT_RCP_ALLIES=0xfffe,
|
|
|
|
PS_CHAT_RCP_ALL=0xffff,
|
|
|
|
};
|
|
|
|
|
2005-02-21 18:13:31 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PS_ASSIGN_OPEN,
|
|
|
|
PS_ASSIGN_CLOSED,
|
|
|
|
PS_ASSIGN_AI,
|
|
|
|
PS_ASSIGN_SESSION
|
|
|
|
};
|
|
|
|
|
2003-11-25 03:11:50 +01:00
|
|
|
#endif // #ifndef _AllNetMessage_H
|
|
|
|
|
|
|
|
#ifdef CREATING_NMT
|
|
|
|
|
|
|
|
#define ALLNETMSGS_DONT_CREATE_NMTS
|
2004-03-08 03:03:24 +01:00
|
|
|
#define START_NMT_CLASS_(_nm) START_NMT_CLASS(C ## _nm, NMT_ ## _nm)
|
2003-11-25 03:11:50 +01:00
|
|
|
|
|
|
|
START_NMTS()
|
|
|
|
|
2004-03-08 03:03:24 +01:00
|
|
|
START_NMT_CLASS_(ServerHandshake)
|
|
|
|
NMT_FIELD_INT(m_Magic, u32, 4)
|
|
|
|
NMT_FIELD_INT(m_ProtocolVersion, u32, 4)
|
|
|
|
NMT_FIELD_INT(m_SoftwareVersion, u32, 4)
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
|
|
|
START_NMT_CLASS_(ClientHandshake)
|
|
|
|
NMT_FIELD_INT(m_MagicResponse, u32, 4)
|
|
|
|
NMT_FIELD_INT(m_ProtocolVersion, u32, 4)
|
|
|
|
NMT_FIELD_INT(m_SoftwareVersion, u32, 4)
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
|
|
|
START_NMT_CLASS_(ServerHandshakeResponse)
|
|
|
|
NMT_FIELD_INT(m_UseProtocolVersion, u32, 4)
|
|
|
|
NMT_FIELD_INT(m_Flags, u32, 4)
|
2004-08-16 17:19:17 +02:00
|
|
|
NMT_FIELD(CStrW, m_Message)
|
2004-03-08 03:03:24 +01:00
|
|
|
END_NMT_CLASS()
|
|
|
|
|
2005-02-21 18:13:31 +01:00
|
|
|
START_NMT_CLASS_(AuthenticationResult)
|
2004-07-04 17:41:17 +02:00
|
|
|
NMT_FIELD_INT(m_Code, u32, 4)
|
2005-02-21 18:13:31 +01:00
|
|
|
NMT_FIELD_INT(m_SessionID, u32, 2)
|
2004-08-16 17:19:17 +02:00
|
|
|
NMT_FIELD(CStrW, m_Message)
|
2004-07-04 17:41:17 +02:00
|
|
|
END_NMT_CLASS()
|
|
|
|
|
2004-03-08 03:03:24 +01:00
|
|
|
START_NMT_CLASS_(Authenticate)
|
2004-08-16 17:19:17 +02:00
|
|
|
NMT_FIELD(CStrW, m_Name)
|
2004-03-08 03:03:24 +01:00
|
|
|
//NMT_FIELD(CPasswordHash, m_Password)
|
2005-01-19 23:32:25 +01:00
|
|
|
NMT_FIELD(CStrW, m_Password)
|
2004-03-08 03:03:24 +01:00
|
|
|
END_NMT_CLASS()
|
|
|
|
|
2004-08-16 17:19:17 +02:00
|
|
|
START_NMT_CLASS_(ChatMessage)
|
|
|
|
NMT_FIELD(CStrW, m_Sender)
|
2004-03-08 03:03:24 +01:00
|
|
|
NMT_FIELD_INT(m_Recipient, u32, 2)
|
2004-08-16 17:19:17 +02:00
|
|
|
NMT_FIELD(CStrW, m_Message)
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
2005-02-21 18:13:31 +01:00
|
|
|
START_NMT_CLASS_(ClientConnect)
|
|
|
|
NMT_START_ARRAY(m_Clients)
|
|
|
|
NMT_FIELD_INT(m_SessionID, u32, 2)
|
|
|
|
NMT_FIELD(CStrW, m_Name)
|
|
|
|
NMT_END_ARRAY()
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
|
|
|
START_NMT_CLASS_(ClientDisconnect)
|
|
|
|
NMT_FIELD_INT(m_SessionID, u32, 2)
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
2004-08-16 17:19:17 +02:00
|
|
|
START_NMT_CLASS_(SetGameConfig)
|
|
|
|
NMT_START_ARRAY(m_Values)
|
2005-01-19 23:32:25 +01:00
|
|
|
NMT_FIELD(CStrW, m_Name)
|
2004-08-16 17:19:17 +02:00
|
|
|
NMT_FIELD(CStrW, m_Value)
|
|
|
|
NMT_END_ARRAY()
|
2003-11-25 03:11:50 +01:00
|
|
|
END_NMT_CLASS()
|
|
|
|
|
2005-02-21 18:13:31 +01:00
|
|
|
START_NMT_CLASS_(AssignPlayerSlot)
|
|
|
|
NMT_FIELD_INT(m_SlotID, u32, 2)
|
|
|
|
NMT_FIELD_INT(m_Assignment, u32, 1)
|
|
|
|
NMT_FIELD_INT(m_SessionID, u32, 2) // Only applicable for PS_ASSIGN_SESSION
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
2005-01-17 05:52:02 +01:00
|
|
|
START_NMT_CLASS_(SetPlayerConfig)
|
|
|
|
NMT_FIELD_INT(m_PlayerID, u32, 2)
|
|
|
|
NMT_START_ARRAY(m_Values)
|
2005-01-19 23:32:25 +01:00
|
|
|
NMT_FIELD(CStrW, m_Name)
|
2005-01-17 05:52:02 +01:00
|
|
|
NMT_FIELD(CStrW, m_Value)
|
|
|
|
NMT_END_ARRAY()
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
2004-08-16 17:19:17 +02:00
|
|
|
START_NMT_CLASS_(StartGame)
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
|
|
|
START_NMT_CLASS_(EndCommandBatch)
|
|
|
|
NMT_FIELD_INT(m_TurnLength, u32, 2)
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
|
|
|
START_NMT_CLASS_(GotoCommand)
|
|
|
|
NMT_FIELD(HEntity, m_Entity)
|
|
|
|
NMT_FIELD_INT(m_TargetX, u32, 2)
|
|
|
|
NMT_FIELD_INT(m_TargetY, u32, 2)
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
2004-09-21 16:40:43 +02:00
|
|
|
/*
|
|
|
|
#define NMT_FIELD_MAPPOS(_nm) NMT_FIELD_INT(_nm##X, u32, 2) NMT_FIELD_INT(_nm##Y, u32, 2)
|
|
|
|
|
|
|
|
START_NMT_CLASS_(SetWaypoint)
|
|
|
|
NMT_FIELD(HEntity, m_Entity)
|
|
|
|
NMT_FIELD_MAPPOS(m_Target)
|
|
|
|
END_NMT_CLASS()
|
|
|
|
|
|
|
|
START_NMT_CLASS_(AddWaypoint)
|
|
|
|
NMT_FIELD(HEntity, m_Entity)
|
|
|
|
NMT_FIELD_MAPPOS(m_Target)
|
|
|
|
END_NMY_CLASS()*/
|
|
|
|
|
2003-11-25 03:11:50 +01:00
|
|
|
END_NMTS()
|
|
|
|
|
|
|
|
#else
|
|
|
|
#ifndef ALLNETMSGS_DONT_CREATE_NMTS
|
|
|
|
|
2004-03-08 03:03:24 +01:00
|
|
|
# ifdef ALLNETMSGS_IMPLEMENT
|
|
|
|
# define NMT_CREATOR_IMPLEMENT
|
|
|
|
# endif
|
2003-11-25 03:11:50 +01:00
|
|
|
|
2004-03-08 03:03:24 +01:00
|
|
|
# define NMT_CREATE_HEADER_NAME "AllNetMessages.h"
|
|
|
|
# include "NMTCreator.h"
|
2003-11-25 03:11:50 +01:00
|
|
|
|
|
|
|
#endif // #ifndef ALLNETMSGS_DONT_CREATE_NMTS
|
|
|
|
#endif // #ifdef CREATING_NMT
|