Exemple #1
0
		public Game(int conns)
		{
			ClientManager = new GameClientManager(conns);
			if (PhoenixEnvironment.GetConfig().data["client.ping.enabled"] == "1")
			{
				ClientManager.StartConnectionChecker();
			}
			DateTime Now = DateTime.Now;
			Logging.Write("Connecting to database...");
			using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
			{
				Logging.WriteLine("completed!");
				PhoenixEnvironment.GameInstance = this;
				LoadSettings(adapter);
				BanManager = new ModerationBanManager();
				RoleManager = new RoleManager();
				HelpTool = new HelpTool();
				Catalog = new Catalog();
				Navigator = new Navigator();
				ItemManager = new ItemManager();
				RoomManager = new RoomManager();
				AdvertisementManager = new AdvertisementManager();
				PixelManager = new PixelManager();
				AchievementManager = new AchievementManager();
				ModerationTool = new ModerationTool();
				BotManager = new BotManager();
				Marketplace = new Marketplace();
				QuestManager = new QuestManager();
				TextManage = new TextManager();
                Guilds = new GroupManager();
				TextManager.LoadTexts(adapter);
				BanManager.LoadBans(adapter);
                RoleManager.LoadRoles(adapter);
				HelpTool.LoadCategories(adapter);
				HelpTool.LoadTopics(adapter);
				ModerationTool.LoadMessagePresets(adapter);
				ModerationTool.LoadPendingTickets(adapter);
				ItemManager.LoadItems(adapter);
				Catalog.Initialize(adapter);
				Catalog.InitCache();
				Navigator.Initialize(adapter);
				RoomManager.LoadModels(adapter);
				RoomManager.LoadCache();
				NavigatorCache = new NavigatorCache();
				AdvertisementManager.LoadRoomAdvertisements(adapter);
				BotManager.LoadBots(adapter);
				AchievementManager.LoadAchievements(adapter);
				PixelManager.Start();
				ChatCommandHandler.InitFilter(adapter);
				QuestManager.InitQuests();
				GroupManager.LoadGroups(adapter);
				DatabaseCleanup(adapter, 1);
			}
			Task = new Task(new Action(LowPriorityWorker.Process));
			Task.Start();
		}
Exemple #2
0
        public void UnlockAchievement(GameClient Session, uint uint_0, int int_0)
        {
            if (!AchievementManager.Achievements.ContainsKey(uint_0))
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("AchievementID: " + uint_0 + " does not exist in our database!");
                Console.ForegroundColor = ConsoleColor.White;
            }
            else
            {
                Achievement @class = AchievementManager.Achievements[uint_0];
                if (@class != null && !this.UserHasAchievement(Session, @class.Id, int_0) && int_0 >= 1 && int_0 <= @class.Levels)
                {
                    int num  = AchievementManager.CalculateAchievementValue(@class.Dynamic_badgelevel, @class.PixelMultiplier, int_0);
                    int num2 = AchievementManager.CalculateAchievementValue(@class.ScoreBase, @class.PixelMultiplier, int_0);
                    using (TimedLock.Lock(Session.GetHabbo().GetBadgeComponent().BadgeList))
                    {
                        List <string> list = new List <string>();
                        foreach (Badge current in Session.GetHabbo().GetBadgeComponent().BadgeList)
                        {
                            if (current.Code.StartsWith(@class.BadgeCode))
                            {
                                list.Add(current.Code);
                            }
                        }
                        foreach (string current2 in list)
                        {
                            Session.GetHabbo().GetBadgeComponent().RemoveBadge(current2);
                        }
                    }
                    Session.GetHabbo().GetBadgeComponent().GiveBadge(Session, AchievementManager.FormatBadgeCode(@class.BadgeCode, int_0, @class.DynamicBadgeLevel), true);
                    if (Session.GetHabbo().Achievements.ContainsKey(@class.Id))
                    {
                        Session.GetHabbo().Achievements[@class.Id] = int_0;
                        using (DatabaseClient class2 = PhoenixEnvironment.GetDatabase().GetClient())
                        {
                            class2.ExecuteQuery(string.Concat(new object[]
                            {
                                "UPDATE user_achievements SET achievement_level = '",
                                int_0,
                                "' WHERE user_id = '",
                                Session.GetHabbo().Id,
                                "' AND achievement_id = '",
                                @class.Id,
                                "' LIMIT 1; UPDATE user_stats SET AchievementScore = AchievementScore + ",
                                num2,
                                " WHERE Id = '",
                                Session.GetHabbo().Id,
                                "' LIMIT 1; "
                            }));
                            goto IL_346;
                        }
                    }
                    Session.GetHabbo().Achievements.Add(@class.Id, int_0);
                    using (DatabaseClient class2 = PhoenixEnvironment.GetDatabase().GetClient())
                    {
                        class2.ExecuteQuery(string.Concat(new object[]
                        {
                            "INSERT INTO user_achievements (user_id,achievement_id,achievement_level) VALUES ('",
                            Session.GetHabbo().Id,
                            "','",
                            @class.Id,
                            "','",
                            int_0,
                            "'); UPDATE user_stats SET AchievementScore = AchievementScore + ",
                            num2,
                            " WHERE Id = '",
                            Session.GetHabbo().Id,
                            "' LIMIT 1; "
                        }));
                    }
IL_346:
                    ServerMessage Message = new ServerMessage(437u);
                    Message.AppendUInt(@class.Id);
                    Message.AppendInt32(int_0);
                    Message.AppendInt32(1337);
                    Message.AppendStringWithBreak(AchievementManager.FormatBadgeCode(@class.BadgeCode, int_0, @class.DynamicBadgeLevel));
                    Message.AppendInt32(num2);
                    Message.AppendInt32(num);
                    Message.AppendInt32(0);
                    Message.AppendInt32(0);
                    Message.AppendInt32(0);
                    if (int_0 > 1)
                    {
                        Message.AppendStringWithBreak(AchievementManager.FormatBadgeCode(@class.BadgeCode, int_0 - 1, @class.DynamicBadgeLevel));
                    }
                    else
                    {
                        Message.AppendStringWithBreak("");
                    }
                    Message.AppendStringWithBreak(@class.Type);
                    Session.SendMessage(Message);
                    Session.GetHabbo().AchievementScore += num2;
                    Session.GetHabbo().ActivityPoints   += num;
                    Session.GetHabbo().UpdateActivityPointsBalance(num);
                    if (Session.GetHabbo().FriendStreamEnabled)
                    {
                        using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                        {
                            string BadgeCode = "";
                            if (@class.DynamicBadgeLevel)
                            {
                                BadgeCode = @class.BadgeCode + int_0.ToString();
                            }
                            else
                            {
                                BadgeCode = @class.BadgeCode;
                            }

                            if (!string.IsNullOrEmpty(BadgeCode))
                            {
                                string look = PhoenixEnvironment.FilterInjectionChars(Session.GetHabbo().Look);
                                adapter.AddParamWithValue("look", look);
                                adapter.ExecuteQuery("INSERT INTO `friend_stream` (`id`, `type`, `userid`, `gender`, `look`, `time`, `data`) VALUES (NULL, '2', '" + Session.GetHabbo().Id + "', '" + Session.GetHabbo().Gender + "', @look, UNIX_TIMESTAMP(), '" + BadgeCode + "');");
                            }
                        }
                    }
                }
            }
        }