Ejemplo n.º 1
0
        public void Append <T>(T value, bool littleEndian = false)
        {
            Type t = typeof(T);

            if (!IsValidType(t))
            {
                throw new Exception("msg_t.AppendMessage: Invalid type!");
            }

            if (t == typeof(bool))
            {
                xbc.WriteInt32(DataBuffer + MessageLength, ((bool)(object)value == true) ? 1 : 0);
                MessageLength += 4;
            }
            else if (t == typeof(string))
            {
                xbc.WriteString
                xbc.WriteString(DataBuffer + MessageLength, (string)(object)value, false);

                MessageLength += (uint)Encoding.UTF8.GetBytes((string)(object)value).Length;
            }
            else if (t == typeof(byte[]))
            {
                byte[] bytes = (byte[])(object)value;
                xbc.SetMemory(DataBuffer + MessageLength, bytes);
                MessageLength += (uint)bytes.Length;
            }
            else if (t == typeof(byte))
            {
                xbc.WriteByte(DataBuffer + MessageLength, (byte)(object)value);
                MessageLength += 1;
            }
            else
            {
                var bytes = typeof(BitConverter)
                            .GetMethod("GetBytes", new Type[] { value.GetType() })
                            .Invoke(null, new object[] { value });

                byte[] data = (byte[])(object)bytes;
                if (!littleEndian)
                {
                    Array.Reverse(data);
                }

                xbc.SetMemory(DataBuffer + MessageLength, data);
                MessageLength += (uint)data.Length;
            }

            UpdateOverflowedBoolean();
        }
Ejemplo n.º 2
0
 private void mFlags(int flag, int client)
 {
     if (client == -1)
     {
         for (int n = 0; n < 12; n++)
         {
             Console.WriteInt32(getPlayerState((uint)n) + 0x331C, 0);
         }
     }
     else
     {
         Console.WriteInt32(getPlayerState((uint)client) + 0x331C, flag);
     }
 }