Example #1
0
 public CVarSetPacketOut(CVar var, Server tserver)
 {
     UsageType = NetUsageType.GENERAL;
     ID = ServerToClientPacket.CVAR_SET;
     DataStream ds = new DataStream();
     DataWriter dw = new DataWriter(ds);
     dw.WriteInt(tserver.Networking.Strings.IndexForString(var.Name.ToLowerFast()));
     dw.WriteFullString(var.Value);
     Data = ds.ToArray();
 }
 private void Setup(CharacterEntity character, HelicopterEntity vehicle)
 {
     DataStream ds = new DataStream();
     DataWriter dw = new DataWriter(ds);
     dw.WriteLong(character.EID);
     dw.WriteByte(1); // TODO: Enum?
     dw.WriteLong(vehicle.EID);
     dw.Flush();
     Data = ds.ToArray();
     dw.Close();
 }
Example #3
0
 public byte[] Combine(List<byte[]> originals, bool angle)
 {
     Bitmap bmp = new Bitmap(Chunk.CHUNK_SIZE * (angle ? TexWidth2 : TexWidth), Chunk.CHUNK_SIZE * (angle ? TexWidth2 : TexWidth), PixelFormat.Format32bppArgb);
     using (Graphics graphics = Graphics.FromImage(bmp))
     {
         graphics.Clear(Transp);
         for (int i = 0; i < originals.Count; i++)
         {
             DataStream ds = new DataStream(originals[i]);
             Bitmap tbmp = new Bitmap(ds);
             graphics.DrawImage(tbmp, 0, 0);
             tbmp.Dispose();
         }
     }
     DataStream temp = new DataStream();
     bmp.Save(temp, ImageFormat.Png);
     return temp.ToArray();
 }
 private void Setup(CharacterEntity character, CarEntity vehicle)
 {
     DataStream ds = new DataStream();
     DataWriter dw = new DataWriter(ds);
     dw.WriteLong(character.EID);
     dw.WriteByte(0); // TODO: Enum?
     dw.WriteInt(vehicle.DrivingMotors.Count);
     dw.WriteInt(vehicle.SteeringMotors.Count);
     for (int i = 0; i < vehicle.DrivingMotors.Count; i++)
     {
         dw.WriteLong(vehicle.DrivingMotors[i].JID);
     }
     for (int i = 0; i < vehicle.SteeringMotors.Count; i++)
     {
         dw.WriteLong(vehicle.SteeringMotors[i].JID);
     }
     dw.Flush();
     Data = ds.ToArray();
     dw.Close();
 }
Example #5
0
 public AddCloudPacketOut(Cloud cloud)
 {
     UsageType = NetUsageType.CLOUDS;
     ID = ServerToClientPacket.ADD_CLOUD;
     DataStream ds = new DataStream();
     DataWriter dw = new DataWriter(ds);
     dw.WriteBytes(cloud.Position.ToDoubleBytes());
     dw.WriteBytes((cloud.Velocity + cloud.TheRegion.Wind).ToDoubleBytes());
     dw.WriteLong(cloud.CID);
     dw.WriteInt(cloud.Points.Count);
     for (int i = 0; i < cloud.Points.Count; i++)
     {
         dw.WriteBytes(cloud.Points[i].ToDoubleBytes());
         dw.WriteFloat((float)cloud.Sizes[i]);
         dw.WriteFloat((float)cloud.EndSizes[i]);
     }
     dw.Flush();
     Data = ds.ToArray();
     dw.Close();
 }
Example #6
0
 public BlockEditPacketOut(Location[] pos, ushort[] mat, byte[] dat, byte[] paints)
 {
     UsageType = NetUsageType.CHUNKS;
     ID = ServerToClientPacket.BLOCK_EDIT;
     DataStream outp = new DataStream();
     DataWriter dw = new DataWriter(outp);
     dw.WriteInt(pos.Length);
     for (int i = 0; i < pos.Length; i++)
     {
         dw.WriteBytes(pos[i].ToDoubleBytes());
     }
     for (int i = 0; i < mat.Length; i++)
     {
         dw.WriteBytes(Utilities.UshortToBytes(mat[i]));
     }
     dw.WriteBytes(dat);
     dw.WriteBytes(paints);
     dw.Flush();
     Data = outp.ToArray();
 }
Example #7
0
 void RenderChunkInternalAngle(WorldSystem.Region tregion, Vector3i chunkCoords, Chunk chunk)
 {
     MaterialImage bmp = new MaterialImage() { Colors = new Color[BmpSize2, BmpSize2] };
     for (int z = 0; z < Chunk.CHUNK_SIZE; z++)
     {
         for (int x = 0; x < Chunk.CHUNK_SIZE; x++)
         {
             for (int y = 0; y < Chunk.CHUNK_SIZE; y++)
             {
                 // TODO: async chunk read locker?
                 BlockInternal bi = chunk.GetBlockAt(x, y, z);
                 if (bi.Material.RendersAtAll())
                 {
                     RenderBlockIntoAngle(bi, x, y, z, bmp);
                 }
             }
         }
     }
     Bitmap tbmp = new Bitmap(BmpSize2, BmpSize2);
     BitmapData bdat = tbmp.LockBits(new Rectangle(0, 0, tbmp.Width, tbmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
     int stride = bdat.Stride;
     // Surely there's a better way to do this!
     unsafe
     {
         byte* ptr = (byte*)bdat.Scan0;
         for (int x = 0; x < BmpSize2; x++)
         {
             for (int y = 0; y < BmpSize2; y++)
             {
                 Color tcol = bmp.Colors[x, y];
                 ptr[(x * 4) + y * stride + 0] = tcol.B;
                 ptr[(x * 4) + y * stride + 1] = tcol.G;
                 ptr[(x * 4) + y * stride + 2] = tcol.R;
                 ptr[(x * 4) + y * stride + 3] = tcol.A;
             }
         }
     }
     DataStream ds = new DataStream();
     tbmp.Save(ds, ImageFormat.Png);
     tregion.ChunkManager.WriteImageAngle((int)chunkCoords.X, (int)chunkCoords.Y, (int)chunkCoords.Z, ds.ToArray());
 }
Example #8
0
 void RenderChunkInternal(WorldSystem.Region tregion, Vector3i chunkCoords, Chunk chunk)
 {
     Stopwatch sw = new Stopwatch();
     sw.Start();
     MaterialImage bmp = new MaterialImage() { Colors = new Color[BmpSize, BmpSize] };
     for (int x = 0; x < Chunk.CHUNK_SIZE; x++)
     {
         for (int y = 0; y < Chunk.CHUNK_SIZE; y++)
         {
             // TODO: async chunk read locker?
             BlockInternal topOpaque = BlockInternal.AIR;
             int topZ = 0;
             for (int z = 0; z < Chunk.CHUNK_SIZE; z++)
             {
                 BlockInternal bi = chunk.GetBlockAt(x, y, z);
                 if (bi.IsOpaque())
                 {
                     topOpaque = bi;
                     topZ = z;
                 }
             }
             if (!topOpaque.Material.RendersAtAll())
             {
                 DrawImage(bmp, MaterialImages[0], x * TexWidth, y * TexWidth, Color.Transparent);
             }
             for (int z = topZ; z < Chunk.CHUNK_SIZE; z++)
             {
                 BlockInternal bi = chunk.GetBlockAt(x, y, z);
                 if (bi.Material.RendersAtAll())
                 {
                     MaterialImage zmatbmp = MaterialImages[bi.Material.TextureID(MaterialSide.TOP)];
                     if (zmatbmp == null)
                     {
                         continue;
                     }
                     Color zcolor = Colors.ForByte(bi.BlockPaint);
                     if (zcolor.A == 0)
                     {
                         zcolor = Color.White;
                     }
                     DrawImage(bmp, zmatbmp, x * TexWidth, y * TexWidth, zcolor);
                 }
             }
         }
     }
     sw.Stop();
     Timings_A += sw.ElapsedTicks / (double)Stopwatch.Frequency;
     sw.Reset();
     sw.Start();
     Bitmap tbmp = new Bitmap(BmpSize2, BmpSize2);
     BitmapData bdat = tbmp.LockBits(new Rectangle(0, 0, tbmp.Width, tbmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
     int stride = bdat.Stride;
     // Surely there's a better way to do this!
     unsafe
     {
         byte* ptr = (byte*)bdat.Scan0;
         for (int x = 0; x < BmpSize; x++)
         {
             for (int y = 0; y < BmpSize; y++)
             {
                 Color tcol = bmp.Colors[x, y];
                 ptr[(x * 4) + y * stride + 0] = tcol.B;
                 ptr[(x * 4) + y * stride + 1] = tcol.G;
                 ptr[(x * 4) + y * stride + 2] = tcol.R;
                 ptr[(x * 4) + y * stride + 3] = tcol.A;
             }
         }
     }
     tbmp.UnlockBits(bdat);
     sw.Stop();
     Timings_B += sw.ElapsedTicks / (double)Stopwatch.Frequency;
     sw.Reset();
     sw.Start();
     DataStream ds = new DataStream();
     tbmp.Save(ds, ImageFormat.Png);
     tbmp.Dispose();
     sw.Stop();
     Timings_C += sw.ElapsedTicks / (double)Stopwatch.Frequency;
     sw.Reset();
     sw.Start();
     lock (OneAtATimePlease) // NOTE: We can probably make this grab off an array of locks to reduce load a little.
     {
         KeyValuePair<int, int> maxes = tregion.ChunkManager.GetMaxes((int)chunkCoords.X, (int)chunkCoords.Y);
         tregion.ChunkManager.SetMaxes((int)chunkCoords.X, (int)chunkCoords.Y, Math.Min(maxes.Key, (int)chunkCoords.Z), Math.Max(maxes.Value, (int)chunkCoords.Z));
     }
     tregion.ChunkManager.WriteImage((int)chunkCoords.X, (int)chunkCoords.Y, (int)chunkCoords.Z, ds.ToArray());
     sw.Stop();
     Timings_D += sw.ElapsedTicks / (double)Stopwatch.Frequency;
 }
Example #9
0
 public byte[] ToBytes()
 {
     DataStream ds = new DataStream(1000);
     DataWriter dw = new DataWriter(ds);
     WriteBasicBytes(dw);
     dw.WriteInt(Components.Count);
     foreach (ItemStackBase itb in Components)
     {
         dw.WriteFullBytes(itb.ToBytes());
     }
     dw.Flush();
     return ds.ToArray();
 }
Example #10
0
 public void GetPage()
 {
     // TODO: FIX ME!
     string pageLow = http_request_page.ToLowerFast();
     #if PAGE_MAGIC
     if (pageLow.StartsWith("/map/region/"))
     {
         string after;
         string region = pageLow.Substring("/map/region/".Length).BeforeAndAfter("/", out after);
         for (int i = 0; i < TheServer.LoadedRegions.Count; i++)
         {
             if (TheServer.LoadedRegions[i].Name == region)
             {
                 string[] dat = after.SplitFast('/');
                 if (dat[0] == "img" && dat.Length >= 4)
                 {
                     int x = Utilities.StringToInt(dat[1]);
                     int y = Utilities.StringToInt(dat[2]);
                     int z = Utilities.StringToInt(dat[3].Before("."));
                     byte[] data = TheServer.LoadedRegions[i].ChunkManager.GetImage(x, y, z);
                     if (data != null)
                     {
                         http_response_contenttype = "image/png";
                         http_response_content = data;
                         return;
                     }
                 }
                 else if (dat[0] == "full_img" && dat.Length >= 3)
                 {
                     int x = Utilities.StringToInt(dat[1]);
                     int y = Utilities.StringToInt(dat[2].Before("."));
                     KeyValuePair<int, int> maxes = TheServer.LoadedRegions[i].ChunkManager.GetMaxes(x, y);
                     List<byte[]> datums = new List<byte[]>();
                     for (int z = maxes.Key; z <= maxes.Value; z++)
                     {
                         byte[] dt = TheServer.LoadedRegions[i].ChunkManager.GetImage(x, y, z);
                         if (dt != null)
                         {
                             datums.Add(dt);
                         }
                     }
                     http_response_contenttype = "image/png";
                     if (datums.Count > 1)
                     {
                         http_response_content = TheServer.BlockImages.Combine(datums, false);
                     }
                     else if (datums.Count == 1)
                     {
                         http_response_content = datums[0];
                     }
                     else
                     {
                         Bitmap bmp = new Bitmap(1, 1);
                         bmp.SetPixel(0, 0, Color.Black);
                         DataStream ds = new DataStream();
                         bmp.Save(ds, ImageFormat.Png);
                         http_response_content = ds.ToArray();
                         ds.Dispose();
                         bmp.Dispose();
                     }
                     return;
                 }
                 else if (dat[0] == "full_img_angle" && dat.Length >= 4)
                 {
                     int x = Utilities.StringToInt(dat[1]);
                     int y = Utilities.StringToInt(dat[2]);
                     int z = Utilities.StringToInt(dat[3].Before("."));
                     byte[] dt = TheServer.LoadedRegions[i].ChunkManager.GetImageAngle(x, y, z);
                     http_response_contenttype = "image/png";
                     if (dt != null)
                     {
                         http_response_content = dt;
                     }
                     else
                     {
                         Bitmap bmp = new Bitmap(1, 1);
                         bmp.SetPixel(0, 0, Color.Transparent);
                         DataStream ds = new DataStream();
                         bmp.Save(ds, ImageFormat.Png);
                         http_response_content = ds.ToArray();
                         ds.Dispose();
                         bmp.Dispose();
                     }
                     return;
                 }
                 else if (dat[0] == "maxes" && dat.Length >= 3)
                 {
                     int x = Utilities.StringToInt(dat[1]);
                     int y = Utilities.StringToInt(dat[2]);
                     KeyValuePair<int, int> maxes = TheServer.LoadedRegions[i].ChunkManager.GetMaxes(x, y);
                     http_response_content = FileHandler.encoding.GetBytes(maxes.Key + "," + maxes.Value);
                     return;
                 }
                 else if (dat[0] == "expquick" && dat.Length >= 3)
                 {
                     int bx = Utilities.StringToInt(dat[1]);
                     int by = Utilities.StringToInt(dat[2]);
                     int sz = Chunk.CHUNK_SIZE * BlockImageManager.TexWidth;
                     StringBuilder content = new StringBuilder();
                     content.Append("<!doctype html>\n<html>\n<head>\n<title>Voxalia EXP-QUICK</title>\n</head>\n<body>\n");
                     const int SIZE = 6;
                     for (int x = -SIZE; x <= SIZE; x++)
                     {
                         for (int y = -SIZE; y <= SIZE; y++)
                         {
                             content.Append("<img style=\"position:absolute;top:" + (y + SIZE) * sz + "px;left:" + (x + SIZE) * sz + "px;\" src=\"/map/region/"
                                 + region + "/full_img/" + (bx + x) + "/" + (by + y) + ".png\" width=\"" + sz + "\" height=\"" + sz + "\" />");
                         }
                     }
                     content.Append("\n</body>\n</html>\n");
                     http_response_content = FileHandler.encoding.GetBytes(content.ToString());
                     return;
                 }
                 else if (dat[0] == "expquick_angle" && dat.Length >= 4)
                 {
                     int bx = Utilities.StringToInt(dat[1]);
                     int by = Utilities.StringToInt(dat[2]);
                     int bz = Utilities.StringToInt(dat[3]);
                     int sz = Chunk.CHUNK_SIZE * BlockImageManager.TexWidth;
                     int sz2 = Chunk.CHUNK_SIZE * BlockImageManager.TexWidth2;
                     StringBuilder content = new StringBuilder();
                     content.Append("<!doctype html>\n<html>\n<head>\n<title>Voxalia EXP-QUICK (Angled)</title>\n</head>\n<body>\n");
                     const int SIZE = 3;
                     for (int x = -SIZE; x <= SIZE; x++)
                     {
                         for (int y = -SIZE; y <= SIZE; y++)
                         {
                             for (int z = -SIZE; z <= SIZE; z++)
                             {
                                 int x1 = (x) * sz;
                                 int y1 = (y) * sz;
                                 int z1 = (bz + z) * sz;
                                 int xw = (SIZE * 2 * sz) + (x1 - y1);
                                 int yw = ((SIZE * 2 * sz) + ((x1 + y1) - (z1))) / 2;
                                 content.Append("<img style=\"position:absolute;top:" + yw + "px;left:" + xw + "px;z-index:" + z + ";\" src=\"/map/region/"
                                     + region + "/full_img_angle/" + (bx + x) + "/" + (by + y) + "/" + (bz + z) + ".png\" width=\"" + sz2 + "\" height=\"" + sz2 + "\" />");
                             }
                         }
                     }
                     content.Append("\n</body>\n</html>\n");
                     http_response_content = FileHandler.encoding.GetBytes(content.ToString());
                     return;
                 }
                 break;
             }
         }
     }
     else
     #endif
     if (pageLow.StartsWith("/log_view/"))
     {
         string[] dat = pageLow.Substring("/log_view/".Length).SplitFast('/');
         string username = dat[0];
         string passcode = dat.Length < 2 ? "" : dat[1];
         bool valid = false;
         StringBuilder content = new StringBuilder();
         content.Append("<!doctype html>\n<html>\n<head>\n<title>Voxalia Log View</title>\n</head>\n<body>\n");
         lock (TheServer.TickLock)
         {
             FDSSection cfg = TheServer.GetPlayerConfig(username);
             valid = cfg != null
                 && cfg.GetString("web.is_admin", "false").ToLowerFast() == "true"
                 && cfg.GetString("web.passcode", "") == Utilities.HashQuick(username.ToLowerFast(), passcode);
         }
         if (valid)
         {
             content.Append("Logs follow:\n<pre><code>\n");
             lock (TheServer.RecentMessagesLock)
             {
                 foreach (string str in TheServer.RecentMessages)
                 {
                     foreach (string substr in str.SplitFast('\n'))
                     {
                         string trimmedsubstr = substr.Trim();
                         if (trimmedsubstr.Length > 0)
                         {
                             content.Append(trimmedsubstr.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;")).Append("\n");
                         }
                     }
                 }
             }
             content.Append("\n</code></pre>");
         }
         else
         {
             content.Append("Not a valid login!");
         }
         content.Append("\n</body>\n</html>\n");
         http_response_content = FileHandler.encoding.GetBytes(content.ToString());
         return;
     }
     Do404();
 }
Example #11
0
 public ChunkInfoPacketOut(Chunk chunk, int lod)
 {
     UsageType = NetUsageType.CHUNKS;
     if (chunk.Flags.HasFlag(ChunkFlags.POPULATING) && (lod != 5 || chunk.LOD == null))
     {
         throw new Exception("Trying to transmit chunk while it's still loading! For chunk at " + chunk.WorldPosition);
     }
     ID = ServerToClientPacket.CHUNK_INFO;
     byte[] data_orig;
     if (lod == 1)
     {
         bool isAir = true;
         data_orig = new byte[chunk.BlocksInternal.Length * 4];
         for (int x = 0; x < chunk.BlocksInternal.Length; x++)
         {
             ushort mat = chunk.BlocksInternal[x].BlockMaterial;
             if (mat != 0)
             {
                 isAir = false;
             }
             data_orig[x * 2] = (byte)(mat & 0xFF);
             data_orig[x * 2 + 1] = (byte)((mat >> 8) & 0xFF);
         }
         if (isAir)
         {
             data_orig = null;
         }
         else
         {
             for (int i = 0; i < chunk.BlocksInternal.Length; i++)
             {
                 data_orig[chunk.BlocksInternal.Length * 2 + i] = chunk.BlocksInternal[i].BlockData;
                 data_orig[chunk.BlocksInternal.Length * 3 + i] = chunk.BlocksInternal[i]._BlockPaintInternal;
             }
         }
     }
     else
     {
         data_orig = chunk.LODBytes(lod, true);
     }
     if (data_orig == null)
     {
         Data = new byte[12];
         // TODO: This is a bit hackish
         ID = ServerToClientPacket.CHUNK_FORGET;
         Utilities.IntToBytes((int)chunk.WorldPosition.X).CopyTo(Data, 0);
         Utilities.IntToBytes((int)chunk.WorldPosition.Y).CopyTo(Data, 4);
         Utilities.IntToBytes((int)chunk.WorldPosition.Z).CopyTo(Data, 8);
         return;
     }
     byte[] gdata = FileHandler.Compress(data_orig);
     DataStream ds = new DataStream(gdata.Length + 16);
     DataWriter dw = new DataWriter(ds);
     dw.WriteInt((int)chunk.WorldPosition.X);
     dw.WriteInt((int)chunk.WorldPosition.Y);
     dw.WriteInt((int)chunk.WorldPosition.Z);
     dw.WriteInt(lod);
     byte[] reach = new byte[chunk.Reachability.Length];
     for (int i = 0; i < reach.Length; i++)
     {
         reach[i] = (byte)(chunk.Reachability[i] ? 1 : 0);
     }
     dw.WriteBytes(reach);
     dw.WriteBytes(gdata);
     Data = ds.ToArray();
 }
Example #12
0
 public byte[] ServerBytes()
 {
     DataStream data = new DataStream(1000);
     DataWriter dw = new DataWriter(data);
     dw.WriteInt(Attributes.Count);
     foreach (KeyValuePair<string, TemplateObject> entry in Attributes)
     {
         dw.WriteFullString(entry.Key);
         if (entry.Value is IntegerTag)
         {
             dw.WriteByte(0);
             dw.WriteLong(((IntegerTag)entry.Value).Internal);
         }
         else if (entry.Value is NumberTag)
         {
             dw.WriteByte(1);
             dw.WriteDouble(((NumberTag)entry.Value).Internal);
         }
         else if (entry.Value is BooleanTag)
         {
             dw.WriteByte(2);
             dw.WriteByte((byte)(((BooleanTag)entry.Value).Internal ? 1 : 0));
         }
         // TODO: shared BaseItemTag?
         else
         {
             dw.WriteByte(3);
             dw.WriteFullString(entry.Value.ToString());
         }
     }
     WriteBasicBytes(dw);
     dw.WriteInt(Components.Count);
     foreach (ItemStack itb in Components)
     {
         dw.WriteFullBytes(itb.ServerBytes());
     }
     dw.Flush();
     return data.ToArray();
 }
Example #13
0
 public byte[] GetCharacterNetData()
 {
     DataStream ds = new DataStream();
     DataWriter dr = new DataWriter(ds);
     dr.WriteBytes(GetPosition().ToDoubleBytes());
     Quaternion quat = GetOrientation();
     dr.WriteFloat((float)quat.X);
     dr.WriteFloat((float)quat.Y);
     dr.WriteFloat((float)quat.Z);
     dr.WriteFloat((float)quat.W);
     dr.WriteFloat((float)GetMass());
     dr.WriteFloat((float)CBAirForce);
     dr.WriteFloat((float)CBAirSpeed);
     dr.WriteFloat((float)CBCrouchSpeed);
     dr.WriteFloat((float)CBDownStepHeight);
     dr.WriteFloat((float)CBGlueForce);
     dr.WriteFloat((float)CBHHeight);
     dr.WriteFloat((float)CBJumpSpeed);
     dr.WriteFloat((float)CBMargin);
     dr.WriteFloat((float)CBMaxSupportSlope);
     dr.WriteFloat((float)CBMaxTractionSlope);
     dr.WriteFloat((float)CBProneSpeed);
     dr.WriteFloat((float)CBRadius);
     dr.WriteFloat((float)CBSlideForce);
     dr.WriteFloat((float)CBSlideJumpSpeed);
     dr.WriteFloat((float)CBSlideSpeed);
     dr.WriteFloat((float)CBStandSpeed);
     dr.WriteFloat((float)CBStepHeight);
     dr.WriteFloat((float)CBTractionForce);
     dr.WriteFloat((float)mod_xrot);
     dr.WriteFloat((float)mod_yrot);
     dr.WriteFloat((float)mod_zrot);
     dr.WriteFloat((float)mod_scale);
     dr.WriteInt(mod_color.ToArgb());
     byte dtx = 0;
     if (Visible)
     {
         dtx |= 1;
     }
     if (CGroup == CollisionUtil.Solid)
     {
         dtx |= 2;
     }
     else if (CGroup == CollisionUtil.NonSolid)
     {
         dtx |= 4;
     }
     else if (CGroup == CollisionUtil.Item)
     {
         dtx |= 2 | 4;
     }
     else if (CGroup == CollisionUtil.Player)
     {
         dtx |= 8;
     }
     else if (CGroup == CollisionUtil.Water)
     {
         dtx |= 2 | 8;
     }
     else if (CGroup == CollisionUtil.WorldSolid)
     {
         dtx |= 2 | 4 | 8;
     }
     else if (CGroup == CollisionUtil.Character)
     {
         dtx |= 16;
     }
     dr.Write(dtx);
     dr.WriteInt(TheServer.Networking.Strings.IndexForString(model));
     dr.Flush();
     byte[] Data = ds.ToArray();
     dr.Close();
     return Data;
 }