More async conversion

This commit is contained in:
mmorrison 2019-01-10 06:03:07 -06:00
parent 484e99b29c
commit efe12a00aa
25 changed files with 774 additions and 858 deletions

View file

@ -10,35 +10,32 @@ class Armagetron extends Core {
async run(state) {
const b = Buffer.from([0,0x35,0,0,0,0,0,0x11]);
await this.udpSend(b,(buffer) => {
const reader = this.reader(buffer);
const buffer = await this.udpSend(b,b => b);
const reader = this.reader(buffer);
reader.skip(6);
reader.skip(6);
state.raw.port = this.readUInt(reader);
state.raw.hostname = this.readString(reader);
state.name = this.stripColorCodes(this.readString(reader));
state.raw.numplayers = this.readUInt(reader);
state.raw.versionmin = this.readUInt(reader);
state.raw.versionmax = this.readUInt(reader);
state.raw.version = this.readString(reader);
state.maxplayers = this.readUInt(reader);
state.raw.port = this.readUInt(reader);
state.raw.hostname = this.readString(reader);
state.name = this.stripColorCodes(this.readString(reader));
state.raw.numplayers = this.readUInt(reader);
state.raw.versionmin = this.readUInt(reader);
state.raw.versionmax = this.readUInt(reader);
state.raw.version = this.readString(reader);
state.maxplayers = this.readUInt(reader);
const players = this.readString(reader);
const list = players.split('\n');
for(const name of list) {
if(!name) continue;
state.players.push({
name: this.stripColorCodes(name)
});
}
const players = this.readString(reader);
const list = players.split('\n');
for(const name of list) {
if(!name) continue;
state.players.push({
name: this.stripColorCodes(name)
});
}
state.raw.options = this.stripColorCodes(this.readString(reader));
state.raw.uri = this.readString(reader);
state.raw.globalids = this.readString(reader);
this.finish(state);
return null;
});
state.raw.options = this.stripColorCodes(this.readString(reader));
state.raw.uri = this.readString(reader);
state.raw.globalids = this.readString(reader);
}
readUInt(reader) {