1
0
Fork 0
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:
Robin Appelman 2015-03-03 22:39:52 +01:00
commit 197dbb9fa5
2 changed files with 16 additions and 5 deletions

View file

@ -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);

View file

@ -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);
}