mirror of
https://github.com/Tribufu/node-gamedig
synced 2026-08-09 07:01:06 +00:00
Convert tabs to spaces
This commit is contained in:
parent
0dd25bfcda
commit
3674d384d0
39 changed files with 2414 additions and 2414 deletions
|
|
@ -1,39 +1,39 @@
|
|||
class M2mp extends require('./core') {
|
||||
constructor() {
|
||||
super();
|
||||
this.encoding = 'latin1';
|
||||
}
|
||||
constructor() {
|
||||
super();
|
||||
this.encoding = 'latin1';
|
||||
}
|
||||
|
||||
run(state) {
|
||||
this.udpSend('M2MP',(buffer) => {
|
||||
run(state) {
|
||||
this.udpSend('M2MP',(buffer) => {
|
||||
const reader = this.reader(buffer);
|
||||
|
||||
const header = reader.string({length:4});
|
||||
if(header !== 'M2MP') return;
|
||||
|
||||
state.name = this.readString(reader);
|
||||
state.raw.numplayers = this.readString(reader);
|
||||
state.maxplayers = this.readString(reader);
|
||||
state.raw.gamemode = this.readString(reader);
|
||||
state.password = !!reader.uint(1);
|
||||
|
||||
while(!reader.done()) {
|
||||
const name = this.readString(reader);
|
||||
if(!name) break;
|
||||
state.players.push({
|
||||
name:name
|
||||
});
|
||||
}
|
||||
|
||||
this.finish(state);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
if(header !== 'M2MP') return;
|
||||
|
||||
readString(reader) {
|
||||
const length = reader.uint(1);
|
||||
return reader.string({length:length-1});
|
||||
}
|
||||
state.name = this.readString(reader);
|
||||
state.raw.numplayers = this.readString(reader);
|
||||
state.maxplayers = this.readString(reader);
|
||||
state.raw.gamemode = this.readString(reader);
|
||||
state.password = !!reader.uint(1);
|
||||
|
||||
while(!reader.done()) {
|
||||
const name = this.readString(reader);
|
||||
if(!name) break;
|
||||
state.players.push({
|
||||
name:name
|
||||
});
|
||||
}
|
||||
|
||||
this.finish(state);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
readString(reader) {
|
||||
const length = reader.uint(1);
|
||||
return reader.string({length:length-1});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = M2mp;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue