Beispiel #1
0
 void NetRec()
 {
     try
     {
         byte[] buffer = new byte[BUFFER_SIZE];
         byte[] ped = new byte[BUFFER_PED];
         byte[] veh = new byte[BUFFER_VEH];
         float  x, y, z;
         uint   tmp;
         while (true)
         {
             sock.Receive(buffer);
             Array.Copy(buffer, 1, ped, 0, BUFFER_PED);
             Array.Copy(buffer, 1 + BUFFER_PED, veh, 0, BUFFER_VEH);
             if (buffer[0] >= id)
             {
                 buffer[0]--;
             }
             //Ped
             x = BitConverter.ToSingle(ped, 0);
             if (x != 0)
             {
                 y = BitConverter.ToSingle(ped, 4);
                 z = BitConverter.ToSingle(ped, 8);
                 if (GetDistance(ref x, ref y, ref z) > DD_PED)
                 {
                     continue;
                 }
                 tmp = (uint)(mem.Read(PTR_NET_PED) + OFS_NET_PED);
                 mem.WriteByte(tmp + OFS_PED * buffer[0], ped, BUFFER_PED);
                 continue;
             }
             //Vehicle
             x = BitConverter.ToSingle(veh, 0);
             if (x != 0)
             {
                 y = BitConverter.ToSingle(veh, 4);
                 z = BitConverter.ToSingle(veh, 8);
                 if (GetDistance(ref x, ref y, ref z) > DD_VEH)
                 {
                     continue;
                 }
                 tmp = (uint)(mem.Read(PTR_NET_VEH) + OFS_NET_VEH);
                 mem.WriteByte(tmp + OFS_VEH * (buffer[0] + 1u), veh, BUFFER_VEH);
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Source + " - " + e.Message, Text,
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         if (game != null && !game.HasExited)
         {
             game.Kill();
         }
         Environment.Exit(0);
     }
 }
Beispiel #2
0
        public uint GetAddr(int typ, int id)
        {
            PtrAddress addr;

            addr = addresses[typ, id];
            uint tmp = addr.addr + baseaddr;

            if (addr.ptr_offs != null)
            {
                tmp = mem.Read(addr.addr) + addr.ptr_offs[0];
                for (int i2 = 1; i2 < addr.ptr_offs.Length; i2++)
                {
                    tmp = mem.Read(tmp) + addr.ptr_offs[i2];
                }
            }
            return(tmp);
        }