mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-11 15:52:25 -05:00
fix bug with player not getting updated on disconnect (related to issue #24)
jint version downgraded for better stability (also locked the engine instance as it's not thread safe) updated readme remove vpn detection from application configuration as it's now in a seperate plugin defaulted webfront bind URl to all interfaces readd the custom say name added visibility percentage to AC
This commit is contained in:
@ -21,4 +21,11 @@ xcopy /Y "%SolutionDir%BUILD\Plugins" "%SolutionDir%Publish\WindowsPrerelease\Pl
|
||||
|
||||
echo Copying script plugins for publish
|
||||
xcopy /Y "%SolutionDir%Plugins\ScriptPlugins" "%SolutionDir%Publish\Windows\Plugins\"
|
||||
xcopy /Y "%SolutionDir%Plugins\ScriptPlugins" "%SolutionDir%Publish\WindowsPrerelease\Plugins\"
|
||||
xcopy /Y "%SolutionDir%Plugins\ScriptPlugins" "%SolutionDir%Publish\WindowsPrerelease\Plugins\"
|
||||
|
||||
echo Copying GSC files for publish
|
||||
xcopy /Y "%SolutionDir%_customcallbacks.gsc" "%SolutionDir%Publish\Windows\userraw\scripts\"
|
||||
xcopy /Y "%SolutionDir%_customcallbacks.gsc" "%SolutionDir%Publish\WindowsPrerelease\userraw\scripts\"
|
||||
|
||||
xcopy /Y "%SolutionDir%_commands.gsc" "%SolutionDir%Publish\Windows\userraw\scripts\"
|
||||
xcopy /Y "%SolutionDir%_commands.gsc" "%SolutionDir%Publish\WindowsPrerelease\userraw\scripts\"
|
@ -1,12 +1,9 @@
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Events;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IW4MAdmin.Application
|
||||
{
|
||||
@ -22,59 +19,57 @@ namespace IW4MAdmin.Application
|
||||
OutOfOrderEvents = new SortedList<long, GameEvent>();
|
||||
}
|
||||
|
||||
public bool AddEvent(GameEvent gameEvent)
|
||||
public void AddEvent(GameEvent gameEvent)
|
||||
{
|
||||
#if DEBUG
|
||||
Manager.GetLogger().WriteDebug($"Got new event of type {gameEvent.Type} for {gameEvent.Owner} with id {gameEvent.Id}");
|
||||
#endif
|
||||
// GameEvent sortedEvent = null;
|
||||
// lock (OutOfOrderEvents)
|
||||
// {
|
||||
// sortedEvent = OutOfOrderEvents.Values.FirstOrDefault();
|
||||
GameEvent sortedEvent = null;
|
||||
lock (OutOfOrderEvents)
|
||||
{
|
||||
sortedEvent = OutOfOrderEvents.Values.FirstOrDefault();
|
||||
|
||||
// while (sortedEvent?.Id == Interlocked.Read(ref NextEventId))
|
||||
// {
|
||||
// if (OutOfOrderEvents.Count > 0)
|
||||
// {
|
||||
// OutOfOrderEvents.RemoveAt(0);
|
||||
// }
|
||||
while (sortedEvent?.Id == Interlocked.Read(ref NextEventId))
|
||||
{
|
||||
if (OutOfOrderEvents.Count > 0)
|
||||
{
|
||||
OutOfOrderEvents.RemoveAt(0);
|
||||
}
|
||||
|
||||
// AddEvent(sortedEvent);
|
||||
// sortedEvent = OutOfOrderEvents.Values.FirstOrDefault();
|
||||
// }
|
||||
// }
|
||||
AddEvent(sortedEvent);
|
||||
sortedEvent = OutOfOrderEvents.Values.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
// // both the gameEvent Id and the LastEventId are thread safe because we want to synchronize when the
|
||||
// // event occurs
|
||||
// if (gameEvent.Id == Interlocked.Read(ref NextEventId))
|
||||
// {
|
||||
//#if DEBUG == true
|
||||
// Manager.GetLogger().WriteDebug($"sent event with id {gameEvent.Id} to be processed");
|
||||
//#endif
|
||||
// both the gameEvent Id and the LastEventId are thread safe because we want to synchronize when the
|
||||
// event occurs
|
||||
if (gameEvent.Id == Interlocked.Read(ref NextEventId))
|
||||
{
|
||||
#if DEBUG == true
|
||||
Manager.GetLogger().WriteDebug($"sent event with id {gameEvent.Id} to be processed");
|
||||
#endif
|
||||
((Manager as ApplicationManager).OnServerEvent)(this, new GameEventArgs(null, false, gameEvent));
|
||||
return true;
|
||||
// Interlocked.Increment(ref NextEventId);
|
||||
// }
|
||||
Interlocked.Increment(ref NextEventId);
|
||||
}
|
||||
|
||||
// // a "newer" event has been added before and "older" one has been added (due to threads and context switching)
|
||||
// // so me must wait until the next expected one arrives
|
||||
// else
|
||||
// {
|
||||
//#if DEBUG == true
|
||||
// Manager.GetLogger().WriteWarning("Incoming event is out of order");
|
||||
// Manager.GetLogger().WriteDebug($"Expected event Id is {Interlocked.Read(ref NextEventId)}, but got {gameEvent.Id} instead");
|
||||
//#endif
|
||||
// a "newer" event has been added before and "older" one has been added (due to threads and context switching)
|
||||
// so me must wait until the next expected one arrives
|
||||
else
|
||||
{
|
||||
#if DEBUG == true
|
||||
Manager.GetLogger().WriteWarning("Incoming event is out of order");
|
||||
Manager.GetLogger().WriteDebug($"Expected event Id is {Interlocked.Read(ref NextEventId)}, but got {gameEvent.Id} instead");
|
||||
#endif
|
||||
|
||||
// // this prevents multiple threads from adding simultaneously
|
||||
// lock (OutOfOrderEvents)
|
||||
// {
|
||||
// if (!OutOfOrderEvents.TryGetValue(gameEvent.Id, out GameEvent discard))
|
||||
// {
|
||||
// OutOfOrderEvents.Add(gameEvent.Id, gameEvent);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// this prevents multiple threads from adding simultaneously
|
||||
lock (OutOfOrderEvents)
|
||||
{
|
||||
if (!OutOfOrderEvents.TryGetValue(gameEvent.Id, out GameEvent discard))
|
||||
{
|
||||
OutOfOrderEvents.Add(gameEvent.Id, gameEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,6 @@ namespace IW4MAdmin
|
||||
{
|
||||
Player Leaving = Players[cNum];
|
||||
Logger.WriteInfo($"Client {Leaving}, state {Leaving.State.ToString()} disconnecting...");
|
||||
Leaving.State = Player.ClientState.Disconnecting;
|
||||
|
||||
// occurs when the player disconnects via log before being authenticated by RCon
|
||||
if (Leaving.State != Player.ClientState.Connected)
|
||||
@ -268,6 +267,7 @@ namespace IW4MAdmin
|
||||
|
||||
else
|
||||
{
|
||||
Leaving.State = Player.ClientState.Disconnecting;
|
||||
Leaving.TotalConnectionTime += (int)(DateTime.UtcNow - Leaving.ConnectionTime).TotalSeconds;
|
||||
Leaving.LastConnection = DateTime.UtcNow;
|
||||
await Manager.GetClientService().Update(Leaving);
|
||||
@ -822,7 +822,7 @@ namespace IW4MAdmin
|
||||
|
||||
Logger.WriteInfo($"Log file is {logPath}");
|
||||
|
||||
Task.Run(() => LogEvent.PollForChanges());
|
||||
_ = Task.Run(() => LogEvent.PollForChanges());
|
||||
#if !DEBUG
|
||||
await Broadcast(loc["BROADCAST_ONLINE"]);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user