Darkelarious wrote: ↑Mon Jun 29, 2020 3:28 pm
I hope to get involved with this soon too. I'd like to think of myself as an expert on ut99/gamespy by now (give our experience with 333networks) and hope to extend this with the knowledge of ut2004 too.
I'm rewriting my ut2004 query module commenting everything I'm doing regarding the packets so it should be easy to understand what's going on/what to expect with the packets.
Examples:
Code: Select all
//byte 1 is the game id, for UT2004 is hex 0x80 or binary 128
//byte 2 and 3 are always 0
//byte 4 is the one you change for different responses, either 0, 1, 2, or 3.
const packets = [
[128, 0, 0, 0], //server info 1 packet
[128, 0, 0, 1], //detailed info 1 packet
[128, 0, 0, 2], //player info 1 - 2 packets
[128, 0, 0, 3] //packet 2 and 3 | 2 - 3 packets
];
Code: Select all
parseServerInfo(data, ip, port){
data = JSON.stringify(data);
data = JSON.parse(data).data;
const serverInfo = {
"ip": ip
};
if(port != undefined){
serverInfo.port = port - 1;
}
//remove first byte(game id 0x80 / 128)
data.splice(0,1);
//remove response code (always 0 for server info)
data.splice(0, 1);
//remove server id (never used) always 4 bytes long
data.splice(0, 4);
//remove server ip (never used) always 4 bytes long
data.splice(0, 4);
//get game query port, always 4 bytes last 2 being 0, and first two being back to front
const portHex = data[1].toString(16) + data[0].toString(16);
serverInfo.port = parseInt(portHex, 16);
//remove server port bytes
data.splice(0,4);
//remove port for status query (never used) always 4 bytes
data.splice(0,4);
...
}
----Edit----
After redoing my ut2004 query module, its nearly 200 lines less with loads of comments