mirror of
https://github.com/demostf/demo.js
synced 2026-06-03 16:44:12 +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:
|
||||
return new ConsoleCmd(type, tick, data, length);
|
||||
case Parser.MessageType.UserCmd:
|
||||
console.log('usercmd');
|
||||
//console.log('usercmd');
|
||||
return true;
|
||||
case Parser.MessageType.DataTables:
|
||||
return new DataTable(type, tick, data, length);
|
||||
|
|
|
|||
|
|
@ -16,9 +16,16 @@ StringTable.prototype.parse = function () {
|
|||
var tableName = this.stream.readASCIIString();
|
||||
var entryCount = this.stream.readBits(16);
|
||||
for (var j = 0; j < entryCount; j++) {
|
||||
var entry = {
|
||||
text: this.stream.readUTF8String()
|
||||
};
|
||||
try {
|
||||
var entry = {
|
||||
text: this.stream.readUTF8String()
|
||||
};
|
||||
} catch (e){
|
||||
return [{
|
||||
packetType: 'stringTable',
|
||||
tables : tables
|
||||
}];
|
||||
}
|
||||
if (this.stream.readBits(1)) {
|
||||
extraDataLength = this.stream.readBits(16);
|
||||
entry.extraData = this.readExtraData(extraDataLength);
|
||||
|
|
@ -69,7 +76,11 @@ StringTable.prototype.readExtraData = function (length) {
|
|||
//console.log(this.stream.readUTF8String());
|
||||
data.push(this.stream.readUTF8String());
|
||||
while (this.stream._index < end) {
|
||||
var string = this.stream.readUTF8String();
|
||||
try {
|
||||
var string = this.stream.readUTF8String();
|
||||
} catch (e) {
|
||||
return data;
|
||||
}
|
||||
if (string) {
|
||||
data.push(string);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue