func ReadUpdateType(br *utils.BitReader) UpdateType { result := Preserve if !br.ReadBoolean() { if br.ReadBoolean() { result = Create } } else { result = Leave if br.ReadBoolean() { result = Delete } } return result }
func (p *Parser) entityCreate(br *utils.BitReader, currentIndex, tick int) *packet_entities.PacketEntity { pe := &packet_entities.PacketEntity{ Tick: tick, ClassId: int(br.ReadUBits(p.ClassIdNumBits)), SerialNum: int(br.ReadUBits(10)), Index: currentIndex, Type: packet_entities.Create, Values: map[string]interface{}{}, } pe.EntityHandle = pe.Handle() pe.Name = p.ClassInfosNameMapping[pe.ClassId] indices := br.ReadPropertiesIndex() pMapping := p.Mapping[pe.ClassId] pMultiples := p.Multiples[pe.ClassId] values := br.ReadPropertiesValues(pMapping, pMultiples, indices) baseline, foundBaseline := p.Stsh.Baseline[pe.ClassId] if foundBaseline { for key, value := range baseline { pe.Values[key] = value } } for key, value := range values { pe.Values[key] = value } return pe }
func (p *Parser) EntityCreate(br *utils.BitReader, currentIndex, tick int) { pe := &PacketEntity{ Tick: tick, ClassId: int(br.ReadUBits(p.classIdNumBits)), SerialNum: int(br.ReadUBits(10)), Index: currentIndex, Type: Create, Values: map[string]interface{}{}, } pe.Name = p.classInfosNameMapping[pe.ClassId] indices := br.ReadPropertiesIndex() values := br.ReadPropertiesValues( p.mapping[pe.ClassId], p.multiples[pe.ClassId], indices, ) if baseline, ok := p.baseline[pe.ClassId]; ok { for key, baseValue := range baseline { if subValue, ok := values[key]; ok { pe.Values[key] = subValue } else { pe.Values[key] = baseValue } } } else { for key, value := range values { pe.Values[key] = value } } p.entities[pe.Index] = pe if handler, ok := p.createClassHandlers[pe.Name]; ok { handler.Callback(pe) } }
func (p *Parser) entityPreserve(br *utils.BitReader, currentIndex, tick int) *packet_entities.PacketEntity { pe := p.Entities[currentIndex] pe.Tick = tick pe.Type = packet_entities.Preserve indices := br.ReadPropertiesIndex() classId := p.ClassInfosIdMapping[pe.Name] pe.Delta = br.ReadPropertiesValues(p.Mapping[classId], p.Multiples[classId], indices) pe.OldDelta = map[string]interface{}{} for key, value := range pe.Delta { pe.OldDelta[key] = pe.Values[key] pe.Values[key] = value } return pe }
func (p *Parser) EntityPreserve(br *utils.BitReader, currentIndex, tick int) { pe := p.entities[currentIndex] pe.Tick = tick pe.Type = Preserve indices := br.ReadPropertiesIndex() values := br.ReadPropertiesValues( p.mapping[p.classInfosIdMapping[pe.Name]], p.multiples[p.classInfosIdMapping[pe.Name]], indices, ) for key, value := range values { pe.Values[key] = value } if handler, ok := p.preserveClassHandlers[pe.Name]; ok { handler.Callback(pe, values) } }