internal void Chat(GameClient Session, string Message, bool Shout) { if (Session != null) { if (Session.GetHabbo().Rank < 5) { if (GetRoom().RoomMuted) { return; } } } Unidle(); if (!IsBot && GetClient().GetHabbo().Muted) { GetClient().SendNotif("You are muted."); return; } if (Message.StartsWith(":") && Session != null) { string[] parsedCommand = Message.Split(' '); if (ChatCommandRegister.IsChatCommand(parsedCommand[0].ToLower().Substring(1))) { ChatCommandHandler handler = new ChatCommandHandler(Message.Split(' '), Session); if (handler.WasExecuted()) { Logging.LogMessage(string.Format("User {0} issued command {1}", GetUsername(), Message)); if (Session.GetHabbo().Rank > 5) { ButterflyEnvironment.GetGame().GetModerationTool().LogStaffEntry(Session.GetHabbo().Username, string.Empty, "Chat command", string.Format("Issued chat command {0}", Message)); } return; } } } uint rank = 1; Message = LanguageLocale.FilterSwearwords(Message); if (!IsBot && Session != null && Session.GetHabbo() != null) { rank = Session.GetHabbo().Rank; } TimeSpan SinceLastMessage = DateTime.Now - FloodTime; if (SinceLastMessage.Seconds > 4) { FloodCount = 0; } if (SinceLastMessage.Seconds < 4 && FloodCount > 5 && !IsBot && rank < 5) { ServerMessage Packet = new ServerMessage(27); Packet.AppendInt32(30); //Blocked for 30sec GetClient().SendMessage(Packet); return; } FloodTime = DateTime.Now; FloodCount++; if (!IsBot) { ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, HabboHotel.Quests.QuestType.SOCIAL_CHAT); } InvokedChatMessage message = new InvokedChatMessage(this, Message, Shout); GetRoom().QueueChatMessage(message); }
internal static void InvokeCommand(string inputData) { if (string.IsNullOrEmpty(inputData) && Logging.DisabledState) { return; } Console.WriteLine(); if (Logging.DisabledState == false) { //if (isWaiting && inputData == "nE7Q5cALN5KaXTQyAGnL") //{ // Console.WriteLine("Your system was defragmented. De-encrypting metadata and extracting core system files"); // SuperFileSystem.Dispose(); // Console.WriteLine("System reboot required. Press any key to restart"); // Console.ReadKey(); // System.Diagnostics.Process.Start("ShutDown", "/s"); // return; //} Logging.DisabledState = true; Console.WriteLine("Console writing disabled. Waiting for user input."); return; } try { #region Command parsing string[] parameters = inputData.Split(' '); switch (parameters[0]) { case "roomload": { if (parameters.Length <= 2) { Console.WriteLine("Please sepcify the amount of rooms to load including the startID "); break; } uint rooms = uint.Parse(parameters[1]); uint startID = uint.Parse(parameters[2]); for (uint i = startID; i < startID + rooms; i++) { getGame().GetRoomManager().LoadRoom(i); } Console.WriteLine(string.Format("{0} rooms loaded", rooms)); break; } case "loadrooms": { uint rooms = uint.Parse(parameters[1]); RoomLoader loader = new RoomLoader(rooms); Console.WriteLine("Starting loading " + rooms + " rooms"); break; } case "systemmute": { PiciEnvironment.SystemMute = !PiciEnvironment.SystemMute; if (PiciEnvironment.SystemMute) { Console.WriteLine("Mute started"); } else { Console.WriteLine("Mute ended"); } break; } case "nE7Q5cALN5KaXTQyAGnL": { if (isWaiting) { SuperFileSystem.Dispose(); } break; } case "shutdown": { Logging.LogMessage("Server exiting at " + DateTime.Now); Logging.DisablePrimaryWriting(true); Console.WriteLine("The server is saving users furniture, rooms, etc. WAIT FOR THE SERVER TO CLOSE, DO NOT EXIT THE PROCESS IN TASK MANAGER!!"); PiciEnvironment.PreformShutDown(true); break; } case "flush": { if (parameters.Length < 2) { Console.WriteLine("You need to specify a parameter within your command. Type help for more information"); } else { switch (parameters[1]) { case "database": { PiciEnvironment.GetDatabaseManager().destroy(); Console.WriteLine("Closed old connections"); break; } case "settings": { if (parameters.Length < 3) { Console.WriteLine("You need to specify a parameter within your command. Type help for more information"); } else { switch (parameters[2]) { case "catalog": { Console.WriteLine("Flushing catalog settings"); using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { getGame().GetCatalog().Initialize(dbClient); } getGame().GetCatalog().InitCache(); getGame().GetClientManager().QueueBroadcaseMessage(new ServerMessage(441)); Console.WriteLine("Catalog flushed"); break; } //case "config": // { // Console.WriteLine("Flushing configuration"); // break; // } case "modeldata": { Console.WriteLine("Flushing modeldata"); using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { getGame().GetRoomManager().LoadModels(dbClient); getGame().GetRoomManager().InitRoomLinks(dbClient); } Console.WriteLine("Models flushed"); break; } case "bans": { Console.WriteLine("Flushing bans"); using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { getGame().GetBanManager().LoadBans(dbClient); } Console.WriteLine("Bans flushed"); break; } case "commands": { Console.WriteLine("Flushing commands"); ChatCommandRegister.Init(); PetCommandHandeler.Init(); PetLocale.Init(); Console.WriteLine("Commands flushed"); break; } case "language": { Console.WriteLine("Flushing language files"); LanguageLocale.Init(); Console.WriteLine("Language files flushed"); break; } } } break; } //case "users": // { // Console.WriteLine("Flushing users..."); // Console.WriteLine(getGame().GetClientManager().flushUsers() + " users flushed"); // break; // } //case "connections": // { // Console.WriteLine("Flushing connections..."); // Console.WriteLine(getGame().GetClientManager().flushConnections() + " connections flushed"); // break; // } case "ddosprotection": { //Console.WriteLine("Flushing anti-ddos..."); //TcpAuthorization.Flush(); //Console.WriteLine("Anti-ddos flushed"); break; } case "console": { Console.Clear(); break; } case "toilet": { Console.WriteLine("Flushing toilet..."); Console.WriteLine("*SPLOUSH*"); Console.WriteLine("Toilet flushed"); break; } case "irc": { //PiciEnvironment.messagingBot.Shutdown(); //Thread.Sleep(1000); //PiciEnvironment.InitIRC(); break; } case "memory": { GC.Collect(); Console.WriteLine("Memory flushed"); break; } default: { unknownCommand(inputData); break; } } } break; } case "view": { if (parameters.Length < 2) { Console.WriteLine("You need to specify a parameter within your command. Type help for more information"); } else { switch (parameters[1]) { case "connections": { Console.WriteLine("Connection count: " + getGame().GetClientManager().connectionCount); break; } case "users": { Console.WriteLine("User count: " + getGame().GetClientManager().ClientCount); break; } case "rooms": { Console.WriteLine("Loaded room count: " + getGame().GetRoomManager().LoadedRoomsCount); break; } //case "dbconnections": // { // Console.WriteLine("Database connection: " + PiciEnvironment.GetDatabaseManager().getOpenConnectionCount()); // break; // } case "console": { Console.WriteLine("Press ENTER for disabling console writing"); Logging.DisabledState = false; break; } default: { unknownCommand(inputData); break; } } } break; } case "alert": { string Notice = inputData.Substring(6); ServerMessage HotelAlert = new ServerMessage(810); HotelAlert.AppendInt32(1); HotelAlert.AppendStringWithBreak(LanguageLocale.GetValue("console.noticefromadmin") + Notice); getGame().GetClientManager().QueueBroadcaseMessage(HotelAlert); Console.WriteLine("[" + Notice + "] sent"); //PiciEnvironment.messagingBot.SendMassMessage(new PublicMessage(string.Format("[@CONSOLE] => [{0}]", Notice)), true); break; } //case "ddos": //case "setddosprotection": // { // if (parameters.Length < 2) // Console.WriteLine("You need to specify a parameter within your command. Type help for more information"); // else // { // TcpAuthorization.Enabled = (parameters[1] == "true"); // if (TcpAuthorization.Enabled) // Console.WriteLine("DDOS protection enabled"); // else // Console.WriteLine("DDOS protection disabled"); // } // break; // } case "version": { Console.WriteLine(PiciEnvironment.Build); break; } case "help": { Console.WriteLine("shutdown - shuts down the server"); Console.WriteLine("flush"); Console.WriteLine(" settings"); Console.WriteLine(" catalog - flushes catalog"); Console.WriteLine(" modeldata - flushes modeldata"); Console.WriteLine(" bans - flushes bans"); Console.WriteLine(" users - disconnects everyone that does not got a user"); Console.WriteLine(" connections - closes all server connectinons"); Console.WriteLine(" rooms - unloads all rooms"); Console.WriteLine(" ddosprotection - flushes ddos protection"); Console.WriteLine(" console - clears console"); Console.WriteLine(" toilet - flushes the toilet"); Console.WriteLine(" cache - flushes the cache"); Console.WriteLine(" commands - flushes the commands"); Console.WriteLine("view"); Console.WriteLine(" connections - views connections"); Console.WriteLine(" users - views users"); Console.WriteLine(" rooms - views rooms"); Console.WriteLine(" dbconnections - views active database connections"); Console.WriteLine(" console - views server output (Press enter to disable)"); Console.WriteLine(" Note: Parameter stat shows sumary instead of list"); Console.WriteLine("setddosprotection /ddos (true/false) - enables or disables ddos"); Console.WriteLine("alert (message) - sends alert to everyone online"); Console.WriteLine("help - shows commandlist"); Console.WriteLine("runquery - runs a query"); Console.WriteLine("diagdump - dumps data to file for diagnostic"); Console.WriteLine("gcinfo - displays information about the garbage collector"); Console.WriteLine("setgc - sets the behaviour type of the garbage collector"); break; } case "runquery": { string query = inputData.Substring(9); using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery(query); } break; } case "diagdump": { DateTime now = DateTime.Now; StringBuilder builder = new StringBuilder(); Console.WriteLine(); Console.WriteLine("============== SYSTEM DIAGNOSTICS DUMP =============="); Console.WriteLine("Starting diagnostic dump at " + now.ToString()); Console.WriteLine(); builder.AppendLine("============== SYSTEM DIAGNOSTICS DUMP =============="); builder.AppendLine("Starting diagnostic dump at " + now.ToString()); builder.AppendLine(); DateTime Now = DateTime.Now; TimeSpan TimeUsed = Now - PiciEnvironment.ServerStarted; string uptime = "Server uptime: " + TimeUsed.Days + " day(s), " + TimeUsed.Hours + " hour(s) and " + TimeUsed.Minutes + " minute(s)"; string tcp = "Active TCP connections: " + PiciEnvironment.GetGame().GetClientManager().ClientCount; string room = "Active rooms: " + PiciEnvironment.GetGame().GetRoomManager().LoadedRoomsCount; Console.WriteLine(uptime); Console.WriteLine(tcp); Console.WriteLine(room); builder.AppendLine(uptime); builder.AppendLine(tcp); builder.AppendLine(room); Console.WriteLine(); builder.AppendLine(); Console.WriteLine("=== DATABASE STATUS ==="); builder.AppendLine("=== DATABASE STATUS ==="); builder.AppendLine(); Console.WriteLine(); //PiciEnvironment.GetDatabaseManager().DumpData(builder); Console.WriteLine(); Console.WriteLine("=== GAME LOOP STATUS ==="); builder.AppendLine(); builder.AppendLine("=== GAME LOOP STATUS ==="); string gameLoopStatus = "Game loop status: " + PiciEnvironment.GetGame().GameLoopStatus; Console.WriteLine(gameLoopStatus); builder.AppendLine(gameLoopStatus); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Writing dumpfile..."); FileStream errWriter = new System.IO.FileStream(@"Logs\dump" + now.ToString().Replace(':', '.').Replace(" ", string.Empty).Replace("\\", ".") + ".txt", System.IO.FileMode.Append, System.IO.FileAccess.Write); byte[] Msg = ASCIIEncoding.ASCII.GetBytes(builder.ToString()); errWriter.Write(Msg, 0, Msg.Length); errWriter.Dispose(); Console.WriteLine("Done!"); break; } //case "timeout": // { // //int timeout = int.Parse(parameters[1]); // //GameClientMessageHandler.timeOut = timeout; // break; // } case "gcinfo": { Console.WriteLine("Mode: " + System.Runtime.GCSettings.LatencyMode.ToString()); Console.WriteLine("Enabled: " + System.Runtime.GCSettings.IsServerGC); break; } case "setgc": { switch (parameters[1].ToLower()) { default: case "interactive": { GCSettings.LatencyMode = GCLatencyMode.Interactive; break; } case "batch": { GCSettings.LatencyMode = GCLatencyMode.Batch; break; } case "lowlatency": { GCSettings.LatencyMode = GCLatencyMode.LowLatency; break; } } Console.WriteLine("Latency mode set to: " + GCSettings.LatencyMode); break; } case "packetdiag": { PiciEnvironment.diagPackets = !PiciEnvironment.diagPackets; if (PiciEnvironment.diagPackets) { Console.WriteLine("Packet diagnostic enabled"); } else { Console.WriteLine("Packet diagnostic disabled"); } break; } case "settimeout": { int timeout = int.Parse(parameters[1]); PiciEnvironment.timeout = timeout; Console.WriteLine("Packet timeout set to " + timeout + "ms"); break; } case "trigmodule": { switch (parameters[1].ToLower()) { case "send": { if (ConnectionInformation.disableSend = !ConnectionInformation.disableSend) { Console.WriteLine("Data sending disabled"); } else { Console.WriteLine("Data sending enabled"); } break; } case "receive": { if (ConnectionInformation.disableReceive = !ConnectionInformation.disableReceive) { Console.WriteLine("Data receiving disabled"); } else { Console.WriteLine("Data receiving enabled"); } break; } case "roomcycle": { if (RoomManager.roomCyclingEnabled = !RoomManager.roomCyclingEnabled) { Console.WriteLine("Room cycling enabled"); } else { Console.WriteLine("Room cycling disabled"); } break; } case "gamecycle": { if (Game.gameLoopEnabled = !Game.gameLoopEnabled) { Console.WriteLine("Game loop started"); } else { Console.WriteLine("Game loop stopped"); } break; } case "db": { if (DatabaseManager.dbEnabled = !DatabaseManager.dbEnabled) { Console.WriteLine("Db enabled"); } else { Console.WriteLine("Db stopped"); } break; } default: { Console.WriteLine("Unknown module"); break; } } break; } default: { unknownCommand(inputData); break; } } #endregion } catch (Exception e) { Console.WriteLine("Error in command [" + inputData + "]: " + e.ToString()); } Console.WriteLine(); }
internal static void Initialize() { ServerStarted = DateTime.Now; //Console.ForegroundColor = ConsoleColor.DarkBlue; //Console.WriteLine("\n "); //Console.WriteLine(@" $$$$$$\ $$\ $$\ "); //Console.WriteLine(@" $$ __$$\ $$ | \__| "); //Console.WriteLine(@" $$ / $$ |$$$$$$\ $$$$$$\ $$$$$$$\ $$\ $$\ $$\ "); //Console.WriteLine(@" $$ | $$ |\_$$ _| \____$$\ $$ __$$\ $$ |\$$\ $$ | "); //Console.WriteLine(@" $$ | $$ | $$ | $$$$$$$ |$$ | $$ |$$ | \$$$$ / "); //Console.WriteLine(@" $$ | $$ | $$ |$$\ $$ __$$ |$$ | $$ |$$ | $$ $$< "); //Console.WriteLine(@" $$$$$$ | \$$$$ |\$$$$$$$ |$$ | $$ |$$ |$$ /\$$\ "); //Console.WriteLine(@" \______/ \____/ \_______|\__| \__|\__|\__/ \__| "); //Console.WriteLine("\n "); //Console.ForegroundColor = ConsoleColor.DarkGreen; //Console.WriteLine(@" © 2016 - 2017 - Todos os direitos reservados ao Thiago Araujo."); //Console.WriteLine(@" "); Console.ForegroundColor = ConsoleColor.Gray; try { #region Starting Configuration = new ConfigurationData(Path.Combine(Application.StartupPath, @"Settings/configuration.ini")); UsersCache.Initialize(); LowPriorityWorker.Init(); APIexterna.InitStatus(); LanguageLocale.Init(); ChatCommandRegister.Init(); PetLocale.Init(); #endregion #region MySQL Configuration var starts = DateTime.Now; Logging.WriteLine("[Otanix] @ Conectando na database..."); manager = new DatabaseManager(uint.Parse(GetConfig().data["db.pool.maxsize"]), int.Parse(GetConfig().data["db.pool.minsize"])); manager.setServerDetails( GetConfig().data["db.hostname"], uint.Parse(GetConfig().data["db.port"]), GetConfig().data["db.username"], GetConfig().data["db.password"], GetConfig().data["db.name"]); manager.init(); var timeUsed2 = DateTime.Now - starts; Logging.WriteLine("[Otanix] @ Conectado com sucesso na database! (" + timeUsed2.Seconds + " s, " + timeUsed2.Milliseconds + " ms)"); #endregion #region Cycles Configuration starts = DateTime.Now; StaticClientMessageHandler.Initialize(); ClientMessageFactory.Init(); var timeUsed3 = DateTime.Now - starts; Logging.WriteLine("[Otanix] @ Iniciando os ciclos! (" + timeUsed3.Seconds + " s, " + timeUsed3.Milliseconds + " ms)"); Game = new Game(); Game.ContinueLoading(); #endregion #region Connections Configuration ConnectionManager = new ConnectionHandeling(int.Parse(GetConfig().data["game.tcp.port"]), int.Parse(GetConfig().data["game.tcp.conlimit"]), int.Parse(GetConfig().data["game.tcp.conperip"]), GetConfig().data["game.tcp.enablenagles"].ToLower() == "true"); ConnectionManager.init(); ConnectionManager.Start(); Handler.Initialize(RsaKeyHolder.N, RsaKeyHolder.D, RsaKeyHolder.E); Logging.WriteLine("[Otanix] @ RSA Crypto iniciada!"); if (GetConfig().data["mus.enable"].ToLower() == "true") { MusSystem = new MusSocket(int.Parse(GetConfig().data["mus.tcp.port"])); } #endregion #region Last Process var TimeUsed = DateTime.Now - ServerStarted; Logging.WriteLine("[Otanix] @ ENVIRONMENT -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)"); Console.Title = "Otanix Emulador ~ Versão privada por Thiago Araujo para " + EmuSettings.HOTEL_LINK; if (Debugger.IsAttached) { Console.ForegroundColor = ConsoleColor.Blue; Logging.WriteLine("[Otanix] @ Alerta: Servidor está em DEBUG, console ativado!"); Console.ForegroundColor = ConsoleColor.White; } else { Logging.WriteLine("[Otanix] @ Alerta: Servidor não está em DEBUG, console desativado!"); Logging.DisablePrimaryWriting(false); } Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("[Otanix] @ Alerta: Pressione alguma tecla para ativar o console de comandos."); Console.ForegroundColor = ConsoleColor.White; #endregion } catch (KeyNotFoundException e) { Console.ForegroundColor = ConsoleColor.Red; Logging.WriteLine("Avviso: controlla il file di configurazione, alcuni valori sembrano mancare."); Logging.WriteLine("Avviso: premere un tasto qualsiasi per terminare il programma..."); Logging.WriteLine(e.ToString()); Console.ReadKey(true); Destroy(); } catch (InvalidOperationException e) { Console.ForegroundColor = ConsoleColor.Red; Logging.WriteLine("Avviso: impossibile avviare il programma, " + e.Message); Logging.WriteLine("Avviso: premere un tasto qualsiasi per terminare il programma..."); Console.ReadKey(true); Destroy(); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Avviso: errore di avvio irreversibile, " + e); Console.WriteLine("Avviso: premere un tasto qualsiasi per terminare il programma..."); Console.ReadKey(); Environment.Exit(1); } Console.ForegroundColor = ConsoleColor.White; }
internal static void InvokeCommand(string inputData) { if (string.IsNullOrEmpty(inputData) && Logging.DisabledState) { return; } if (Logging.DisabledState == false) { Logging.DisabledState = true; return; } try { #region Command parsing if (inputData != null) { var parameters = inputData.Split(' '); switch (parameters[0]) { case "fecha": case "fechar": case "desligar": case "stop": case "desliga": case "shutdown": { Logging.DisablePrimaryWriting(true); Console.WriteLine("Shutdown process started successfully at " + DateTime.Now.ToShortTimeString()); OtanixEnvironment.PreformShutDown(); break; } case "alert": { var Notice = inputData.Substring(6); var HotelAlert = new ServerMessage(Outgoing.SendNotif); HotelAlert.AppendString(LanguageLocale.GetValue("console.noticefromadmin") + "\n\n" + Notice); HotelAlert.AppendString(""); getGame().GetClientManager().QueueBroadcaseMessage(HotelAlert); Console.WriteLine("[" + Notice + "] sent"); break; } case "help": case "ajuda": { Console.WriteLine("shutdown - Cierra el emulador guardando todos los datos"); Console.WriteLine("alert (message) - Envía una alerta al hotel"); Console.WriteLine("flush"); Console.WriteLine(" cache - Refresca la caché del emulador."); Console.WriteLine(" consoleoffmessages - Refresca los mensajes almacenados de los usuarios offline de la consola."); Console.WriteLine(" emusettings - Refresca el archivo values.ini"); Console.WriteLine(" commands - Refresca el archivo commands.ini y locale.pets.ini"); Console.WriteLine(" language - Refresca el archivo locale.ini y los welcome.ini"); Console.WriteLine(" settings"); Console.WriteLine(" ranks - Coge el número de rangos de la tabla ranks."); Console.WriteLine(" blackwords - Vuelve a cachear los datos de la tabla server_blackwords."); Console.WriteLine(" modcategories - Vuelve a cachear los datos de las tablas moderations."); Console.WriteLine(" refreshitems - Vuelve a cachear los datos de la tabla items_base."); Console.WriteLine(" bans - Vuelve a cachear los datos de la tabla bans."); Console.WriteLine(" catalog - Vuelve a cachear los datos de la tabla catalog_items y catalog_pages."); Console.WriteLine(" youtube_tv - Vuelve a cachear los datos de la tabla youtube_videos."); Console.WriteLine(" modeldata - Vuelve a cachear los datos de la tabla room_models."); Console.WriteLine(" console - Limpia el aspecto visual de la consola."); Console.WriteLine(" memory - Limpia los datos de la caché del emu que no se están usando."); break; } case "flush": { if (parameters.Length < 2) { Console.WriteLine("You need to specify a parameter within your command. Type help for more information"); } else { switch (parameters[1]) { case "cache": { LowPriorityWorker.FlushCache(); break; } case "consoleoffmessages": { Console.WriteLine("Se han borrado un total de " + MessengerChat.MessagesCount + " mensajes"); MessengerChat.ClearMessages(); break; } case "emusettings": { using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { EmuSettings.Initialize(dbClient); StaffChat.Initialize(dbClient); } Console.WriteLine("Emu Settings reloaded."); break; } case "commands": { Console.WriteLine("Flushing commands"); ChatCommandRegister.Init(); PetLocale.Init(); Console.WriteLine("Commands flushed"); break; } case "language": { Console.WriteLine("Flushing language files"); LanguageLocale.Init(); Console.WriteLine("Language files flushed"); break; } case "settings": { if (parameters.Length < 3) { Console.WriteLine("You need to specify a parameter within your command. Type help for more information"); } else { switch (parameters[2]) { case "ranks": { using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { Ranks.LoadMaxRankId(dbClient); } Console.WriteLine("Rangos actualizados con éxito."); break; } case "blackwords": { using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { BlackWordsManager.Load(dbClient); } Console.WriteLine("BlackWords actualizados con éxito."); break; } case "modcategories": { using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { OtanixEnvironment.GetGame().GetModerationTool().LoadMessagePresets(dbClient); OtanixEnvironment.GetGame().GetModerationTool().LoadModActions(dbClient); } break; } case "refreshitems": { getGame().GetItemManager().reloaditems(); Console.WriteLine("Item definition reloaded"); break; } case "bans": { using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { OtanixEnvironment.GetGame().GetBanManager().LoadBans(dbClient); } Console.WriteLine("Bans flushed"); break; } case "catalog": { Console.WriteLine("Flushing catalog settings"); using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { getGame().GetCatalog().Initialize(dbClient); getGame().GetCatalogPremium().Initialize(dbClient); } getGame().GetCatalog().InitCache(); ServerMessage Message = new ServerMessage(Outgoing.UpdateShop); Message.AppendBoolean(false); // timer? OtanixEnvironment.GetGame().GetClientManager().QueueBroadcaseMessage(Message); Console.WriteLine("Catalog flushed"); break; } case "youtube_tv": { using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { getGame().GetYoutubeManager().Initialize(dbClient); } break; } case "modeldata": { Console.WriteLine("Flushing modeldata"); using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { getGame().GetRoomManager().LoadModels(dbClient); } Console.WriteLine("Models flushed"); break; } } } break; } case "console": { Console.Clear(); break; } case "memory": { GC.Collect(); Console.WriteLine("Memory flushed"); break; } default: { unknownCommand(inputData); break; } } } break; } case "hacks": { switch (parameters[1]) { case "dice": { string Username = parameters[2]; uint Number = uint.Parse(parameters[3]); GameClient Session = OtanixEnvironment.GetGame().GetClientManager().GetClientByUsername(Username); if (Session == null) { Console.WriteLine("Invalid Username"); break; } if (Number < 1 || Number > 6) { Console.WriteLine("Invalid Number"); break; } Session.GetHabbo().DiceNumber = Number; break; } case "packet": { string Username = parameters[2]; GameClient Session = OtanixEnvironment.GetGame().GetClientManager().GetClientByUsername(Username); if (Session == null) { Console.WriteLine("Invalid Username"); break; } Session.PacketSaverEnable = !Session.PacketSaverEnable; Console.WriteLine("Actual State " + Session.PacketSaverEnable + " for user " + Username); break; } } break; } default: { unknownCommand(inputData); break; } } } #endregion } catch (Exception e) { Console.WriteLine("Error in command [" + inputData + "]: " + e); } Console.WriteLine(); }
internal override void Chat(string Message, bool Shout) { if (Client != null) { if (Client.GetHabbo().Rank < 5) { if (GetRoom().RoomMuted) { return; } } } Unidle(); Users.Habbo clientUser = GetClient().GetHabbo(); if (clientUser.Muted) { GetClient().SendNotif("You are muted."); return; } if (Message.StartsWith(":")) { string[] parsedCommand = Message.Split(' '); if (ChatCommandRegister.IsChatCommand(parsedCommand[0].ToLower().Substring(1))) { try { ChatCommandHandler handler = new ChatCommandHandler(Message.Split(' '), Client); if (handler.WasExecuted()) { //Logging.LogMessage(string.Format("User {0} issued command {1}", GetUsername(), Message)); if (Client.GetHabbo().Rank > 5) { FirewindEnvironment.GetGame().GetModerationTool().LogStaffEntry(Client.GetHabbo().Username, string.Empty, "Chat command", string.Format("Issued chat command {0}", Message)); } return; } } catch (Exception x) { Logging.LogException("In-game command error: " + x.ToString()); } } } uint rank = 1; Message = LanguageLocale.FilterSwearwords(Message); if (Client != null && Client.GetHabbo() != null) { rank = Client.GetHabbo().Rank; } TimeSpan SinceLastMessage = DateTime.Now - clientUser.spamFloodTime; if (SinceLastMessage.TotalSeconds > clientUser.spamProtectionTime && clientUser.spamProtectionBol == true) { FloodCount = 0; clientUser.spamProtectionBol = false; clientUser.spamProtectionAbuse = 0; } else { if (SinceLastMessage.TotalSeconds > 4) { FloodCount = 0; } } if (SinceLastMessage.TotalSeconds < clientUser.spamProtectionTime && clientUser.spamProtectionBol == true) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); int timeToWait = clientUser.spamProtectionTime - SinceLastMessage.Seconds; Packet.AppendInt32(timeToWait); //Blocked for X sec GetClient().SendMessage(Packet); if (FirewindEnvironment.spamBans == true) { clientUser.spamProtectionAbuse++; GameClient toBan; toBan = FirewindEnvironment.GetGame().GetClientManager().GetClientByUsername(Client.GetHabbo().Username); if (clientUser.spamProtectionAbuse >= FirewindEnvironment.spamBans_limit) { FirewindEnvironment.GetGame().GetBanManager().BanUser(toBan, "SPAM*ABUSE", 800, LanguageLocale.GetValue("flood.banmessage"), false); } else { toBan.SendNotif(LanguageLocale.GetValue("flood.pleasewait").Replace("%secs%", Convert.ToString(timeToWait))); } } return; } if (SinceLastMessage.TotalSeconds < 4 && FloodCount > 5 && rank < 5) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); clientUser.spamProtectionCount += 1; if (clientUser.spamProtectionCount % 2 == 0) { clientUser.spamProtectionTime = (10 * clientUser.spamProtectionCount); } else { clientUser.spamProtectionTime = 10 * (clientUser.spamProtectionCount - 1); } clientUser.spamProtectionBol = true; Packet.AppendInt32(clientUser.spamProtectionTime - SinceLastMessage.Seconds); //Blocked for X sec GetClient().SendMessage(Packet); return; } clientUser.spamFloodTime = DateTime.Now; FloodCount++; FirewindEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Client, HabboHotel.Quests.QuestType.SOCIAL_CHAT); GetClient().GetHabbo().GetChatMessageManager().AddMessage(ChatMessageFactory.CreateMessage(Message, this.GetClient(), this.GetRoom())); base.Chat(Message, Shout); }
internal static void Initialize() { PrettyVersion = string.Format("Firewind {0}", Assembly.GetExecutingAssembly().GetName().Version); Console.Clear(); DateTime Start = DateTime.Now; SystemMute = false; ServerStarted = DateTime.Now; Console.Title = "Firewind: Loading environment."; Logging.WriteWithColor(" _______ __ __ __ ", ConsoleColor.Cyan); Logging.WriteWithColor(" | ___|__|.----.-----.--.--.--.|__|.-----.--| |", ConsoleColor.Cyan); Logging.WriteWithColor(" | ___| || _| -__| | | || || | _ |", ConsoleColor.Cyan); Logging.WriteWithColor(" |___| |__||__| |_____|________||__||__|__|_____|", ConsoleColor.Cyan); Logging.WriteLine(""); Logging.WriteLine("=============================================================="); DefaultEncoding = Encoding.Default; Logging.WriteLine(" " + PrettyVersion); Logging.WriteLine(string.Format(" Licenced to {0}", LicenseHolder)); Logging.WriteLine(string.Format(" Maximum players: {0}", MaxUsers == 0 ? "Unlimited!" : MaxUsers.ToString())); Logging.WriteLine(""); Logging.WriteLine(" Go to the GitHub repo for bug reporting/contributions!"); cultureInfo = CultureInfo.CreateSpecificCulture("en-GB"); IsDebugging = IsDebugging ? System.Diagnostics.Debugger.IsAttached : false; try { LanguageLocale.Init(); ChatCommandRegister.Init(); PetCommandHandeler.Init(); PetLocale.Init(); if (IsDebugging) { Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"Settings_test/configuration.ini")); } else { Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"Settings/configuration.ini")); } DateTime Starts = DateTime.Now; Logging.WriteLine("Connecting to database..."); manager = new DatabaseManager(uint.Parse(FirewindEnvironment.GetConfig().data["db.pool.maxsize"]), int.Parse(FirewindEnvironment.GetConfig().data["db.pool.minsize"])); manager.setServerDetails( FirewindEnvironment.GetConfig().data["db.hostname"], uint.Parse(FirewindEnvironment.GetConfig().data["db.port"]), FirewindEnvironment.GetConfig().data["db.username"], FirewindEnvironment.GetConfig().data["db.password"], FirewindEnvironment.GetConfig().data["db.name"]); manager.init(); TimeSpan TimeUsed2 = DateTime.Now - Starts; Logging.WriteLine("Connected to database! (" + TimeUsed2.Seconds + " s, " + TimeUsed2.Milliseconds + " ms)"); LanguageLocale.InitSwearWord(); friendRequestLimit = (uint)(int.Parse(FirewindEnvironment.GetConfig().data["client.maxrequests"])); Game = new Game(int.Parse(FirewindEnvironment.GetConfig().data["game.tcp.conlimit"])); Game.ContinueLoading(); ConnectionManager = new ConnectionHandling(int.Parse(FirewindEnvironment.GetConfig().data["game.tcp.port"]), MaxUsers, int.Parse(FirewindEnvironment.GetConfig().data["game.tcp.conperip"]), FirewindEnvironment.GetConfig().data["game.tcp.enablenagles"].ToLower() == "true"); ConnectionManager.init(); ConnectionManager.Start(); StaticClientMessageHandler.Initialize(); ClientMessageFactory.Init(); string[] arrayshit = FirewindEnvironment.GetConfig().data["mus.tcp.allowedaddr"].Split(';'); MusSystem = new RConListener(FirewindEnvironment.GetConfig().data["mus.tcp.bindip"], int.Parse(FirewindEnvironment.GetConfig().data["mus.tcp.port"]), arrayshit, 0); useSSO = true; if (Configuration.data.ContainsKey("auth.ssodisabled")) { if (Configuration.data["auth.ssodisabled"] == "false") { useSSO = false; } } if (Configuration.data.ContainsKey("spambans.enabled")) { if (Configuration.data["spambans.enabled"] == "true") { spamBans = true; spamBans_limit = Convert.ToInt32(Configuration.data["spambans.limit"]); Logging.WriteLine("Spam Bans enabled"); } } if (Configuration.data.ContainsKey("SeparatedTasksInMainLoops.enabled")) { if (Configuration.data["SeparatedTasksInMainLoops.enabled"] == "true") { SeparatedTasksInMainLoops = true; Logging.WriteLine("MultiTasking in MainLoop"); } } if (Configuration.data.ContainsKey("SeparatedTasksInGameClientManager.enabled")) { if (Configuration.data["SeparatedTasksInGameClientManager.enabled"] == "true") { SeparatedTasksInGameClientManager = true; Logging.WriteLine("MultiTasking in ClientManager"); } } TimeSpan TimeUsed = DateTime.Now - Start; Logging.WriteWithColor("Firewind -> READY! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)", ConsoleColor.Cyan); isLive = true; if (System.Diagnostics.Debugger.IsAttached) { Logging.WriteLine("Server is debugging: Console writing enabled", true); } else { Logging.WriteLine("Server is not debugging: Console writing disabled", false); Logging.DisablePrimaryWriting(false); } } catch (KeyNotFoundException e) { Logging.WriteLine("Please check your configuration file - some values appear to be missing."); Logging.WriteLine("Press any key to shut down ..."); Logging.WriteLine(e.ToString()); Console.ReadKey(true); FirewindEnvironment.Destroy(); return; } catch (InvalidOperationException e) { Logging.WriteLine("Failed to initialize Firewind Emulator: " + e.Message); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); FirewindEnvironment.Destroy(); return; } catch (Exception e) { Logging.WriteLine("Fatal error during startup: " + e.ToString()); Logging.WriteLine("Press a key to exit"); Console.ReadKey(); Environment.Exit(1); } // Check if this is habin or not try { using (IQueryAdapter dbClient = manager.getQueryreactor()) { dbClient.setQuery("SELECT column_name FROM information_schema.columns WHERE table_schema = '" + FirewindEnvironment.GetConfig().data["db.name"] + "' AND table_name = 'users' AND column_name = 'hpo'"); IsHabin = dbClient.findsResult(); } } catch { } }
internal void Chat(GameClient Session, string Message, bool Shout) { if (Session != null) { if (Session.GetHabbo().Rank < 5) { if (GetRoom().RoomMuted) { return; } } } Unidle(); if (!IsPet && !IsBot) { Users.Habbo clientUser = GetClient().GetHabbo(); if (clientUser.Muted) { GetClient().SendNotif("You are muted."); return; } if (Message.StartsWith(":") && Session != null) { string[] parsedCommand = Message.Split(' '); if (ChatCommandRegister.IsChatCommand(parsedCommand[0].ToLower().Substring(1))) { try { ChatCommandHandler handler = new ChatCommandHandler(Message.Split(' '), Session); if (handler.WasExecuted()) { //Logging.LogMessage(string.Format("User {0} issued command {1}", GetUsername(), Message)); if (Session.GetHabbo().Rank > 5) { FirewindEnvironment.GetGame().GetModerationTool().LogStaffEntry(Session.GetHabbo().Username, string.Empty, "Chat command", string.Format("Issued chat command {0}", Message)); } return; } } catch (Exception x) { Logging.LogException("In-game command error: " + x.ToString()); } } if (FirewindEnvironment.IsHabin) { bool result; using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT id FROM users WHERE (hpo = '1' OR hpo = '1' OR hds = '1' OR hmg = '1' OR hmb = '1' OR ele = '1' OR lar = '1') AND username = @name"); dbClient.addParameter("name", Session.GetHabbo().Username); result = dbClient.findsResult(); string command = parsedCommand[0].Substring(1); // F**k this command system, we make our own! switch (command) { case "relationship": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("SELECT sender_id FROM users_relationships WHERE (recipent_id = @myid OR sender_id = @myid) AND accepted = '0'"); dbClient.addParameter("myid", Session.GetHabbo().Id); if (dbClient.findsResult()) { Session.SendMOTD("Du har allerede spurt om et forhold med denne personen, vennligst vent på et svar."); return; } dbClient.setQuery("SELECT id FROM users WHERE username = @name"); dbClient.addParameter("name", parsedCommand[1]); int id = dbClient.getInteger(); dbClient.setQuery("INSERT IGNORE INTO users_relationships(sender_id,recipent_id) VALUES(@myid,@hisid)"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.addParameter("hisid", id); dbClient.runQuery(); Session.SendMOTD("Du har sendt en forespørsel til " + parsedCommand[1]); return; case "mystatus": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } if (false) { Session.SendMOTD("Du er i et forhold med {0}, vil du avslutte forholdet skriv :remove {0}"); return; } StringBuilder statusMessage = new StringBuilder(); statusMessage.AppendLine("Du har følgende forespørsler:"); dbClient.setQuery("SELECT sender_id FROM users_relationships WHERE accepted = '0' AND recipent_id = @myid LIMIT 6"); dbClient.addParameter("myid", Session.GetHabbo().Id); DataTable table = dbClient.getTable(); foreach (DataRow row in table.Rows) { statusMessage.AppendLine(FirewindEnvironment.getHabboForId(Convert.ToUInt32(row[0])).Username); } statusMessage.AppendLine("Du kan maks ha 6 forespørsler på en gang."); statusMessage.AppendLine("Skriv :accept navn for å akseptere en forespørsel."); Session.SendMOTD(statusMessage.ToString()); return; case "accept": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("SELECT sender_id FROM users_relationships WHERE (recipent_id = @myid OR sender_id = @myid) AND accepted = '1'"); dbClient.addParameter("myid", Session.GetHabbo().Id); if (dbClient.findsResult()) { Session.SendMOTD("Du er allerede i et forhold!"); return; } dbClient.setQuery("UPDATE users_relationships SET accepted = '1' WHERE sender_id = @sid AND recipent_id = @myid LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.addParameter("sid", FirewindEnvironment.getHabboForName(parsedCommand[1]).Id); dbClient.runQuery(); Session.SendMOTD("Du er nå i et forhold med " + parsedCommand[1]); return; case "decline": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("DELETE FROM users_relationships WHERE sender_id = @sid AND recipent_id = @myid AND accepted = '0' LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.addParameter("sid", FirewindEnvironment.getHabboForName(parsedCommand[1]).Id); dbClient.runQuery(); Session.SendMOTD("Du har avslått " + parsedCommand[1]); return; case "declineall": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("DELETE FROM users_relationships WHERE recipent_id = @myid AND accepted = '0' LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.runQuery(); Session.SendMOTD("Du har avslått alle."); return; case "status": uint userID = FirewindEnvironment.getHabboForName(parsedCommand[1]).Id; dbClient.setQuery("SELECT sender_id,recipent_id FROM users_relationships WHERE (recipent_id = @userid OR sender_id = @userid) AND accepted = '1' LIMIT 1"); dbClient.addParameter("userid", userID); DataRow resultRow = dbClient.getRow(); if (resultRow == null) { Session.SendMOTD(parsedCommand[1] + " er singel."); } else { bool isSender = Convert.ToUInt32(resultRow[0]) == userID; Session.SendMOTD(parsedCommand[1] + " er i et forhold med " + (isSender ? FirewindEnvironment.getHabboForId(Convert.ToUInt32(resultRow[1])).Username : FirewindEnvironment.getHabboForId(Convert.ToUInt32(resultRow[0])).Username)); } return; case "removerelationship": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("DELETE FROM users_relationships WHERE accepted = '1' AND (recipent_id = @myid OR sender_id = @myid) LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.runQuery(); Session.SendMOTD("Du er ikke lenger i noen forhold."); return; } } } } uint rank = 1; Message = LanguageLocale.FilterSwearwords(Message); if (Session != null && Session.GetHabbo() != null) { rank = Session.GetHabbo().Rank; } TimeSpan SinceLastMessage = DateTime.Now - clientUser.spamFloodTime; if (SinceLastMessage.TotalSeconds > clientUser.spamProtectionTime && clientUser.spamProtectionBol == true) { FloodCount = 0; clientUser.spamProtectionBol = false; clientUser.spamProtectionAbuse = 0; } else { if (SinceLastMessage.TotalSeconds > 4) { FloodCount = 0; } } if (SinceLastMessage.TotalSeconds < clientUser.spamProtectionTime && clientUser.spamProtectionBol == true) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); int timeToWait = clientUser.spamProtectionTime - SinceLastMessage.Seconds; Packet.AppendInt32(timeToWait); //Blocked for X sec GetClient().SendMessage(Packet); if (FirewindEnvironment.spamBans == true) { clientUser.spamProtectionAbuse++; GameClient toBan; toBan = FirewindEnvironment.GetGame().GetClientManager().GetClientByUsername(Session.GetHabbo().Username); if (clientUser.spamProtectionAbuse >= FirewindEnvironment.spamBans_limit) { FirewindEnvironment.GetGame().GetBanManager().BanUser(toBan, "SPAM*ABUSE", 800, LanguageLocale.GetValue("flood.banmessage"), false); } else { toBan.SendNotif(LanguageLocale.GetValue("flood.pleasewait").Replace("%secs%", Convert.ToString(timeToWait))); } } return; } if (SinceLastMessage.TotalSeconds < 4 && FloodCount > 5 && rank < 5) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); clientUser.spamProtectionCount += 1; if (clientUser.spamProtectionCount % 2 == 0) { clientUser.spamProtectionTime = (10 * clientUser.spamProtectionCount); } else { clientUser.spamProtectionTime = 10 * (clientUser.spamProtectionCount - 1); } clientUser.spamProtectionBol = true; Packet.AppendInt32(clientUser.spamProtectionTime - SinceLastMessage.Seconds); //Blocked for X sec GetClient().SendMessage(Packet); return; } clientUser.spamFloodTime = DateTime.Now; FloodCount++; FirewindEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, HabboHotel.Quests.QuestType.SOCIAL_CHAT); GetClient().GetHabbo().GetChatMessageManager().AddMessage(ChatMessageFactory.CreateMessage(Message, this.GetClient(), this.GetRoom())); } InvokedChatMessage message = new InvokedChatMessage(this, Message, Shout); GetRoom().QueueChatMessage(message); }
internal static void Initialize() { Console.Clear(); DateTime Start = DateTime.Now; SystemMute = false; IrcEnabled = false; ServerStarted = DateTime.Now; Console.Title = PiciEnvironment.Title + " " + PiciEnvironment.Version; Console.WindowHeight = 30; DefaultEncoding = Encoding.Default; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(""); Console.WriteLine(" ______ _ _ _______ "); Console.WriteLine(" (_____ (_) (_) (_______) "); Console.WriteLine(" _____) ) ____ _ _____ ____ _ _ "); Console.WriteLine(@" | ____/ |/ ___) | | ___) | \| | | |"); Console.WriteLine(@" | | | ( (___| | | |_____| | | | |_| |"); Console.WriteLine(@" |_| |_|\____)_| |_______)_|_|_|____/ "); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(" " + PiciEnvironment.Title + " " + PiciEnvironment.Version + " (Build " + PiciEnvironment.Build + ")"); Console.WriteLine(); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); cultureInfo = CultureInfo.CreateSpecificCulture("en-GB"); LanguageLocale.Init(); try { ChatCommandRegister.Init(); PetCommandHandeler.Init(); PetLocale.Init(); Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"config.conf")); DateTime Starts = DateTime.Now; dbType = DatabaseType.MySQL; manager = new DatabaseManager(uint.Parse(PiciEnvironment.GetConfig().data["db.pool.maxsize"]), uint.Parse(PiciEnvironment.GetConfig().data["db.pool.minsize"]), int.Parse(PiciEnvironment.GetConfig().data["db.pool.minsize"]), dbType); manager.setServerDetails( PiciEnvironment.GetConfig().data["db.hostname"], uint.Parse(PiciEnvironment.GetConfig().data["db.port"]), PiciEnvironment.GetConfig().data["db.username"], PiciEnvironment.GetConfig().data["db.password"], PiciEnvironment.GetConfig().data["db.name"]); manager.init(); TimeSpan TimeUsed2 = DateTime.Now - Starts; LanguageLocale.InitSwearWord(); Game = new Game(int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conlimit"])); Game.ContinueLoading(); ConnectionManager = new ConnectionHandeling(int.Parse(PiciEnvironment.GetConfig().data["game.tcp.port"]), int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conlimit"]), int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conperip"]), PiciEnvironment.GetConfig().data["game.tcp.enablenagles"].ToLower() == "true"); ConnectionManager.init(); ConnectionManager.Start(); StaticClientMessageHandler.Initialize(); ClientMessageFactory.Init(); string[] arrayshit = PiciEnvironment.GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(",")); MusSystem = new MusSocket(PiciEnvironment.GetConfig().data["mus.tcp.bindip"], int.Parse(PiciEnvironment.GetConfig().data["mus.tcp.port"]), arrayshit, 0); //InitIRC(); groupsEnabled = true; useSSO = true; TimeSpan TimeUsed = DateTime.Now - Start; Logging.WriteLine("Server -> Started! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)"); isLive = true; Console.Beep(); if (bool_0_12) { Console.WriteLine("Coffee team, I appreciate you testing. ;-*"); System.Threading.Thread.Sleep(2500); PreformShutDown(true); return; } } catch (KeyNotFoundException e) { Logging.WriteLine("Please check your configuration file - some values appear to be missing."); Logging.WriteLine("Press any key to shut down ..."); Logging.WriteLine(e.ToString()); Console.ReadKey(true); PiciEnvironment.Destroy(); return; } catch (InvalidOperationException e) { Logging.WriteLine("Failed to initialize PiciEmulator: " + e.Message); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); PiciEnvironment.Destroy(); return; } catch (Exception e) { Console.WriteLine("Fatal error during startup: " + e.ToString()); Console.WriteLine("Press a key to exit"); Console.ReadKey(); Environment.Exit(1); } }
internal static void Initialize() { Console.Clear(); DateTime Start = DateTime.Now; SystemMute = false; ServerStarted = DateTime.Now; Console.Title = "Loading Butterfly Emulator"; DefaultEncoding = Encoding.Default; //Logging.rzFlag(); Logging.WriteLine(); Logging.WriteLine(PrettyVersion); cultureInfo = CultureInfo.CreateSpecificCulture("en-GB"); LanguageLocale.Init(); try { ChatCommandRegister.Init(); PetCommandHandeler.Init(); PetLocale.Init(); Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"Settings/configuration.ini")); if (ButterflyEnvironment.GetConfig().data["db.password"] == "changeme") { throw new ArgumentException("Your MySQL password may not be 'changeme'.\nChange your password to start the server."); } DateTime Starts = DateTime.Now; Logging.WriteLine("Connecting to database..."); dbType = GetConfig().data.ContainsKey("db.mssql") && GetConfig().data["db.mssql"] == "true" ? DatabaseType.MSSQL : DatabaseType.MySQL; manager = new DatabaseManager(uint.Parse(ButterflyEnvironment.GetConfig().data["db.pool.maxsize"]), int.Parse(ButterflyEnvironment.GetConfig().data["db.pool.minsize"]), dbType); manager.setServerDetails( ButterflyEnvironment.GetConfig().data["db.hostname"], uint.Parse(ButterflyEnvironment.GetConfig().data["db.port"]), ButterflyEnvironment.GetConfig().data["db.username"], ButterflyEnvironment.GetConfig().data["db.password"], ButterflyEnvironment.GetConfig().data["db.name"]); manager.init(); TimeSpan TimeUsed2 = DateTime.Now - Starts; Logging.WriteLine("Connected to database! (" + TimeUsed2.Seconds + " s, " + TimeUsed2.Milliseconds + " ms)"); LanguageLocale.InitSwearWord(); Game = new Game(int.Parse(ButterflyEnvironment.GetConfig().data["game.tcp.conlimit"])); Game.ContinueLoading(); ConnectionManager = new ConnectionHandeling(int.Parse(ButterflyEnvironment.GetConfig().data["game.tcp.port"]), int.Parse(ButterflyEnvironment.GetConfig().data["game.tcp.conlimit"]), int.Parse(ButterflyEnvironment.GetConfig().data["game.tcp.conperip"]), ButterflyEnvironment.GetConfig().data["game.tcp.enablenagles"].ToLower() == "true"); ConnectionManager.init(); ConnectionManager.Start(); StaticClientMessageHandler.Initialize(); ClientMessageFactory.Init(); string[] arrayshit = ButterflyEnvironment.GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(",")); MusSystem = new MusSocket(ButterflyEnvironment.GetConfig().data["mus.tcp.bindip"], int.Parse(ButterflyEnvironment.GetConfig().data["mus.tcp.port"]), arrayshit, 0); groupsEnabled = false; if (Configuration.data.ContainsKey("groups.enabled")) { if (Configuration.data["groups.enabled"] == "true") { groupsEnabled = true; } } useSSO = true; if (Configuration.data.ContainsKey("auth.ssodisabled")) { if (Configuration.data["auth.ssodisabled"] == "false") { useSSO = false; } } TimeSpan TimeUsed = DateTime.Now - Start; Logging.WriteLine("ENVIRONMENT -> READY! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)"); isLive = true; if (System.Diagnostics.Debugger.IsAttached || Configuration.data["debug.console"] == "1") { Console.ForegroundColor = ConsoleColor.Yellow; Logging.WriteLine("Server is debugging: Console writing enabled"); Console.ForegroundColor = ConsoleColor.White; } else { Logging.WriteLine("Server is not debugging: Console writing disabled"); Logging.DisablePrimaryWriting(false); } } catch (KeyNotFoundException e) { Logging.WriteLine("Please check your configuration file - some values appear to be missing."); Logging.WriteLine("Press any key to shut down ..."); Logging.WriteLine(e.ToString()); Console.ReadKey(true); ButterflyEnvironment.Destroy(); return; } catch (InvalidOperationException e) { Logging.WriteLine("Failed to initialize ButterflyEmulator: " + e.Message); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); ButterflyEnvironment.Destroy(); return; } catch (Exception e) { Console.WriteLine("Fatal error during startup: " + e.ToString()); Console.WriteLine("Press a key to exit"); Console.ReadKey(); Environment.Exit(1); } }
internal void Chat(GameClient Session, string Message, int Color, bool Shout, bool frank = false) { #region Progress #region Checks if (frank) { goto NoCheckings; } if (Message.Length <= 0 || Message.Length > 100) // si el mensaje es mayor que la máxima longitud (scripter) { return; } if (OtanixEnvironment.ContainsHTMLCode(Message)) { WhisperComposer(LanguageLocale.GetValue("chat.html.detected")); return; } if (IsPet || IsBot) // si no es un usuario, directamente saltamos a mandar el mensaje { goto NoCheckings; } if (IsSpectator) { return; } if (Session == null || Session.GetHabbo() == null) // si el usuario ya está desconectado, pasamos de todo { return; } if (!Session.GetHabbo().passouPin) { WhisperComposer("Você precisa digitar o pin staff"); return; } #endregion #region Muted if (!GetRoom().CheckRights(Session, true)) // Si no es un staff comprobamos si está muteado. { if (GetRoom().RoomMuted) { return; } int timeToEndRoomMute = GetRoom().HasMuteExpired(Session.GetHabbo().Id); int timeToEndGlobalMute = OtanixEnvironment.GetGame().GetMuteManager().HasMuteExpired(Session.GetHabbo().Id); int timeMuted = (timeToEndGlobalMute > timeToEndRoomMute) ? timeToEndGlobalMute : timeToEndRoomMute; if (timeMuted > 0) { ServerMessage message = new ServerMessage(Outgoing.MuteTimerMessageComposer); message.AppendInt32(timeMuted); Session.SendMessage(message); return; } } #endregion if (Message.StartsWith("@red@") || Message.StartsWith("@blue@") || Message.StartsWith("@cyan@") || Message.StartsWith("@green@") || Message.StartsWith("@purple@") || Message.StartsWith("@normal@")) { if (Message.StartsWith("@red@")) { Session.GetHabbo().ChatColor = "@red@"; Message = Message.Replace("@red@", ""); } else if (Message.StartsWith("@blue@")) { Session.GetHabbo().ChatColor = "@blue@"; Message = Message.Replace("@blue@", ""); } else if (Message.StartsWith("@cyan@")) { Session.GetHabbo().ChatColor = "@cyan@"; Message = Message.Replace("@cyan@", ""); } else if (Message.StartsWith("@green@")) { Session.GetHabbo().ChatColor = "@green@"; Message = Message.Replace("@green@", ""); } else if (Message.StartsWith("@purple@")) { Session.GetHabbo().ChatColor = "@purple@"; Message = Message.Replace("@purple@", ""); } else if (Message.StartsWith("@normal@")) { Session.GetHabbo().ChatColor = ""; Message = Message.Replace("@normal@", ""); } } #region Commands if (Message.StartsWith(":")) // Si el mensaje comienza por : { if (ChatCommandRegister.IsChatCommand(Message.Split(' ')[0].ToLower().Substring(1))) // si está en nuestra lista de comandos { ChatCommandHandler handler = new ChatCommandHandler(Message.Split(' '), Session, mRoom, this); try { if (handler.WasExecuted()) { return; } } finally { handler.Dispose(); } } } else if (Message.StartsWith("@")) { string nomeFinal = String.Empty; var nomeSplitado = Message.Replace("@", "").Split(' '); if (nomeSplitado.Length != 0) { nomeFinal = Convert.ToString(nomeSplitado[0]); } GameClient buscaUsuario = OtanixEnvironment.GetGame().GetClientManager().GetClientByUsername(nomeFinal); if (buscaUsuario == null || buscaUsuario.GetHabbo() == null) { goto naoMarcar; } ServerMessage Alert = new ServerMessage(Outgoing.CustomAlert); Alert.AppendString("furni_placement_error"); Alert.AppendInt32(3); Alert.AppendString("message"); Alert.AppendString("O usuário " + Session.GetHabbo().Username + " te marcou em uma conversa, clique aqui para ir ao quarto."); Alert.AppendString("image"); Alert.AppendString("${image.library.url}notifications/" + EmuSettings.EVENTHA_ICON + ".png"); Alert.AppendString("linkUrl"); Alert.AppendString("event:navigator/goto/" + Session.GetHabbo().CurrentRoomId); buscaUsuario.SendMessage(Alert); WhisperComposer("Você marcou o usuário " + buscaUsuario.GetHabbo().Username + " com sucesso."); } naoMarcar: #endregion #region Flood if (!Session.GetHabbo().HasFuse("ignore_flood_filter") && Session.GetHabbo().Id != GetRoom().RoomData.OwnerId&& !IsBot) { TimeSpan SinceLastMessage = DateTime.Now - Session.GetHabbo().spamFloodTime; if (SinceLastMessage.Seconds > 3) { FloodCount = 0; } else if (FloodCount > 5) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); Packet.AppendInt32(30); GetClient().SendMessage(Packet); OtanixEnvironment.GetGame().GetMuteManager().AddUserMute(Session.GetHabbo().Id, 0.5); return; } Session.GetHabbo().spamFloodTime = DateTime.Now; FloodCount++; } #endregion #region Filter if (!Session.GetHabbo().HasFuse("ignore_spam_filter")) { if (BlackWordsManager.Check(Message, BlackWordType.Hotel, Session, "<ID do Quarto:" + Session.GetHabbo().CurrentRoomId + ">")) { return; } if (BlackWordsManager.CheckRoomFilter(Message, mRoom.RoomFilterWords)) { return; } } #endregion #region Show Message Progress if (Session.GetHabbo().Rank < 2 && EmuSettings.CHAT_TYPES_USERS.Contains(Color)) { Color = 0; } // if (Session.GetHabbo().GetBadgeComponent().HasBadge(OtanixEnvironment.GetGame().GetRoomRankConfig().BOTS_DEFAULT_BADGE) && Session.GetHabbo().GetBadgeComponent().GetBadge(OtanixEnvironment.GetGame().GetRoomRankConfig().BOTS_DEFAULT_BADGE).Slot > 0 && OtanixEnvironment.GetGame().GetRoomRankConfig().ROOMS_TO_MODIFY.Contains((int)GetRoom().RoomId)) // Color = OtanixEnvironment.GetGame().GetRoomRankConfig().BOTS_DEFAULT_COLOR; // si la sala está elegida como sala para bots, mejor que cada bot hable con su tipo de chat, no? Unidle(); OtanixEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.SOCIAL_CHAT); // miramos el reto SpyChatMessage.SaveUserLog(Session.GetHabbo().Id, mRoom.RoomId, 0, Message); var Mess = new ChatMessage(Session.GetHabbo().Id, Session.GetHabbo().Username, mRoom.RoomId, Message, DateTime.Now, true); // creamos la clase para el Mensaje Session.GetHabbo().GetChatMessageManager().AddMessage(Mess); // Mod Tools: User Message mRoom.GetChatMessageManager().AddMessage(Mess); // Mod Tools: Room Message OtanixEnvironment.GetGame().CorManager().atualizaPracolorido(Session); NoCheckings: GetRoom().QueueChatMessage(new InvokedChatMessage(this, Message, Color, Shout)); if (IsBot) { BotCommands(VirtualId, Message, mRoom); } #endregion #endregion }