public void ReloadAllWarpplates()
 {
     try
     {
         using (QueryResult queryResult = DbExt.QueryReader(this.database, "SELECT * FROM Warpplates WHERE WorldID=@0", new object[]
         {
             Main.worldID.ToString()
         }))
         {
             this.Warpplates.Clear();
             while (queryResult.Read())
             {
                 int num = queryResult.Get<int>("X1");
                 int num2 = queryResult.Get<int>("Y1");
                 int height = queryResult.Get<int>("height");
                 int width = queryResult.Get<int>("width");
                 int num3 = queryResult.Get<int>("Protected");
                 string text = queryResult.Get<string>("UserIds");
                 string name = queryResult.Get<string>("WarpplateName");
                 string warpdest = queryResult.Get<string>("WarpplateDestination");
                 int delay = queryResult.Get<int>("Delay");
                 string label = queryResult.Get<string>("Label");
                 string[] array = text.Split(new char[]
                 {
                     ','
                 }, StringSplitOptions.RemoveEmptyEntries);
                 Warpplate warpplate = new Warpplate(new Vector2((float)num, (float)num2), new Rectangle(num, num2, width, height), name, warpdest, num3 != 0, Main.worldID.ToString(), label);
                 warpplate.Delay = delay;
                 try
                 {
                     for (int i = 0; i < array.Length; i++)
                     {
                         int item;
                         if (int.TryParse(array[i], out item))
                         {
                             warpplate.AllowedIDs.Add(item);
                         }
                         else
                         {
                             Log.Warn("One of your UserIDs is not a usable integer: " + array[i]);
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     Log.Error("Your database contains invalid UserIDs (they should be ints).");
                     Log.Error("A lot of things will fail because of this. You must manually delete and re-create the allowed field.");
                     Log.Error(ex.ToString());
                     Log.Error(ex.StackTrace);
                 }
                 this.Warpplates.Add(warpplate);
             }
         }
     }
     catch (Exception ex2)
     {
         Log.Error(ex2.ToString());
     }
 }
Esempio n. 2
0
        public void ReloadAllWarpplates()
        {
            try
            {
                using (var reader = database.QueryReader("SELECT * FROM Warpplates WHERE WorldID=@0", Main.worldID.ToString()))
                {
                    Warpplates.Clear();
                    while (reader.Read())
                    {
                        int X1 = reader.Get<int>("X1");
                        int Y1 = reader.Get<int>("Y1");
                        int height = reader.Get<int>("height");
                        int width = reader.Get<int>("width");
                        int Protected = reader.Get<int>("Protected");
                        string mergedids = reader.Get<string>("UserIds");
                        string name = reader.Get<string>("WarpplateName");
                        string warpdest = reader.Get<string>("WarpplateDestination");
                        int Delay = reader.Get<int>("Delay");
                        string label = reader.Get<string>("Label");

                        string[] splitids = mergedids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                        Warpplate r = new Warpplate(new Vector2(X1, Y1), new Rectangle(X1, Y1, width, height), name, warpdest, Protected != 0, Main.worldID.ToString(), label);
                        r.Delay = Delay;

                        try
                        {
                            for (int i = 0; i < splitids.Length; i++)
                            {
                                int id;

                                if (Int32.TryParse(splitids[i], out id)) // if unparsable, it's not an int, so silently skip
                                    r.AllowedIDs.Add(id);
                                else
                                    Log.Warn("One of your UserIDs is not a usable integer: " + splitids[i]);
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Error("Your database contains invalid UserIDs (they should be ints).");
                            Log.Error("A lot of things will fail because of this. You must manually delete and re-create the allowed field.");
                            Log.Error(e.ToString());
                            Log.Error(e.StackTrace);
                        }

                        Warpplates.Add(r);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }
Esempio n. 3
0
 private static string D(Warpplate wp)
 {
     return String.IsNullOrEmpty(wp.Label) ? wp.Name + " (default)" : wp.Label;
 }
 private static string D(Warpplate wp)
 {
     if (!string.IsNullOrEmpty(wp.Label))
     {
         return wp.Label;
     }
     return wp.Name + " (default)";
 }