mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 01:55:19 -04:00
Add undocumented protocol version (WIP)
This commit is contained in:
parent
dc4bb0caf3
commit
922110ec43
@ -439,16 +439,17 @@ void Classic_WriteSetBlock(int x, int y, int z, cc_bool place, BlockID block) {
|
||||
Server.WriteBuffer = data;
|
||||
}
|
||||
|
||||
#define Classic_HandshakeSize() (Server.ProtocolVersion > PROTOCOL_0019 ? 131 : 130)
|
||||
void Classic_SendLogin(void) {
|
||||
cc_uint8 data[131];
|
||||
data[0] = OPCODE_HANDSHAKE;
|
||||
{
|
||||
data[1] = 7; /* protocol version */
|
||||
data[1] = Server.ProtocolVersion;
|
||||
WriteString(&data[2], &Game_Username);
|
||||
WriteString(&data[66], &Game_Mppass);
|
||||
data[130] = Game_UseCPE ? 0x42 : 0x00;
|
||||
}
|
||||
Server.SendData(data, 131);
|
||||
Server.SendData(data, Classic_HandshakeSize());
|
||||
}
|
||||
|
||||
static void Classic_Handshake(cc_uint8* data) {
|
||||
@ -507,7 +508,6 @@ static void Classic_LevelDataChunk(cc_uint8* data) {
|
||||
struct MapState* m;
|
||||
int usedLength;
|
||||
float progress;
|
||||
cc_uint32 read;
|
||||
cc_result res;
|
||||
|
||||
/* Workaround for some servers that send LevelDataChunk before LevelInit due to their async sending behaviour */
|
||||
@ -738,7 +738,7 @@ static void Classic_Reset(void) {
|
||||
map_begunLoading = false;
|
||||
classic_receivedFirstPos = false;
|
||||
|
||||
Net_Set(OPCODE_HANDSHAKE, Classic_Handshake, 131);
|
||||
Net_Set(OPCODE_HANDSHAKE, Classic_Handshake, Classic_HandshakeSize());
|
||||
Net_Set(OPCODE_PING, Classic_Ping, 1);
|
||||
Net_Set(OPCODE_LEVEL_BEGIN, Classic_LevelInit, 1);
|
||||
Net_Set(OPCODE_LEVEL_DATA, Classic_LevelDataChunk, 1028);
|
||||
|
@ -41,6 +41,11 @@ enum OPCODE_ {
|
||||
OPCODE_COUNT
|
||||
};
|
||||
|
||||
enum PROTOCOL_VERSION_ {
|
||||
PROTOCOL_0017 = 4, PROTOCOL_0019 = 5,
|
||||
PROTOCOL_0020 = 6, PROTOCOL_0030 = 7,
|
||||
};
|
||||
|
||||
|
||||
typedef void (*Net_Handler)(cc_uint8* data);
|
||||
#define Net_Set(opcode, handler, size) Protocol.Handlers[opcode] = handler; Protocol.Sizes[opcode] = size;
|
||||
|
@ -40,6 +40,7 @@ static void Server_ResetState(void) {
|
||||
Server.SupportsPlayerClick = false;
|
||||
Server.SupportsPartialMessages = false;
|
||||
Server.SupportsFullCP437 = false;
|
||||
Server.ProtocolVersion = PROTOCOL_0030;
|
||||
}
|
||||
|
||||
void Server_RetrieveTexturePack(const cc_string* url) {
|
||||
|
@ -58,6 +58,8 @@ CC_VAR extern struct _ServerConnectionData {
|
||||
/* Whether the server supports all of code page 437, not just ASCII. */
|
||||
cc_bool SupportsFullCP437;
|
||||
|
||||
/* Protocol version */
|
||||
cc_uint8 ProtocolVersion;
|
||||
/* Address of the server if multiplayer, empty string if singleplayer. */
|
||||
cc_string Address;
|
||||
/* Port of the server if multiplayer, 0 if singleplayer. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user