mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -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;
|
Server.WriteBuffer = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define Classic_HandshakeSize() (Server.ProtocolVersion > PROTOCOL_0019 ? 131 : 130)
|
||||||
void Classic_SendLogin(void) {
|
void Classic_SendLogin(void) {
|
||||||
cc_uint8 data[131];
|
cc_uint8 data[131];
|
||||||
data[0] = OPCODE_HANDSHAKE;
|
data[0] = OPCODE_HANDSHAKE;
|
||||||
{
|
{
|
||||||
data[1] = 7; /* protocol version */
|
data[1] = Server.ProtocolVersion;
|
||||||
WriteString(&data[2], &Game_Username);
|
WriteString(&data[2], &Game_Username);
|
||||||
WriteString(&data[66], &Game_Mppass);
|
WriteString(&data[66], &Game_Mppass);
|
||||||
data[130] = Game_UseCPE ? 0x42 : 0x00;
|
data[130] = Game_UseCPE ? 0x42 : 0x00;
|
||||||
}
|
}
|
||||||
Server.SendData(data, 131);
|
Server.SendData(data, Classic_HandshakeSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Classic_Handshake(cc_uint8* data) {
|
static void Classic_Handshake(cc_uint8* data) {
|
||||||
@ -507,7 +508,6 @@ static void Classic_LevelDataChunk(cc_uint8* data) {
|
|||||||
struct MapState* m;
|
struct MapState* m;
|
||||||
int usedLength;
|
int usedLength;
|
||||||
float progress;
|
float progress;
|
||||||
cc_uint32 read;
|
|
||||||
cc_result res;
|
cc_result res;
|
||||||
|
|
||||||
/* Workaround for some servers that send LevelDataChunk before LevelInit due to their async sending behaviour */
|
/* 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;
|
map_begunLoading = false;
|
||||||
classic_receivedFirstPos = 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_PING, Classic_Ping, 1);
|
||||||
Net_Set(OPCODE_LEVEL_BEGIN, Classic_LevelInit, 1);
|
Net_Set(OPCODE_LEVEL_BEGIN, Classic_LevelInit, 1);
|
||||||
Net_Set(OPCODE_LEVEL_DATA, Classic_LevelDataChunk, 1028);
|
Net_Set(OPCODE_LEVEL_DATA, Classic_LevelDataChunk, 1028);
|
||||||
|
@ -41,6 +41,11 @@ enum OPCODE_ {
|
|||||||
OPCODE_COUNT
|
OPCODE_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum PROTOCOL_VERSION_ {
|
||||||
|
PROTOCOL_0017 = 4, PROTOCOL_0019 = 5,
|
||||||
|
PROTOCOL_0020 = 6, PROTOCOL_0030 = 7,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef void (*Net_Handler)(cc_uint8* data);
|
typedef void (*Net_Handler)(cc_uint8* data);
|
||||||
#define Net_Set(opcode, handler, size) Protocol.Handlers[opcode] = handler; Protocol.Sizes[opcode] = size;
|
#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.SupportsPlayerClick = false;
|
||||||
Server.SupportsPartialMessages = false;
|
Server.SupportsPartialMessages = false;
|
||||||
Server.SupportsFullCP437 = false;
|
Server.SupportsFullCP437 = false;
|
||||||
|
Server.ProtocolVersion = PROTOCOL_0030;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_RetrieveTexturePack(const cc_string* url) {
|
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. */
|
/* Whether the server supports all of code page 437, not just ASCII. */
|
||||||
cc_bool SupportsFullCP437;
|
cc_bool SupportsFullCP437;
|
||||||
|
|
||||||
|
/* Protocol version */
|
||||||
|
cc_uint8 ProtocolVersion;
|
||||||
/* Address of the server if multiplayer, empty string if singleplayer. */
|
/* Address of the server if multiplayer, empty string if singleplayer. */
|
||||||
cc_string Address;
|
cc_string Address;
|
||||||
/* Port of the server if multiplayer, 0 if singleplayer. */
|
/* Port of the server if multiplayer, 0 if singleplayer. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user