public ServerMessage ComposeUpdateList() { lock (mInnerUpdates) { List <MessengerUpdate> UpdateInfo = new List <MessengerUpdate>(); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { foreach (uint FriendId in mInner) { if (!mInnerUpdates.ContainsKey(FriendId)) { continue; } CharacterInfo Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, FriendId); if (Info == null) { continue; } UpdateInfo.Add(new MessengerUpdate(mInnerUpdates[FriendId], Info)); } mInnerUpdates.Clear(); } return(MessengerUpdateListComposer.Compose(UpdateInfo)); } }
public static void Main(string[] args) { bool_0 = true; DateTime now = DateTime.Now; Output.InitializeStream(true, OutputLevel.DebugInformation); Output.WriteLine("Initializing BoomBang game environment..."); ConfigManager.Initialize(Constants.DataFileDirectory + @"\server-main.cfg"); Output.SetVerbosityLevel((OutputLevel)ConfigManager.GetValue("output.verbositylevel")); foreach (string str in args) { Output.WriteLine("Command line argument: " + str); Input.ProcessInput(str.Split(new char[] { ' ' })); } try { Output.WriteLine("Initializing MySQL manager..."); SqlDatabaseManager.Initialize(); Output.WriteLine("Setting up server listener on port " + ((int)ConfigManager.GetValue("net.bind.port")) + "..."); boomBangTcpListener_0 = new BoomBangTcpListener(new IPEndPoint(IPAddress.Any, (int)ConfigManager.GetValue("net.bind.port")), (int)ConfigManager.GetValue("net.backlog"), new OnNewConnectionCallback(SessionManager.HandleIncomingConnection)); using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { Output.WriteLine("Resetting database counters and statistics..."); smethod_0(client); Output.WriteLine("Initializing game components and workers..."); DataRouter.Initialize(); GlobalHandler.Initialize(); SessionManager.Initialize(); CharacterInfoLoader.Initialize(); UserCredentialsAuthenticator.Initialize(); RegisterManager.Initialize(); Class1.smethod_0(); LaptopHandler.Initialize(); CatalogManager.Initialize(client); FlowerPowerManager.Initialize(); NewsCacheManager.Initialize(client); Navigator.Initialize(client); SpaceManager.Initialize(client); SpaceInfoLoader.Initialize(); SpaceHandler.Initialize(); GameHandler.Initialize(); CrossdomainPolicy.Initialize(@"Data\crossdomain.xml"); WordFilterManager.Initialize(client); AdvertisementManager.Initialize(); ContestHandler.Initialize(); SilverCoinsWorker.Initialize(); ModerationBanManager.Initialize(client); } } catch (Exception exception) { HandleFatalError("Could not initialize BoomBang game environment: " + exception.Message + "\nStack trace: " + exception.StackTrace); return; } TimeSpan span = (TimeSpan)(DateTime.Now - now); Output.WriteLine("The server has initialized successfully (" + Math.Round(span.TotalSeconds, 2) + " seconds). Ready for connections.", OutputLevel.Notification); Output.WriteLine("Pulsa ENTER e introduce un comando. Ten una guía de comandos escribiendo HELP", OutputLevel.Notification); Console.Beep(); }
public static void Takeaway(SqlDatabaseClient MySqlClient, int Amount, string name) { uint ID = CharacterResolverCache.GetUidFromName(name); CharacterInfo info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, ID); int int_0 = info.int_0; int_0 -= Amount; MySqlClient.SetParameter("id", ID); MySqlClient.SetParameter("credits", int_0); MySqlClient.ExecuteNonQuery("UPDATE usuarios SET creditos_oro = @credits WHERE id = @id"); }
public static ServerMessage Compose(ReadOnlyCollection <uint> Friends) { // @LXKAXKAXVBXaCHIkXuzd0zoNeXxIHHH01-01-2011 13:18:32Alex BrookerPYQA ServerMessage Message = new ServerMessage(OpcodesOut.MESSENGER_FRIENDS_LIST); Message.AppendInt32(300); Message.AppendInt32(300); Message.AppendInt32(800); Message.AppendInt32(1100); Message.AppendInt32(0); // unknown. club membership limits y/n maybe?? Message.AppendInt32(Friends.Count); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { foreach (uint FriendId in Friends) { CharacterInfo Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, FriendId); if (Info == null) { continue; } Session Session = SessionManager.GetSessionByCharacterId(Info.Id); Message.AppendUInt32(Info.Id); Message.AppendStringWithBreak(Info.Username); Message.AppendBoolean(true); Message.AppendBoolean(Info.HasLinkedSession); Message.AppendBoolean(Session != null && Session.InRoom); Message.AppendStringWithBreak(Info.HasLinkedSession ? Info.Figure : string.Empty); Message.AppendBoolean(false); Message.AppendStringWithBreak(Info.HasLinkedSession ? Info.Motto : string.Empty); if (Info.HasLinkedSession) { Message.AppendStringWithBreak(string.Empty); } else { DateTime LastOnline = UnixTimestamp.GetDateTimeFromUnixTimestamp(Info.TimestampLastOnline); Message.AppendStringWithBreak(LastOnline.ToShortDateString() + " " + LastOnline.ToShortTimeString()); } Message.AppendStringWithBreak(Info.RealName); Message.AppendStringWithBreak(string.Empty); // Unknown - since RELEASE63-33530-33497 } } return(Message); }
private static void CautionUser(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tool")) { return; } uint UserId = Message.PopWiredUInt32(); string MessageText = Message.PopString(); Session TargetSession = SessionManager.GetSessionByCharacterId(UserId); if (TargetSession != null) { TargetSession.SendData(HotelManagerNotificationComposer.Compose("Caution from moderator:\n\n" + MessageText)); ModerationTicketManager.MarkTicketRespondedToForUser(UserId); } else { Session.SendData(NotificationMessageComposer.Compose("That user is not online at this point in time.")); } CharacterInfo Info = (TargetSession != null ? TargetSession.CharacterInfo : null); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { if (Info == null) { Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, UserId); } if (Info != null) { Info.ModerationCautions++; } ModerationLogs.LogModerationAction(MySqlClient, Session, "Sent caution to user", "User " + TargetSession.CharacterInfo.Username + " (ID " + TargetSession.CharacterId + "): '" + MessageText + "'."); MySqlClient.SetParameter("userid", TargetSession.CharacterInfo.Id); MySqlClient.SetParameter("modid", Session.CharacterId); MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent()); MySqlClient.SetParameter("value", MessageText); MySqlClient.ExecuteNonQuery("INSERT INTO user_cautions (moderator_id,user_id,value,timestamp) VALUES (@modid,@userid,@value,@timestamp)"); } }
public static ServerMessage Compose(ReadOnlyCollection <uint> Friends, List <uint> Requests) { ServerMessage message = new ServerMessage(Opcodes.LAPTOPLOADFRIENDS); message.Append((int)(Friends.Count + Requests.Count)); using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { foreach (uint num in Friends) { CharacterInfo characterInfo = CharacterInfoLoader.GetCharacterInfo(client, num); if (characterInfo != null) { message.Append(characterInfo.Id); message.Append(characterInfo.Username); message.Append(characterInfo.Motto); message.Append(characterInfo.AvatarType); message.Append(characterInfo.AvatarColors); message.Append(characterInfo.Age); message.Append(characterInfo.City); message.Append(""); message.Append(1); message.Append(false); } } foreach (uint num2 in Requests) { CharacterInfo info2 = CharacterInfoLoader.GetCharacterInfo(client, num2); if (info2 != null) { message.Append(info2.Id); message.Append(info2.Username); message.Append(info2.Motto); message.Append(info2.AvatarType); message.Append(info2.AvatarColors); message.Append(info2.Age); message.Append(info2.City); message.Append(""); message.Append(1); message.Append(1); } } } return(message); }
public static ServerMessage Compose(ReadOnlyCollection <uint> Friends, List <uint> Requests) { ServerMessage message = new ServerMessage(FlagcodesOut.LAPTOP, ItemcodesOut.LAPTOP_LOAD_FRIENDS, false); message.AppendParameter((int)(Friends.Count + Requests.Count), false); using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { foreach (uint num in Friends) { CharacterInfo characterInfo = CharacterInfoLoader.GetCharacterInfo(client, num); if (characterInfo != null) { message.AppendParameter(characterInfo.UInt32_0, false); message.AppendParameter(characterInfo.Username, false); message.AppendParameter(characterInfo.Motto, false); message.AppendParameter(characterInfo.AvatarType, false); message.AppendParameter(characterInfo.AvatarColors, false); message.AppendParameter(characterInfo.Age, false); message.AppendParameter(characterInfo.City, false); message.AppendNullParameter(false); message.AppendParameter(1, false); message.AppendParameter(false, false); } } foreach (uint num2 in Requests) { CharacterInfo info2 = CharacterInfoLoader.GetCharacterInfo(client, num2); if (info2 != null) { message.AppendParameter(info2.UInt32_0, false); message.AppendParameter(info2.Username, false); message.AppendParameter(info2.Motto, false); message.AppendParameter(info2.AvatarType, false); message.AppendParameter(info2.AvatarColors, false); message.AppendParameter(info2.Age, false); message.AppendParameter(info2.City, false); message.AppendNullParameter(false); message.AppendParameter(1, false); message.AppendParameter(true, false); } } } return(message); }
private static void smethod_3(Session session_0, ClientMessage clientMessage_0) { string str = InputFilter.FilterString(clientMessage_0.ReadString().Replace('%', ' '), false); if (str.Length >= 1) { CharacterInfo characterInfo = null; using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { client.SetParameter("query", str); DataRow row = client.ExecuteQueryRow("SELECT id FROM usuarios WHERE usuario = @query LIMIT 1"); if (row != null) { characterInfo = CharacterInfoLoader.GetCharacterInfo(client, (uint)row["id"]); } } session_0.SendData(LaptopSearchResultComposer.Compose(characterInfo), false); } }
public void TryAuthenticate(string Username, string Password, string RemoteAddress, bool Register = false) { using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { uint characterId = UserCredentialsAuthenticator.TryAuthenticate(client, Username, Password, RemoteAddress); if (characterId == 0) { this.SendData(AuthenticationKoComposer.Compose(false), false); } else { BoomBang.Game.Characters.CharacterInfo info = CharacterInfoLoader.GetCharacterInfo(client, characterId, this.uint_0, true); if (ModerationBanManager.IsUserIdBlacklisted(info.UInt32_0)) { this.SendData(ModerationBanComposer.Compose(ModerationBanManager.GetBanDetails(info.UInt32_0)), false); SessionManager.StopSession(this.uint_0); } else if ((info != null) && info.HasLinkedSession) { this.characterInfo_0 = info; this.characterInfo_0.TimestampLastOnline = UnixTimestamp.GetCurrent(); CharacterResolverCache.AddToCache(this.characterInfo_0.UInt32_0, this.characterInfo_0.Username, true); this.sessionLaptopFriendCache_0 = new SessionLaptopFriendCache(client, this.CharacterId); this.userIgnoreCache_0 = new UserIgnoreCache(client, this.CharacterId); this.bool_1 = true; if (Register) { this.SendData(RegisterComposer.Compose(this.characterInfo_0), false); } else { this.SendData(AuthenticationOkComposer.Compose(this.characterInfo_0), false); } LaptopHandler.MarkUpdateNeeded(this, 0, true); } else { SessionManager.StopSession(this.uint_0); } } } }
private static void CautionUser(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tool")) { return; } uint UserId = Message.PopWiredUInt32(); string MessageText = Message.PopString(); Session TargetSession = SessionManager.GetSessionByCharacterId(UserId); if (TargetSession != null) { TargetSession.SendData(HotelManagerNotificationComposer.Compose("Caution from moderator:\n\n" + MessageText)); ModerationTicketManager.MarkTicketRespondedToForUser(UserId); } else { Session.SendData(NotificationMessageComposer.Compose("That user is not online at this point in time.")); } CharacterInfo Info = (TargetSession != null ? TargetSession.CharacterInfo : null); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { if (Info == null) { Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, UserId); } if (Info != null) { Info.ModerationCautions++; } ModerationLogs.LogModerationAction(MySqlClient, Session, "Sent caution to user", "User " + TargetSession.CharacterInfo.Username + " (ID " + TargetSession.CharacterId + "): '" + MessageText + "'."); } }
private static void OnFriendRemove(Session Session, ClientMessage Message) { int Amount = Message.PopWiredInt32(); // Precaution: limit queries to 50 if (Amount > 50) { Amount = 50; } List <MessengerUpdate> LocalUpdates = new List <MessengerUpdate>(); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { for (int i = 0; i < Amount; i++) { uint FriendId = Message.PopWiredUInt32(); if (DestroyFriendship(MySqlClient, Session.CharacterId, FriendId)) { Session.MessengerFriendCache.RemoveFromCache(FriendId); LocalUpdates.Add(new MessengerUpdate(-1, CharacterInfoLoader.GenerateNullCharacter(FriendId))); Session TargetSession = SessionManager.GetSessionByCharacterId(FriendId);; if (TargetSession != null) { TargetSession.MessengerFriendCache.RemoveFromCache(Session.CharacterId); TargetSession.SendData(MessengerUpdateListComposer.Compose(new List <MessengerUpdate>() { new MessengerUpdate(-1, CharacterInfoLoader.GenerateNullCharacter(Session.CharacterId)) })); } } } } Session.SendData(MessengerUpdateListComposer.Compose(LocalUpdates)); }
private static void OnMessengerSearch(Session Session, ClientMessage Message) { string SearchQuery = UserInputFilter.FilterString(Message.PopString().Replace('%', ' ')); if (SearchQuery.Length < 1) { return; } List <CharacterInfo> Results = new List <CharacterInfo>(); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { MySqlClient.SetParameter("query", SearchQuery + "%"); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT id FROM characters WHERE username LIKE @query LIMIT 50"); foreach (DataRow Row in Table.Rows) { Results.Add(CharacterInfoLoader.GetCharacterInfo(MySqlClient, (uint)Row["id"])); } } ReadOnlyCollection <uint> CurrentFriends = Session.MessengerFriendCache.Friends; List <CharacterInfo> Friends = new List <CharacterInfo>(); List <CharacterInfo> NonFriends = new List <CharacterInfo>(); foreach (CharacterInfo Info in Results) { if (CurrentFriends.Contains(Info.Id)) { Friends.Add(Info); continue; } NonFriends.Add(Info); } Session.SendData(MessengerSearchResultsComposer.Compose(Friends, NonFriends)); }
private static void GetUserInfo(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tool")) { return; } CharacterInfo Info = null; using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, Message.PopWiredUInt32()); } if (Info == null) { Session.SendData(NotificationMessageComposer.Compose("Could not retrieve user information.")); return; } Session.SendData(ModerationUserInfoComposer.Compose(Info, SessionManager.GetSessionByCharacterId(Info.Id))); }
private static void OnFriendRequest(Session Session, ClientMessage Message) { string RequestName = UserInputFilter.FilterString(Message.PopString()); uint TargetId = CharacterResolverCache.GetUidFromName(RequestName); if (TargetId < 1 || TargetId == Session.CharacterId) { return; } CharacterInfo TargetUserInfo = null; using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { TargetUserInfo = CharacterInfoLoader.GetCharacterInfo(MySqlClient, TargetId); if (!TargetUserInfo.PrivacyAcceptFriends) { Session.SendData(MessengerErrorEvent.Compose(39, 3)); return; } if (FriendshipExists(MySqlClient, Session.CharacterId, TargetUserInfo.Id, false)) { return; } CreateFriendship(MySqlClient, Session.CharacterId, TargetUserInfo.Id, false); } Session NotifySession = SessionManager.GetSessionByCharacterId(TargetUserInfo.Id); if (NotifySession != null) { NotifySession.SendData(MessengerRequestNoficiationComposer.Compose(Session.CharacterId, Session.CharacterInfo.Username)); } QuestManager.ProgressUserQuest(Session, QuestType.SOCIAL_FRIEND); }
public ServerMessage ComposeUpdateList() { lock (this.dictionary_0) { List <LaptopUpdate> updates = new List <LaptopUpdate>(); using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { foreach (uint num in this.list_0) { if (this.dictionary_0.ContainsKey(num)) { CharacterInfo characterInfo = CharacterInfoLoader.GetCharacterInfo(client, num); if (characterInfo != null) { updates.Add(new LaptopUpdate(this.dictionary_0[num], characterInfo)); } } } this.dictionary_0.Clear(); } return(LaptopUpdateListComposer.Compose(updates)); } }
private static void smethod_5(Session session_0, ClientMessage clientMessage_0) { uint characterId = clientMessage_0.ReadUnsignedInteger(); if ((characterId >= 1) && (characterId != session_0.CharacterId)) { CharacterInfo characterInfo = null; using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { characterInfo = CharacterInfoLoader.GetCharacterInfo(client, characterId); if (FriendshipExists(client, session_0.CharacterId, characterInfo.UInt32_0, false)) { return; } CreateFriendship(client, session_0.CharacterId, characterInfo.UInt32_0, false); } Session sessionByCharacterId = SessionManager.GetSessionByCharacterId(characterInfo.UInt32_0); if (sessionByCharacterId != null) { sessionByCharacterId.SendData(LaptopRequestNotificationComposer.Compose(session_0.CharacterInfo), false); } } }
public void TryAuthenticate(string Ticket, string RemoteAddress) { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { uint AuthedUid = SingleSignOnAuthenticator.TryAuthenticate(MySqlClient, Ticket, RemoteAddress); if (AuthedUid <= 0) { SessionManager.StopSession(mId); return; } CharacterInfo Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, AuthedUid, mId, true); if (Info == null || !Info.HasLinkedSession) // not marked online = CharacterInfoLoader failed somehow { SessionManager.StopSession(mId); return; } mCharacterInfo = Info; mAchieventCache = new AchievementCache(MySqlClient, CharacterId); mBadgeCache = new BadgeCache(MySqlClient, CharacterId, mAchieventCache); if (!HasRight("login")) { SessionManager.StopSession(mId); return; } mCharacterInfo.TimestampLastOnline = UnixTimestamp.GetCurrent(); CharacterResolverCache.AddToCache(mCharacterInfo.Id, mCharacterInfo.Username, true); mMessengerFriendCache = new SessionMessengerFriendCache(MySqlClient, CharacterId); mFavoriteRoomsCache = new FavoriteRoomsCache(MySqlClient, CharacterId); mRatedRoomsCache = new RatedRoomsCache(); mInventoryCache = new InventoryCache(MySqlClient, CharacterId); mIgnoreCache = new UserIgnoreCache(MySqlClient, CharacterId); mNewItemsCache = new NewItemsCache(MySqlClient, CharacterId); mAvatarEffectCache = new AvatarEffectCache(MySqlClient, CharacterId); mQuestCache = new QuestCache(MySqlClient, CharacterId); mPetCache = new PetInventoryCache(MySqlClient, CharacterId); // Subscription manager MySqlClient.SetParameter("userid", CharacterId); DataRow Row = MySqlClient.ExecuteQueryRow("SELECT * FROM user_subscriptions WHERE user_id = @userid"); mSubscriptionManager = (Row != null ? new ClubSubscription(CharacterId, (ClubSubscriptionLevel)int.Parse((Row["subscription_level"].ToString())), (double)Row["timestamp_created"], (double)Row["timestamp_expire"], (double)Row["past_time_hc"], (double)Row["past_time_vip"]) : new ClubSubscription(CharacterId, ClubSubscriptionLevel.None, 0, 0, 0, 0)); if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.VipClub) { mBadgeCache.DisableSubscriptionBadge("ACH_VipClub"); } if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.BasicClub) { mBadgeCache.DisableSubscriptionBadge("ACH_BasicClub"); } mAvatarEffectCache.CheckEffectExpiry(this); mAuthProcessed = true; SendData(AuthenticationOkComposer.Compose()); SendData(FuseRightsListComposer.Compose(this)); SendData(UserHomeRoomComposer.Compose(mCharacterInfo.HomeRoom)); SendData(UserEffectListComposer.Compose(AvatarEffectCache.Effects)); SendData(NavigatorFavoriteRoomsComposer.Compose(FavoriteRoomsCache.FavoriteRooms)); SendData(InventoryNewItemsComposer.Compose(NewItemsCache.NewItems)); SendData(MessageOfTheDayComposer.Compose("Welcome to uberHotel.org BETA.\n\n\nThank you for participating in the uberHotel.org BETA test. We hope to gather relevant feedback and ideas to help make this hotel into a success.\n\nPlease submit any bugs, feedback, or ideas via:\nhttp://snowlight.uservoice.com\n\n\nHave fun, and thank you for joining us!")); SendData(AchievementDataListComposer.Compose(AchievementManager.Achievements.Values.ToList())); // This is available status packet (AvailabilityStatusMessageComposer) ServerMessage UnkMessage2 = new ServerMessage(290); UnkMessage2.AppendInt32(1); UnkMessage2.AppendInt32(0); SendData(UnkMessage2); // This is info feed packet (InfoFeedEnableMessageComposer) ServerMessage UnkMessage3 = new ServerMessage(517); UnkMessage3.AppendInt32(1); // 1 = enabled 0 = disabled (true/false) SendData(UnkMessage3); // This is activity points message (ActivityPointsMessageComposer) not sure how this is handled... ServerMessage UnkMessage4 = new ServerMessage(628); UnkMessage4.AppendInt32(1); UnkMessage4.AppendInt32(0); UnkMessage4.AppendInt32(2971); SendData(UnkMessage4); SendData(ClientConfigComposer.Compose(CharacterInfo.ConfigVolume, false)); if (HasRight("moderation_tool")) { SendData(ModerationToolComposer.Compose(this, ModerationPresets.UserMessagePresets, ModerationPresets.UserActionPresets, ModerationPresets.RoomMessagePresets)); foreach (ModerationTicket ModTicket in ModerationTicketManager.ActiveTickets) { SendData(ModerationTicketComposer.Compose(ModTicket)); } } MessengerHandler.MarkUpdateNeeded(this, 0, true); } }
public static void Main(string[] args) { mAlive = true; DateTime InitStart = DateTime.Now; // Set up basic output, configuration, etc Output.InitializeStream(true, OutputLevel.DebugInformation); Output.WriteLine("Initializing Snowlight..."); ConfigManager.Initialize(Constants.DataFileDirectory + "\\server-main.cfg"); Output.SetVerbosityLevel((OutputLevel)ConfigManager.GetValue("output.verbositylevel")); // Load Lang LangManager.Initialize(Constants.LangFileDirectory + "\\lang_" + ConfigManager.GetValue("lang") + ".lang"); // Process args foreach (string arg in args) { Output.WriteLine("Command line argument: " + arg); Input.ProcessInput(arg.Split(' ')); } try { // Initialize and test database Output.WriteLine("Initializing MySQL manager..."); SqlDatabaseManager.Initialize(); // Initialize network components Output.WriteLine("Setting up server listener on port " + (int)ConfigManager.GetValue("net.bind.port") + "..."); mServer = new SnowTcpListener(new IPEndPoint(IPAddress.Any, (int)ConfigManager.GetValue("net.bind.port")), (int)ConfigManager.GetValue("net.backlog"), new OnNewConnectionCallback( SessionManager.HandleIncomingConnection)); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Output.WriteLine("Resetting database counters and statistics..."); PerformDatabaseCleanup(MySqlClient); Output.WriteLine("Initializing game components and workers..."); // Core DataRouter.Initialize(); // Sessions, characters Handshake.Initialize(); GlobalHandler.Initialize(); SessionManager.Initialize(); CharacterInfoLoader.Initialize(); RightsManager.Initialize(MySqlClient); SingleSignOnAuthenticator.Initialize(); // Room management and navigator RoomManager.Initialize(MySqlClient); RoomInfoLoader.Initialize(); RoomHandler.Initialize(); RoomItemHandler.Initialize(); Navigator.Initialize(MySqlClient); // Help and moderation HelpTool.Initialize(MySqlClient); ModerationPresets.Initialize(MySqlClient); ModerationTicketManager.Initialize(MySqlClient); ModerationHandler.Initialize(); ModerationBanManager.Initialize(MySqlClient); // Catalog, pets and items ItemDefinitionManager.Initialize(MySqlClient); CatalogManager.Initialize(MySqlClient); CatalogPurchaseHandler.Initialize(); Inventory.Initialize(); ItemEventDispatcher.Initialize(); PetDataManager.Initialize(MySqlClient); // Messenger MessengerHandler.Initialize(); // Achievements and quests AchievementManager.Initialize(MySqlClient); QuestManager.Initialize(MySqlClient); // Misc/extras CrossdomainPolicy.Initialize("Data\\crossdomain.xml"); InfobusManager.Initialize(); ActivityPointsWorker.Initialize(); BotManager.Initialize(MySqlClient); InterstitialManager.Initialize(MySqlClient); ChatEmotions.Initialize(); EffectsCacheWorker.Initialize(); RecyclerManager.Initialize(MySqlClient); DrinkSetManager.Initialize(MySqlClient); SongManager.Initialize(); TradeHandler.Initialize(); RandomGenerator.Initialize(); StatisticsSyncUtil.Initialize(); // Polish WarningSurpressors.Initialize(); } } catch (Exception e) { HandleFatalError("Could not initialize Snowlight: " + e.Message + "\n" + e.StackTrace); return; } // Init complete TimeSpan TimeSpent = DateTime.Now - InitStart; Output.WriteLine("The server has initialized successfully (" + Math.Round(TimeSpent.TotalSeconds, 2) + " seconds). Ready for connections.", OutputLevel.Notification); Output.WriteLine((string)LangManager.GetValue("initialized.info.cmd"), OutputLevel.Notification); Console.Beep(); Input.Listen(); // This will make the main thread process console while Program.Alive. }
public static void Main(string[] args) { mAlive = true; DateTime InitStart = DateTime.Now; // Set up basic output Console.WriteLine("Initializing Snowlight..."); // Cannot be localized before config+lang is loaded // Load configuration, translation, and re-configure output from config data ConfigManager.Initialize(Constants.DataFileDirectory + "server-main.cfg"); Output.InitializeStream(true, (OutputLevel)ConfigManager.GetValue("output.verbositylevel")); Output.WriteLine("Initializing Snowlight..."); Localization.Initialize(Constants.LangFileDirectory + "lang_" + ConfigManager.GetValue("lang") + ".lang"); // Process args foreach (string arg in args) { Output.WriteLine(Localization.GetValue("core.init.cmdarg", arg)); Input.ProcessInput(arg.Split(' ')); } try { // Initialize and test database Output.WriteLine(Localization.GetValue("core.init.mysql")); SqlDatabaseManager.Initialize(); // Initialize network components Output.WriteLine(Localization.GetValue("core.init.net", ConfigManager.GetValue("net.bind.port").ToString())); mServer = new SnowTcpListener(new IPEndPoint((IPAddress)ConfigManager.GetValue("net.bind.ip"), (int)ConfigManager.GetValue("net.bind.port")), (int)ConfigManager.GetValue("net.backlog"), new OnNewConnectionCallback( SessionManager.HandleIncomingConnection)); Output.WriteLine(Localization.GetValue("core.init.net", ConfigManager.GetValue("net.cmd.bind.port").ToString())); musServer = new SnowTcpListener(new IPEndPoint((IPAddress)ConfigManager.GetValue("net.cmd.bind.ip"), (int)ConfigManager.GetValue("net.cmd.bind.port")), (int)ConfigManager.GetValue("net.backlog"), new OnNewConnectionCallback( CommandListener.parse)); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Output.WriteLine(Localization.GetValue("core.init.dbcleanup")); PerformDatabaseCleanup(MySqlClient); Output.WriteLine(Localization.GetValue("core.init.game")); // Core DataRouter.Initialize(); // Sessions, characters Handshake.Initialize(); GlobalHandler.Initialize(); SessionManager.Initialize(); CharacterInfoLoader.Initialize(); RightsManager.Initialize(MySqlClient); SingleSignOnAuthenticator.Initialize(); // Room management and navigator RoomManager.Initialize(MySqlClient); RoomInfoLoader.Initialize(); RoomHandler.Initialize(); RoomItemHandler.Initialize(); Navigator.Initialize(MySqlClient); // Help and moderation HelpTool.Initialize(MySqlClient); ModerationPresets.Initialize(MySqlClient); ModerationTicketManager.Initialize(MySqlClient); ModerationHandler.Initialize(); ModerationBanManager.Initialize(MySqlClient); // Catalog, pets and items ItemDefinitionManager.Initialize(MySqlClient); CatalogManager.Initialize(MySqlClient); CatalogPurchaseHandler.Initialize(); Inventory.Initialize(); ItemEventDispatcher.Initialize(); PetDataManager.Initialize(MySqlClient); // Messenger MessengerHandler.Initialize(); // Achievements and quests AchievementManager.Initialize(MySqlClient); QuestManager.Initialize(MySqlClient); // Misc/extras CrossdomainPolicy.Initialize("Data\\crossdomain.xml"); InfobusManager.Initialize(); ActivityPointsWorker.Initialize(); BotManager.Initialize(MySqlClient); InterstitialManager.Initialize(MySqlClient); ChatEmotions.Initialize(); EffectsCacheWorker.Initialize(); RecyclerManager.Initialize(MySqlClient); DrinkSetManager.Initialize(MySqlClient); SongManager.Initialize(); TradeHandler.Initialize(); RandomGenerator.Initialize(); StatisticsSyncUtil.Initialize(); Wordfilter.Initialize(MySqlClient); // Polish WarningSurpressors.Initialize(); } } catch (Exception e) { HandleFatalError(Localization.GetValue("core.init.error.details", new string[] { e.Message, e.StackTrace })); return; } // Init complete TimeSpan TimeSpent = DateTime.Now - InitStart; Output.WriteLine(Localization.GetValue("core.init.ok", Math.Round(TimeSpent.TotalSeconds, 2).ToString()), OutputLevel.Notification); Output.WriteLine((string)Localization.GetValue("core.init.ok.cmdinfo"), OutputLevel.Notification); Console.Write("$" + Environment.UserName.ToLower() + "@snowlight> "); Console.Beep(); Input.Listen(); // This will make the main thread process console while Program.Alive. }
private static void CloseTicket(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tickets")) { return; } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { int ResultCode = Message.PopWiredInt32(); int Unknown1 = Message.PopWiredInt32(); lock (mSyncRoot) { ModerationTicket Ticket = GetTicket(Message.PopWiredUInt32()); if (Ticket == null || Ticket.Status != ModerationTicketStatus.Assigned || Ticket.ModeratorUserId != Session.CharacterId) { return; } ModerationTicketStatus ResultStatus = ModerationTicketStatus.Resolved; Session TargetSession = SessionManager.GetSessionByCharacterId(Ticket.ReporteeUserId); switch (ResultCode) { case 1: ResultStatus = ModerationTicketStatus.ClosedInvalid; break; case 2: ResultStatus = ModerationTicketStatus.ClosedAbusive; break; } Ticket.UpdateStatus(MySqlClient, ResultStatus); SendDataToAllModerators(ModerationTicketComposer.Compose(Ticket)); if (TargetSession != null && !Ticket.ModeratorResponded) { TargetSession.SendData(HelpCfhClosedResultComposer.Compose(ResultCode)); } if (ResultStatus == ModerationTicketStatus.ClosedAbusive) { CharacterInfo TargetInfo = TargetSession == null?CharacterInfoLoader.GetCharacterInfo(MySqlClient, Ticket.ReporteeUserId) : TargetSession.CharacterInfo; if (TargetInfo != null) { TargetInfo.ModerationTicketsCooldownSeconds = 600; TargetInfo.ModerationTicketsAbusive++; // Sync our new statistics manually if this will not happen by session closure if (TargetSession == null) { TargetInfo.SynchronizeStatistics(MySqlClient); } } } } } }
public void TryAuthenticate(string Ticket, string RemoteAddress) { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { uint AuthedUid = SingleSignOnAuthenticator.TryAuthenticate(MySqlClient, Ticket, RemoteAddress); if (AuthedUid <= 0) { SessionManager.StopSession(mId); return; } CharacterInfo Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, AuthedUid, mId, true); if (Info == null || !Info.HasLinkedSession) // not marked online = CharacterInfoLoader failed somehow { SessionManager.StopSession(mId); return; } mCharacterInfo = Info; mAchieventCache = new AchievementCache(MySqlClient, CharacterId); mBadgeCache = new BadgeCache(MySqlClient, CharacterId, mAchieventCache); if (!HasRight("login")) { SessionManager.StopSession(mId); return; } mCharacterInfo.TimestampLastOnline = UnixTimestamp.GetCurrent(); CharacterResolverCache.AddToCache(mCharacterInfo.Id, mCharacterInfo.Username, true); mMessengerFriendCache = new SessionMessengerFriendCache(MySqlClient, CharacterId); mFavoriteRoomsCache = new FavoriteRoomsCache(MySqlClient, CharacterId); mRatedRoomsCache = new RatedRoomsCache(); mInventoryCache = new InventoryCache(MySqlClient, CharacterId); mIgnoreCache = new UserIgnoreCache(MySqlClient, CharacterId); mNewItemsCache = new NewItemsCache(MySqlClient, CharacterId); mAvatarEffectCache = new AvatarEffectCache(MySqlClient, CharacterId); mQuestCache = new QuestCache(MySqlClient, CharacterId); mPetCache = new PetInventoryCache(MySqlClient, CharacterId); // Subscription manager MySqlClient.SetParameter("userid", CharacterId); DataRow Row = MySqlClient.ExecuteQueryRow("SELECT * FROM user_subscriptions WHERE user_id = @userid"); mSubscriptionManager = (Row != null ? new ClubSubscription(CharacterId, (ClubSubscriptionLevel)int.Parse((Row["subscription_level"].ToString())), (double)Row["timestamp_created"], (double)Row["timestamp_expire"], (double)Row["past_time_hc"], (double)Row["past_time_vip"]) : new ClubSubscription(CharacterId, ClubSubscriptionLevel.None, 0, 0, 0, 0)); if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.VipClub) { mBadgeCache.DisableSubscriptionBadge("ACH_VipClub"); } if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.BasicClub) { mBadgeCache.DisableSubscriptionBadge("ACH_BasicClub"); } mAvatarEffectCache.CheckEffectExpiry(this); mAuthProcessed = true; SendData(AuthenticationOkComposer.Compose()); SendData(FuseRightsListComposer.Compose(this)); SendData(UserHomeRoomComposer.Compose(mCharacterInfo.HomeRoom)); SendData(UserEffectListComposer.Compose(AvatarEffectCache.Effects)); SendData(NavigatorFavoriteRoomsComposer.Compose(FavoriteRoomsCache.FavoriteRooms)); SendData(InventoryNewItemsComposer.Compose(NewItemsCache.NewItems)); SendData(AchievementDataListComposer.Compose(AchievementManager.Achievements.Values.ToList())); SendData(AvailabilityStatusMessageComposer.Compose()); SendData(InfoFeedEnableMessageComposer.Compose(1)); SendData(ActivityPointsMessageComposer.Compose()); if (HasRight("moderation_tool")) { SendData(ModerationToolComposer.Compose(this, ModerationPresets.UserMessagePresets, ModerationPresets.UserActionPresets, ModerationPresets.RoomMessagePresets)); foreach (ModerationTicket ModTicket in ModerationTicketManager.ActiveTickets) { SendData(ModerationTicketComposer.Compose(ModTicket)); } } MessengerHandler.MarkUpdateNeeded(this, 0, true); } }
public static void Main(string[] args) { mAlive = true; DateTime InitStart = DateTime.Now; // Set up basic output Console.WriteLine("Initializing Snowlight..."); // Cannot be localized before config+lang is loaded // Load configuration, translation, and re-configure output from config data ConfigManager.Initialize(Constants.DataFileDirectory + "server-main.cfg"); Output.InitializeStream(true, (OutputLevel)ConfigManager.GetValue("output.verbositylevel")); Output.WriteLine("Initializing Snowlight..."); Localization.Initialize(Constants.LangFileDirectory + "lang_" + ConfigManager.GetValue("lang") + ".lang"); // Process args foreach (string arg in args) { Output.WriteLine(Localization.GetValue("core.init.cmdarg", arg)); Input.ProcessInput(arg.Split(' ')); } try { // Initialize and test database Output.WriteLine(Localization.GetValue("core.init.mysql")); SqlDatabaseManager.Initialize(); // Initialize network components Output.WriteLine(Localization.GetValue("core.init.net", ConfigManager.GetValue("net.bind.port").ToString())); mServer = new SnowTcpListener(new IPEndPoint((IPAddress)ConfigManager.GetValue("net.bind.ip"), (int)ConfigManager.GetValue("net.bind.port")), (int)ConfigManager.GetValue("net.backlog"), new OnNewConnectionCallback( SessionManager.HandleIncomingConnection)); /*Output.WriteLine(Localization.GetValue("core.init.net", ConfigManager.GetValue("net.cmd.bind.port").ToString())); * musServer = new SnowTcpListener(new IPEndPoint((IPAddress)ConfigManager.GetValue("net.cmd.bind.ip"), (int)ConfigManager.GetValue("net.cmd.bind.port")), * (int)ConfigManager.GetValue("net.backlog"), new OnNewConnectionCallback( * CommandListener.parse));*/ using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Output.WriteLine(Localization.GetValue("core.init.dbcleanup")); PerformDatabaseCleanup(MySqlClient); Output.WriteLine(Localization.GetValue("core.init.game")); // Core DataRouter.Initialize(); // Sessions, characters SessionManager.Initialize(); // RandomGenerator.Initialize(); StatisticsSyncUtil.Initialize(); //Global Handler Global.Initialize(); //Login Handler Login.Initialize(); CharacterInfoLoader.Initialize(); UserCredentialsAuthenticator.Initialize(); //Bpad Handler LaptopHandler.Initialize(); //FlowerHandler FlowerPower.Initialize(); ContestHandler.Initialize(); CatalogManager.Initialize(MySqlClient); NewsCacheManager.Initialize(MySqlClient); SpaceInfoLoader.Initialize(); Navigator.Initialize(MySqlClient); LaptopHandler.Initialize(); UserCredentialsAuthenticator.Initialize(); SpaceManager.Initialize(MySqlClient); SpaceHandler.Initialize(); SilverCoinsWorker.Initialize(); } } catch (Exception e) { HandleFatalError(Localization.GetValue("core.init.error.details", new string[] { e.Message, e.StackTrace })); return; } // Init complete TimeSpan TimeSpent = DateTime.Now - InitStart; Output.WriteLine(Localization.GetValue("core.init.ok", Math.Round(TimeSpent.TotalSeconds, 2).ToString()), OutputLevel.Notification); Output.WriteLine((string)Localization.GetValue("core.init.ok.cmdinfo"), OutputLevel.Notification); Console.Write("$" + Environment.UserName.ToLower() + "@snowlight> "); Console.Beep(); Input.Listen(); // This will make the main thread process console while Program.Alive. }