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(' ');
console.error(text);
},
canvas: (function() { return getElementById('GameCanvas'); })(),
canvas: (function() { return document.getElementById('GameCanvas'); })(),
setStatus: function(text) {
console.log(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;
}
void Classic_SendLogin(const String* username, const String* verKey) {
void Classic_SendLogin(void) {
cc_uint8 data[131];
data[0] = OPCODE_HANDSHAKE;
{
data[1] = 7; /* protocol version */
WriteString(&data[2], username);
WriteString(&data[66], verKey);
WriteString(&data[2], &Game_Username);
WriteString(&data[66], &Game_Mppass);
data[130] = Game_UseCPE ? 0x42 : 0x00;
}
Server.SendData(data, 131);
@ -787,11 +787,11 @@ void CPE_SendPlayerClick(int button, cc_bool pressed, cc_uint8 targetId, struct
Server.SendData(data, 15);
}
static void CPE_SendExtInfo(const String* appName, int extsCount) {
static void CPE_SendExtInfo(int extsCount) {
cc_uint8 data[67];
data[0] = OPCODE_EXT_INFO;
{
WriteString(&data[1], appName);
WriteString(&data[1], &Server.AppName);
Stream_SetU16_BE(&data[65], extsCount);
}
Server.SendData(data, 67);
@ -836,7 +836,7 @@ static void CPE_SendCpeExtInfoReply(void) {
#else
if (!Game_AllowCustomBlocks) count -= 2;
#endif
CPE_SendExtInfo(&Server.AppName, count);
CPE_SendExtInfo(count);
for (i = 0; i < Array_Elems(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_WritePosition(Vec3 pos, float yaw, float pitch);
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);
#endif

View File

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