Beispiel #1
0
        private static void LoadCsvFiles()
        {
            StreamReader reader = new StreamReader(m_Path);

            string line;
            int    lineNum = 0;

            while ((line = reader.ReadLine()) != null)
            {
                ++lineNum;
                line = line.Trim();
                if (line.StartsWith("#"))
                {
                    continue;
                }
                string[] parts = line.Split(m_Sep);
                if (parts.Length != 9)
                {
                    continue;
                }
                try
                {
                    Point3D pointLoc = new Point3D(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]));

                    /*
                     * if(parts[3] == "Trammel")
                     * {
                     *  parts[3] = "Greyhawk";
                     * }
                     */
                    Map mapLoc = Map.Parse(parts[3]);

                    Point3D pointDest = new Point3D(int.Parse(parts[4]), int.Parse(parts[5]), int.Parse(parts[6]));

                    /*
                     * if (parts[7] == "Trammel")
                     * {
                     *  parts[7] = "Greyhawk";
                     * }
                     */
                    Map mapDest = Map.Parse(parts[7]);

                    Teleport teleport = new Teleport(pointLoc, mapLoc, pointDest, mapDest);
                    if (bool.Parse(parts[8]))
                    {
                        teleport.Oneway = false;
                    }

                    Point4D Loc = new Point4D(pointLoc.X, pointLoc.Y, pointLoc.Z, mapLoc.MapID);
                    if (m_TeleportersD1.ContainsKey(Loc))
                    {
                        continue;
                    }
                    m_TeleportersD1.Add(Loc, teleport);

                    if (teleport.Oneway == false)
                    {
                        Teleport teleport2 = new Teleport(pointLoc, mapLoc, pointDest, mapDest);
                        teleport2.Oneway = teleport.Oneway;
                        Point4D Dest = new Point4D(pointDest.X, pointDest.Y, pointDest.Z, mapDest.MapID);
                        if (m_TeleportersD2.ContainsKey(Dest))
                        {
                            continue;
                        }
                        m_TeleportersD2.Add(Dest, teleport2);
                    }
                }
                catch (FormatException)
                {
                    Console.WriteLine(string.Format("Bad number format on line {0}", lineNum));
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(string.Format("Argument Execption {0} on line {1}", ex.Message, lineNum));
                }
            }
            reader.Close();
        }
Beispiel #2
0
        private static void LoadLocations()
        {
            int err_count = 0;

            if (m_Paths == null)
            {
                return;
            }

            string[] paths = m_Paths;

            for (int i = 0; i < paths.Length; i++)
            {
                if (paths[i] == null)
                {
                    continue;
                }

                string text = paths[i];
                if (File.Exists(text))
                {
                    using (StreamReader streamReader = new StreamReader(text))
                    {
                        string text2;
                        while ((text2 = streamReader.ReadLine()) != null)
                        {
                            if (text2.Length != 0 && !text2.StartsWith("#"))
                            {
                                try
                                {
                                    string[] array = text2.Split(new char[]
                                    {
                                        '|'
                                    });
                                    string[] array2 = text2.Split(new char[]
                                    {
                                        '|'
                                    });
                                    int x     = Convert.ToInt32(array[0]);
                                    int y     = Convert.ToInt32(array[1]);
                                    int z     = Convert.ToInt32(array[2]);
                                    int index = Convert.ToInt32(array[3]);

                                    int x2     = Convert.ToInt32(array[4]);
                                    int y2     = Convert.ToInt32(array[5]);
                                    int z2     = Convert.ToInt32(array[6]);
                                    int index2 = Convert.ToInt32(array[7]);

                                    Map mapLoc = Map.AllMaps[index];

                                    Map mapDest = Map.AllMaps[index2];

                                    Point3D  pointLoc  = new Point3D(x, y, z);
                                    Point3D  pointDest = new Point3D(x2, y2, z2);
                                    Teleport teleport  = new Teleport(pointLoc, mapLoc, pointDest, mapDest);

                                    if (array2[8] == "true")
                                    {
                                        teleport.Active = true;
                                    }
                                    else
                                    {
                                        teleport.Active = false;
                                    }
                                    if (array2[9] == "true")
                                    {
                                        teleport.Creatures = true;
                                    }
                                    else
                                    {
                                        teleport.Creatures = false;
                                    }
                                    if (array2[10] == "true")
                                    {
                                        teleport.CombatCheck = true;
                                    }
                                    else
                                    {
                                        teleport.CombatCheck = false;
                                    }
                                    if (array2[11] == "true")
                                    {
                                        teleport.CriminalCheck = true;
                                    }
                                    else
                                    {
                                        teleport.CriminalCheck = false;
                                    }
                                    teleport.SourceEffect = Utility.ToInt32(array2[12]);
                                    teleport.DestEffect   = Utility.ToInt32(array2[13]);
                                    teleport.SoundID      = Utility.ToInt32(array[14]);
                                    teleport.Delay        = TimeSpan.FromSeconds(Convert.ToInt32(array[15]));
                                    if (array2[16] == "true")
                                    {
                                        teleport.Oneway = true;
                                    }
                                    else
                                    {
                                        teleport.Oneway = false;
                                    }
                                    if (array2[17] == "true")
                                    {
                                        teleport.Bonded = true;
                                    }
                                    else
                                    {
                                        teleport.Bonded = false;
                                    }

                                    Point4D Loc = new Point4D(x, y, z, mapLoc.MapID);
                                    if (m_TeleportersD1.ContainsKey(Loc))
                                    {
                                        continue;
                                    }
                                    m_TeleportersD1.Add(Loc, teleport);
                                    if (teleport.Oneway == false)
                                    {
                                        Teleport teleport2 = new Teleport(pointLoc, mapLoc, pointDest, mapDest);
                                        teleport2.Active        = teleport.Active;
                                        teleport2.Bonded        = teleport.Bonded;
                                        teleport2.CombatCheck   = teleport.CombatCheck;
                                        teleport2.Creatures     = teleport.Creatures;
                                        teleport2.CriminalCheck = teleport.CriminalCheck;
                                        teleport2.Delay         = teleport.Delay;
                                        teleport2.DestEffect    = teleport.DestEffect;
                                        teleport2.SoundID       = teleport.SoundID;
                                        teleport2.SourceEffect  = teleport.SourceEffect;
                                        teleport2.Oneway        = teleport.Oneway;
                                        Point4D Dest = new Point4D(x2, y2, z2, mapDest.MapID);
                                        if (m_TeleportersD2.ContainsKey(Dest))
                                        {
                                            continue;
                                        }
                                        m_TeleportersD2.Add(Dest, teleport2);
                                    }
                                }
                                catch
                                {
                                    err_count++;

                                    /*
                                     * Console.Write("ERROR: Bad teleport location entry in ({0}) ", new object[]
                                     *                                  {
                                     *                                          text
                                     *                                  });
                                     * Console.WriteLine(" ERROR COUNT: ({0})", err_count);
                                     */
                                }
                            }
                        }
                    }
                }
            }
        }