mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 15:17:36 +00:00
Super epic commit 2
Added pretty much every game ever Tons of new protocols and game definitions Cleaned up and discovered some new tricks in gamespy3 and quake2
This commit is contained in:
parent
b51877ef5c
commit
e23aa6cf9c
21 changed files with 854 additions and 222 deletions
|
|
@ -42,14 +42,19 @@ Reader.prototype = {
|
|||
var delim = options.delimiter || this.query.delimiter;
|
||||
if(typeof delim == 'string') delim = delim.charCodeAt(0);
|
||||
while(true) {
|
||||
if(end >= this.buffer.length) return '';
|
||||
if(end >= this.buffer.length) {
|
||||
end = this.buffer.length;
|
||||
break;
|
||||
}
|
||||
if(this.buffer.readUInt8(end) == delim) break;
|
||||
end++;
|
||||
}
|
||||
this.i = end+1;
|
||||
} else {
|
||||
end = start+options.length;
|
||||
if(end > this.buffer.length) return '';
|
||||
if(end >= this.buffer.length) {
|
||||
end = this.buffer.length;
|
||||
}
|
||||
this.i = end;
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +69,7 @@ Reader.prototype = {
|
|||
},
|
||||
int: function(bytes) {
|
||||
var r = 0;
|
||||
if(this.i+bytes <= this.buffer.length) {
|
||||
if(this.remaining() >= bytes) {
|
||||
if(this.query.byteorder == 'be') {
|
||||
if(bytes == 1) r = this.buffer.readInt8(this.i);
|
||||
else if(bytes == 2) r = this.buffer.readInt16BE(this.i);
|
||||
|
|
@ -80,7 +85,7 @@ Reader.prototype = {
|
|||
},
|
||||
uint: function(bytes) {
|
||||
var r = 0;
|
||||
if(this.i+bytes <= this.buffer.length) {
|
||||
if(this.remaining() >= bytes) {
|
||||
if(this.query.byteorder == 'be') {
|
||||
if(bytes == 1) r = this.buffer.readUInt8(this.i);
|
||||
else if(bytes == 2) r = this.buffer.readUInt16BE(this.i);
|
||||
|
|
@ -98,13 +103,16 @@ Reader.prototype = {
|
|||
},
|
||||
float: function() {
|
||||
var r = 0;
|
||||
if(this.i+4 <= this.buffer.length) {
|
||||
if(this.remaining() >= 4) {
|
||||
if(this.query.byteorder == 'be') r = this.buffer.readFloatBE(this.i);
|
||||
else r = this.buffer.readFloatLE(this.i);
|
||||
}
|
||||
this.i += 4;
|
||||
return r;
|
||||
},
|
||||
remaining: function() {
|
||||
return this.buffer.length-this.i;
|
||||
},
|
||||
rest: function() {
|
||||
return this.buffer.slice(this.i);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue