public Event?Process(Connection.Message message) { using (var stream = Bitstream.CreateWith(message.Data)) { if (message.Type == (uint)NET_Messages.net_NOP) { return(null); } else if (message.Type == (uint)NET_Messages.net_Disconnect) { return(Process(Serializer.Deserialize <CNETMsg_Disconnect>(stream))); } else if (message.Type == (uint)NET_Messages.net_Tick) { return(Process(Serializer.Deserialize <CNETMsg_Tick>(stream))); } else if (message.Type == (uint)NET_Messages.net_SetConVar) { return(Process(Serializer.Deserialize <CNETMsg_SetConVar>(stream))); } else if (message.Type == (uint)NET_Messages.net_SignonState) { return(Process(Serializer.Deserialize <CNETMsg_SignonState>(stream))); } else if (message.Type == (uint)SVC_Messages.svc_ServerInfo) { return(Process(Serializer.Deserialize <CSVCMsg_ServerInfo>(stream))); } else if (message.Type == (uint)SVC_Messages.svc_SendTable) { return(Process(Serializer.Deserialize <CSVCMsg_SendTable>(stream))); } else if (message.Type == (uint)SVC_Messages.svc_ClassInfo) { return(Process(Serializer.Deserialize <CSVCMsg_ClassInfo>(stream))); } else if (message.Type == (uint)SVC_Messages.svc_PacketEntities) { return(Process(Serializer.Deserialize <CSVCMsg_PacketEntities>(stream))); } else if (message.Type == (uint)SVC_Messages.svc_CreateStringTable) { return(Process(Serializer.Deserialize <CSVCMsg_CreateStringTable>(stream))); } else if (message.Type == (uint)SVC_Messages.svc_UpdateStringTable) { return(Process(Serializer.Deserialize <CSVCMsg_UpdateStringTable>(stream))); } else if (message.Type == (uint)SVC_Messages.svc_Print) { return(Process(Serializer.Deserialize <CSVCMsg_Print>(stream))); } else if (message.Type == (uint)SVC_Messages.svc_GameEventList) { return(Process(Serializer.Deserialize <CSVCMsg_GameEventList>(stream))); } else { log.Warn("Unknown message " + message.Type); return(null); } } }
private void WriteUserCmd(UserCmd cmd, UserCmd last, Bitstream stream) { if (cmd.Command != last.Command + 1) { stream.WriteBool(true); stream.WriteUInt32(cmd.Command); } else { stream.WriteBool(false); } if (cmd.Tick != last.Tick + 1) { stream.WriteBool(true); stream.WriteUInt32(cmd.Tick); } else { stream.WriteBool(false); } if (cmd.ViewAngles.X != last.ViewAngles.X) { stream.WriteBool(true); stream.WriteFloat(cmd.ViewAngles.X); } else { stream.WriteBool(false); } if (cmd.ViewAngles.X != last.ViewAngles.X) { stream.WriteBool(true); stream.WriteFloat(cmd.ViewAngles.X); } else { stream.WriteBool(false); } if (cmd.ViewAngles.Z != last.ViewAngles.Z) { stream.WriteBool(true); stream.WriteFloat(cmd.ViewAngles.Z); } else { stream.WriteBool(false); } if (cmd.ForwardMove != last.ForwardMove) { stream.WriteBool(true); stream.WriteFloat(cmd.ForwardMove); } else { stream.WriteBool(false); } if (cmd.SideMove != last.SideMove) { stream.WriteBool(true); stream.WriteFloat(cmd.SideMove); } else { stream.WriteBool(false); } if (cmd.UpMove != last.UpMove) { stream.WriteBool(true); stream.WriteFloat(cmd.UpMove); } else { stream.WriteBool(false); } if (cmd.Buttons != last.Buttons) { stream.WriteBool(true); stream.WriteUInt32(cmd.Buttons); } else { stream.WriteBool(false); } if (cmd.Impulse != last.Impulse) { stream.WriteBool(true); stream.WriteByte(cmd.Impulse); } else { stream.WriteBool(false); } if (cmd.CrosshairTrace != last.CrosshairTrace) { stream.WriteBool(true); stream.WriteBitVec3Coord(cmd.CrosshairTrace); } else { stream.WriteBool(false); } if (cmd.CursorUnitEntIndex != last.CursorUnitEntIndex) { stream.WriteBool(true); stream.WriteBits(cmd.CursorUnitEntIndex, 11); } else { stream.WriteBool(false); } if (cmd.QueryEntIndex != last.QueryEntIndex) { stream.WriteBool(true); stream.WriteBits(cmd.QueryEntIndex, 11); } else { stream.WriteBool(false); } if (cmd.CursorUnitEntIndex != last.CursorUnitEntIndex) { stream.WriteBool(true); stream.WriteBits(cmd.CursorUnitEntIndex, 11); if (cmd.QueryEntIndex != last.QueryEntIndex) { stream.WriteBool(true); stream.WriteBits(cmd.QueryEntIndex, 11); } else { stream.WriteBool(false); } } else { stream.WriteBool(false); } if (cmd.MouseDx != last.MouseDx) { stream.WriteBool(true); stream.WriteUInt16(cmd.MouseDx); } else { stream.WriteBool(false); } if (cmd.MouseDy != last.MouseDy) { stream.WriteBool(true); stream.WriteUInt16(cmd.MouseDy); } else { stream.WriteBool(false); } if (cmd.Offset3c != last.Offset3c) { stream.WriteBool(true); stream.WriteUInt16(cmd.Offset3c); } else { stream.WriteBool(false); } // 0x44 to 0x74 inclusive if (cmd.OrderId != last.OrderId) { stream.WriteBool(true); stream.WriteInt16(cmd.OrderId); stream.WriteInt16((short) cmd.Order.Value.SelectedUnits.Count); foreach (var entity in cmd.Order.Value.SelectedUnits) { stream.WriteBits(entity, 11); } stream.WriteInt16(cmd.Order.Value.OrderType); stream.WriteInt16(cmd.Order.Value.EntityIndex1); stream.WriteBitVec3Coord(cmd.Order.Value.PreparedOrderPoint); stream.WriteBits(cmd.Order.Value.BaseNpcHandle, 11); stream.WriteBool(cmd.Order.Value.QueueOrder); } else { stream.WriteBool(false); } if (cmd.CameraX != last.CameraX || cmd.CameraY != last.CameraY) { stream.WriteBool(true); stream.WriteUInt16(cmd.CameraX); stream.WriteUInt16(cmd.CameraY); } else { stream.WriteBool(false); } if (cmd.ClickBehavior != last.ClickBehavior) { stream.WriteBool(true); stream.WriteByte(cmd.ClickBehavior); } else { stream.WriteBool(false); } if (cmd.SpectatorStatsSomething != last.SpectatorStatsSomething) { stream.WriteBool(true); stream.WriteByte(cmd.SpectatorStatsSomething); } else { stream.WriteBool(false); } if (cmd.ShopModeSomething != last.ShopModeSomething) { stream.WriteBool(true); stream.WriteByte(cmd.ShopModeSomething); } else { stream.WriteBool(false); } if (cmd.HudStatsDropdownCategoryIndex != last.HudStatsDropdownCategoryIndex) { stream.WriteBool(true); stream.WriteByte(cmd.HudStatsDropdownCategoryIndex); } else { stream.WriteBool(false); } if (cmd.HudStatsDropdownSortMethod != last.HudStatsDropdownSortMethod) { stream.WriteBool(true); stream.WriteByte(cmd.HudStatsDropdownSortMethod); } else { stream.WriteBool(false); } }