Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace NewestCOServer
{
public class DMaps
{
public static ArrayList MapsNeeded = new ArrayList() {700, 1038,1000, 1001, 1002, 1036, 1037, 1039, 1011, 1015, 1020, 1028, 1785 };
public static Hashtable H_DMaps = new Hashtable();
public static bool Loaded = false;
public static void Load()
{
if (Directory.Exists(Program.ConquerPath))
{
uint Time = Native.timeGetTime();
Program.WriteLine("Starting to load DMaps.");
FileStream FS = new FileStream(Program.ConquerPath + @"ini\GameMap.dat", FileMode.Open);
BinaryReader BR = new BinaryReader(FS);
uint MapCount = BR.ReadUInt32();
for (uint i = 0; i < MapCount; i++)
{
ushort MapID = (ushort)BR.ReadUInt32();
string Path = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadInt32()));
if (MapsNeeded.Contains((int)MapID))
{
DMap D = new DMap(MapID, Path);
H_DMaps.Add(MapID, D);
}
BR.ReadInt32();
}
BR.Close();
FS.Close();
Loaded = true;
Program.WriteLine("DMaps loaded successfully in " + (Native.timeGetTime() - Time) + " milliseconds.");
}
else
Program.WriteLine("The specified Conquer Online folder doesn't exist. DMaps couldn't be loaded.");
}
}
public struct DMapCell
{
private Boolean _noAccess;
public Boolean High;
public DMapCell(Boolean noAccess)
{
_noAccess = noAccess;
High = false;
}
public Boolean NoAccess
{
get
{
return _noAccess;
}
internal set
{
_noAccess = value;
}
}
}
public class DMap
{
private Int32 Width;
private Int32 Height;
private DMapCell[,] Cells;
public DMap(ushort MapID, string Path)
{
Program.WriteLine("Loading " + MapID.ToString() + " : " + Program.ConquerPath + Path + "");
if (File.Exists(Program.ConquerPath + Path))
{
FileStream FS = new FileStream(Program.ConquerPath + Path, FileMode.Open);
BinaryReader BR = new BinaryReader(FS);
BR.ReadBytes(268);
Width = BR.ReadInt32();
Height = BR.ReadInt32();
Cells = new DMapCell[Width, Height];
byte[] cell_data = BR.ReadBytes(((6 * Width) + 4) * Height);
int offset = 0;
for (int y = 0; y < Width; y++)
{
for (int x = 0; x < Height; x++)
{
Boolean noAccess = BitConverter.ToBoolean(cell_data, offset) != false;
if (MapID == 1002)
{
if (x >= 606 && x <= 641)
if (y >= 674 && y <= 680)
noAccess = false;
if (x >= 148 && x <= 194)
if (y >= 541 && y <= 546)
noAccess = false;
}
Cells[x, y] = new DMapCell(noAccess);
if (MapID == 1038)
{
if (x <= 119)
Cells[x, y].High = true;
if (x >= 120 && x <= 216 && y <= 210)
Cells[x, y].High = true;
}
offset += 6;
}
offset += 4;
}
BR.Close();
FS.Close();
}
}
public DMapCell GetCell(ushort X, ushort Y)
{
return Cells[X, Y];
}
}
}
There's my Dmap.cs