Fix N00BS

This commit is contained in:
Li 2022-07-19 12:33:44 +12:00
parent 0c299729dd
commit b3df338715
15 changed files with 71 additions and 81 deletions

View file

@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HISPd", "HISPd\HISPd.csproj
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "N00BS", "N00BS\N00BS.csproj", "{6B45A1E8-0F54-4BF7-AF48-41B9FE676570}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "N00BSInstaller", "N00BSInstaller\N00BSInstaller.vdproj", "{D330A197-67D4-42B0-8906-54264AF95EC1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Android|Any CPU = Android|Any CPU
@ -72,6 +70,7 @@ Global
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.iOS|ARM64.ActiveCfg = iOS|ARM64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.iOS|ARM64.Build.0 = iOS|ARM64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.iOS|x64.ActiveCfg = iOS|x64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.iOS|x64.Build.0 = iOS|x64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.iOS|x86.ActiveCfg = iOS|x86
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Linux|Any CPU.ActiveCfg = Linux|Any CPU
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Linux|Any CPU.Build.0 = Linux|Any CPU
@ -130,6 +129,7 @@ Global
{DEAD5CB0-C6B6-4B63-B1FB-A9F649CA1D27}.iOS|ARM64.ActiveCfg = iOS|ARM64
{DEAD5CB0-C6B6-4B63-B1FB-A9F649CA1D27}.iOS|ARM64.Build.0 = iOS|ARM64
{DEAD5CB0-C6B6-4B63-B1FB-A9F649CA1D27}.iOS|x64.ActiveCfg = iOS|x64
{DEAD5CB0-C6B6-4B63-B1FB-A9F649CA1D27}.iOS|x64.Build.0 = iOS|x64
{DEAD5CB0-C6B6-4B63-B1FB-A9F649CA1D27}.iOS|x86.ActiveCfg = iOS|x86
{DEAD5CB0-C6B6-4B63-B1FB-A9F649CA1D27}.Linux|Any CPU.ActiveCfg = Linux|Any CPU
{DEAD5CB0-C6B6-4B63-B1FB-A9F649CA1D27}.Linux|Any CPU.Build.0 = Linux|Any CPU
@ -199,38 +199,6 @@ Global
{6B45A1E8-0F54-4BF7-AF48-41B9FE676570}.Windows|x64.Build.0 = Windows|x64
{6B45A1E8-0F54-4BF7-AF48-41B9FE676570}.Windows|x86.ActiveCfg = Windows|x86
{6B45A1E8-0F54-4BF7-AF48-41B9FE676570}.Windows|x86.Build.0 = Windows|x86
{D330A197-67D4-42B0-8906-54264AF95EC1}.Android|Any CPU.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Android|ARM.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Android|ARM64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Android|x64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Android|x86.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Debug|Any CPU.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Debug|ARM.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Debug|ARM64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Debug|x64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Debug|x86.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.iOS|Any CPU.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.iOS|ARM.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.iOS|ARM64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.iOS|x64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.iOS|x86.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Linux|Any CPU.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Linux|ARM.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Linux|ARM64.ActiveCfg = Debug
{D330A197-67D4-42B0-8906-54264AF95EC1}.Linux|x64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Linux|x86.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.MacOS|Any CPU.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.MacOS|ARM.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.MacOS|ARM64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.MacOS|x64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.MacOS|x86.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Windows|Any CPU.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Windows|ARM.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Windows|ARM64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Windows|x64.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Windows|x64.Build.0 = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Windows|x86.ActiveCfg = Windows
{D330A197-67D4-42B0-8906-54264AF95EC1}.Windows|x86.Build.0 = Windows
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -48,14 +48,17 @@ namespace HISP.Cli
}
public static void LogToFile(bool error, string type,string text)
{
sw.WriteLineAsync(text + sw.NewLine);
sw.WriteLineAsync(DateTime.Now.ToString("MM-dd-YYYY HH:mm:dd") + ": [" + type + "] " + text + sw.NewLine);
}
public static void LogStdout(bool error, string type, string text)
{
if (type == "CRASH")
LogToFile(error, type, text);
if (error)
Console.Error.WriteAsync("[" + type + "] " + text + Console.Error.NewLine);
Console.Error.WriteAsync(DateTime.Now.ToString("MM-dd-YYYY HH:mm:dd")+": [" + type + "] " + text + Console.Error.NewLine);
else
Console.Out.WriteAsync("[" + type + "] " + text + Console.Out.NewLine);
Console.Out.WriteAsync(DateTime.Now.ToString("MM-dd-YYYY HH:mm:dd") + ": [" + type + "] " + text + Console.Out.NewLine);
}
@ -120,6 +123,10 @@ namespace HISP.Cli
LogFile = HispLogVar;
Logger.SetCallback(LogToFile);
}
else
{
LogFile = Path.Combine(BaseDir, "crash.log");
}
if (HispBaseDir != null)
{

View file

@ -1,5 +1,5 @@
Package: hisp
Version: 1.7.92
Version: 1.7.99
Depends: coreutils,systemd,mariadb-server,libsqlite3-dev,zlib1g-dev,libicu-dev,libkrb5-dev
Maintainer: Li
Homepage: https://islehorse.com

View file

@ -1,7 +1,10 @@
#!/bin/sh
useradd -r horseisle
mkdir -p /etc/hisp
mkdir -p /var/log/hisp
chown -R horseisle:horseisle /etc/hisp
chown -R horseisle:horseisle /var/log/hisp
systemctl enable HISP.service
systemctl start HISP

View file

@ -25,7 +25,7 @@ Group=horseisle
WorkingDirectory=/etc/hisp
ExecStart=/usr/bin/HISPd
Environment=USER=horseisle HOME=/etc/hisp HISP_BASE_DIR=/etc/hisp HISP_CONF_FILE=/etc/hisp/server.properties
Environment=USER=horseisle HOME=/etc/hisp HISP_BASE_DIR=/etc/hisp HISP_CONF_FILE=/etc/hisp/server.properties HISP_LOG_FILE=/var/log/hisp/hisp.log
[Install]
WantedBy=multi-user.target

View file

@ -30,5 +30,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.7.92.0")]
[assembly: AssemblyFileVersion("1.7.92.0")]
[assembly: AssemblyVersion("1.7.99.0")]
[assembly: AssemblyFileVersion("1.7.99.0")]

View file

@ -43,8 +43,12 @@ namespace HISP.Server
public static void OnShutdown()
{
MySqlConnection.ClearAllPools();
SqliteConnection.ClearAllPools();
if(!ConfigReader.SqlLite)
MySqlConnection.ClearAllPools();
else
SqliteConnection.ClearAllPools();
}
public static bool TryExecuteSqlQuery(string query)
@ -134,7 +138,6 @@ namespace HISP.Server
if (ConfigReader.SqlLite)
{
try
{
DbCommand sqlCommand = db.CreateCommand();

View file

@ -21,21 +21,24 @@ namespace HISP.Server
{
Process.GetCurrentProcess().Close();
}
public static Action OnShutdown = defaultOnShutdownCallback;
public static Action OnShutdown = defaultOnShutdownCallback;
public static void SetShutdownCallback(Action callback)
{
OnShutdown = callback;
}
public static void RegisterCrashHandler()
{
#if (!DEBUG)
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(HispCrashHandler);
#endif
}
public static void Start()
{
#if (!DEBUG)
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
#endif
RegisterCrashHandler();
Console.Title = ServerVersion.GetBuildString();
ConfigReader.OpenConfig();
CrossDomainPolicy.GetPolicy();
@ -61,25 +64,18 @@ namespace HISP.Server
GameServer.StartServer();
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
private static void HispCrashHandler(object sender, UnhandledExceptionEventArgs e)
{
Exception execpt = (Exception)e.ExceptionObject;
Logger.ErrorPrint("HISP HAS CRASHED :(");
Logger.ErrorPrint("Unhandled Exception: " + execpt.ToString());
Logger.ErrorPrint(execpt.StackTrace);
string crashMsg = "HISP HAS CRASHED :(";
crashMsg += "Build: " + ServerVersion.GetBuildString();
crashMsg += "Unhandled Exception: " + execpt.Message;
crashMsg += execpt.StackTrace;
try
{
File.AppendAllText("crashlog.txt", "HISP HAS CRASHED :(\n");
File.AppendAllText("crashlog.txt", "Unhandled Exception: " + execpt.ToString() + "\n");
File.AppendAllText("crashlog.txt", execpt.StackTrace + "\n");
}
catch (Exception) { };
Thread.Sleep(5000);
Environment.Exit(1);
Logger.CrashPrint(crashMsg);
}
}
}

View file

@ -102,9 +102,9 @@ namespace HISP.Server
client.LoggedinUser.Inventory.AddIgnoringFull(rubyItem);
}
client.LoggedinUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.GameUpdates).Count++;
client.LoggedinUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.GameUpdates).Count++;
Logger.DebugPrint("Kicking: " + client.LoggedinUser.Username);
}
client.Kick("Server shutdown.");
}

View file

@ -8258,18 +8258,16 @@ namespace HISP.Server
}
public static void ShutdownServer()
{
Logger.InfoPrint("Shutting down.");
Logger.InfoPrint("Server shutting down.");
try
{
GameClient.OnShutdown();
GameServer.OnShutdown();
Database.OnShutdown();
Entry.OnShutdown();
}
catch (Exception)
{
Environment.Exit(1);
}
catch (Exception) { }
Entry.OnShutdown();
}
public static void StartServer()

View file

@ -41,6 +41,10 @@ namespace HISP.Server
{
if (ConfigReader.LogLevel >= 5)
logFunction(false, "DEBUG", text);
}
public static void CrashPrint(string text)
{
logFunction(true, "CRASH", text);
}
}
}

View file

@ -68,6 +68,12 @@ namespace HISP.Noobs
return rand.Next(0, 255).ToString();
}
public static void ShowCrash(bool error, string type, string text)
{
if (type == "CRASH")
MessageBox.Show(text, type, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public static void Main(string[] args)
{
@ -104,6 +110,9 @@ namespace HISP.Noobs
Task startForm = new Task(StartLRFrm);
startForm.Start();
Entry.RegisterCrashHandler();
Logger.SetCallback(ShowCrash);
ConfigReader.ConfigurationFileName = Path.Combine(BaseDir, "server.properties");
ConfigReader.OpenConfig();
ConfigReader.SqlLite = true;
@ -117,7 +126,6 @@ namespace HISP.Noobs
ConfigReader.DatabaseName = Path.Combine(BaseDir, "game1");
IncrementProgress();
Database.OpenDatabase();
IncrementProgress();
@ -131,6 +139,7 @@ namespace HISP.Noobs
}
// Start HI1 Server
IncrementProgress();

View file

@ -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.7.92.0")]
[assembly: AssemblyFileVersion("1.7.92.0")]
[assembly: AssemblyVersion("1.7.99.0")]
[assembly: AssemblyFileVersion("1.7.99.0")]

View file

@ -164,7 +164,7 @@
//
this.allUsersSubscribedToolStripMenuItem.CheckOnClick = true;
this.allUsersSubscribedToolStripMenuItem.Name = "allUsersSubscribedToolStripMenuItem";
this.allUsersSubscribedToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.allUsersSubscribedToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.allUsersSubscribedToolStripMenuItem.Text = "All users subscribed";
this.allUsersSubscribedToolStripMenuItem.CheckedChanged += new System.EventHandler(this.allUsersSubscribedToolStripMenuItem_CheckedChanged);
//
@ -172,7 +172,7 @@
//
this.fixOfficalBugsToolStripMenuItem.CheckOnClick = true;
this.fixOfficalBugsToolStripMenuItem.Name = "fixOfficalBugsToolStripMenuItem";
this.fixOfficalBugsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.fixOfficalBugsToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.fixOfficalBugsToolStripMenuItem.Text = "Fix offical bugs";
this.fixOfficalBugsToolStripMenuItem.CheckedChanged += new System.EventHandler(this.fixOfficalBugsToolStripMenuItem_CheckedChanged);
//
@ -190,12 +190,14 @@
this.editServerPropertiesToolStripMenuItem.Name = "editServerPropertiesToolStripMenuItem";
this.editServerPropertiesToolStripMenuItem.Size = new System.Drawing.Size(184, 22);
this.editServerPropertiesToolStripMenuItem.Text = "Edit server.properties";
this.editServerPropertiesToolStripMenuItem.Click += new System.EventHandler(this.editServerPropertiesToolStripMenuItem_Click);
//
// openServerFolderToolStripMenuItem
//
this.openServerFolderToolStripMenuItem.Name = "openServerFolderToolStripMenuItem";
this.openServerFolderToolStripMenuItem.Size = new System.Drawing.Size(184, 22);
this.openServerFolderToolStripMenuItem.Text = "Open server folder";
this.openServerFolderToolStripMenuItem.Click += new System.EventHandler(this.openServerFolderToolStripMenuItem_Click);
//
// SystemTrayIcon
//

View file

@ -76,8 +76,8 @@ namespace HISP.Noobs
private void editServerPropertiesToolStripMenuItem_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = "notepad.exe";
p.StartInfo.Arguments = Path.Combine(Program.BaseDir, "server.properties");
p.StartInfo.FileName = Path.Combine(Program.BaseDir, "server.properties");
p.StartInfo.UseShellExecute = true;
p.Start();
}
@ -85,8 +85,8 @@ namespace HISP.Noobs
private void openServerFolderToolStripMenuItem_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = "explorer.exe";
p.StartInfo.Arguments = Program.BaseDir;
p.StartInfo.FileName = Program.BaseDir;
p.StartInfo.UseShellExecute = true;
p.Start();
}