Simplify protocol.c for when string arguments don't need to be variable

Also add missing document. in hosting-flask.md, fixes #679 (Thanks ToonDragon)
This commit is contained in:
UnknownShadow200 2020-06-15 17:44:18 +10:00
parent 2b83dbc32a
commit c44153a50b
4 changed files with 11 additions and 11 deletions

View File

@ -143,7 +143,7 @@ if __name__ == "__main__":
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
console.error(text); console.error(text);
}, },
canvas: (function() { return getElementById('GameCanvas'); })(), canvas: (function() { return document.getElementById('GameCanvas'); })(),
setStatus: function(text) { setStatus: function(text) {
console.log(text); console.log(text);
document.getElementById('logmsg').innerHTML = text; document.getElementById('logmsg').innerHTML = text;

View File

@ -367,13 +367,13 @@ void Classic_WriteSetBlock(int x, int y, int z, cc_bool place, BlockID block) {
Server.WriteBuffer = data; Server.WriteBuffer = data;
} }
void Classic_SendLogin(const String* username, const String* verKey) { 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] = 7; /* protocol version */
WriteString(&data[2], username); WriteString(&data[2], &Game_Username);
WriteString(&data[66], verKey); WriteString(&data[66], &Game_Mppass);
data[130] = Game_UseCPE ? 0x42 : 0x00; data[130] = Game_UseCPE ? 0x42 : 0x00;
} }
Server.SendData(data, 131); Server.SendData(data, 131);
@ -787,12 +787,12 @@ void CPE_SendPlayerClick(int button, cc_bool pressed, cc_uint8 targetId, struct
Server.SendData(data, 15); Server.SendData(data, 15);
} }
static void CPE_SendExtInfo(const String* appName, int extsCount) { static void CPE_SendExtInfo(int extsCount) {
cc_uint8 data[67]; cc_uint8 data[67];
data[0] = OPCODE_EXT_INFO; data[0] = OPCODE_EXT_INFO;
{ {
WriteString(&data[1], appName); WriteString(&data[1], &Server.AppName);
Stream_SetU16_BE(&data[65], extsCount); Stream_SetU16_BE(&data[65], extsCount);
} }
Server.SendData(data, 67); Server.SendData(data, 67);
} }
@ -802,7 +802,7 @@ static void CPE_SendExtEntry(const String* extName, int extVersion) {
data[0] = OPCODE_EXT_ENTRY; data[0] = OPCODE_EXT_ENTRY;
{ {
WriteString(&data[1], extName); WriteString(&data[1], extName);
Stream_SetU32_BE(&data[65], extVersion); Stream_SetU32_BE(&data[65], extVersion);
} }
Server.SendData(data, 69); Server.SendData(data, 69);
} }
@ -836,7 +836,7 @@ static void CPE_SendCpeExtInfoReply(void) {
#else #else
if (!Game_AllowCustomBlocks) count -= 2; if (!Game_AllowCustomBlocks) count -= 2;
#endif #endif
CPE_SendExtInfo(&Server.AppName, count); CPE_SendExtInfo(count);
for (i = 0; i < Array_Elems(cpe_clientExtensions); i++) { for (i = 0; i < Array_Elems(cpe_clientExtensions); i++) {
name = String_FromReadonly(cpe_clientExtensions[i]); name = String_FromReadonly(cpe_clientExtensions[i]);

View File

@ -57,6 +57,6 @@ extern cc_bool cpe_needD3Fix;
void Classic_SendChat(const String* text, cc_bool partial); void Classic_SendChat(const String* text, cc_bool partial);
void Classic_WritePosition(Vec3 pos, float yaw, float pitch); void Classic_WritePosition(Vec3 pos, float yaw, float pitch);
void Classic_WriteSetBlock(int x, int y, int z, cc_bool place, BlockID block); void Classic_WriteSetBlock(int x, int y, int z, cc_bool place, BlockID block);
void Classic_SendLogin(const String* username, const String* verKey); void Classic_SendLogin(void);
void CPE_SendPlayerClick(int button, cc_bool pressed, cc_uint8 targetId, struct RayTracer* t); void CPE_SendPlayerClick(int button, cc_bool pressed, cc_uint8 targetId, struct RayTracer* t);
#endif #endif

View File

@ -251,7 +251,7 @@ static void MPConnection_FinishConnect(void) {
net_readCurrent = net_readBuffer; net_readCurrent = net_readBuffer;
Server.WriteBuffer = net_writeBuffer; Server.WriteBuffer = net_writeBuffer;
Classic_SendLogin(&Game_Username, &Game_Mppass); Classic_SendLogin();
net_lastPacket = Game.Time; net_lastPacket = Game.Time;
} }