using System; using System.Collections.Generic; using System.Linq; using System.Text; using DuckEmulator.Security; using DuckEmulator.HabboHotel.Inside.Storage.MySql.Database.Interfaces; using DuckEmulator.HabboHotel.Outside.Clients; using DuckEmulator.HabboHotel.Outside.Rooms; namespace DuckEmulator.HabboHotel.Outside.Misc { class Global { private SecurityTimer Timer; // 60 sec ref. private SecurityTimer TimeTimer; // 1 sec ref. internal Global() { Timer = new SecurityTimer((1000 * 60), Expose); Timer.Release(); UpdateConsoleTitle(); TimeTimer = new SecurityTimer(1000, UpdateConsoleTitle); TimeTimer.Release(); } private void Expose() { DateTime Started = DateTime.Now; DuckEnvironment.SocketListener.CleanDDossers(); foreach (Client Client in DuckEnvironment.ClientManager.Clients.Values.ToList()) { if (Client.GetHabbo() != null) { Client.GetHabbo().CheckTimeAchievements(); } } foreach (Room Room in DuckEnvironment.RoomManager.GetRooms()) { if (Room.IsAlive) { Room.CheckUsers(); if (Room.UserCount > 0) { if (Room.UserCount == 1 && Room.RoomEngine.GetUserByHabboName(Room.Owner) != null) { continue; } uint OwnerId = DuckEnvironment.ClientManager.GetIdByUsername(Room.Owner); if (OwnerId <= 0) { continue; } Client Client = DuckEnvironment.ClientManager.GetClientByHabboId(OwnerId); if (Client != null) { Client.GetHabbo().TimeInRoom++; Client.GetHabbo().UpdateVariable("time_inroom", Client.GetHabbo().TimeInRoom); DuckEnvironment.AchievementManager.UpdateAchievement(Client.GetHabbo(), 127); } else { using (IQueryAdapter Adapter = DuckEnvironment.GetAdapter()) { Adapter.runFastQuery("UPDATE users SET time_inroom = time_inroom + 1 WHERE id = '" + OwnerId + "' LIMIT 1"); } } } } } } internal void UpdateConsoleTitle() { Console.Title = "Sessions alive " + DuckEnvironment.ClientManager.Clients.Count + " | Rooms alive " + DuckEnvironment.RoomManager.AliveRooms.Count + " | " + DuckEnvironment.GetRunningTime(true) + ""; foreach (Client Client in DuckEnvironment.ClientManager.Clients.Values.ToList()) { if (Client.GetHabbo() != null) { if (Client.GetHabbo().GetEffectsTable() != null) { Client.GetHabbo().GetEffectsTable().CheckExpired(); } } } } } }