import { Uint64LE } from 'int64-buffer' ; import { OutPacketBase } from 'packets/out/packet' ; import { Room , RoomStatus } from 'room/room' ; import { OutRoomPlayerNetInfo } from 'packets/out/room/playernetinfo' ; import { UserInfoFullUpdate } from 'packets/out/userinfo/fulluserupdate' ; /**
 * sends the newly created room information to an user
 */ export class OutRoomCreateAndJoin { public static build ( room , outPacket ) { outPacket . writeUInt32 ( room . host . userId ) ; outPacket . writeUInt8 ( 2 ) ; outPacket . writeUInt8 ( 2 ) ; outPacket . writeUInt16 ( room . id ) ; outPacket . writeUInt8 ( 5 ) ; outPacket . writeUInt64 ( new Uint64LE ( 'FFFFFFFFFFFFFFFF' , 16 ) ) ; outPacket . writeString ( room . settings . roomName ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt32 ( 0 ) ; outPacket . writeUInt32 ( 0 ) ; outPacket . writeString ( null ) ; outPacket . writeUInt16 ( 0 ) ; outPacket . writeUInt8 ( 1 ) ; outPacket . writeUInt8 ( room . settings . gameModeId ) ; outPacket . writeUInt8 ( room . settings . mapId ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 1 ) ; outPacket . writeUInt8 ( room . settings . winLimit ) ; outPacket . writeUInt16 ( room . settings . killLimit ) ; outPacket . writeUInt8 ( 1 ) ; outPacket . writeUInt8 ( 10 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( room . getStatus ( ) ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 90 ) ; const unk27 = [ ] ; outPacket . writeUInt8 ( unk27 . length ) ; for ( const iterator of unk27 ) { outPacket . writeUInt8 ( iterator ) ; } outPacket . writeUInt8 ( 1 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 1 ) ; outPacket . writeUInt8 ( 1 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( room . settings . areBotsEnabled ? 1 : 0 ) ; if ( room . settings . areBotsEnabled ) { outPacket . writeUInt8 ( room . settings . botDifficulty ) ; outPacket . writeUInt8 ( room . settings . numCtBots ) ; outPacket . writeUInt8 ( room . settings . numTrBots ) ; } outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( room . getStatus ( ) === RoomStatus . Ingame ? 1 : 0 ) ; outPacket . writeUInt16 ( 16000 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 3 ) ; outPacket . writeUInt8 ( room . usersInfo . length ) ; for ( const userEntry of room . usersInfo ) { outPacket . writeUInt32 ( userEntry . userId ) ; OutRoomPlayerNetInfo . build ( userEntry . conn , userEntry . team , outPacket ) ; UserInfoFullUpdate . build ( userEntry . conn . session . user , outPacket ) ; } } }