protected Collector(string name) { Name = name; ModuleName = GetType().Name; ConsolePrefix = $"[{ModuleName}]"; JsonName = char.ToLower(ModuleName[0]) + ModuleName.Substring(1); WriteConsoleVerbose("Initializing collector ..."); }
public PatchBitEntry(byte [] rawBytes) { var index = 0x00; OpCode = (PatchBits.OpCode_)BitConverter.ToInt32(rawBytes, index); index += 4; ActionSize = BitConverter.ToInt32(rawBytes, index); index += 4; PatternSize = BitConverter.ToInt32(rawBytes, index); index += 4; Rva = BitConverter.ToInt32(rawBytes, index); index += 4; UnknownInt = BitConverter.ToInt32(rawBytes, index); index += 4; ModuleName = Encoding.Unicode.GetString(rawBytes, index, 0x20); var nullPos = ModuleName.IndexOf('\0'); if (nullPos > -1) { ModuleName = ModuleName.Substring(0, nullPos); } index += 0x20; // module size var buff = new byte[0x20]; Buffer.BlockCopy(rawBytes, index, buff, 0, 0x20); UnknownBytes = buff; index += 0x20; //unknown, seen all 0x0 Pattern = new byte[PatternSize]; Buffer.BlockCopy(rawBytes, index, Pattern, 0, PatternSize); index += PatternSize; //Trace.Assert(index==rawBytes.Length,"Remaining bytes in rawBytes"); }
/// <summary> /// Save the server to the database. The server is assumed to be /// locked. /// </summary> /// <returns>True if the save was successful.</returns> public bool Save() { if (MasterServer.ConnectionString == null) { return(false); } try { if (ModuleName == null) { ModuleName = ""; } if (ServerName == null) { ServerName = ""; } if (ModuleDescription == null) { ModuleDescription = ""; } if (ModuleUrl == null) { ModuleUrl = ""; } if (PWCUrl == null) { PWCUrl = ""; } if (ServerDescription == null) { ServerDescription = ""; } string Query = String.Format( @"INSERT INTO `game_servers` ( `game_server_id`, `product_id`, `expansions_mask`, `build_number`, `module_name`, `server_name`, `active_player_count`, `maximum_player_count`, `local_vault`, `last_heartbeat`, `server_address`, `online`, `private_server`, `module_description`, `module_url`, `game_type`, `minimum_level`, `maximum_level`, `pvp_level`, `player_pause`, `one_party_only`, `elc_enforced`, `ilr_enforced`, `pwc_url`, `server_description`) VALUES ( {0}, {1}, {2}, {3}, '{4}', '{5}', {6}, {7}, {8}, '{9}', '{10}', {11}, {12}, '{13}', '{14}', {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, '{23}', '{24}') ON DUPLICATE KEY UPDATE `expansions_mask` = {2}, `build_number` = {3}, `module_name` = '{4}', `server_name` = '{5}', `active_player_count` = {6}, `maximum_player_count` = {7}, `local_vault` = {8}, `last_heartbeat` = '{9}', `server_address` = '{10}', `online` = {11}, `private_server` = {12}, `module_description` = '{13}', `module_url` = '{14}', `game_type` = {15}, `minimum_level` = {16}, `maximum_level` = {17}, `pvp_level` = {18}, `player_pause` = {19}, `one_party_only` = {20}, `elc_enforced` = {21}, `ilr_enforced` = {22}, `pwc_url` = '{23}', `server_description` = '{24}'", DatabaseId, MasterServer.ProductID, ExpansionsMask, BuildNumber, MySqlHelper.EscapeString(ModuleName.Length > 32 ? ModuleName.Substring(0, 32) : ModuleName), MySqlHelper.EscapeString(ServerName.Length > 256 ? ServerName.Substring(0, 256) : ServerName), ActivePlayerCount, MaximumPlayerCount, LocalVault, MasterServer.DateToSQLDate(LastHeartbeat), MySqlHelper.EscapeString(ServerAddress.ToString()), Online, PrivateServer, MySqlHelper.EscapeString(ModuleDescription.Length > 256 ? ModuleDescription.Substring(0, 256) : ModuleDescription), MySqlHelper.EscapeString(ModuleUrl.Length > 256 ? ModuleUrl.Substring(0, 256) : ModuleUrl), GameType, MinimumLevel, MaximumLevel, PVPLevel, PlayerPause, OnePartyOnly, ELCEnforced, ILREnforced, MySqlHelper.EscapeString(PWCUrl.Length > 256 ? PWCUrl.Substring(0, 256) : PWCUrl), MySqlHelper.EscapeString(ServerDescription.Length > 256 ? ServerDescription.Substring(0, 256) : ServerDescription) ); MasterServer.ExecuteQueryNoReaderCombine(Query); LastSaveTick = (uint)Environment.TickCount; } catch (Exception e) { Logger.Log(LogLevel.Error, "NWGameServer.Save(): Failed to save server {0}: Exception: {1}", ServerAddress, e); return(false); } return(true); }