Beispiel #1
0
        protected override void ParseAsCsvStream(System.IO.Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    ProgressReport.Invoke();
                    String   row    = c.ReadLine();
                    String[] fields = row.Split(',');

                    NumberFormatInfo global  = System.Globalization.NumberFormatInfo.InvariantInfo;
                    byte             toid    = byte.Parse(fields[1], global);
                    byte             fromid  = byte.Parse(fields[0], global);
                    byte             tomapid = byte.Parse(fields[5], global);
                    float            x       = float.Parse(fields[2], global);
                    float            y       = float.Parse(fields[3], global);
                    float            z       = float.Parse(fields[4], global);

                    Portal portal = new Portal(tomapid, x, y, z);

                    Dictionary <byte, Portal> portals_tmp;
                    if (this.portals.TryGetValue(fromid, out portals_tmp) == false)
                    {
                        portals_tmp = new Dictionary <byte, Portal>();
                    }
                    portals_tmp[toid]    = portal;
                    this.portals[fromid] = portals_tmp;
                }
            }
        }
Beispiel #2
0
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    //REPORT PROGRESS
                    ProgressReport.Invoke();
                    String   row    = c.ReadLine();
                    String[] fields = row.Split(',');


                    maps.Add(

                        //ASSOCIATE MAP-ID WITH ZONE INSTANCE
                        byte.Parse(fields[1], NumberFormatInfo.InvariantInfo),

                        //CREATE NEW CHARACTER INFO
                        new Info
                        (
                            ushort.Parse(fields[2], NumberFormatInfo.InvariantInfo),
                            ushort.Parse(fields[3], NumberFormatInfo.InvariantInfo),
                            ushort.Parse(fields[4], NumberFormatInfo.InvariantInfo)
                        )
                        );
                }
            }
        }
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            byte Line = 0;

            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    Line++;
                    ProgressReport.Invoke();
                    String   row    = c.ReadLine();
                    String[] fields = row.Split(',');

                    try
                    {
                        Zone zone;
                        if (!Singleton.Zones.TryGetZone(uint.Parse(fields[0], NumberFormatInfo.InvariantInfo), out zone))
                        {
                            WriteError("WorldObjectsFactory (single)", "Zone of id {0} was not found", fields[0]);
                        }

                        float x         = float.Parse(fields[1], NumberFormatInfo.InvariantInfo);
                        float y         = float.Parse(fields[2], NumberFormatInfo.InvariantInfo);
                        float z         = float.Parse(fields[3], NumberFormatInfo.InvariantInfo);
                        uint  modelid   = uint.Parse(fields[4], NumberFormatInfo.InvariantInfo);
                        byte  ismapitem = byte.Parse(fields[5], NumberFormatInfo.InvariantInfo);
                        int   yaw       = int.Parse(fields[6], NumberFormatInfo.InvariantInfo);

                        MapObject regionObject;

                        bool iscreated = ismapitem != 1
                            ? Singleton.Templates.SpawnNpcInstance(modelid, new Point(x, y, z), yaw, zone, out regionObject)
                            : Singleton.Templates.SpawnItemInstance(modelid, new Point(x, y, z), yaw, zone, out regionObject);

                        if (!iscreated)
                        {
                            if (npcspawnsaswarnings.Enabled)
                            {
                                WriteWarning("WorldObjectsFactory (single)", "Cannot initialize {1} {0}", fields[4], ismapitem == 1 ? "actionobject" : "npc");
                            }
                            else
                            {
                                WriteError("WorldObjectsFactory (single)", "Cannot initialize {1} {0}", fields[4], ismapitem == 1 ? "actionobject" : "npc");
                            }
                        }
                    }
                    catch (FormatException)
                    {
                        WriteError("WorldObjectsFactory (single)", "Incorrect format at line {0}: {1}", Line, row);
                    }
                }
            }
        }
        /// <summary>
        /// Default included event that invokes a csv based stream.
        /// </summary>
        /// <param name="stream">Stream to read data from</param>
        /// <param name="ProgressReport">Class to report the state of reading</param>
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    ProgressReport.Invoke();
                    String   row    = c.ReadLine();
                    String[] fields = row.Split(',');

                    uint weapontype = uint.Parse(fields[0], NumberFormatInfo.InvariantInfo);

                    Dictionary <uint, Info> temp;
                    bool isnew = weapons.TryGetValue(weapontype, out temp);
                    if (isnew == false)
                    {
                        temp = new Dictionary <uint, Info>();
                    }


                    uint   key         = uint.Parse(fields[1], NumberFormatInfo.InvariantInfo);
                    uint   maxdura     = uint.Parse(fields[2], NumberFormatInfo.InvariantInfo);
                    ushort minshortatk = ushort.Parse(fields[3], NumberFormatInfo.InvariantInfo);
                    ushort maxshortatk = ushort.Parse(fields[4], NumberFormatInfo.InvariantInfo);
                    ushort minrangeatk = ushort.Parse(fields[5], NumberFormatInfo.InvariantInfo);
                    ushort maxrangeatk = ushort.Parse(fields[6], NumberFormatInfo.InvariantInfo);
                    ushort minmagicatk = ushort.Parse(fields[7], NumberFormatInfo.InvariantInfo);
                    ushort maxmagicatk = ushort.Parse(fields[8], NumberFormatInfo.InvariantInfo);
                    uint   weaponskill = uint.Parse(fields[10], NumberFormatInfo.InvariantInfo);
                    uint   unknown     = uint.Parse(fields[9], NumberFormatInfo.InvariantInfo);

                    temp.Add(key, new Info(
                                 maxdura, minshortatk, maxshortatk,
                                 minrangeatk, maxrangeatk, minmagicatk,
                                 maxmagicatk, weaponskill, unknown
                                 ));

                    if (isnew == false)
                    {
                        weapons.Add(weapontype, temp);
                    }
                }
            }
        }
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    ProgressReport.Invoke();
                    String   row    = c.ReadLine();
                    String[] fields = row.Split(',');

                    Zone zone;
                    byte count = byte.Parse(fields[5], System.Globalization.NumberFormatInfo.InvariantInfo);
                    if (Singleton.Zones.TryGetZone(uint.Parse(fields[1], NumberFormatInfo.InvariantInfo), out zone))
                    {
                        for (int i = 0; i < count; i++)
                        {
                            float x          = float.Parse(fields[2], System.Globalization.NumberFormatInfo.InvariantInfo);
                            float y          = float.Parse(fields[3], System.Globalization.NumberFormatInfo.InvariantInfo);
                            float z          = float.Parse(fields[4], System.Globalization.NumberFormatInfo.InvariantInfo);
                            int   spawnrange = int.Parse(fields[6], System.Globalization.NumberFormatInfo.InvariantInfo);
                            uint  modelid    = uint.Parse(fields[0], System.Globalization.NumberFormatInfo.InvariantInfo);

                            MapObject regionObject;
                            Point     location  = GeneratePointInRange(new Point(x, y, z), spawnrange);
                            bool      isspawned = Singleton.Templates.SpawnNpcInstance(modelid, location, rand.Next(0, ushort.MaxValue), zone, out regionObject);
                            if (!isspawned)
                            {
                                if (mobspawnsaswarnings.Enabled)
                                {
                                    WriteWarning("WorldObjectsFactory (multi)", "Cannot initialize {1} {0}", fields[0], "npc");
                                }
                                else
                                {
                                    WriteError("WorldObjectsFactory (multi)", "Cannot initialize {1} {0}", fields[0], "npc");
                                }
                            }
                        }
                    }
                }
            }
        }
 protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
 {
     using (StreamReader c = new StreamReader(stream))
     {
         c.ReadLine();
         while (c.Peek() > 0)
         {
             ProgressReport.Invoke();
             String   row    = c.ReadLine();
             String[] fields = row.Split(',');
             levelTable.Add(byte.Parse(fields[0], NumberFormatInfo.InvariantInfo), new Info(
                                uint.Parse(fields[1], NumberFormatInfo.InvariantInfo),
                                uint.Parse(fields[2], NumberFormatInfo.InvariantInfo),
                                uint.Parse(fields[3], NumberFormatInfo.InvariantInfo),
                                uint.Parse(fields[4], NumberFormatInfo.InvariantInfo),
                                uint.Parse(fields[5], NumberFormatInfo.InvariantInfo)
                                ));
         }
     }
 }
Beispiel #7
0
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    ProgressReport.Invoke();
                    String   row    = c.ReadLine();
                    String[] fields = row.Split(',');

                    Info info = new Info();
                    info.price = uint.Parse(fields[1], NumberFormatInfo.InvariantInfo);
                    info.x     = float.Parse(fields[2], NumberFormatInfo.InvariantInfo);
                    info.y     = float.Parse(fields[3], NumberFormatInfo.InvariantInfo);
                    info.z     = float.Parse(fields[4], NumberFormatInfo.InvariantInfo);
                    info.map   = byte.Parse(fields[5], NumberFormatInfo.InvariantInfo);
                    warps.Add(ushort.Parse(fields[0], NumberFormatInfo.InvariantInfo), info);
                }
            }
        }
        protected override void ParseAsCsvStream(System.IO.Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    ProgressReport.Invoke();
                    String   row          = c.ReadLine();
                    String[] fields       = row.Split(',');
                    Type     additiontype = typeof(AdditionsBonus);


                    uint   AdditionId = uint.Parse(fields[0], NumberFormatInfo.InvariantInfo);
                    uint[] Functions  = new uint[] { (uint)Enum.Parse(additiontype, fields[1]), (uint)Enum.Parse(additiontype, fields[2]), (uint)Enum.Parse(additiontype, fields[3]),
                                                     (uint)Enum.Parse(additiontype, fields[4]), (uint)Enum.Parse(additiontype, fields[5]), (uint)Enum.Parse(additiontype, fields[6]),
                                                     (uint)Enum.Parse(additiontype, fields[7]), (uint)Enum.Parse(additiontype, fields[8]), (uint)Enum.Parse(additiontype, fields[9]),
                                                     (uint)Enum.Parse(additiontype, fields[10]) };

                    int[] Values = new int[] { int.Parse(fields[11], NumberFormatInfo.InvariantInfo),
                                               int.Parse(fields[12], NumberFormatInfo.InvariantInfo),
                                               int.Parse(fields[13], NumberFormatInfo.InvariantInfo),
                                               int.Parse(fields[14], NumberFormatInfo.InvariantInfo),
                                               int.Parse(fields[15], NumberFormatInfo.InvariantInfo),
                                               int.Parse(fields[16], NumberFormatInfo.InvariantInfo),
                                               int.Parse(fields[17], NumberFormatInfo.InvariantInfo),
                                               int.Parse(fields[18], NumberFormatInfo.InvariantInfo),
                                               int.Parse(fields[19], NumberFormatInfo.InvariantInfo),
                                               int.Parse(fields[20], NumberFormatInfo.InvariantInfo) };



                    Info info = Info.From(addition_table, Functions, Values);
                    if (info != null)
                    {
                        _additions.Add(AdditionId, info);
                    }
                }
            }
        }
Beispiel #9
0
        protected override void ParseAsXmlStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (XmlTextReader reader = new XmlTextReader(stream))
            {
                Info     info           = null;
                uint     AdditionId     = 0;
                uint     Interval       = 0;
                uint     EffectDuration = 0;
                string   value          = null;
                uint[]   Functions      = null;
                int[]    Values         = null;
                String[] fields         = null;
                Type     additiontype   = typeof(AdditionsBonus);

                while (reader.Read())
                {
                    ProgressReport.Invoke();
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        value = null;
                        if (reader.Name.ToUpperInvariant() == "ROW")
                        {
                            Functions      = null;
                            Values         = null;
                            fields         = null;
                            AdditionId     = 0;
                            Interval       = 0;
                            EffectDuration = 0;
                        }
                        break;

                    case XmlNodeType.Text:
                        value = reader.Value;
                        break;

                    case XmlNodeType.EndElement:
                        switch (reader.Name.ToUpperInvariant())
                        {
                        case "ROW": goto Add;

                        case "ID":
                            AdditionId = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;

                        case "TYPE": break;

                        case "DISPOSITION": break;

                        case "INTERVAL":
                            Interval = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;

                        case "EFFECTDURATION":
                            EffectDuration = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;

                        case "FUNCTION":
                            fields    = value.Split(',');
                            Functions = new uint[] { (uint)Enum.Parse(additiontype, fields[0]),
                                                     (uint)Enum.Parse(additiontype, fields[1]),
                                                     (uint)Enum.Parse(additiontype, fields[2]),
                                                     (uint)Enum.Parse(additiontype, fields[3]),
                                                     (uint)Enum.Parse(additiontype, fields[4]),
                                                     (uint)Enum.Parse(additiontype, fields[5]),
                                                     (uint)Enum.Parse(additiontype, fields[6]),
                                                     (uint)Enum.Parse(additiontype, fields[7]),
                                                     (uint)Enum.Parse(additiontype, fields[8]),
                                                     (uint)Enum.Parse(additiontype, fields[9]) };
                            break;

                        case "VALUE":
                            fields = value.Split(',');
                            Values = new int[] { int.Parse(fields[0], NumberFormatInfo.InvariantInfo),
                                                 int.Parse(fields[1], NumberFormatInfo.InvariantInfo),
                                                 int.Parse(fields[2], NumberFormatInfo.InvariantInfo),
                                                 int.Parse(fields[3], NumberFormatInfo.InvariantInfo),
                                                 int.Parse(fields[4], NumberFormatInfo.InvariantInfo),
                                                 int.Parse(fields[5], NumberFormatInfo.InvariantInfo),
                                                 int.Parse(fields[6], NumberFormatInfo.InvariantInfo),
                                                 int.Parse(fields[7], NumberFormatInfo.InvariantInfo),
                                                 int.Parse(fields[8], NumberFormatInfo.InvariantInfo),
                                                 int.Parse(fields[9], NumberFormatInfo.InvariantInfo) };
                            break;
                        }
                        break;
                    }
                    continue;
Add:
                    try
                    {
                        info = Info.From(addition_table, Functions, Values);
                        if (info != null)
                        {
                            info.Addition       = AdditionId;
                            info.Interval       = Interval;
                            info.EffectDuration = EffectDuration;
                            _additions.Add(AdditionId, info);
                        }
                    }
                    catch (ArgumentException)
                    {
                        WriteError("AdditionFactory", "Duplicate id detected: {0}", AdditionId);
                        return;
                    }

                    continue;
                }
            }
        }
Beispiel #10
0
        protected override void ParseAsXmlStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (XmlTextReader reader = new XmlTextReader(stream))
            {
                Info   current = null;
                string value   = null;
                while (reader.Read())
                {
                    try
                    {
                        ProgressReport.Invoke();
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                            if (reader.Name.ToUpperInvariant() == "SKILL")
                            {
                                current = new Info();
                            }
                            value = null;
                            break;

                        case XmlNodeType.Text:
                            value = reader.Value;
                            break;

                        case XmlNodeType.EndElement:
                            string[] values;
                            switch (reader.Name.ToUpperInvariant())
                            {
                            case "SKILL": goto Add;

                            case "SKILLID": current.skillid = uint.Parse(value, NumberFormatInfo.InvariantInfo); current.skill = FindSkillHandler(current.skillid, methods); break;

                            case "SKILLTYPE": current.skilltype = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "MAXSKILLEXP": current.maximumexperience = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "GROWLEVEL": current.maximumgrowlevel = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "MINRANGE": current.minimumrange = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "MAXRANGE": current.maximumrange = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "TARGET": current.target = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "CASTTIME": current.casttime = int.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "DELAY": current.delay = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "SP": current.SP = int.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "SPECIAL": current.special = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "SPECIALLVREQUIREMENT": current.specialJlvl = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "RACE": current.race = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "STANCE": current.stance = ConsoleUtils.ParseToUintArray(value); break;

                            case "ADDITION": current.addition = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "HATEONCAST": current.requiredlp = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "HATE": current.hate = short.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "ATTACKTYPE": current.attacktype = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "ELEMENTTYPE": current.elementtype = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;

                            case "WEAPONREQUIREMENT":
                                values = value.Split(',');
                                current.requiredWeapons = new byte[]
                                {
                                    byte.Parse(values[0], NumberFormatInfo.InvariantInfo),      //HAND
                                    byte.Parse(values[1], NumberFormatInfo.InvariantInfo),      //SHORTSWORD
                                    byte.Parse(values[2], NumberFormatInfo.InvariantInfo),      //LONGSWORD
                                    byte.Parse(values[3], NumberFormatInfo.InvariantInfo),      //SWORDSTICK
                                    byte.Parse(values[4], NumberFormatInfo.InvariantInfo),      //DAMPTFLINTE
                                    byte.Parse(values[5], NumberFormatInfo.InvariantInfo),      //BOW
                                    byte.Parse(values[6], NumberFormatInfo.InvariantInfo),      //DAMPTSCHWERTZ
                                    byte.Parse(values[7], NumberFormatInfo.InvariantInfo),      //KATANA
                                    byte.Parse(values[8], NumberFormatInfo.InvariantInfo),      //SPECIALIST
                                };
                                break;

                            case "JOBREQUIREMENT":
                                values = value.Split(',');
                                current.requiredJobs = new byte[]
                                {
                                    byte.Parse(values[0], NumberFormatInfo.InvariantInfo),      //NOVICE
                                    byte.Parse(values[1], NumberFormatInfo.InvariantInfo),      //SWORDSMAN
                                    byte.Parse(values[3], NumberFormatInfo.InvariantInfo),      //RECRUIT
                                    byte.Parse(values[2], NumberFormatInfo.InvariantInfo),      //THIEF
                                    byte.Parse(values[4], NumberFormatInfo.InvariantInfo),      //ENCHANTER
                                    byte.Parse(values[5], NumberFormatInfo.InvariantInfo),      //CLOWN
                                    byte.Parse(values[6], NumberFormatInfo.InvariantInfo),      //KNIGHT
                                    byte.Parse(values[7], NumberFormatInfo.InvariantInfo),      //ASSASIN
                                    byte.Parse(values[8], NumberFormatInfo.InvariantInfo),      //SPECIALIST
                                    byte.Parse(values[9], NumberFormatInfo.InvariantInfo),      //SAGE
                                    byte.Parse(values[10], NumberFormatInfo.InvariantInfo),     //GAMBLER
                                    byte.Parse(values[11], NumberFormatInfo.InvariantInfo),     //FALCATA
                                    byte.Parse(values[12], NumberFormatInfo.InvariantInfo),     //FPRSYTHIE
                                    byte.Parse(values[13], NumberFormatInfo.InvariantInfo),     //NEMOPHILA
                                    byte.Parse(values[14], NumberFormatInfo.InvariantInfo)      //VEILCHENBLAU
                                };
                                break;
                            }
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        throw new SystemException(string.Format("File caused a error at fileline: {0}", reader.LineNumber), e);
                    }
                    continue;
Add:
                    try
                    {
                        current.skill = FindSkillHandler(current.skillid, methods);
                        this.spells.Add(current.skillid, current);
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Duplicate Id detected {0}", current.skillid);
                    }
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Default included event that invokes a csv based stream.
        /// </summary>
        /// <param name="stream">Stream to read data from</param>
        /// <param name="ProgressReport">Class to report the state of reading</param>
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                ProgressReport.Invoke();

                bool isnpcspawns = false;
                int  line        = 0;
                {
                    String   row    = c.ReadLine();
                    String[] fields = row.Split(',');
                    isnpcspawns = fields.Length > 20;
                }

                while (c.Peek() > 0)
                {
                    ++line;
                    String   row    = c.ReadLine();
                    String[] fields = row.Split(',');

                    //Npc Information detected
                    uint id = uint.Parse(fields[0], NumberFormatInfo.InvariantInfo);
                    if (isnpcspawns)
                    {
                        NpcInfo info = new NpcInfo();
                        info.HP         = ushort.Parse(fields[3], NumberFormatInfo.InvariantInfo);
                        info.SP         = ushort.Parse(fields[4], NumberFormatInfo.InvariantInfo);
                        info.Level      = ushort.Parse(fields[5], NumberFormatInfo.InvariantInfo);
                        info.CEXP       = ushort.Parse(fields[6], NumberFormatInfo.InvariantInfo);
                        info.JEXP       = ushort.Parse(fields[7], NumberFormatInfo.InvariantInfo);
                        info.WEXP       = ushort.Parse(fields[8], NumberFormatInfo.InvariantInfo);
                        info.Def        = ushort.Parse(fields[9], NumberFormatInfo.InvariantInfo);
                        info.Flee       = ushort.Parse(fields[10], NumberFormatInfo.InvariantInfo);
                        info.AtkMin     = ushort.Parse(fields[11], NumberFormatInfo.InvariantInfo);
                        info.AtkMax     = ushort.Parse(fields[12], NumberFormatInfo.InvariantInfo);
                        info.Cri        = ushort.Parse(fields[13], NumberFormatInfo.InvariantInfo);
                        info.Hit        = ushort.Parse(fields[14], NumberFormatInfo.InvariantInfo);
                        info.ASPD       = ushort.Parse(fields[15], NumberFormatInfo.InvariantInfo);
                        info.Sightrange = ushort.Parse(fields[16], NumberFormatInfo.InvariantInfo);
                        info.Size       = ushort.Parse(fields[17], NumberFormatInfo.InvariantInfo);
                        info.Walkspeed  = uint.Parse(fields[18], NumberFormatInfo.InvariantInfo);
                        info.Runspeed   = uint.Parse(fields[19], NumberFormatInfo.InvariantInfo);
                        info.AIMode     = byte.Parse(fields[20], NumberFormatInfo.InvariantInfo);

                        if (TryGetConstructorInfo(fields[1], out info.info) == false)
                        {
                            throw new SystemException(string.Format("Constructor information on type {0} was not found on line: {1}", fields[1], line));
                        }

                        if (this.templates.ContainsKey(id))
                        {
                            throw new SystemException(string.Format("A duplicated entry has been detected: {0}-{1} on line {2}", id, fields[2], line));
                        }

                        this.templates.Add(id, info);
                    }
                    //Item information detected
                    else
                    {
                        ConstructorInfo info;
                        if (TryGetConstructorInfo(fields[1], out info) == false)
                        {
                            throw new SystemException(string.Format("Constructor information on type {0} was not found on line: {1}", fields[1], line));
                        }

                        if (this.itemtemplates.ContainsKey(id))
                        {
                            throw new SystemException(string.Format("A duplicated entry has been detected: {0}-{1} on line {2}", id, fields[2], line));
                        }

                        itemtemplates.Add(id, info);
                    }
                }
            }
        }
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    //REPORT PROGRESS
                    ProgressReport.Invoke();
                    String   row    = c.ReadLine();
                    String[] fields = row.Split(',');

                    try
                    {
                        int    Flags           = 0;
                        byte   eventid         = Convert.ToByte(fields[0]);  //Unique id of the event
                        byte   UseDate         = Convert.ToByte(fields[6]);  //1   - Use a date to check
                        byte   UseTime         = Convert.ToByte(fields[7]);  //2   - Use a timespan to check
                        byte   EnableMonday    = Convert.ToByte(fields[8]);  //4   - Is active on monday
                        byte   EnableThuesday  = Convert.ToByte(fields[9]);  //8   - Is active on thuesday
                        byte   EnableWednesday = Convert.ToByte(fields[10]); //16  - Is active on wednessday
                        byte   EnableThursday  = Convert.ToByte(fields[11]); //32  - Is active on thursday
                        byte   EnableFriday    = Convert.ToByte(fields[12]); //64  - Is active on friday
                        byte   EnableSaturday  = Convert.ToByte(fields[13]); //128 - Is active on saturday
                        byte   EnableSunday    = Convert.ToByte(fields[14]); //256 - Is active on sunday
                        string EventName       = fields[1];                  //Name of the event

                        if (UseDate == 1)
                        {
                            Flags |= 1;
                        }
                        if (UseTime == 1)
                        {
                            Flags |= 2;
                        }
                        if (EnableMonday == 1)
                        {
                            Flags |= 4;
                        }
                        if (EnableThuesday == 1)
                        {
                            Flags |= 8;
                        }
                        if (EnableWednesday == 1)
                        {
                            Flags |= 16;
                        }
                        if (EnableThursday == 1)
                        {
                            Flags |= 32;
                        }
                        if (EnableFriday == 1)
                        {
                            Flags |= 64;
                        }
                        if (EnableSaturday == 1)
                        {
                            Flags |= 128;
                        }
                        if (EnableSunday == 1)
                        {
                            Flags |= 256;
                        }

                        DateTime eventstart = DateTime.Parse(fields[2], CultureInfo.InvariantCulture);
                        DateTime eventend   = DateTime.Parse(fields[3], CultureInfo.InvariantCulture);
                        TimeSpan timestart  = TimeSpan.Parse(fields[4]);
                        TimeSpan timetend   = TimeSpan.Parse(fields[5]);

                        EventDateTime date = new EventDateTime();
                        date.end       = eventend.Add(timetend);
                        date.start     = eventstart.Add(timestart);
                        date.eventname = EventName;
                        date.Flags     = Flags;
                        if (CanCheckTimespan(date))
                        {
                            date.IsActive = IsActiveToday(date) && IsBetweenDateTime(date) && IsBetweenTimeStamp(date);
                        }
                        else
                        {
                            date.IsActive = true;
                        }

                        _eventdates.Add(eventid, date);
                    }
                    catch (Exception e)
                    {
                        HostContext.AddUnhandeldException(e);
                    }
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// Default included event that invokes a csv based stream.
        /// </summary>
        /// <param name="stream">Stream to read data from</param>
        /// <param name="ProgressReport">Class to report the state of reading</param>
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    //REPORT PROGRESS
                    ProgressReport.Invoke();
                    String   row    = c.ReadLine();
                    String[] fields = row.Split(',');

                    //LOAD A HEIGHTMAP
                    HeightMap heightmap          = new HeightMap();
                    HeightMap.HeightMapInfo info = new HeightMap.HeightMapInfo();

                    try
                    {
                        //FILL OUT HEIGHTMAP INFORMATION
                        string filename = Path.Combine(Environment.CurrentDirectory, dirHeightmap);
                        if (fields[10].Length > 0)
                        {
                            info.location[0] = float.Parse(fields[12], NumberFormatInfo.InvariantInfo);
                            info.location[1] = float.Parse(fields[13], NumberFormatInfo.InvariantInfo);
                            info.location[2] = float.Parse(fields[14], NumberFormatInfo.InvariantInfo);
                            info.scale[0]    = int.Parse(fields[15], NumberFormatInfo.InvariantInfo);
                            info.scale[1]    = int.Parse(fields[16], NumberFormatInfo.InvariantInfo);
                            info.scale[2]    = int.Parse(fields[17], NumberFormatInfo.InvariantInfo);
                            info.size        = int.Parse(fields[11], NumberFormatInfo.InvariantInfo);
                            filename         = Path.Combine(filename, fields[10]);

                            //IF HEIGHTMAP IS NOT LOADED PROCEED
                            HeightMap.LoadFromFile(filename, info, out heightmap);
                        }

                        float    catheleyax   = float.Parse(fields[2], NumberFormatInfo.InvariantInfo);
                        float    catheleyay   = float.Parse(fields[3], NumberFormatInfo.InvariantInfo);
                        float    catheleyaz   = float.Parse(fields[4], NumberFormatInfo.InvariantInfo);
                        float    promisex     = float.Parse(fields[6], NumberFormatInfo.InvariantInfo);
                        float    promisey     = float.Parse(fields[7], NumberFormatInfo.InvariantInfo);
                        float    promizez     = float.Parse(fields[8], NumberFormatInfo.InvariantInfo);
                        byte     catheleyamap = byte.Parse(fields[5], NumberFormatInfo.InvariantInfo);
                        byte     promisemap   = byte.Parse(fields[9], NumberFormatInfo.InvariantInfo);
                        uint     regioncode   = uint.Parse(fields[19], NumberFormatInfo.InvariantInfo);
                        uint     zoneid       = uint.Parse(fields[0], NumberFormatInfo.InvariantInfo);
                        ZoneType zonetype     = (ZoneType)Enum.Parse(typeof(ZoneType), fields[18], true);
                        Zone     zone;

                        if (TryFindZoneString(fields[1], out zone))
                        {
                            SetMembers(zone, (byte)zoneid, heightmap, zonetype,
                                       catheleyamap, new Point(catheleyax, catheleyay, catheleyaz),
                                       promisemap, new Point(promisex, promisey, promizez),
                                       regioncode);

                            maps.Add(zoneid, zone);
                        }
                    }
                    catch (Exception e)
                    {
                        HostContext.AddUnhandeldException(e);
                    }
                }
            }
        }