mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-08 22:25:42 +12:00
Prevent timer from being "optomized out" ..
This commit is contained in:
parent
e1ae589e93
commit
6f58bbeacf
1 changed files with 17 additions and 20 deletions
|
@ -15,8 +15,7 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
|
|
||||||
public static Socket ServerSocket;
|
public static Socket ServerSocket;
|
||||||
private static Timer serverTimer;
|
|
||||||
|
|
||||||
public static GameClient[] ConnectedClients // Done to prevent Enumerator Changed errors.
|
public static GameClient[] ConnectedClients // Done to prevent Enumerator Changed errors.
|
||||||
{
|
{
|
||||||
get {
|
get {
|
||||||
|
@ -29,10 +28,22 @@ namespace HISP.Server
|
||||||
|
|
||||||
public static Random RandomNumberGenerator = new Random();
|
public static Random RandomNumberGenerator = new Random();
|
||||||
|
|
||||||
// used for world time,
|
/*
|
||||||
|
* Private stuff
|
||||||
|
*/
|
||||||
private static int gameTickSpeed = 4320; // Changing this to ANYTHING else will cause desync with the client.
|
private static int gameTickSpeed = 4320; // Changing this to ANYTHING else will cause desync with the client.
|
||||||
|
|
||||||
private static List<GameClient> connectedClients = new List<GameClient>();
|
private static List<GameClient> connectedClients = new List<GameClient>();
|
||||||
|
private static Timer serverTimer;
|
||||||
|
private static void onTick(object state)
|
||||||
|
{
|
||||||
|
World.TickWorldClock();
|
||||||
|
|
||||||
|
if (World.ServerTime.Minutes % 30 == 0)
|
||||||
|
{
|
||||||
|
DroppedItems.Update();
|
||||||
|
}
|
||||||
|
serverTimer.Change(gameTickSpeed, gameTickSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This section is where all the event handlers live,
|
* This section is where all the event handlers live,
|
||||||
|
@ -1451,9 +1462,7 @@ namespace HISP.Server
|
||||||
ServerSocket.Bind(ep);
|
ServerSocket.Bind(ep);
|
||||||
Logger.InfoPrint("Binding to ip: " + ConfigReader.BindIP + " On port: " + ConfigReader.Port.ToString());
|
Logger.InfoPrint("Binding to ip: " + ConfigReader.BindIP + " On port: " + ConfigReader.Port.ToString());
|
||||||
ServerSocket.Listen(10000);
|
ServerSocket.Listen(10000);
|
||||||
|
|
||||||
serverTimer = new Timer(new TimerCallback(onTick), null, gameTickSpeed, gameTickSpeed);
|
serverTimer = new Timer(new TimerCallback(onTick), null, gameTickSpeed, gameTickSpeed);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Logger.InfoPrint("Waiting for new connections...");
|
Logger.InfoPrint("Waiting for new connections...");
|
||||||
|
@ -1464,20 +1473,8 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Private methods..
|
|
||||||
*/
|
|
||||||
|
|
||||||
private static void onTick(object state)
|
|
||||||
{
|
|
||||||
World.TickWorldClock();
|
|
||||||
|
|
||||||
if(World.ServerTime.Minutes % 20 == 0)
|
|
||||||
{
|
|
||||||
DroppedItems.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue