mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 00:54:14 +02:00
soft handle errors when reading string tables
This commit is contained in:
parent
4e002c4ebf
commit
197dbb9fa5
2 changed files with 16 additions and 5 deletions
|
|
@ -179,7 +179,7 @@ Parser.prototype.readMessage = function () {
|
||||||
case Parser.MessageType.ConsoleCmd:
|
case Parser.MessageType.ConsoleCmd:
|
||||||
return new ConsoleCmd(type, tick, data, length);
|
return new ConsoleCmd(type, tick, data, length);
|
||||||
case Parser.MessageType.UserCmd:
|
case Parser.MessageType.UserCmd:
|
||||||
console.log('usercmd');
|
//console.log('usercmd');
|
||||||
return true;
|
return true;
|
||||||
case Parser.MessageType.DataTables:
|
case Parser.MessageType.DataTables:
|
||||||
return new DataTable(type, tick, data, length);
|
return new DataTable(type, tick, data, length);
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,16 @@ StringTable.prototype.parse = function () {
|
||||||
var tableName = this.stream.readASCIIString();
|
var tableName = this.stream.readASCIIString();
|
||||||
var entryCount = this.stream.readBits(16);
|
var entryCount = this.stream.readBits(16);
|
||||||
for (var j = 0; j < entryCount; j++) {
|
for (var j = 0; j < entryCount; j++) {
|
||||||
var entry = {
|
try {
|
||||||
text: this.stream.readUTF8String()
|
var entry = {
|
||||||
};
|
text: this.stream.readUTF8String()
|
||||||
|
};
|
||||||
|
} catch (e){
|
||||||
|
return [{
|
||||||
|
packetType: 'stringTable',
|
||||||
|
tables : tables
|
||||||
|
}];
|
||||||
|
}
|
||||||
if (this.stream.readBits(1)) {
|
if (this.stream.readBits(1)) {
|
||||||
extraDataLength = this.stream.readBits(16);
|
extraDataLength = this.stream.readBits(16);
|
||||||
entry.extraData = this.readExtraData(extraDataLength);
|
entry.extraData = this.readExtraData(extraDataLength);
|
||||||
|
|
@ -69,7 +76,11 @@ StringTable.prototype.readExtraData = function (length) {
|
||||||
//console.log(this.stream.readUTF8String());
|
//console.log(this.stream.readUTF8String());
|
||||||
data.push(this.stream.readUTF8String());
|
data.push(this.stream.readUTF8String());
|
||||||
while (this.stream._index < end) {
|
while (this.stream._index < end) {
|
||||||
var string = this.stream.readUTF8String();
|
try {
|
||||||
|
var string = this.stream.readUTF8String();
|
||||||
|
} catch (e) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
if (string) {
|
if (string) {
|
||||||
data.push(string);
|
data.push(string);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue