Loading Maps

04/08/2011 11:19 Syst3m_W1z4rd#1
Would this be a good way to load maps with settings?
Code:
        public static void Load()
        {
            try
            {
                for (int i = 0; i < MapIDs.Length; i++)
                {
                    IniFile I = new IniFile(Path + MapIDs[i]);

                    Attack.PKMap pkmap = new Attack.PKMap();
                    pkmap.FreePK = I.ReadBool("PKMap", "FreePK", 0);
                    pkmap.PKPointsGain = I.ReadUInt16("PKMap", "PKPoints", 10);
                    pkmap.CanKill = I.ReadBool("PKMap", "KillMap", 0);
                    pkmap.RandomSpawn = I.ReadBool("PKMap", "RandomSpawn", 0);

                    Core.Map map = new Core.Map(pkmap);
                    map.MapID = I.ReadUInt16("Map", "MapID", 0);
                    map.DefaultX = I.ReadUInt16("Map", "X", 0);
                    map.DefaultY = I.ReadUInt16("Map", "Y", 0);
                    map.Password = I.ReadString("Map", "Password", "");
                    map.MaxPlayers = I.ReadUInt16("Map", "MaxPlayers", 0);//0 = no limit

                    DMaps.Load(map);
                }
            }
            catch (Exception Exc) { Console.WriteLine(Exc.ToString()); }
        }
04/08/2011 11:26 _DreadNought_#2
Should check out what I released a couple months back.. speeds the whole thing up.

I don't load all the maps at once only the main once(tc,bi etc) theres about 7 of those then if someone was to enter the PK map it would very quickly and efficiently load the map while the player has 0 idea that the map only just got loaded. that way you only load the maps that get used no point loading more then you need.
04/08/2011 11:28 Syst3m_W1z4rd#3
I will be checking that out :)

This, right?
[Only registered and activated users can see links. Click Here To Register...]
04/08/2011 11:35 _DreadNought_#4
Yup might wonna clean it up a lil(wasn't gonna release the best) but that works very well and fast.
another void I used was uhm.. when a player goes into a map it checks if its loaded.. eg
Code:
public bool isLoad(uint _ID)
{
if (maps.contains(_ID))
return true;
else
return false;
}
usage
Code:
if (!isLoaded(ID))
Load(ID);
04/08/2011 13:25 Syst3m_W1z4rd#5
I won't be using the code you provided, but I will be doing it the same way. Like loading the maps when needed :) Thanks again. Oh and I'm always shorting down things like :P
04/08/2011 18:53 _DreadNought_#6
:)