import { Uint64LE } from 'int64-buffer' ; import { Room } from 'room/room' ; import { User } from 'user/user' ; import { OutPacketBase } from 'packets/out/packet' ; /**
 * shared room structure, used by room list
 */ export class RoomListItem { private room : Room ; constructor ( room ) { this . room = room ; } public build ( outPacket ) { const host = this . room . host . conn . session . user ; if ( host == null ) { return ; } outPacket . writeUInt16 ( this . room . id ) ; outPacket . writeUInt64 ( new Uint64LE ( 'FFFFFFFFFFFFFFFF' , 16 ) ) ; outPacket . writeString ( this . room . settings . roomName ) ; outPacket . writeUInt8 ( this . room . id ) ; outPacket . writeUInt8 ( this . room . IsPasswordProtected ( ) === true ? 1 : 0 ) ; outPacket . writeUInt16 ( 0 ) ; outPacket . writeUInt8 ( this . room . settings . gameModeId ) ; outPacket . writeUInt8 ( this . room . settings . mapId ) ; outPacket . writeUInt8 ( this . room . usersInfo . length ) ; outPacket . writeUInt8 ( this . room . settings . maxPlayers ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt32 ( host . id ) ; outPacket . writeString ( host . playername ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt32 ( 0xd73da43d ) ; outPacket . writeUInt16 ( 0x9f31 ) ; outPacket . writeUInt16 ( 0xb2b9 ) ; outPacket . writeUInt32 ( 0xd73da43d ) ; outPacket . writeUInt16 ( 0x9f31 ) ; outPacket . writeUInt16 ( 0xb2b9 ) ; outPacket . writeUInt8 ( 5 ) ; const unk20 = 0 ; outPacket . writeUInt8 ( unk20 ) ; outPacket . writeUInt8 ( 5 ) ; outPacket . writeUInt8 ( this . room . settings . status ) ; outPacket . writeUInt8 ( this . room . settings . areBotsEnabled ? 1 : 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt16 ( this . room . settings . startMoney ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 1 ) ; outPacket . writeUInt64 ( new Uint64LE ( 0x5af6f7bf ) ) ; outPacket . writeUInt8 ( this . room . settings . winLimit ) ; outPacket . writeUInt16 ( this . room . settings . killLimit ) ; outPacket . writeUInt8 ( this . room . settings . forceCamera ) ; outPacket . writeUInt8 ( 4 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( this . room . settings . nextMapEnabled ) ; outPacket . writeUInt8 ( this . room . settings . changeTeams ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( 0 ) ; outPacket . writeUInt8 ( host . vip_level !== 0 ? 1 : 0 ) ; outPacket . writeUInt8 ( host . vip_level ) ; outPacket . writeUInt8 ( this . room . settings . difficulty ) ; } }