[RELEASE]More DMaps

06/13/2010 05:58 .Summer#1
This for tanels 5165 source :)
Replace your DMap.cs with this:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CoSX
{
    public class DMaps
    {
        public static int DMapsLoaded = 0;
        /*DMAP LIST*/ public static ArrayList MapsNeeded = new ArrayList() { 1019, 700, 1020, 1021, 1025, 1026, 1027, 1028, 5000, 1037, 1039, 1040, 1041, 1060, 1061, 1062, 1064, 1082, 1098, 1099, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1505, 1506, 1507, 1508, 1509, 1550, 1551, 2021, 2022, 2023, 2024, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 700, 1070, 1075, 1076, 1077, 1078, 1079, 1090, 1091, 1080, 1081, 1050, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 6001, 6000, 1018, 1005, 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))
            {
                int Maps = 0;
                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);
                        Maps += 1;
                    }
                    BR.ReadInt32();
                }
                BR.Close();
                FS.Close();
                Loaded = true;
                DMapsLoaded = Maps;
                Program.WriteLine("Total DMaps: " + DMapsLoaded);
                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];
        }
    }
}
done :D
06/13/2010 06:32 Arcо#2
And whats the difference between this and the original version?
06/13/2010 06:42 .Summer#3
just loading more LOL.
the other loads like 10dmaps.
this loads 101.
06/13/2010 06:50 zblowfish#4
Quote:
Originally Posted by .Summer View Post
just loading more LOL.
the other loads like 10dmaps.
this loads 101.
So instead of just posting the dmaps you added you want us to change the whole code?
06/13/2010 06:51 .Summer#5
was easier, then explain.
06/13/2010 06:51 Arcо#6
:facepalm:
Just have them replace the line
Code:
public static ArrayList MapsNeeded
Why with all the pointlessness in your releases.
Another way to load more dmaps is to take out the mapsneeded check..
then you load all the dmaps.
06/13/2010 06:53 .Summer#7
Quote:
Originally Posted by .Arco View Post
:facepalm:
Just have them replace the line
Code:
public static ArrayList MapsNeeded
Why with all the pointlessness in your releases.
Another way to load more dmaps is to take out the mapsneeded check..
then you load all the dmaps.
True :D
06/13/2010 06:55 Arcо#8
I think I may request a close on this.
This is just desperate for thanks.
Pretty much already released, but you did it the time consuming way.
[Only registered and activated users can see links. Click Here To Register...]
06/13/2010 06:57 .Summer#9
Is not a re release, wich cant be closed, then cuz no rules breaked.
just a useless release LOL :P
but anyway i got no interest in it :D
06/13/2010 08:39 Huseby#10
Even if it is pointless, its no reason to close it, =p.
06/13/2010 18:21 Korvacs#11
Its an even more long-winded way of loading all dmaps, Yuki's original release is definately the simplest and most efficient way with minimal changes to the source code.

So im classing this as a re-release.

#Closed.