This repository was archived by the owner on Jul 2, 2024. It is now read-only.
File tree 2 files changed +18
-6
lines changed
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -6,19 +6,21 @@ import {GameEventListPacket} from '../../Data/Packet';
6
6
export function ParseGameEventList ( stream : BitStream ) : GameEventListPacket { // 30: gameEventList
7
7
// list of game events and parameters
8
8
const numEvents = stream . readBits ( 9 ) ;
9
+
9
10
const length = stream . readBits ( 20 ) ;
11
+ const listData = stream . readBitStream ( length ) ;
10
12
const eventList : Map < number , GameEventDefinition < GameEventType > > = new Map ( ) ;
11
13
for ( let i = 0 ; i < numEvents ; i ++ ) {
12
- const id = stream . readBits ( 9 ) ;
13
- const name = stream . readASCIIString ( ) as GameEvent [ 'name' ] ;
14
- let type = stream . readBits ( 3 ) ;
14
+ const id = listData . readBits ( 9 ) ;
15
+ const name = listData . readASCIIString ( ) as GameEvent [ 'name' ] ;
16
+ let type = listData . readBits ( 3 ) ;
15
17
const entries : GameEventEntry [ ] = [ ] ;
16
18
while ( type !== 0 ) {
17
19
entries . push ( {
18
20
type,
19
- name : stream . readASCIIString ( )
21
+ name : listData . readASCIIString ( )
20
22
} ) ;
21
- type = stream . readBits ( 3 ) ;
23
+ type = listData . readBits ( 3 ) ;
22
24
}
23
25
eventList . set ( id , {
24
26
id,
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export function ParseVoiceInit(stream: BitStream): VoiceInitPacket {
6
6
const quality = stream . readUint8 ( ) ;
7
7
8
8
// no clue, from 2017-2-14 update
9
- const extraData = ( codec === 'vaudio_celt' && quality === 255 ) ? stream . readUint16 ( ) : 0 ;
9
+ const extraData = readExtraData ( stream , codec , quality ) ;
10
10
11
11
return {
12
12
packetType : 'voiceInit' ,
@@ -16,6 +16,16 @@ export function ParseVoiceInit(stream: BitStream): VoiceInitPacket {
16
16
} ;
17
17
}
18
18
19
+ function readExtraData ( stream : BitStream , codec : string , quality : number ) {
20
+ if ( quality === 255 ) {
21
+ return stream . readUint16 ( ) ;
22
+ } else if ( codec === 'vaudio_celt' ) {
23
+ return 11025 ;
24
+ } else {
25
+ return 0 ;
26
+ }
27
+ }
28
+
19
29
export function EncodeVoiceInit ( packet : VoiceInitPacket , stream : BitStream ) {
20
30
stream . writeASCIIString ( packet . codec ) ;
21
31
stream . writeUint8 ( packet . quality ) ;
You can’t perform that action at this time.
0 commit comments