mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-24 13:47:46 +00:00
fixed high cpu usage caused by spawning stupid amounts of script objects each tick
This commit is contained in:
parent
53207a9ff0
commit
ddad27a5f9
7 changed files with 41 additions and 27 deletions
|
@ -18,7 +18,8 @@ namespace FFXIVClassic_Map_Server
|
||||||
public static Logger Log;
|
public static Logger Log;
|
||||||
public static Server Server;
|
public static Server Server;
|
||||||
public static Random Random;
|
public static Random Random;
|
||||||
public static DateTime Tick;
|
public static DateTime LastTick = DateTime.Now;
|
||||||
|
public static DateTime Tick = DateTime.Now;
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
|
|
||||||
private Server mServer;
|
private Server mServer;
|
||||||
|
|
||||||
private const int MILIS_LOOPTIME = 10;
|
private const int MILIS_LOOPTIME = 333;
|
||||||
private Timer mZoneTimer;
|
private Timer mZoneTimer;
|
||||||
|
|
||||||
//Content Groups
|
//Content Groups
|
||||||
|
@ -1017,6 +1017,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
Program.Tick = DateTime.Now;
|
Program.Tick = DateTime.Now;
|
||||||
foreach (Zone zone in zoneList.Values)
|
foreach (Zone zone in zoneList.Values)
|
||||||
zone.Update(Program.Tick);
|
zone.Update(Program.Tick);
|
||||||
|
Program.LastTick = Program.Tick;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -616,6 +616,9 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
{
|
{
|
||||||
foreach (Actor a in mActorList.Values)
|
foreach (Actor a in mActorList.Values)
|
||||||
a.Update(tick);
|
a.Update(tick);
|
||||||
|
|
||||||
|
var deltaTime = (tick - Program.LastTick).Milliseconds;
|
||||||
|
LuaEngine.GetInstance().CallLuaFunction(null, this, "onUpdate", true, deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,9 +166,9 @@ namespace FFXIVClassic_Map_Server.actors.area
|
||||||
public override void Update(DateTime tick)
|
public override void Update(DateTime tick)
|
||||||
{
|
{
|
||||||
// todo: again, this is retarded but debug stuff
|
// todo: again, this is retarded but debug stuff
|
||||||
var diffTime = tick - lastUpdate;
|
|
||||||
base.Update(tick);
|
base.Update(tick);
|
||||||
|
|
||||||
|
var diffTime = tick - lastUpdate;
|
||||||
// arbitrary cap
|
// arbitrary cap
|
||||||
if (diffTime.Milliseconds >= 33)
|
if (diffTime.Milliseconds >= 33)
|
||||||
{
|
{
|
||||||
|
|
|
@ -396,8 +396,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
|
|
||||||
public override void Update(DateTime tick)
|
public override void Update(DateTime tick)
|
||||||
{
|
{
|
||||||
var deltaTime = (tick - aiContainer.GetLatestUpdate()).Milliseconds;
|
|
||||||
LuaEngine.GetInstance().CallLuaFunction(null, this, "onUpdate", true, deltaTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//A party member list packet came, set the party
|
//A party member list packet came, set the party
|
||||||
|
|
|
@ -278,7 +278,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
|
|
||||||
private void CallLuaFunctionNpc(Player player, Npc target, string funcName, bool optional, params object[] args)
|
private void CallLuaFunctionNpc(Player player, Npc target, string funcName, bool optional, params object[] args)
|
||||||
{
|
{
|
||||||
object[] args2 = new object[args.Length + (player == null ? 1:2)];
|
object[] args2 = new object[args.Length + (player == null ? 1 : 2)];
|
||||||
Array.Copy(args, 0, args2, (player == null ? 1 : 2), args.Length);
|
Array.Copy(args, 0, args2, (player == null ? 1 : 2), args.Length);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
|
@ -437,7 +437,8 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
Coroutine coroutine = mSleepingOnPlayerEvent[player.actorId];
|
Coroutine coroutine = mSleepingOnPlayerEvent[player.actorId];
|
||||||
mSleepingOnPlayerEvent.Remove(player.actorId);
|
mSleepingOnPlayerEvent.Remove(player.actorId);
|
||||||
|
|
||||||
try{
|
try
|
||||||
|
{
|
||||||
DynValue value = coroutine.Resume();
|
DynValue value = coroutine.Resume();
|
||||||
ResolveResume(null, coroutine, value);
|
ResolveResume(null, coroutine, value);
|
||||||
}
|
}
|
||||||
|
@ -465,7 +466,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
{
|
{
|
||||||
GetInstance().AddWaitEventCoroutine(player, coroutine);
|
GetInstance().AddWaitEventCoroutine(player, coroutine);
|
||||||
}
|
}
|
||||||
else if (player != null && value.Tuple != null && value.Tuple.Length >= 1 && value.Tuple[0].String != null)
|
else if (value.Tuple != null && value.Tuple.Length >= 1 && value.Tuple[0].String != null)
|
||||||
{
|
{
|
||||||
switch (value.Tuple[0].String)
|
switch (value.Tuple[0].String)
|
||||||
{
|
{
|
||||||
|
@ -620,9 +621,16 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
//script.Call(script.Globals["onTrigger"], LuaParam.ToArray());
|
//script.Call(script.Globals["onTrigger"], LuaParam.ToArray());
|
||||||
|
|
||||||
// gm commands dont need to be coroutines?
|
// gm commands dont need to be coroutines?
|
||||||
|
try
|
||||||
|
{
|
||||||
Coroutine coroutine = script.CreateCoroutine(script.Globals["onTrigger"]).Coroutine;
|
Coroutine coroutine = script.CreateCoroutine(script.Globals["onTrigger"]).Coroutine;
|
||||||
DynValue value = coroutine.Resume(LuaParam.ToArray());
|
DynValue value = coroutine.Resume(LuaParam.ToArray());
|
||||||
LuaEngine.GetInstance().ResolveResume(player, coroutine, value);
|
GetInstance().ResolveResume(player, coroutine, value);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Program.Log.Error("LuaEngine.RunGMCommand: {0} - {1}", path, e.Message);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -680,4 +688,3 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.26430.6
|
VisualStudioVersion = 15.0.26430.15
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FFXIVClassic Map Server", "FFXIVClassic Map Server\FFXIVClassic Map Server.csproj", "{E8FA2784-D4B9-4711-8CC6-712A4B1CD54F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FFXIVClassic Map Server", "FFXIVClassic Map Server\FFXIVClassic Map Server.csproj", "{E8FA2784-D4B9-4711-8CC6-712A4B1CD54F}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
@ -23,6 +23,9 @@ EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher Editor", "Launcher Editor\Launcher Editor.csproj", "{0FFA9D2F-41C6-443C-99B7-665702CF548F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher Editor", "Launcher Editor\Launcher Editor.csproj", "{0FFA9D2F-41C6-443C-99B7-665702CF548F}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
GlobalSection(Performance) = preSolution
|
||||||
|
HasPerformanceSessions = true
|
||||||
|
EndGlobalSection
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
|
|
Loading…
Add table
Reference in a new issue