Quote:
Originally Posted by 2slam
thats awesome but i didnt get the mechanism on how it work.
P.s : if i wanna to study structure of files and make dlls and converters with (zero knowldge) how much time could it took me to achieve smth like that ? Please dont make fun of me or troll on me.
|
Depends on how good you are at searching.
Every file is pretty well documented and I'm positive I have posted about their structures before (as have other members). All you need to do is do a little research into the game files and you'll find their structure is pretty simple.
<edit> instead of posting the map viewer source, I have a different program that converted conquer maps to my own file format for editing. This will give you a nice start on how to read from the required files. You can also update it so that it reads directly from wdf archives using already public libraries around epvp.
Code:
public const string RESOURCE_LOCATION = "D:\\Extracted Wdf Files\\";
private void ConvertMapButton_Click(object sender, EventArgs e)
{
Program.CellsPerTile = 8;
ConvertMapOpenFileDialogue.InitialDirectory = RESOURCE_LOCATION+ "map\\map\\";
ConvertMapOpenFileDialogue.Filter = "DMap (*.DMap)|*.DMap*;";
if (ConvertMapOpenFileDialogue.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
//Load dmap file to pull map name/tilesize
BinaryReader dmap = new BinaryReader(ConvertMapOpenFileDialogue.OpenFile());
dmap.ReadUInt32();//MAP ID
dmap.ReadUInt32();//Unknown/blank
string pulLocation = Encoding.ASCII.GetString(dmap.ReadBytes(239)).Replace("\0", "").Split('.')[0]+".pul";
//SET MAP NAME AND TILESIZE
Program.MapName = pulLocation.Split('\\')[2].Split('.')[0];
dmap.ReadByte();
Program.TileSize = 256;
//TODO COORD LOADING
//Load Pul file to get tile information
BinaryReader pul = new BinaryReader(File.Open(RESOURCE_LOCATION + pulLocation, FileMode.Open));
string aniLocation = "ani\\"+ Encoding.ASCII.GetString(pul.ReadBytes(264)).Split('.')[0].Split('\\')[1] +".ani";
//SET TILE WIDTH AND HEIGHT
Program.TileWidth = pul.ReadInt32();
Program.TileHeight= pul.ReadInt32();
MapDirectory = Application.StartupPath + "\\maps\\" + Program.MapName + "\\";
Directory.CreateDirectory(MapDirectory);
Directory.CreateDirectory(MapDirectory + @"\Textures");
//Load Ani file to Load images as needed for new map.
StreamReader aniIn = new StreamReader (File.Open(RESOURCE_LOCATION + aniLocation, FileMode.Open));
string[] tempLines = aniIn.ReadToEnd().Replace("\r", "").Split('\n');
List<string> aniLines = new List<string>();
foreach (string str in tempLines)
if (str.Length > 0)
aniLines.Add(str);
string tileLocationToRead, tileName;
ushort tileID;
Manifest.Collection manifest = new Manifest.Collection(MapDirectory + "\\Manifest.xml");
//Write the QuadInformation file
FileStream fs = new FileStream(MapDirectory + "QuadInfo.qi", FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(Program.TileWidth);//Width of map in tiles
bw.Write(Program.TileHeight);//Height of map in tiles
bw.Write(Program.TileSize);//Size of tiles in pixels
bw.Write(Program.CellsPerTile);//Number of cells per tiles. We only use this for drawing but w/e!
for (int y = 0; y < Program.TileHeight; y++)
for (int x = 0; x < Program.TileWidth; x++)
{
tileID = pul.ReadUInt16();
//We now load in the new resources!!
tileLocationToRead = aniLines[2 + (tileID * 3)].Split('=')[1].Replace('/', '\\');
tileName = tileLocationToRead.Split('\\')[tileLocationToRead.Split('\\').Length -1];
if (!File.Exists(MapDirectory + "Textures\\" + tileID + ".dds"))
File.Copy(RESOURCE_LOCATION + tileLocationToRead, MapDirectory + "Textures\\" + tileID+".dds");
//Todo read from wdf archive directly
//Need to copy the texture over to the texture folder... It is in
if(!manifest.TextureElements.ContainsKey(tileID))
manifest.AddTexture(tileID, "\\Textures\\"+tileID+".dds");
bw.Write((ushort)tileID);
}
bw.Close();
fs.Close();
manifest.SaveManifest();
//CLOSE ALL OPEN READERS
dmap.Close();
pul.Close();
//Write the CellInformation file
int _cellWidth = Program.TileWidth * Program.CellsPerTile;
int _cellHeight = Program.TileHeight * Program.CellsPerTile;
fs = new FileStream(MapDirectory + "CellInfo.ci", FileMode.Create);
bw = new BinaryWriter(fs);
bw.Write(_cellWidth);
bw.Write(_cellHeight);
for (int Y = 0; Y < _cellHeight; Y++)
for (int X = 0; X < _cellWidth; X++)
{
bw.Write((byte)1);//Access = true
bw.Write((short)0);//Height = 0
bw.Write((ushort)0);//ActionKey = 0
}
bw.Close();
bw.Dispose();
fs.Close();
fs.Dispose();
MessageBox.Show("Finished Conversion. Attempting to Load Map.");
DialogResult = System.Windows.Forms.DialogResult.OK;
}
}