@@ -303,6 +303,10 @@ func parseStringTable(
303
303
flags int32 ,
304
304
variantBitCount bool ) (items []* stringTableItem ) {
305
305
items = make ([]* stringTableItem , 0 )
306
+ // Some tables have no data
307
+ if len (buf ) == 0 {
308
+ return items
309
+ }
306
310
307
311
// Create a reader for the buffer
308
312
r := bit .NewSmallBitReader (bytes .NewReader (buf ))
@@ -312,14 +316,9 @@ func parseStringTable(
312
316
index := int32 (- 1 )
313
317
keys := make ([]string , 0 , stringtableKeyHistorySize + 1 )
314
318
315
- // Some tables have no data
316
- if len (buf ) == 0 {
317
- return items
318
- }
319
-
320
319
// Loop through entries in the data structure
321
320
//
322
- // Each entry is a tuple consisting of {index, key, value}
321
+ // Each entry is a tuple consisting of {index, missing m_iItemDefinitionIndex property key, value}
323
322
//
324
323
// Index can either be incremented from the previous position or
325
324
// overwritten with a given entry.
@@ -373,46 +372,49 @@ func parseStringTable(
373
372
if len (keys ) > stringtableKeyHistorySize {
374
373
keys = keys [1 :]
375
374
}
376
- }
377
375
378
- // Some entries have a value.
379
- hasValue := r .ReadBit ()
380
- if hasValue {
381
- bitSize := uint (0 )
382
- isCompressed := false
383
- if userDataFixed {
384
- bitSize = uint (userDataSize )
385
- } else {
386
- if (flags & 0x1 ) != 0 {
387
- isCompressed = r .ReadBit ()
388
- }
376
+ // Some entries have a value.
377
+ hasValue := r .ReadBit ()
378
+ if hasValue {
379
+ bitSize := uint (0 )
380
+ isCompressed := false
389
381
390
- if variantBitCount {
391
- bitSize = r . ReadUBitInt () * 8
382
+ if userDataFixed {
383
+ bitSize = uint ( userDataSize )
392
384
} else {
393
- bitSize = r .ReadInt (17 ) * 8
385
+ if (flags & 0x1 ) != 0 {
386
+ isCompressed = r .ReadBit ()
387
+ }
388
+
389
+ if variantBitCount {
390
+ bitSize = r .ReadUBitInt () * 8
391
+ } else {
392
+ bitSize = r .ReadInt (17 ) * 8
393
+ }
394
394
}
395
- }
396
- value = r .ReadBits (int (bitSize ))
397
395
398
- if isCompressed {
399
- tmp , err := snappy .Decode (nil , value )
400
- if err != nil {
401
- panic (fmt .Sprintf ("unable to decode snappy compressed stringtable item (%s, %d, %s): %s" , name , index , key , err ))
396
+ value = r .ReadBits (int (bitSize ))
397
+
398
+ if isCompressed {
399
+ tmp , err := snappy .Decode (nil , value )
400
+ if err != nil {
401
+ panic (fmt .Sprintf ("unable to decode snappy compressed stringtable item (%s, %d, %s): %s" , name , index , key , err ))
402
+ }
403
+
404
+ value = tmp
402
405
}
403
- value = tmp
404
406
}
405
- }
406
407
407
- items = append (items , & stringTableItem {index , key , value })
408
+ items = append (items , & stringTableItem {index , key , value })
409
+ }
408
410
}
409
411
410
412
return items
411
413
}
412
414
413
415
var instanceBaselineKeyRegex = regexp .MustCompile (`^\d+:\d+$` )
414
416
415
- func (p * parser ) processStringTableS2 (tab createStringTable , br * bit. BitReader ) {
417
+ func (p * parser ) processStringTableS2 (tab createStringTable ) {
416
418
items := parseStringTable (tab .StringData , tab .GetNumEntries (), tab .GetName (), tab .GetUserDataFixedSize (), tab .GetUserDataSize (), tab .GetFlags (), tab .GetUsingVarintBitcounts ())
417
419
418
420
for _ , item := range items {
@@ -452,23 +454,23 @@ func (p *parser) processStringTable(tab createStringTable) {
452
454
tab .StringData = b
453
455
}
454
456
455
- br := bit .NewSmallBitReader (bytes .NewReader (tab .StringData ))
456
-
457
457
if tab .isS2 {
458
- p .processStringTableS2 (tab , br )
458
+ p .processStringTableS2 (tab )
459
459
} else {
460
+ br := bit .NewSmallBitReader (bytes .NewReader (tab .StringData ))
461
+
460
462
if br .ReadBit () {
461
463
panic ("unknown stringtable format" )
462
464
}
463
465
464
466
p .processStringTableS1 (tab , br )
467
+
468
+ p .poolBitReader (br )
465
469
}
466
470
467
471
if tab .GetName () == stNameModelPreCache {
468
472
p .processModelPreCacheUpdate ()
469
473
}
470
-
471
- p .poolBitReader (br )
472
474
}
473
475
474
476
func parsePlayerInfo (reader io.Reader ) common.PlayerInfo {
0 commit comments