예제 #1
0
        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.Length);

                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);
            }
        }