mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 15:17:36 +00:00
chore: Convert all files to LF endings (#400)
* Convert to LF? * Modify gitattributes * Force LF * Git --renormalize * Update .gitattributes to enforce eol=lf * Redo CRLF -> LF on remaining files
This commit is contained in:
parent
a8bc7521f6
commit
cee42e7a88
65 changed files with 5697 additions and 5697 deletions
|
|
@ -1,41 +1,41 @@
|
|||
import Core from './core.js'
|
||||
|
||||
export default class mafia2mp extends Core {
|
||||
constructor () {
|
||||
super()
|
||||
this.encoding = 'latin1'
|
||||
this.header = 'M2MP'
|
||||
this.isMafia2Online = false
|
||||
}
|
||||
|
||||
async run (state) {
|
||||
const body = await this.udpSend(this.header, (buffer) => {
|
||||
const reader = this.reader(buffer)
|
||||
const header = reader.string(this.header.length)
|
||||
if (header !== this.header) return
|
||||
return reader.rest()
|
||||
})
|
||||
|
||||
const reader = this.reader(body)
|
||||
state.name = this.readString(reader)
|
||||
state.numplayers = parseInt(this.readString(reader))
|
||||
state.maxplayers = parseInt(this.readString(reader))
|
||||
state.raw.gamemode = this.readString(reader)
|
||||
state.password = !!reader.uint(1)
|
||||
state.gamePort = this.options.port - 1
|
||||
|
||||
while (!reader.done()) {
|
||||
const player = {}
|
||||
player.name = this.readString(reader)
|
||||
if (!player.name) break
|
||||
if (this.isMafia2Online) {
|
||||
player.ping = parseInt(this.readString(reader))
|
||||
}
|
||||
state.players.push(player)
|
||||
}
|
||||
}
|
||||
|
||||
readString (reader) {
|
||||
return reader.pascalString(1, -1)
|
||||
}
|
||||
}
|
||||
import Core from './core.js'
|
||||
|
||||
export default class mafia2mp extends Core {
|
||||
constructor () {
|
||||
super()
|
||||
this.encoding = 'latin1'
|
||||
this.header = 'M2MP'
|
||||
this.isMafia2Online = false
|
||||
}
|
||||
|
||||
async run (state) {
|
||||
const body = await this.udpSend(this.header, (buffer) => {
|
||||
const reader = this.reader(buffer)
|
||||
const header = reader.string(this.header.length)
|
||||
if (header !== this.header) return
|
||||
return reader.rest()
|
||||
})
|
||||
|
||||
const reader = this.reader(body)
|
||||
state.name = this.readString(reader)
|
||||
state.numplayers = parseInt(this.readString(reader))
|
||||
state.maxplayers = parseInt(this.readString(reader))
|
||||
state.raw.gamemode = this.readString(reader)
|
||||
state.password = !!reader.uint(1)
|
||||
state.gamePort = this.options.port - 1
|
||||
|
||||
while (!reader.done()) {
|
||||
const player = {}
|
||||
player.name = this.readString(reader)
|
||||
if (!player.name) break
|
||||
if (this.isMafia2Online) {
|
||||
player.ping = parseInt(this.readString(reader))
|
||||
}
|
||||
state.players.push(player)
|
||||
}
|
||||
}
|
||||
|
||||
readString (reader) {
|
||||
return reader.pascalString(1, -1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue