本文整理汇总了C#中AdKatsRecord类的典型用法代码示例。如果您正苦于以下问题:C# AdKatsRecord类的具体用法?C# AdKatsRecord怎么用?C# AdKatsRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AdKatsRecord类属于命名空间,在下文中一共展示了AdKatsRecord类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MuteTarget
public void MuteTarget(AdKatsRecord record)
{
this.DebugWrite("Entering muteTarget", 6);
try {
if (!this.HasAccess(record.target_player, this._CommandKeyDictionary["player_mute"])) {
if (!this._RoundMutedPlayers.ContainsKey(record.target_name)) {
this._RoundMutedPlayers.Add(record.target_name, 0);
this.PlayerSayMessage(record.target_name, this._MutedPlayerMuteMessage);
this.SendMessageToSource(record, record.target_name + " has been muted for this round.");
}
else {
this.SendMessageToSource(record, record.target_name + " already muted for this round.");
}
}
else {
this.SendMessageToSource(record, "You can't mute an admin, dimwit.");
}
record.record_action_executed = true;
}
catch (Exception e) {
record.record_exception = new AdKatsException("Error while taking action for Mute record.", e);
this.HandleException(record.record_exception);
this.FinalizeRecord(record);
}
this.DebugWrite("Exiting muteTarget", 6);
}
开发者ID:Chicago847,项目名称:AdKats,代码行数:26,代码来源:AdKats.cs
示例2: FetchIROStatus
//DONE
private Boolean FetchIROStatus(AdKatsRecord record)
{
DebugWrite("FetchIROStatus starting!", 6);
//Make sure database connection active
if (this.HandlePossibleDisconnect()) {
record.record_exception = new AdKatsException("Database not connected.");
return false;
}
try {
using (MySqlConnection connection = this.GetDatabaseConnection()) {
using (MySqlCommand command = connection.CreateCommand()) {
command.CommandText = @"
SELECT
`record_time` AS `latest_time`
FROM
`adkats_records_main`
INNER JOIN
`adkats_commands`
ON
`adkats_records_main`.`command_type` = `adkats_commands`.`command_id`
WHERE
`adkats_commands`.`command_key` = 'player_punish'
AND
`adkats_records_main`.`target_id` = " + record.target_player.player_id + @"
AND
DATE_ADD(`record_time`, INTERVAL " + this._IROTimeout + @" MINUTE) > UTC_TIMESTAMP()
ORDER BY
`record_time`
DESC LIMIT 1";
using (MySqlDataReader reader = command.ExecuteReader()) {
if (reader.Read()) {
this.DebugWrite("Punish is Double counted", 6);
return true;
}
return false;
}
}
}
}
catch (Exception e) {
this.HandleException(new AdKatsException("Error while checking if punish will be IRO.", e));
//Assume false if any errors
return false;
}
}
开发者ID:Chicago847,项目名称:AdKats,代码行数:47,代码来源:AdKats.cs
示例3: FetchUnreadRecords
//DONE
private IEnumerable<AdKatsRecord> FetchUnreadRecords()
{
DebugWrite("fetchUnreadRecords starting!", 6);
//Create return list
List<AdKatsRecord> records = new List<AdKatsRecord>();
//Make sure database connection active
if (this.HandlePossibleDisconnect()) {
return records;
}
try {
using (MySqlConnection connection = this.GetDatabaseConnection()) {
using (MySqlCommand command = connection.CreateCommand()) {
String sql = @"
SELECT
`record_id`,
`server_id`,
`command_type`,
`command_action`,
`command_numeric`,
`target_name`,
`target_id`,
`source_name`,
`record_message`,
`record_time`
FROM
`" + this._MySqlDatabaseName + @"`.`adkats_records_main`
WHERE
`adkats_read` = 'N'
AND
`server_id` = " + this._ServerID;
command.CommandText = sql;
using (MySqlDataReader reader = command.ExecuteReader()) {
//Grab the record
while (reader.Read()) {
AdKatsRecord record = new AdKatsRecord();
record.record_source = AdKatsRecord.Sources.Database;
record.record_id = reader.GetInt64("record_id");
record.server_id = reader.GetInt64("server_id");
Int32 commandTypeInt = reader.GetInt32("command_type");
if (!this._CommandIDDictionary.TryGetValue(commandTypeInt, out record.command_type)) {
this.ConsoleError("Unable to parse command type " + commandTypeInt + " when fetching record by ID.");
}
Int32 commandActionInt = reader.GetInt32("command_action");
if (!this._CommandIDDictionary.TryGetValue(commandActionInt, out record.command_action)) {
this.ConsoleError("Unable to parse command action " + commandActionInt + " when fetching record by ID.");
}
record.command_numeric = reader.GetInt32("command_numeric");
record.target_name = reader.GetString("target_name");
object value = reader.GetValue(6);
Int64 targetIDParse = -1;
DebugWrite("id fetched!", 6);
if (Int64.TryParse(value.ToString(), out targetIDParse)) {
DebugWrite("id parsed! " + targetIDParse, 6);
//Check if the player needs to be imported, or if they are already in the server
AdKatsPlayer importedPlayer = this.FetchPlayer(false, true, targetIDParse, null, null, null);
if (importedPlayer == null) {
continue;
}
AdKatsPlayer currentPlayer = null;
if (!String.IsNullOrEmpty(importedPlayer.player_name) && this._PlayerDictionary.TryGetValue(importedPlayer.player_name, out currentPlayer)) {
this.DebugWrite("External player is currently in the server, using existing data.", 5);
record.target_player = currentPlayer;
}
else {
this.DebugWrite("External player is not in the server, fetching from database.", 5);
record.target_player = importedPlayer;
}
record.target_name = record.target_player.player_name;
}
else {
DebugWrite("id parse failed!", 6);
}
record.source_name = reader.GetString("source_name");
record.record_message = reader.GetString("record_message");
record.record_time = reader.GetDateTime("record_time");
records.Add(record);
}
}
}
}
}
catch (Exception e) {
this.HandleException(new AdKatsException("Error while fetching unread records from database.", e));
}
DebugWrite("fetchUnreadRecords finished!", 6);
return records;
}
开发者ID:Chicago847,项目名称:AdKats,代码行数:90,代码来源:AdKats.cs
示例4: DatabaseCommunicationThreadLoop
//.........这里部分代码省略.........
if (this._CBanProcessingQueue.Count > 0) {
if (!this._UseBanEnforcerPreviousState) {
this.ConsoleWarn("Do not disable AdKats or change any settings until upload is complete!");
}
this.DebugWrite("DBCOMM: Preparing to lock inbound cBan queue to retrive new cBans", 7);
Double totalCBans = 0;
Double bansImported = 0;
Boolean earlyExit = false;
DateTime startTime = DateTime.UtcNow;
Queue<CBanInfo> inboundCBans;
lock (this._CBanProcessingQueue) {
this.DebugWrite("DBCOMM: Inbound cBans found. Grabbing.", 6);
//Grab all cBans in the queue
inboundCBans = new Queue<CBanInfo>(this._CBanProcessingQueue.ToArray());
totalCBans = inboundCBans.Count;
//Clear the queue for next run
this._CBanProcessingQueue.Clear();
}
//Loop through all cBans in order that they came in
Boolean bansFound = false;
while (inboundCBans.Count > 0) {
//Break from the loop if the plugin is disabled or the setting is reverted.
if (!this._IsEnabled || !this._UseBanEnforcer) {
this.ConsoleWarn("You exited the ban upload process early, the process was not completed.");
earlyExit = true;
break;
}
bansFound = true;
CBanInfo cBan = inboundCBans.Dequeue();
//Create the record
AdKatsRecord record = new AdKatsRecord();
record.record_source = AdKatsRecord.Sources.InternalAutomated;
//Permabans and Temp bans longer than 1 year will be defaulted to permaban
if (cBan.BanLength.Seconds > 0 && cBan.BanLength.Seconds < 31536000) {
record.command_type = this._CommandKeyDictionary["player_ban_temp"];
record.command_action = this._CommandKeyDictionary["player_ban_temp"];
record.command_numeric = cBan.BanLength.Seconds / 60;
}
else {
record.command_type = this._CommandKeyDictionary["player_ban_perm"];
record.command_action = this._CommandKeyDictionary["player_ban_perm"];
record.command_numeric = 0;
}
record.source_name = this._CBanAdminName;
record.server_id = this._ServerID;
record.target_player = this.FetchPlayer(true, true, -1, cBan.SoldierName, cBan.Guid, cBan.IpAddress);
if (!String.IsNullOrEmpty(record.target_player.player_name)) {
record.target_name = record.target_player.player_name;
}
record.isIRO = false;
record.record_message = cBan.Reason;
//Update the ban enforcement depending on available information
Boolean nameAvailable = !String.IsNullOrEmpty(record.target_player.player_name);
Boolean guidAvailable = !String.IsNullOrEmpty(record.target_player.player_guid);
Boolean ipAvailable = !String.IsNullOrEmpty(record.target_player.player_ip);
//Create the ban
AdKatsBan aBan = new AdKatsBan {
ban_record = record,
ban_enforceName = nameAvailable && (this._DefaultEnforceName || (!guidAvailable && !ipAvailable) || !String.IsNullOrEmpty(cBan.SoldierName)),
ban_enforceGUID = guidAvailable && (this._DefaultEnforceGUID || (!nameAvailable && !ipAvailable) || !String.IsNullOrEmpty(cBan.Guid)),
ban_enforceIP = ipAvailable && (this._DefaultEnforceIP || (!nameAvailable && !guidAvailable) || !String.IsNullOrEmpty(cBan.IpAddress))
开发者ID:Chicago847,项目名称:AdKats,代码行数:67,代码来源:AdKats.cs
示例5: CancelSourcePendingAction
public void CancelSourcePendingAction(AdKatsRecord record)
{
this.DebugWrite("Entering cancelSourcePendingAction", 7);
try {
this.DebugWrite("attempting to cancel command", 6);
lock (_ActionConfirmMutex) {
if (!this._ActionConfirmDic.Remove(record.source_name)) {
//this.sendMessageToSource(record, "No command to cancel.");
}
else {
this.SendMessageToSource(record, "Previous command Canceled.");
}
}
}
catch (Exception e) {
record.record_exception = this.HandleException(new AdKatsException("Error while canceling source pending action.", e));
}
this.DebugWrite("Exiting cancelSourcePendingAction", 7);
}
开发者ID:Chicago847,项目名称:AdKats,代码行数:19,代码来源:AdKats.cs
示例6: BanEnforcerThreadLoop
private void BanEnforcerThreadLoop()
{
try {
this.DebugWrite("BANENF: Starting Ban Enforcer Thread", 1);
Thread.CurrentThread.Name = "BanEnforcer";
while (true) {
try {
this.DebugWrite("BANENF: Entering Ban Enforcer Thread Loop", 7);
if (!this._IsEnabled) {
this.DebugWrite("BANENF: Detected AdKats not enabled. Exiting thread " + Thread.CurrentThread.Name, 6);
break;
}
//Get all unchecked players
Queue<AdKatsPlayer> playerCheckingQueue = new Queue<AdKatsPlayer>();
if (this._BanEnforcerCheckingQueue.Count > 0 && this._UseBanEnforcer) {
this.DebugWrite("BANENF: Preparing to lock banEnforcerMutex to retrive new players", 6);
lock (_BanEnforcerMutex) {
this.DebugWrite("BANENF: Inbound players found. Grabbing.", 5);
//Grab all players in the queue
playerCheckingQueue = new Queue<AdKatsPlayer>(this._BanEnforcerCheckingQueue.ToArray());
//Clear the queue for next run
this._BanEnforcerCheckingQueue.Clear();
}
}
else {
this.DebugWrite("BANENF: No inbound ban checks. Waiting for Input.", 4);
//Wait for input
this._BanEnforcerWaitHandle.Reset();
this._BanEnforcerWaitHandle.WaitOne(Timeout.Infinite);
continue;
}
//Get all checks in order that they came in
while (playerCheckingQueue.Count > 0) {
//Grab first/next player
AdKatsPlayer aPlayer = playerCheckingQueue.Dequeue();
this.DebugWrite("BANENF: begin reading player", 5);
if (this._PlayerDictionary.ContainsKey(aPlayer.player_name)) {
AdKatsBan aBan = this.FetchPlayerBan(aPlayer);
if (aBan != null) {
this.DebugWrite("BANENF: BAN ENFORCED", 3);
//Create the new record
AdKatsRecord record = new AdKatsRecord {
record_source = AdKatsRecord.Sources.InternalAutomated,
source_name = "BanEnforcer",
isIRO = false,
server_id = this._ServerID,
target_name = aPlayer.player_name,
target_player = aPlayer,
command_type = this._CommandKeyDictionary["banenforcer_enforce"],
command_numeric = (int) aBan.ban_id,
record_message = aBan.ban_record.record_message
};
//Queue record for upload
this.QueueRecordForProcessing(record);
//Enforce the ban
this.EnforceBan(aBan, true);
}
else {
this.DebugWrite("BANENF: No ban found for player", 5);
//Only call a ban check if the player does not already have a ban
if (this._UseHackerChecker) {
this.QueuePlayerForHackerCheck(aPlayer);
}
}
}
}
}
catch (Exception e)
{
if (e is ThreadAbortException)
{
this.HandleException(new AdKatsException("ban enforcer thread aborted. Exiting."));
break;
}
this.HandleException(new AdKatsException("Error occured in ban enforcer thread. Skipping current loop.", e));
}
}
this.DebugWrite("BANENF: Ending Ban Enforcer Thread", 1);
}
catch (Exception e) {
this.HandleException(new AdKatsException("Error occured in ban enforcer thread.", e));
}
}
开发者ID:Chicago847,项目名称:AdKats,代码行数:88,代码来源:AdKats.cs
示例7: CommandParsingThreadLoop
private void CommandParsingThreadLoop()
{
try {
this.DebugWrite("COMMAND: Starting Command Parsing Thread", 1);
Thread.CurrentThread.Name = "Command";
while (true) {
try {
this.DebugWrite("COMMAND: Entering Command Parsing Thread Loop", 7);
if (!this._IsEnabled) {
this.DebugWrite("COMMAND: Detected AdKats not enabled. Exiting thread " + Thread.CurrentThread.Name, 6);
break;
}
//Sleep for 10ms
Thread.Sleep(10);
//Get all unparsed inbound messages
if (this._UnparsedCommandQueue.Count > 0) {
this.DebugWrite("COMMAND: Preparing to lock command queue to retrive new commands", 7);
Queue<KeyValuePair<String, String>> unparsedCommands;
lock (_UnparsedCommandMutex) {
this.DebugWrite("COMMAND: Inbound commands found. Grabbing.", 6);
//Grab all messages in the queue
unparsedCommands = new Queue<KeyValuePair<String, String>>(this._UnparsedCommandQueue.ToArray());
//Clear the queue for next run
this._UnparsedCommandQueue.Clear();
}
//Loop through all commands in order that they came in
while (unparsedCommands.Count > 0) {
this.DebugWrite("COMMAND: begin reading command", 6);
//Dequeue the first/next command
KeyValuePair<String, String> commandPair = unparsedCommands.Dequeue();
String speaker = commandPair.Key;
String command = commandPair.Value;
AdKatsRecord record;
if (speaker == "Server") {
record = new AdKatsRecord {
record_source = AdKatsRecord.Sources.ServerCommand,
source_name = "ProconAdmin"
};
}
else {
record = new AdKatsRecord {
record_source = AdKatsRecord.Sources.InGame,
source_name = speaker
};
}
//Complete the record creation
this.CompleteRecordInformation(record, command);
}
}
else {
this.DebugWrite("COMMAND: No inbound commands, ready.", 7);
//No commands to parse, ready.
this._CommandParsingWaitHandle.Reset();
this._CommandParsingWaitHandle.WaitOne(Timeout.Infinite);
}
}
catch (Exception e)
{
if (e is ThreadAbortException)
{
this.HandleException(new AdKatsException("Command thread aborted. Exiting."));
break;
}
this.HandleException(new AdKatsException("Error occured in Command thread. Skipping current loop.", e));
}
}
this.DebugWrite("COMMAND: Ending Command Thread", 1);
}
catch (Exception e) {
this.HandleException(new AdKatsException("Error occured in command parsing thread.", e));
}
}
开发者ID:Chicago847,项目名称:AdKats,代码行数:77,代码来源:AdKats.cs
示例8: RestartLevel
public void RestartLevel(AdKatsRecord record)
{
this.DebugWrite("Entering restartLevel", 6);
try {
this.ExecuteCommand("procon.protected.send", "mapList.restartRound");
this.SendMessageToSource(record, "Round Restarted.");
record.record_action_executed = true;
}
catch (Exception e) {
record.record_exception = new AdKatsException("Error while taking action for RestartLevel record.", e);
this.HandleException(record.record_exception);
this.FinalizeRecord(record);
}
this.DebugWrite("Exiting restartLevel", 6);
}
开发者ID:Chicago847,项目名称:AdKats,代码行数:15,代码来源:AdKats.cs
示例9: RoundWhitelistTarget
public void RoundWhitelistTarget(AdKatsRecord record)
{
this.DebugWrite("Entering roundWhitelistTarget", 6);
try {
if (!this._TeamswapRoundWhitelist.ContainsKey(record.target_name)) {
if (this._TeamswapRoundWhitelist.Count < this._PlayersToAutoWhitelist + 2) {
this._TeamswapRoundWhitelist.Add(record.target_name, false);
String command = this._CommandKeyDictionary["self_teamswap"].command_text;
this.SendMessageToSource(record, record.target_name + " can now use @" + command + " for this round.");
}
else {
this.SendMessageToSource(record, "Cannot whitelist more than two extra people per round.");
}
}
else {
this.SendMessageToSource(record, record.target_name + " is already in this round's TeamSwap whitelist.");
}
record.record_action_executed = true;
}
catch (Exception e) {
record.record_exception = new AdKatsException("Error while taking action for RoundWhitelist record.", e);
this.HandleException(record.record_exception);
this.FinalizeRecord(record);
}
this.DebugWrite("Exiting roundWhitelistTarget", 6);
}
开发者ID:Chicago847,项目名称:AdKats,代码行数:26,代码来源:AdKats.cs
示例10: PlayerTell
public void PlayerTell(AdKatsRecord record)
{
this.DebugWrite("Entering playerTell", 6);
try {
this.PlayerTellMessage(record.target_name, record.record_message);
this.SendMessageToSource(record, record.target_name + " has been told '" + record.record_message + "' by TELL");
record.record_action_executed = true;
}
catch (Exception e) {
record.record_exception = new AdKatsException("Error while taking action for playerTell record.", e);
this.HandleException(record.record_exception);
this.FinalizeRecord(record);
}
this.DebugWrite("Exiting playerTell", 6);
}
开发者ID:Chicago847,项目名称:AdKats,代码行数:15,代码来源:AdKats.cs
示例11: PunishTarget
public void PunishTarget(AdKatsRecord record)
{
this.DebugWrite("Entering punishTarget", 6);
try {
//If the record has any exceptions, skip everything else and just kill the player
if (record.record_exception == null) {
//Get number of points the player from server
Int32 points = this.FetchPoints(record.target_player);
this.DebugWrite(record.target_player.player_name + " has " + points + " points.", 5);
//Get the proper action to take for player punishment
String action = "noaction";
String skippedAction = null;
if (points > (this._PunishmentHierarchy.Length - 1)) {
action = this._PunishmentHierarchy[this._PunishmentHierarchy.Length - 1];
}
else if (points > 0) {
action = this._PunishmentHierarchy[points - 1];
if (record.isIRO) {
skippedAction = this._PunishmentHierarchy[points - 2];
}
}
else {
action = this._PunishmentHierarchy[0];
}
//Handle the case where and IRO punish skips higher level punishment for a lower one, use the higher one
if (skippedAction != null && this._PunishmentSeverityIndex.IndexOf(skippedAction) > this._PunishmentSeverityIndex.IndexOf(action)) {
action = skippedAction;
}
//Set additional message
String pointMessage = " [" + ((record.isIRO) ? ("IRO ") : ("")) + points + "pts]";
if (!record.record_message.Contains(pointMessage)) {
record.record_message += pointMessage;
}
const string additionalMessage = "";
Boolean isLowPop = this._OnlyKillOnLowPop && (this._PlayerDictionary.Count < this._LowPopPlayerCount);
Boolean iroOverride = record.isIRO && this._IROOverridesLowPop;
this.DebugWrite("Server low population: " + isLowPop + " (" + this._PlayerDictionary.Count + " <? " + this._LowPopPlayerCount + ") | Override: " + iroOverride, 5);
//Call correct action
if ((action == "kill" || (isLowPop && !iroOverride)) && !action.Equals("ban")) {
record.command_action = (isLowPop) ? (this._CommandKeyDictionary["player_kill_lowpop"]) : (this._CommandKeyDictionary["player_kill"]);
this.KillTarget(record, additionalMessage);
}
else if (action == "kick") {
record.command_action = this._CommandKeyDictionary["player_kick"];
this.KickTarget(record, additionalMessage);
}
else if (action == "tban60") {
record.command_numeric = 60;
record.command_action = this._CommandKeyDictionary["player_ban_temp"];
this.TempBanTarget(record, additionalMessage);
}
else if (action == "tban120") {
record.command_numeric = 120;
record.command_action = this._CommandKeyDictionary["player_ban_temp"];
this.TempBanTarget(record, additionalMessage);
}
else if (action == "tbanday") {
record.command_numeric = 1440;
record.command_action = this._CommandKeyDictionary["player_ban_temp"];
this.TempBanTarget(record, additionalMessage);
}
else if (action == "tbanweek") {
record.command_numeric = 10080;
record.command_action = this._CommandKeyDictionary["player_ban_temp"];
this.TempBanTarget(record, additionalMessage);
}
else if (action == "tban2weeks") {
record.command_numeric = 20160;
record.command_action = this._CommandKeyDictionary["player_ban_temp"];
this.TempBanTarget(record, additionalMessage);
}
else if (action == "tbanmonth") {
record.command_numeric = 43200;
record.command_action = this._CommandKeyDictionary["player_ban_temp"];
this.TempBanTarget(record, additionalMessage);
}
else if (action == "ban") {
record.command_action = this._CommandKeyDictionary["player_ban_perm"];
this.PermaBanTarget(record, additionalMessage);
}
else {
record.command_action = this._CommandKeyDictionary["player_kill"];
this.KillTarget(record, additionalMessage);
record.record_exception = new AdKatsException("Punish options are set incorrectly. '" + action + "' not found. Inform plugin setting manager.");
this.HandleException(record.record_exception);
}
}
else {
//Exception found, just kill the player
record.command_action = this._CommandKeyDictionary["player_kill"];
this.KillTarget(record, null);
}
record.record_action_executed = true;
}
catch (Exception e) {
//.........这里部分代码省略.........
开发者ID:Chicago847,项目名称:AdKats,代码行数:101,代码来源:AdKats.cs
示例12: PlayerListingThreadLoop
public void PlayerListingThreadLoop()
{
try {
this.DebugWrite("PLIST: Starting Player Listing Thread", 1);
Thread.CurrentThread.Name = "playerlisting";
while (true) {
try {
this.DebugWrite("PLIST: Entering Player Listing Thread Loop", 7);
if (!this._IsEnabled) {
this.DebugWrite("PLIST: Detected AdKats not enabled. Exiting thread " + Thread.CurrentThread.Name, 6);
break;
}
//Get all unparsed inbound lists
Queue<List<CPlayerInfo>> inboundPlayerLists;
if (this._PlayerListProcessingQueue.Count > 0) {
this.DebugWrite("PLIST: Preparing to lock player list queues to retrive new player lists", 7);
lock (this._PlayerListProcessingQueue) {
this.DebugWrite("PLIST: Inbound player lists found. Grabbing.", 6);
//Grab all lists in the queue
inboundPlayerLists = new Queue<List<CPlayerInfo>>(this._PlayerListProcessingQueue.ToArray());
//Clear the queue for next run
this._PlayerListProcessingQueue.Clear();
}
}
else {
this.DebugWrite("PLIST: No inbound player lists. Waiting for Input.", 4);
//Wait for input
this._PlayerListProcessingWaitHandle.Reset();
this._PlayerListProcessingWaitHandle.WaitOne(Timeout.Infinite);
continue;
}
//Loop through all messages in order that they came in
while (inboundPlayerLists.Count > 0) {
this.DebugWrite("PLIST: begin reading player lists", 6);
//Dequeue the first/next message
List<CPlayerInfo> players = inboundPlayerLists.Dequeue();
this.DebugWrite("Listing Players", 5);
//Player list and ban list need to be locked for this operation
lock (this._PlayersMutex) {
List<String> playerNames = new List<String>();
//Reset the player counts of both sides and recount everything
this._UsPlayerCount = 0;
this._RuPlayerCount = 0;
//Loop over all players in the list
foreach (CPlayerInfo player in players) {
playerNames.Add(player.SoldierName);
AdKatsPlayer aPlayer = null;
//Check if the player is already in the player dictionary
if (this._PlayerDictionary.TryGetValue(player.SoldierName, out aPlayer)) {
//If they are update the internal frostbite player info
this._PlayerDictionary[player.SoldierName].frostbitePlayerInfo = player;
}
else {
//If they aren't in the list, fetch their profile from the database
aPlayer = this.FetchPlayer(true, false, -1, player.SoldierName, player.GUID, null);
//Add the frostbite player info
aPlayer.frostbitePlayerInfo = player;
//Set their last death/spawn times
aPlayer.lastDeath = DateTime.UtcNow;
aPlayer.lastSpawn = DateTime.UtcNow;
//Add them to the dictionary
this._PlayerDictionary.Add(player.SoldierName, aPlayer);
//If using ban enforcer, check the player's ban status
if (this._UseBanEnforcer) {
this.QueuePlayerForBanCheck(aPlayer);
}
else if (this._UseHackerChecker) {
//Queue the player for a hacker check
this.QueuePlayerForHackerCheck(aPlayer);
}
}
if (player.TeamID == UsTeamID) {
this._UsPlayerCount++;
}
else if (player.TeamID == RuTeamID) {
this._RuPlayerCount++;
}
}
//Make sure the player dictionary is clean of any straglers
List<String> dicPlayerNames = this._PlayerDictionary.Keys.ToList();
Int32 straglerCount = 0;
Int32 dicCount = this._PlayerDictionary.Count;
foreach (String playerName in dicPlayerNames) {
if (!playerNames.Contains(playerName)) {
straglerCount++;
this.DebugWrite("PLIST: Removing " + playerName + " from current player list (VIA CLEANUP).", 4);
this._PlayerDictionary.Remove(playerName);
}
}
//Inform the admins of disconnect
if (straglerCount > (dicCount / 2)) {
//Create the report record
AdKatsRecord record = new AdKatsRecord {
record_source = AdKatsRecord.Sources.InternalAutomated,
isDebug = true,
server_id = this._ServerID,
//.........这里部分代码省略.........
开发者ID:Chicago847,项目名称:AdKats,代码行数:101,代码来源:AdKats.cs
示例13: OnHttpRequest
public override HttpWebServerResponseData OnHttpRequest(HttpWebServerRequestData data)
{
String responseString = "AdKats Remote: ";
try {
foreach (String key in data.Query.AllKeys) {
this.DebugWrite("Query Key: " + key + " val: " + data.Query[key], 6);
}
this.DebugWrite("method: " + data.Method, 6);
//this.DebugWrite("doc: " + data.Document, 6);
AdKatsRecord record = new AdKatsRecord {
record_source = AdKatsRecord.Sources.HTTP
};
NameValueCollection dataCollection = null;
if (System.String.Compare(data.Method, "GET", System.StringComparison.OrdinalIgnoreCase) == 0) {
dataCollection = data.Query;
}
else if (System.String.Compare(data.Method, "POST", System.StringComparison.OrdinalIgnoreCase) == 0) {
return null; //dataCollection = data.POSTData;
}
if (dataCollection != null) {
String commandString = dataCollection["command_type"];
record.command_type = this._CommandKeyDictionary[commandString];
if (dataCollection["access_key"] != null && dataCollection["access_key"] == this._ExternalCommandAccessKey) {
//If command not parsable, return without creating
if (record.command_type != null) {
//Set the command action
record.command_action = record.command_type;
//Set the source
String sourceName = dataCollection["source_name"];
record.source_name = !String.IsNullOrEmpty(sourceName) ? sourceName : "HTTPAdmin";
String duration = dataCollection["record_durationMinutes"];
record.command_numeric = !string.IsNullOrEmpty(duration) ? Int32.Parse(duration) : 0;
String message = dataCollection["record_message"];
if (!String.IsNullOrEmpty(message)) {
if (message.Length >= this._RequiredReasonLength) {
record.record_message = message;
//Check the target
String targetName = dataCollection["target_name"];
//Check for an exact match
if (!String.IsNullOrEmpty(targetName)) {
record.target_name = targetName;
this.CompleteTargetInformation(record, false);
responseString += "Complete.";
}
else {
responseString += "target_name cannot be null";
}
}
else {
responseString += "Reason too short. Needs to be at least " + this._RequiredReasonLength + " chars.";
}
}
else {
responseString += "record_message cannot be null.";
}
}
else {
responseString += "Command '" + commandString + "' Not Parsable. Check AdKats doc for valid DB commands.";
}
}
else {
responseString += "access_key either not given or incorrect.";
}
}
}
catch (Exception e) {
responseString += e.ToString();
}
return new HttpWebServerResponseData(responseString);
}
开发者ID:Chicago847,项目名称:AdKats,代码行数:76,代码来源:AdKats.cs
|
请发表评论