Správné vypnutí serveru v případě crashe z důvodu obsazeného portu, soubor na nastavení rozlišení, odstranění nepoužívané metody Enemy.SilentSpawn a implementace metody SoundManager.GetRandomisedPitchInstance
This commit is contained in:
parent
243f071a43
commit
8742f9eb55
10 changed files with 46 additions and 56 deletions
|
|
@ -16,12 +16,6 @@ public abstract class Enemy : GlobalEnemy<MapTile, TileConnector> {
|
|||
MovementOpportunity = new(movementInterval);
|
||||
SetDifficulty(difficulty);
|
||||
}
|
||||
|
||||
// unused
|
||||
public virtual void SpawnSilent(MapTile location) {
|
||||
Console.WriteLine($"!!! Silent spawn not implemented for enemy {Type} ({Name}), reverting to regular spawn");
|
||||
Spawn(location);
|
||||
}
|
||||
|
||||
public override void Spawn(MapTile location) {
|
||||
base.Spawn(location);
|
||||
|
|
|
|||
|
|
@ -122,10 +122,6 @@ public static class GameLogic {
|
|||
}
|
||||
Thread.Sleep(1000);
|
||||
Server.Stop();
|
||||
|
||||
if (!Server.AutoStop){
|
||||
Program.Restart();
|
||||
}
|
||||
}
|
||||
|
||||
private static (int p1Usage, int p2Usage) CalculatePowerUsage() {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ public static class Server {
|
|||
public static readonly Dictionary<int, ServerPlayer> Players = new();
|
||||
public static ServerPlayer OtherPlayer(ServerPlayer player) => player.State.Pid == P1.State.Pid ? P2 : P1;
|
||||
|
||||
public static bool AutoStop{ get; set; } = true;
|
||||
|
||||
private static EventBasedNetListener listener;
|
||||
private static NetManager server;
|
||||
|
||||
|
|
@ -61,6 +59,10 @@ public static class Server {
|
|||
listener.PeerDisconnectedEvent += OnPeerDisconnected;
|
||||
|
||||
server.Start(port);
|
||||
if (!server.IsRunning){
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
Run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,8 @@
|
|||
using System.Diagnostics;
|
||||
using ONDServer.Net;
|
||||
using ONDServer.Net;
|
||||
|
||||
namespace ONDServer;
|
||||
|
||||
public static class Program {
|
||||
public static void Main(string[] args) {
|
||||
if (args.Contains("--persistent")){
|
||||
Server.AutoStop = false;
|
||||
}
|
||||
Server.Start(9012);
|
||||
}
|
||||
|
||||
public static void Restart() {
|
||||
Console.WriteLine("Game concluded -> restarting server");
|
||||
Process.Start(new ProcessStartInfo{ FileName = Environment.ProcessPath, UseShellExecute = false });
|
||||
Environment.Exit(0);
|
||||
}
|
||||
try{
|
||||
Server.Start(9012);
|
||||
}
|
||||
finally{
|
||||
Server.Stop();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue