From d630abb66a49ac6312dcc4f867fddf9ee96c18c7 Mon Sep 17 00:00:00 2001
From: Li
Date: Sun, 20 Nov 2022 15:33:36 +1300
Subject: [PATCH] Some improvements ..
---
HorseIsleServer/HISPd/Program.cs | 46 ++++++++++---------
.../HISPd/Properties/AssemblyInfo.cs | 4 +-
.../HISPd/Resources/DEBIAN/control | 2 +-
HorseIsleServer/LibHISP/Game/Chat/Command.cs | 3 +-
HorseIsleServer/LibHISP/Game/Services/Shop.cs | 2 +-
.../LibHISP/Properties/AssemblyInfo.cs | 4 +-
HorseIsleServer/LibHISP/Server/GameClient.cs | 7 +--
.../LibHISP/Server/GameDataJson.cs | 4 +-
HorseIsleServer/LibHISP/Server/GameServer.cs | 6 +--
HorseIsleServer/LibHISP/Server/Logger.cs | 8 ++++
.../MPN00BS/Properties/AssemblyInfo.cs | 4 +-
11 files changed, 51 insertions(+), 39 deletions(-)
diff --git a/HorseIsleServer/HISPd/Program.cs b/HorseIsleServer/HISPd/Program.cs
index c4b63fd..40ef1ea 100755
--- a/HorseIsleServer/HISPd/Program.cs
+++ b/HorseIsleServer/HISPd/Program.cs
@@ -46,12 +46,14 @@ namespace HISP.Cli
{
if(fs != null)
{
+ fs.Flush();
fs.Close();
fs.Dispose();
fs = null;
}
if(sw != null)
{
+ sw.Flush();
sw.Close();
sw.Dispose();
sw = null;
@@ -81,25 +83,27 @@ namespace HISP.Cli
{
if (type == "CRASH")
LogToFile(error, type, text);
-
- if (error)
- Console.Error.WriteAsync(formatMessage(type, text));
- else
- Console.Out.WriteAsync(formatMessage(type, text));
-
+ try
+ {
+ if (error)
+ Console.Error.WriteAsync(formatMessage(type, text));
+ else
+ Console.Out.WriteAsync(formatMessage(type, text));
+ }
+ catch (Exception) { };
}
public static void Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit += ProcessQuitHandler;
- string BaseDir = Directory.GetCurrentDirectory();
+ string baseDir = Directory.GetCurrentDirectory();
Logger.SetCallback(LogStdout);
Entry.SetShutdownCallback(OnShutdown);
- string HispConfVar = Environment.GetEnvironmentVariable("HISP_CONF_FILE");
- string HispLogVar = Environment.GetEnvironmentVariable("HISP_LOG_FILE");
- string HispBaseDir = Environment.GetEnvironmentVariable("HISP_BASE_DIR");
+ string hispConfVar = Environment.GetEnvironmentVariable("HISP_CONF_FILE");
+ string hispLogVar = Environment.GetEnvironmentVariable("HISP_LOG_FILE");
+ string hispBaseDir = Environment.GetEnvironmentVariable("HISP_BASE_DIR");
foreach (string arg in args)
{
@@ -129,8 +133,8 @@ namespace HISP.Cli
Logger.SetCallback(LogToFile);
break;
case "--base-directory":
- BaseDir = argu[1];
- Directory.SetCurrentDirectory(BaseDir);
+ baseDir = argu[1];
+ Directory.SetCurrentDirectory(baseDir);
break;
default:
continue;
@@ -141,25 +145,25 @@ namespace HISP.Cli
}
}
- if (HispConfVar != null)
+ if (hispConfVar != null)
{
- ConfigReader.ConfigurationFileName = HispConfVar;
+ ConfigReader.ConfigurationFileName = hispConfVar;
}
- if (HispLogVar != null)
+ if (hispLogVar != null)
{
- LogFile = HispLogVar;
+ LogFile = hispLogVar;
Logger.SetCallback(LogToFile);
}
else
{
- LogFile = Path.Combine(BaseDir, "crash.log");
+ LogFile = Path.Combine(baseDir, "crash.log");
}
- if (HispBaseDir != null)
+ if (hispBaseDir != null)
{
- BaseDir = HispBaseDir;
- Directory.SetCurrentDirectory(BaseDir);
+ baseDir = hispBaseDir;
+ Directory.SetCurrentDirectory(baseDir);
}
Entry.Start();
@@ -170,7 +174,7 @@ namespace HISP.Cli
private static void ProcessQuitHandler(object sender, EventArgs e)
{
- GameServer.ShutdownServer();
+ GameServer.ShutdownServer("HISPd process quitting.");
}
}
}
diff --git a/HorseIsleServer/HISPd/Properties/AssemblyInfo.cs b/HorseIsleServer/HISPd/Properties/AssemblyInfo.cs
index 35ad9bd..7524f03 100755
--- a/HorseIsleServer/HISPd/Properties/AssemblyInfo.cs
+++ b/HorseIsleServer/HISPd/Properties/AssemblyInfo.cs
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.8.55.0")]
-[assembly: AssemblyFileVersion("1.8.55.0")]
+[assembly: AssemblyVersion("1.8.56.0")]
+[assembly: AssemblyFileVersion("1.8.56.0")]
diff --git a/HorseIsleServer/HISPd/Resources/DEBIAN/control b/HorseIsleServer/HISPd/Resources/DEBIAN/control
index 1d22687..3a72ccc 100755
--- a/HorseIsleServer/HISPd/Resources/DEBIAN/control
+++ b/HorseIsleServer/HISPd/Resources/DEBIAN/control
@@ -1,5 +1,5 @@
Package: hisp
-Version: 1.8.55
+Version: 1.8.56
Depends: coreutils,systemd,mariadb-server,libsqlite3-dev,zlib1g-dev,libicu-dev,libkrb5-dev
Maintainer: Li
Homepage: https://islehorse.com
diff --git a/HorseIsleServer/LibHISP/Game/Chat/Command.cs b/HorseIsleServer/LibHISP/Game/Chat/Command.cs
index 1a5ab65..ec399e4 100755
--- a/HorseIsleServer/LibHISP/Game/Chat/Command.cs
+++ b/HorseIsleServer/LibHISP/Game/Chat/Command.cs
@@ -92,7 +92,8 @@ namespace HISP.Game.Chat
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message), PacketBuilder.CHAT_BOTTOM_LEFT);
user.LoggedinClient.SendPacket(chatPacket);
- GameServer.ShutdownServer();
+
+ GameServer.ShutdownServer("Administrator initiated");
return true;
}
diff --git a/HorseIsleServer/LibHISP/Game/Services/Shop.cs b/HorseIsleServer/LibHISP/Game/Services/Shop.cs
index c8216cd..a29485a 100755
--- a/HorseIsleServer/LibHISP/Game/Services/Shop.cs
+++ b/HorseIsleServer/LibHISP/Game/Services/Shop.cs
@@ -24,7 +24,7 @@ namespace HISP.Game.Services
if (Item.ItemIdExist(stock))
this.Inventory.AddInfinity(Item.GetItemById(stock));
else
- Logger.WarnPrint("Item ID: " + stock + " Does not exist.");
+ Logger.WarnPrint("Item ID: " + stock + " doesn't exist, but shop " + id + " stocks it");
}
ItemInstance[] instances = Database.GetShopInventory(this.Id);
diff --git a/HorseIsleServer/LibHISP/Properties/AssemblyInfo.cs b/HorseIsleServer/LibHISP/Properties/AssemblyInfo.cs
index 03b14f5..daace4b 100755
--- a/HorseIsleServer/LibHISP/Properties/AssemblyInfo.cs
+++ b/HorseIsleServer/LibHISP/Properties/AssemblyInfo.cs
@@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.8.55.0")]
-[assembly: AssemblyFileVersion("1.8.55.0")]
+[assembly: AssemblyVersion("1.8.56.0")]
+[assembly: AssemblyFileVersion("1.8.56.0")]
diff --git a/HorseIsleServer/LibHISP/Server/GameClient.cs b/HorseIsleServer/LibHISP/Server/GameClient.cs
index c45d5de..8678be9 100755
--- a/HorseIsleServer/LibHISP/Server/GameClient.cs
+++ b/HorseIsleServer/LibHISP/Server/GameClient.cs
@@ -1,7 +1,6 @@
using System;
using System.Net.Sockets;
using System.Threading;
-using System.Collections.Generic;
using HISP.Player;
using HISP.Game;
using HISP.Game.Horse;
@@ -9,7 +8,6 @@ using HISP.Game.Events;
using HISP.Game.Items;
using HISP.Util;
using HISP.Server.Network;
-using System.Net;
namespace HISP.Server
{
@@ -83,7 +81,7 @@ namespace HISP.Server
}
- public static void OnShutdown()
+ public static void OnShutdown(string reason)
{
try
{
@@ -101,8 +99,7 @@ namespace HISP.Server
client.LoggedinUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.GameUpdates).Count++;
Logger.DebugPrint("Kicking: " + client.LoggedinUser.Username);
}
- client.Kick("Server shutdown.");
-
+ client.Kick("Server shutdown: "+reason);
}
}
catch (Exception) { };
diff --git a/HorseIsleServer/LibHISP/Server/GameDataJson.cs b/HorseIsleServer/LibHISP/Server/GameDataJson.cs
index b2630a2..6ee8f0a 100755
--- a/HorseIsleServer/LibHISP/Server/GameDataJson.cs
+++ b/HorseIsleServer/LibHISP/Server/GameDataJson.cs
@@ -416,7 +416,9 @@ namespace HISP.Server
if (gameData.quest_list[i].chained_questid != null)
quest.ChainedQuestId = gameData.quest_list[i].chained_questid;
quest.Minigame = gameData.quest_list[i].minigame;
- Logger.DebugPrint("Registered Quest: " + quest.Id + " - " + quest.Title);
+
+ if(quest.Title.Trim() != "")
+ Logger.DebugPrint("Registered Quest: " + quest.Id + " - " + quest.Title);
Quest.AddQuestEntry(quest);
}
diff --git a/HorseIsleServer/LibHISP/Server/GameServer.cs b/HorseIsleServer/LibHISP/Server/GameServer.cs
index c4e441f..387efa0 100755
--- a/HorseIsleServer/LibHISP/Server/GameServer.cs
+++ b/HorseIsleServer/LibHISP/Server/GameServer.cs
@@ -8240,12 +8240,12 @@ namespace HISP.Server
if (minuteTimer != null)
minuteTimer.Dispose();
}
- public static void ShutdownServer()
+ public static void ShutdownServer(string shutdownReason = "No reason provided.")
{
- Logger.InfoPrint("Server shutting down.");
+ Logger.InfoPrint("Server shutting down; " + shutdownReason);
try
{
- GameClient.OnShutdown();
+ GameClient.OnShutdown(shutdownReason);
GameServer.OnShutdown();
Database.OnShutdown();
}
diff --git a/HorseIsleServer/LibHISP/Server/Logger.cs b/HorseIsleServer/LibHISP/Server/Logger.cs
index 3fee678..d8e27b5 100755
--- a/HorseIsleServer/LibHISP/Server/Logger.cs
+++ b/HorseIsleServer/LibHISP/Server/Logger.cs
@@ -11,6 +11,14 @@ namespace HISP.Server
private static Action logFunction = defaultCallbackFunc;
+ private void log(bool error, string type, string text)
+ {
+ string[] msgs = text.Replace("\r", "").Split("\n");
+ foreach(string msg in msgs)
+ {
+ logFunction(error, type, msg);
+ }
+ }
public static void SetCallback(Action callback)
{
diff --git a/HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs b/HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs
index a97b62d..988b8d6 100755
--- a/HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs
+++ b/HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs
@@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.8.55.0")]
-[assembly: AssemblyFileVersion("1.8.55.0")]
+[assembly: AssemblyVersion("1.8.56.0")]
+[assembly: AssemblyFileVersion("1.8.56.0")]