コード例 #1
0
 public static void Remove(ClanData clandata)
 {
     if (clandata != null)
     {
         Clans.Remove(clandata.ID);
     }
 }
コード例 #2
0
        public static bool SaveAsDatabaseSQL()
        {
            bool result;

            if (!Core.DatabaseType.Equals("MYSQL"))
            {
                result = false;
            }
            else
            {
                using (Dictionary <uint, ClanData> .ValueCollection.Enumerator enumerator = Clans.Database.Values.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ClanData current = enumerator.Current;
                        Clans.SQL_Update(current, true);
                    }
                    goto IL_68;
                }
IL_5A:
                LibRust.Cycle();
                Thread.Sleep(100);
IL_68:
                if (MySQL.Queued)
                {
                    goto IL_5A;
                }
                result = true;
            }
            return(result);
        }
コード例 #3
0
        public static void Remove(string name)
        {
            ClanData clanData = Clans.Find(name);

            if (clanData != null)
            {
                Clans.Remove(clanData);
            }
        }
コード例 #4
0
 public static void Initialize()
 {
     Clans.SaveFilePath = Path.Combine(Core.SavePath, Clans.string_0);
     Clans.Database     = new Dictionary <uint, ClanData>();
     Clans.dictionary_0 = new Dictionary <uint, ulong>();
     if (Core.DatabaseType.Contains("FILE"))
     {
         Clans.Initialized = Clans.LoadAsTextFile();
     }
     if (Core.DatabaseType.Contains("MYSQL"))
     {
         Clans.Initialized = Clans.LoadAsDatabaseSQL();
     }
 }
コード例 #5
0
        public static ClanData Create(string name, ulong leader_id, DateTime created)
        {
            ClanData clanData = new ClanData(Helper.NewSerial, name, "", leader_id, created);
            ClanData result;

            if (clanData == null)
            {
                result = null;
            }
            else
            {
                Clans.Database.Add(clanData.ID, clanData);
                if (Core.DatabaseType.Equals("MYSQL"))
                {
                    Clans.SQL_Update(clanData, false);
                }
                result = clanData;
            }
            return(result);
        }
コード例 #6
0
        public static bool Initialize()
        {
            Initialized = AssemblyVerifed;
            if (!Initialized)
            {
                return(false);
            }
            Helper.Log("RustExtended Initialization", true);
            World.Initialize();
            Zones.Initialize();
            Economy.Initialize();
            Helper.Log("RustExtended Economy " + (Economy.Enabled ? "Enabled" : "Disabled") + ".", true);
            Helper.Log("RustExtended Shopping " + (Shop.Enabled ? "Enabled" : "Disabled") + ".", true);
            Users.Initialize();
            Banned.Initialize();
            Clans.Initialize();
            Blocklist.Initialize();
            LoadoutInitialized = InitializeLoadout();
            if (Config.Initialized)
            {
                Helper.Log("  - " + PremiumConnections + " Allocated Premium Connection(s)", true);
                Helper.Log("  - " + Commands.Count + " Total Command(s)", true);
                Helper.Log("  - " + Ranks.Count + " Total Rank(s)", true);
                Helper.Log("  - " + Kits.Count + " Total Kit(s)", true);
                Helper.Log("  - " + ForbiddenUsername.Count + " Total Forbidden Name(s)", true);
                Helper.Log("  - " + ForbiddenObscene.Count + " Total Obscene(s)", true);
                Helper.Log("  - " + Events.Motd.Count + " Total Message Event(s)", true);
                Helper.Log("  - " + Clans.Levels.Count + " Total Clan Level(s)", true);
            }
            if (LoadoutInitialized)
            {
                Helper.Log("  - " + Loadout.Count + " Loadout", true);
            }
            if (Zones.Initialized)
            {
                Helper.Log("  - " + Zones.Count + " Total Zone(s)", true);
            }
            if (Users.Initialized)
            {
                Helper.Log("  - " + Users.Count + " Total User(s)", true);
            }
            if (Banned.Initialized)
            {
                Helper.Log("  - " + Banned.Count + " Banned User(s)", true);
            }
            if (Clans.Initialized)
            {
                Helper.Log("  - " + Clans.Count + " Total Clan(s)", true);
            }
            if (Economy.Enabled && Shop.Initialized)
            {
                Helper.Log("  - " + Shop.GroupCount + " Total Shop Group(s)", true);
                Helper.Log("  - " + Shop.ItemCount + " Total Shop Item(s)", true);
            }
            if (Blocklist.Initialized)
            {
                Helper.Log("  - " + Blocklist.Count + " Total Blocked IP", true);
            }
            if (Override.LootsFileCreated)
            {
                Helper.Log(" Loots file has been created.", true);
            }
            else if (OverrideLoots && Override.LootsInitialized)
            {
                Helper.Log("  - " + Override.LootsCount + " Overridden Loot(s)", true);
            }
            if (Override.ItemsFileCreated)
            {
                Helper.Log(" Items file has been created.", true);
            }
            else if (OverrideItems && Override.ItemsInitialized)
            {
                Helper.Log("  - " + Override.ItemsCount + " Overridden Item(s)", true);
            }
            Events.Initialize();
            GenericSpawners = UnityEngine.Object.FindObjectsOfType <GenericSpawner>();
            for (int i = 0; i < GenericSpawners.Length; i++)
            {
                int num2 = 0;
                switch (i)
                {
                case 0x2b:
                    GenericSpawners[i].transform.position = new Vector3(6019f, 428.8f, -2296.3f);
                    break;

                case 0x2c:
                    GenericSpawners[i].transform.position = new Vector3(5819f, 428.8f, -1896.3f);
                    break;
                }
                foreach (GenericSpawnerSpawnList.GenericSpawnInstance instance in GenericSpawners[i]._spawnList)
                {
                    GenericSpawnsTotal += instance.targetPopulation;
                    num2 += instance.targetPopulation;
                }
                Helper.Log(string.Format("[GenericSpawner #{0}] Position={1}, Radius={2}, Spawns={3}({4}), Think Delay={5}", new object[] { i, GenericSpawners[i].transform.position.AsString(), GenericSpawners[i].radius, GenericSpawners[i]._spawnList.Count, num2, GenericSpawners[i].thinkDelay }), false);
            }
            return(Initialized);
        }
コード例 #7
0
 public static void DoProcessUsers()
 {
     if (!Events.bool_1)
     {
         Events.bool_1 = true;
         foreach (UserData current in Users.All)
         {
             NetUser netUser = NetUser.FindByUserID(current.SteamID);
             if (netUser != null && !netUser.did_join)
             {
                 netUser = null;
             }
             List <Countdown> list = new List <Countdown>();
             foreach (Countdown current2 in Users.CountdownList(current.SteamID))
             {
                 if (current2.Expires)
                 {
                     if (current2.Expired)
                     {
                         list.Add(current2);
                     }
                     else if (current2.Command.Equals("pvp", StringComparison.OrdinalIgnoreCase) && current.HasFlag(UserFlags.nopvp) && Convert.ToInt32(current2.TimeLeft) < Core.CommandNoPVPCountdown)
                     {
                         current.SetFlag(UserFlags.nopvp, false);
                         if (netUser != null)
                         {
                             Broadcast.Notice(netUser, "☢", Config.GetMessage("Command.PvP.Enabled", netUser, null), 5f);
                         }
                         Broadcast.NoticeAll("☢", Config.GetMessage("Command.PvP.NoticeEnabled", null, current.Username), netUser, 5f);
                     }
                 }
             }
             foreach (Countdown current3 in list)
             {
                 Users.CountdownRemove(current.SteamID, current3);
             }
             if (current.PremiumDate.Millisecond != 0 && current.PremiumDate < DateTime.Now)
             {
                 Users.SetFlags(current.SteamID, UserFlags.premium, false);
                 Users.SetRank(current.SteamID, Users.DefaultRank);
                 Users.SetPremiumDate(current.SteamID, default(DateTime));
                 Broadcast.Notice(netUser, "☢", Config.GetMessage("Player.Premium.Expired", null, null), 5f);
             }
             if (Core.OwnershipDestroyAutoDisable > 0 && Core.DestoryOwnership.ContainsKey(current.SteamID) && Core.DestoryOwnership[current.SteamID] < DateTime.Now)
             {
                 Core.DestoryOwnership.Remove(current.SteamID);
                 if (netUser != null)
                 {
                     Broadcast.Notice(netUser, "☢", Config.GetMessage("Command.Destroy.Disabled", null, null), 5f);
                 }
             }
             Character character;
             if (netUser != null && netUser.did_join && netUser.admin && Character.FindByUser(netUser.userID, out character))
             {
                 Metabolism component = character.GetComponent <Metabolism>();
                 if (component.GetCalorieLevel() < 3000f)
                 {
                     component.AddCalories(3000f - component.GetCalorieLevel());
                 }
                 if (component.GetRadLevel() > 0f)
                 {
                     component.AddAntiRad(component.GetRadLevel());
                 }
             }
         }
         Events.bool_1 = false;
         if (Core.DatabaseType.Equals("MYSQL") && !Events.bool_3 && DateTime.Now.Subtract(Events.dateTime_0).TotalMilliseconds > Core.MySQL_SyncInterval)
         {
             if (Core.MySQL_LogLevel > 2u)
             {
                 Helper.LogSQL("Thread \"ProcessUsers\": Synchronizing server data from MySQL database", false);
             }
             SystemTimestamp restart = SystemTimestamp.Restart;
             Events.bool_3 = true;
             Core.SQL_UpdateServer();
             if (Core.MySQL_Synchronize)
             {
                 Users.SQL_SynchronizeUsers();
             }
             if (Core.MySQL_Synchronize)
             {
                 Clans.SQL_SynchronizeClans();
             }
             Events.dateTime_0 = DateTime.Now;
             Events.bool_3     = false;
             restart.Stop();
             if (Core.MySQL_LogLevel > 2u)
             {
                 Helper.LogSQL("Thread \"ProcessUsers\": Synchronized, is took " + restart.ElapsedSeconds.ToString("0.0000") + " second(s).", false);
             }
         }
     }
 }
コード例 #8
0
 public static void SQL_SynchronizeClans()
 {
     if (Core.DatabaseType.Equals("MYSQL"))
     {
         MySQL.Result result = MySQL.Query("SELECT * FROM `db_clans`;", true);
         if (result != null)
         {
             using (List <MySQL.Row> .Enumerator enumerator = result.Row.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     Predicate <ClanLevel> predicate = null;
                     Clans.Class3          @class    = new Clans.Class3();
                     @class.row_0 = enumerator.Current;
                     uint     asUInt = @class.row_0.Get("id").AsUInt;
                     ClanData clanData;
                     if (Clans.Database.ContainsKey(asUInt))
                     {
                         clanData = Clans.Get(asUInt);
                     }
                     else
                     {
                         Clans.Database.Add(asUInt, clanData = new ClanData(asUInt, null, null, 0uL, default(DateTime)));
                     }
                     if (!Clans.dictionary_0.ContainsKey(asUInt))
                     {
                         Clans.dictionary_0.Add(asUInt, 0uL);
                     }
                     if (Clans.Database[clanData.ID].Hash == Clans.dictionary_0[clanData.ID])
                     {
                         clanData.Name     = @class.row_0.Get("name").AsString;
                         clanData.Abbr     = @class.row_0.Get("abbrev").AsString;
                         clanData.LeaderID = @class.row_0.Get("leader_id").AsUInt64;
                         clanData.Created  = @class.row_0.Get("created").AsDateTime;
                         clanData.Flags    = @class.row_0.Get("flags").AsEnum <ClanFlags>();
                         clanData.Balance  = @class.row_0.Get("balance").AsUInt64;
                         clanData.Tax      = @class.row_0.Get("tax").AsUInt;
                         ClanData         clanData2 = clanData;
                         List <ClanLevel> levels    = Clans.Levels;
                         if (predicate == null)
                         {
                             predicate = new Predicate <ClanLevel>(@class.method_0);
                         }
                         clanData2.SetLevel(levels.Find(predicate));
                         clanData.Experience = @class.row_0.Get("experience").AsUInt64;
                         string[] array = @class.row_0.Get("location").AsString.Replace(", ", ",").Split(new char[]
                         {
                             ','
                         });
                         if (array.Length > 0)
                         {
                             float.TryParse(array[0].Trim(), out clanData.Location.x);
                         }
                         if (array.Length > 1)
                         {
                             float.TryParse(array[1].Trim(), out clanData.Location.y);
                         }
                         if (array.Length > 2)
                         {
                             float.TryParse(array[2].Trim(), out clanData.Location.z);
                         }
                         clanData.MOTD    = @class.row_0.Get("motd").AsString;
                         clanData.Penalty = @class.row_0.Get("penalty").AsDateTime;
                     }
                     else
                     {
                         Clans.SQL_Update(clanData, false);
                     }
                     Clans.dictionary_0[asUInt] = Clans.Database[asUInt].Hash;
                 }
             }
         }
     }
 }
コード例 #9
0
        public static bool LoadAsDatabaseSQL()
        {
            Predicate <ClanLevel> predicate = null;

            Clans.Class1 @class = new Clans.Class1();
            Clans.Loaded = 0;
            ClanData clanData = null;
            UserData userData = null;

            @class.row_0 = null;
            MySQL.Result result  = MySQL.Query("SELECT * FROM `db_clans`;", false);
            MySQL.Result result2 = MySQL.Query("SELECT * FROM `db_clans_members`;", false);
            MySQL.Result result3 = MySQL.Query("SELECT * FROM `db_clans_hostile`;", false);
            if (result2 != null && result != null)
            {
                foreach (MySQL.Row current in result2.Row)
                {
                    Clans.Class2 class2 = new Clans.Class2();
                    class2.class1_0 = @class;
                    ulong asUInt = current.Get("user_id").AsUInt64;
                    class2.uint_0 = current.Get("clan_id").AsUInt;
                    userData      = Users.GetBySteamID(asUInt);
                    if (userData != null && class2.uint_0 != 0u)
                    {
                        if (@class.row_0 == null || @class.row_0.Get("id").AsUInt != class2.uint_0)
                        {
                            @class.row_0 = result.Row.Find(new Predicate <MySQL.Row>(class2.method_0));
                        }
                        if (@class.row_0 == null)
                        {
                            MySQL.Query(string.Format(Clans.SQL_DELETE_MEMBER, asUInt), false);
                        }
                        else
                        {
                            ClanMemberFlags value = current.Get("privileges").AsEnum <ClanMemberFlags>();
                            if (clanData == null || clanData.ID != class2.uint_0)
                            {
                                clanData = Clans.Get(class2.uint_0);
                            }
                            if (clanData == null)
                            {
                                clanData          = new ClanData(class2.uint_0, null, null, 0uL, default(DateTime));
                                clanData.Name     = @class.row_0.Get("name").AsString;
                                clanData.Abbr     = @class.row_0.Get("abbrev").AsString;
                                clanData.LeaderID = @class.row_0.Get("leader_id").AsUInt64;
                                clanData.Created  = @class.row_0.Get("created").AsDateTime;
                                clanData.Flags    = @class.row_0.Get("flags").AsEnum <ClanFlags>();
                                clanData.Balance  = @class.row_0.Get("balance").AsUInt64;
                                clanData.Tax      = @class.row_0.Get("tax").AsUInt;
                                ClanData         clanData2 = clanData;
                                List <ClanLevel> levels    = Clans.Levels;
                                if (predicate == null)
                                {
                                    predicate = new Predicate <ClanLevel>(@class.method_0);
                                }
                                clanData2.SetLevel(levels.Find(predicate));
                                clanData.Experience = @class.row_0.Get("experience").AsUInt64;
                                string[] array = @class.row_0.Get("location").AsString.Split(new char[]
                                {
                                    ','
                                });
                                if (array.Length > 0)
                                {
                                    float.TryParse(array[0], out clanData.Location.x);
                                }
                                if (array.Length > 1)
                                {
                                    float.TryParse(array[1], out clanData.Location.y);
                                }
                                if (array.Length > 2)
                                {
                                    float.TryParse(array[2], out clanData.Location.z);
                                }
                                clanData.MOTD    = @class.row_0.Get("motd").AsString;
                                clanData.Penalty = @class.row_0.Get("penalty").AsDateTime;
                                if (result3 != null)
                                {
                                    foreach (MySQL.Row current2 in result3.Row)
                                    {
                                        if (current2.Get("clan_id").AsUInt == class2.uint_0)
                                        {
                                            clanData.Hostile.Add(current2.Get("hostile_id").AsUInt, current2.Get("ending").AsDateTime);
                                        }
                                    }
                                }
                                Clans.Database.Add(clanData.ID, clanData);
                                Clans.Loaded++;
                            }
                            clanData.Members.Add(userData, value);
                            userData.Clan = clanData;
                        }
                    }
                    else
                    {
                        MySQL.Query(string.Format(Clans.SQL_DELETE_MEMBER, asUInt), false);
                    }
                }
            }
            Clans.dictionary_0.Clear();
            foreach (uint current3 in Clans.Database.Keys)
            {
                Clans.dictionary_0.Add(current3, Clans.Database[current3].Hash);
            }
            return(true);
        }
コード例 #10
0
        public static bool Initialize()
        {
            Core.Initialized = Core.AssemblyVerifed;
            bool result;

            if (!Core.Initialized)
            {
                result = false;
            }
            else
            {
                Helper.Log("RustExtended Initialization", true);
                World.Initialize();
                Zones.Initialize();
                Economy.Initialize();
                Users.Initialize();
                Banned.Initialize();
                Clans.Initialize();
                Blocklist.Initialize();
                Core.LoadoutInitialized = Core.InitializeLoadout();
                if (Spawns.Singleton != null)
                {
                    Spawns.Singleton.Initialize();
                }
                if (Config.Initialized)
                {
                    Helper.Log("  - " + Core.PremiumConnections + " Allocated Premium Connection(s)", true);
                    Helper.Log("  - " + Core.Commands.Count + " Total Command(s)", true);
                    Helper.Log("  - " + Core.Ranks.Count + " Total Rank(s)", true);
                    Helper.Log("  - " + Core.Kits.Count + " Total Kit(s)", true);
                    Helper.Log("  - " + Core.ForbiddenUsername.Count + " Total Forbidden Name(s)", true);
                    Helper.Log("  - " + Core.ForbiddenObscene.Count + " Total Obscene(s)", true);
                    Helper.Log("  - " + Events.Motd.Count + " Total Message Event(s)", true);
                    Helper.Log("  - " + Clans.Levels.Count + " Total Clan Level(s)", true);
                }
                if (Core.LoadoutInitialized)
                {
                }
                if (Zones.Initialized)
                {
                }
                if (Users.Initialized)
                {
                }
                if (Banned.Initialized)
                {
                }
                if (Clans.Initialized)
                {
                }
                if (Economy.Enabled && Shop.Initialized)
                {
                    Helper.Log("  - " + Shop.GroupCount + " Total Shop Group(s)", true);
                    Helper.Log("  - " + Shop.ItemCount + " Total Shop Item(s)", true);
                }
                if (Blocklist.Initialized)
                {
                    Helper.Log("  - " + Blocklist.Count + " Total Blocked IP", true);
                }
                if (!Override.LootsFileCreated)
                {
                    if (Core.OverrideLoots && Override.LootsInitialized)
                    {
                    }
                }
                if (!Override.ItemsFileCreated)
                {
                    if (Core.OverrideItems && Override.ItemsInitialized)
                    {
                    }
                }
                if (Spawns.Initialized)
                {
                    Helper.Log("  - " + Spawns.TotalGeneric + " Generic Spawner(s)", true);
                    Helper.Log("  - " + Spawns.TotalLootable + " Lootable Spawner(s)", true);
                }
                Events.Initialize();
                result = Core.Initialized;
            }
            return(result);
        }
コード例 #11
0
 public static void DoProcessUsers()
 {
     if (!bool_1)
     {
         bool_1 = true;
         foreach (UserData data in Users.All)
         {
             Character character;
             NetUser   player = NetUser.FindByUserID(data.SteamID);
             if ((player != null) && !player.did_join)
             {
                 player = null;
             }
             System.Collections.Generic.List <Countdown> list = new System.Collections.Generic.List <Countdown>();
             foreach (Countdown countdown in Users.CountdownList(data.SteamID))
             {
                 if (countdown.Expires)
                 {
                     if (countdown.Expired)
                     {
                         list.Add(countdown);
                     }
                     else if ((countdown.Command.Equals("pvp", StringComparison.OrdinalIgnoreCase) && data.HasFlag(UserFlags.nopvp)) && (Convert.ToInt32(countdown.TimeLeft) < Core.CommandNoPVPCountdown))
                     {
                         data.SetFlag(UserFlags.nopvp, false);
                         if (player != null)
                         {
                             Broadcast.Notice(player, "☢", Config.GetMessage("Command.PvP.Enabled", player, null), 5f);
                         }
                         Broadcast.NoticeAll("☢", Config.GetMessage("Command.PvP.NoticeEnabled", null, data.Username), player, 5f);
                     }
                 }
             }
             foreach (Countdown countdown2 in list)
             {
                 Users.CountdownRemove(data.SteamID, countdown2);
             }
             if ((data.PremiumDate.Millisecond != 0) && (data.PremiumDate < DateTime.Now))
             {
                 Users.SetFlags(data.SteamID, UserFlags.premium, false);
                 Users.SetRank(data.SteamID, Users.DefaultRank);
                 DateTime date = new DateTime();
                 Users.SetPremiumDate(data.SteamID, date);
                 Broadcast.Notice(player, "☢", Config.GetMessage("Player.Premium.Expired", null, null), 5f);
             }
             if (((Core.OwnershipDestroyAutoDisable > 0) && Core.DestoryOwnership.ContainsKey(data.SteamID)) && (Core.DestoryOwnership[data.SteamID] < DateTime.Now))
             {
                 Core.DestoryOwnership.Remove(data.SteamID);
                 if (player != null)
                 {
                     Broadcast.Notice(player, "☢", Config.GetMessage("Command.Destroy.Disabled", null, null), 5f);
                 }
             }
             if (((player != null) && player.did_join) && (player.admin && Character.FindByUser(player.userID, out character)))
             {
                 Metabolism component = character.GetComponent <Metabolism>();
                 if (component.GetCalorieLevel() < 3000f)
                 {
                     component.AddCalories(3000f - component.GetCalorieLevel());
                 }
                 if (component.GetRadLevel() > 0f)
                 {
                     component.AddAntiRad(component.GetRadLevel());
                 }
             }
         }
         bool_1 = false;
         if ((Core.DatabaseType.Equals("MYSQL") && !bool_3) && (DateTime.Now.Subtract(dateTime_0).TotalMilliseconds > Core.MySQL_SyncInterval))
         {
             if (Core.MySQL_LogLevel > 2)
             {
                 Helper.LogSQL("Thread \"ProcessUsers\": Synchronizing server data from MySQL database", false);
             }
             SystemTimestamp restart = SystemTimestamp.Restart;
             bool_3 = true;
             Core.SQL_UpdateServer();
             if (Core.MySQL_Synchronize)
             {
                 Users.SQL_SynchronizeUsers();
             }
             if (Core.MySQL_Synchronize)
             {
                 Clans.SQL_SynchronizeClans();
             }
             dateTime_0 = DateTime.Now;
             bool_3     = false;
             restart.Stop();
             if (Core.MySQL_LogLevel > 2)
             {
                 Helper.LogSQL("Thread \"ProcessUsers\": Synchronized, is took " + restart.ElapsedSeconds.ToString("0.0000") + " second(s).", false);
             }
         }
     }
 }