1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

more stability changes

This commit is contained in:
RaidMax
2018-10-03 21:20:49 -05:00
parent ca9e20ebd3
commit a1dcc739b0
12 changed files with 108 additions and 32 deletions

View File

@ -773,12 +773,12 @@ namespace SharedLibraryCore.Commands
else if (unflagEvent.FailReason == GameEvent.EventFailReason.Invalid)
{
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FLAG_UNFLAG"]} ^5{E.Target.Name}");
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNFLAG_NOTFLAGGED"]);
}
else
{
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNFLAG_NOTFLAGGED"]);
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FLAG_UNFLAG"]} ^5{E.Target.Name}");
}
return Task.CompletedTask;
@ -825,6 +825,11 @@ namespace SharedLibraryCore.Commands
commandEvent.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORT_FAIL_SELF"]);
}
else if (reportEvent.FailReason == GameEvent.EventFailReason.Throttle)
{
commandEvent.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORT_FAIL_TOOMANY"]);
}
else if (reportEvent.Failed)
{
commandEvent.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORT_FAIL_DUPLICATE"]);
@ -1324,6 +1329,7 @@ namespace SharedLibraryCore.Commands
var nextMapMatch = currentMap.First().Index != lastMap.Index ?
regexMatches[regexMatches.IndexOf(currentMap.First()) + 1] :
regexMatches.First();
nextMap = s.Maps.FirstOrDefault(m => m.Name == nextMapMatch.Groups[3].ToString()) ?? nextMap;
string nextGametype = nextMapMatch.Groups[2].ToString().Length == 0 ?
Utilities.GetLocalizedGametype(s.Gametype) :

View File

@ -26,7 +26,11 @@ namespace SharedLibraryCore
/// <summary>
/// executing the event would cause an invalid state
/// </summary>
Invalid
Invalid,
/// <summary>
/// client is doing too much of something
/// </summary>
Throttle
}
public enum EventType

View File

@ -81,7 +81,10 @@ namespace SharedLibraryCore.Objects
ConnectionTime = DateTime.UtcNow;
ClientNumber = -1;
DelayedEvents = new Queue<GameEvent>();
_additionalProperties = new Dictionary<string, object>();
_additionalProperties = new Dictionary<string, object>
{
{ "_reportCount", 0 }
};
}
public override string ToString() => $"{Name}::{NetworkId}";
@ -116,19 +119,22 @@ namespace SharedLibraryCore.Objects
{
Type = GameEvent.EventType.Warn,
Message = warnReason,
Data = warnReason,
Origin = sender,
Target = this,
Owner = sender.CurrentServer
};
// enforce level restrictions
if (sender.Level <= this.Level)
if (this.Level > sender.Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
return e;
}
this.Warnings++;
else
{
this.Warnings++;
}
sender.CurrentServer.Manager.GetEventHandler().AddEvent(e);
return e;
@ -181,6 +187,8 @@ namespace SharedLibraryCore.Objects
Owner = sender.CurrentServer
};
int reportCount = sender.GetAdditionalProperty<int>("_reportCount");
if (this.Level > sender.Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
@ -191,12 +199,18 @@ namespace SharedLibraryCore.Objects
e.FailReason = GameEvent.EventFailReason.Invalid;
}
else if (reportCount > 2)
{
e.FailReason = GameEvent.EventFailReason.Throttle;
}
else if (CurrentServer.Reports.Count(report => (report.Origin.NetworkId == sender.NetworkId &&
report.Target.NetworkId == this.NetworkId)) > 0)
{
e.FailReason = GameEvent.EventFailReason.Exception;
}
sender.SetAdditionalProperty("_reportCount", reportCount + 1);
sender.CurrentServer.Manager.GetEventHandler().AddEvent(e);
return e;
}
@ -391,7 +405,18 @@ namespace SharedLibraryCore.Objects
[NotMapped]
Dictionary<string, object> _additionalProperties;
public T GetAdditionalProperty<T>(string name) => (T)_additionalProperties[name];
public void SetAdditionalProperty(string name, object value) => _additionalProperties.Add(name, value);
public void SetAdditionalProperty(string name, object value)
{
if (_additionalProperties.ContainsKey(name))
{
_additionalProperties[name] = value;
}
else
{
_additionalProperties.Add(name, value);
}
}
[NotMapped]
public int ClientNumber { get; set; }
[NotMapped]

View File

@ -209,7 +209,7 @@ namespace SharedLibraryCore
/// <param name="Origin">The person who banned the target</param>
abstract protected Task Ban(String Reason, Player Target, Player Origin);
abstract public Task Warn(String Reason, Player Target, Player Origin);
abstract protected Task Warn(String Reason, Player Target, Player Origin);
/// <summary>
/// Unban a player by npID / GUID

View File

@ -28,7 +28,7 @@ namespace SharedLibraryCore.Services
{
if (_context == null)
{
_context = new DatabaseContext(ShouldTrack);
_context = new DatabaseContext(!ShouldTrack);
}
return _context;