mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-02 19:42:05 -04:00
Added a thread and update() calls for gamestate changing.
This commit is contained in:
parent
6a6ee67ae2
commit
9372b4bc32
@ -52,6 +52,7 @@ namespace FFXIVClassic_Map_Server
|
|||||||
mWorldManager.LoadActorClasses();
|
mWorldManager.LoadActorClasses();
|
||||||
mWorldManager.LoadSpawnLocations();
|
mWorldManager.LoadSpawnLocations();
|
||||||
mWorldManager.SpawnAllActors();
|
mWorldManager.SpawnAllActors();
|
||||||
|
mWorldManager.StartZoneThread();
|
||||||
|
|
||||||
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ConfigConstants.OPTIONS_BINDIP), int.Parse(ConfigConstants.OPTIONS_PORT));
|
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ConfigConstants.OPTIONS_BINDIP), int.Parse(ConfigConstants.OPTIONS_PORT));
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ using FFXIVClassic_Map_Server.actors.group;
|
|||||||
using FFXIVClassic_Map_Server.packets.send.group;
|
using FFXIVClassic_Map_Server.packets.send.group;
|
||||||
using FFXIVClassic_Map_Server.packets.WorldPackets.Receive;
|
using FFXIVClassic_Map_Server.packets.WorldPackets.Receive;
|
||||||
using FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group;
|
using FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace FFXIVClassic_Map_Server
|
namespace FFXIVClassic_Map_Server
|
||||||
{
|
{
|
||||||
@ -37,6 +39,9 @@ namespace FFXIVClassic_Map_Server
|
|||||||
|
|
||||||
private Server mServer;
|
private Server mServer;
|
||||||
|
|
||||||
|
private const int MILIS_LOOPTIME = 10;
|
||||||
|
private Timer mZoneTimer;
|
||||||
|
|
||||||
public WorldManager(Server server)
|
public WorldManager(Server server)
|
||||||
{
|
{
|
||||||
mServer = server;
|
mServer = server;
|
||||||
@ -802,6 +807,21 @@ namespace FFXIVClassic_Map_Server
|
|||||||
player.QueuePacket(groupInviteResultPacket);
|
player.QueuePacket(groupInviteResultPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void StartZoneThread()
|
||||||
|
{
|
||||||
|
mZoneTimer = new Timer(ZoneThreadLoop, null, 0, MILIS_LOOPTIME);
|
||||||
|
Program.Log.Info("Zone Loop has started");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ZoneThreadLoop(Object state)
|
||||||
|
{
|
||||||
|
lock (zoneList)
|
||||||
|
{
|
||||||
|
foreach (Area area in zoneList.Values)
|
||||||
|
area.Update(MILIS_LOOPTIME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Player GetPCInWorld(string name)
|
public Player GetPCInWorld(string name)
|
||||||
{
|
{
|
||||||
foreach (Zone zone in zoneList.Values)
|
foreach (Zone zone in zoneList.Values)
|
||||||
|
@ -303,6 +303,10 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
zone.BroadcastPacketAroundActor(this, ChangeSpeedPacket);
|
zone.BroadcastPacketAroundActor(this, ChangeSpeedPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update(double deltaTime)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateActorName(int actorNumber)
|
public void GenerateActorName(int actorNumber)
|
||||||
{
|
{
|
||||||
//Format Class Name
|
//Format Class Name
|
||||||
|
@ -373,5 +373,14 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update(double deltaTime)
|
||||||
|
{
|
||||||
|
lock (mActorList)
|
||||||
|
{
|
||||||
|
foreach (Actor a in mActorList.Values)
|
||||||
|
a.Update(deltaTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,6 +482,30 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update(double deltaTime)
|
||||||
|
{
|
||||||
|
LuaScript parent = null, child = null;
|
||||||
|
|
||||||
|
if (File.Exists("./scripts/base/" + classPath + ".lua"))
|
||||||
|
parent = LuaEngine.LoadScript("./scripts/base/" + classPath + ".lua");
|
||||||
|
if (File.Exists(String.Format("./scripts/unique/{0}/{1}/{2}.lua", zone.zoneName, className, uniqueIdentifier)))
|
||||||
|
child = LuaEngine.LoadScript(String.Format("./scripts/unique/{0}/{1}/{2}.lua", zone.zoneName, className, uniqueIdentifier));
|
||||||
|
|
||||||
|
if (parent == null && child == null)
|
||||||
|
{
|
||||||
|
//LuaEngine.SendError(player, String.Format("ERROR: Could not find script for actor {0}.", GetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Run Script
|
||||||
|
if (child != null && child.Globals["onThink"] != null)
|
||||||
|
child.Call(child.Globals["onThink"], this, deltaTime);
|
||||||
|
else if (parent != null && parent.Globals["onThink"] != null)
|
||||||
|
parent.Call(parent.Globals["onThink"], this, deltaTime);
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//A party member list packet came, set the party
|
//A party member list packet came, set the party
|
||||||
/* public void SetParty(MonsterPartyGroup group)
|
/* public void SetParty(MonsterPartyGroup group)
|
||||||
{
|
{
|
||||||
|
@ -1361,5 +1361,10 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
currentParty = null;
|
currentParty = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update(double delta)
|
||||||
|
{
|
||||||
|
LuaEngine.OnPlayerUpdate(this, delta);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,21 @@ namespace FFXIVClassic_Map_Server.lua
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void OnPlayerUpdate(Player player, double delta)
|
||||||
|
{
|
||||||
|
if (File.Exists(FILEPATH_PLAYER))
|
||||||
|
{
|
||||||
|
LuaScript script = LoadScript(FILEPATH_PLAYER);
|
||||||
|
|
||||||
|
if (script == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Run Script
|
||||||
|
if (!script.Globals.Get("onUpdate").IsNil())
|
||||||
|
script.Call(script.Globals["onUpdate"], player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region RunGMCommand
|
#region RunGMCommand
|
||||||
public static void RunGMCommand(Player player, String cmd, string[] param, bool help = false)
|
public static void RunGMCommand(Player player, String cmd, string[] param, bool help = false)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user