Port N00BS to linux

This commit is contained in:
Li 2022-07-25 19:16:21 +12:00
parent 64fed1c6c4
commit 8297c56f21
181 changed files with 282 additions and 132 deletions

0
HorseIsleServer/MPN00BS/App.axaml Normal file → Executable file
View file

0
HorseIsleServer/MPN00BS/App.axaml.cs Normal file → Executable file
View file

View file

@ -0,0 +1,3 @@
<cross-domain-policy>
<allow-access-from domain="*" to-ports="12321" secure="false"/>
</cross-domain-policy>

30
HorseIsleServer/MPN00BS/HTTP/ContentServer.cs Normal file → Executable file
View file

@ -34,7 +34,6 @@ namespace HTTP
{
clientSock = ClientSocket;
baseServ = Server;
baseServ.WriteDebugOutput("Client Connected @ " + clientSock.RemoteEndPoint.ToString());
ProcessRequests();
clientSock.Close();
@ -107,7 +106,6 @@ namespace HTTP
private void RespondGet(string name)
{
baseServ.WriteDebugOutput("GET " + name);
if (ContentItemExists(name))
{
@ -156,7 +154,6 @@ namespace HTTP
private void RespondHead(string path)
{
string name = Path.GetFileName(path);
baseServ.WriteDebugOutput("HEAD " + path);
if (ContentItemExists(name))
{
@ -262,26 +259,37 @@ namespace HTTP
{
public List<ContentItem> Contents = new List<ContentItem>();
public Socket ServerSocket;
public void WriteDebugOutput(string txt)
{
Console.WriteLine("[HTTP] " + txt);
}
public void CreateClient(object sender, SocketAsyncEventArgs e)
{
do
{
if(shutdownServer)
return;
Socket eSocket = e.AcceptSocket;
if (eSocket != null)
new ContentClient(this, eSocket);
e.AcceptSocket = null;
} while (!ServerSocket.AcceptAsync(e));
}
public ContentServer(string ip)
public void Shutdown() {
shutdownServer = true;
ServerSocket.Dispose();
ServerSocket = null;
}
private bool shutdownServer = false;
public string ipaddr;
public short portnum;
public ContentServer(string ip, short port)
{
WriteDebugOutput("Listening for connections on port 80.");
IPEndPoint ep = new IPEndPoint(IPAddress.Parse(ip), 80);
ipaddr = ip;
portnum = port;
IPEndPoint ep = new IPEndPoint(IPAddress.Parse(ip), port);
ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
ServerSocket.Bind(ep);
ServerSocket.Listen(0x7fffffff);

0
HorseIsleServer/MPN00BS/HispLogo.gif Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before After
Before After

0
HorseIsleServer/MPN00BS/HispViewModel.cs Normal file → Executable file
View file

0
HorseIsleServer/MPN00BS/LoadingWindow.axaml Normal file → Executable file
View file

4
HorseIsleServer/MPN00BS/LoadingWindow.axaml.cs Normal file → Executable file
View file

@ -38,6 +38,7 @@ namespace MPN00BS
Dispatcher.UIThread.InvokeAsync(() =>
{
ServerStarter.CloseHorseIsleClient();
ServerStarter.ShutdownHTTPServer();
this.Close();
});
}
@ -52,9 +53,6 @@ namespace MPN00BS
public LoadingWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
ServerStarter.StartHttpServer();
new Task( () => ServerStarter.StartHispServer(ProgressUpdate, OnNoUsersFound, OnServerStarted, OnShutdown)).Start();
}

22
HorseIsleServer/MPN00BS/MPN00BS.csproj Normal file → Executable file
View file

@ -98,7 +98,12 @@
<DefineConstants>OS_LINUX;ARCH_ARM64</DefineConstants>
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Linux|AnyCPU'">
<Optimize>true</Optimize>
<DefineConstants>OS_LINUX;ARCH_ANYCPU</DefineConstants>
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MacOS|x64'">
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<Optimize>true</Optimize>
@ -218,8 +223,6 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.17" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.17" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.17" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4" />
</ItemGroup>
@ -228,8 +231,17 @@
</ItemGroup>
<ItemGroup>
<None Update="flashplayer\WINDOWS\flash.exe">
<ContentWithTargetPath Include="flashplayer/LINUX/flash.elf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<TargetPath>flashplayer/LINUX/flash.elf</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<ItemGroup>
<ContentWithTargetPath Include="flashplayer\WINDOWS\flash.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>flashplayer\WINDOWS\flash.exe</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
</Project>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>C:\Users\Li\Documents\git\HISP\HorseIsleServer\MPN00BS\Properties\PublishProfiles\Win64.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>

0
HorseIsleServer/MPN00BS/MessageBox.axaml Normal file → Executable file
View file

0
HorseIsleServer/MPN00BS/MessageBox.axaml.cs Normal file → Executable file
View file

0
HorseIsleServer/MPN00BS/MiniMvvm/MiniCommand.cs Normal file → Executable file
View file

View file

0
HorseIsleServer/MPN00BS/MiniMvvm/ViewModelBase.cs Normal file → Executable file
View file

0
HorseIsleServer/MPN00BS/MpOrSp.axaml Normal file → Executable file
View file

3
HorseIsleServer/MPN00BS/MpOrSp.axaml.cs Normal file → Executable file
View file

@ -9,9 +9,6 @@ namespace MPN00BS
public MpOrSp()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void playSingleplayerClick(object sender, RoutedEventArgs e)
{

0
HorseIsleServer/MPN00BS/Program.cs Normal file → Executable file
View file

4
HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs Normal file → Executable file
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.110.0")]
[assembly: AssemblyFileVersion("1.7.110.0")]
[assembly: AssemblyVersion("1.7.112.0")]
[assembly: AssemblyFileVersion("1.7.112.0")]

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

0
HorseIsleServer/MPN00BS/RegisterWindow.axaml Normal file → Executable file
View file

3
HorseIsleServer/MPN00BS/RegisterWindow.axaml.cs Normal file → Executable file
View file

@ -15,9 +15,6 @@ namespace MPN00BS
public RegisterWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}

0
HorseIsleServer/MPN00BS/ResetWindow.axaml Normal file → Executable file
View file

3
HorseIsleServer/MPN00BS/ResetWindow.axaml.cs Normal file → Executable file
View file

@ -14,9 +14,6 @@ namespace MPN00BS
public ResetWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void ValidateInput()

0
HorseIsleServer/MPN00BS/ServerSelection.axaml Normal file → Executable file
View file

11
HorseIsleServer/MPN00BS/ServerSelection.axaml.cs Normal file → Executable file
View file

@ -2,6 +2,8 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using System;
namespace MPN00BS
@ -11,9 +13,6 @@ namespace MPN00BS
public ServerSelection()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent()
@ -31,7 +30,11 @@ namespace MPN00BS
private void OnClientExit()
{
this.Close();
Dispatcher.UIThread.InvokeAsync(() =>
{
ServerStarter.ShutdownHTTPServer();
this.Close();
});
}
}
}

43
HorseIsleServer/MPN00BS/ServerStarter.cs Normal file → Executable file
View file

@ -31,7 +31,9 @@ namespace MPN00BS
cs.Contents.Add(ci);
}
public static void ShutdownHTTPServer(){
cs.Shutdown();
}
public static void ShowCrash(bool error, string type, string text)
{
@ -56,9 +58,20 @@ namespace MPN00BS
HorseIsleClientExitCallback = callback;
clientProcess = new Process();
#if OS_WINDOWS
clientProcess.StartInfo.FileName = Path.Combine(Directory.GetCurrentDirectory(), "flashplayer", "WINDOWS", "flash.exe");
clientProcess.StartInfo.Arguments = "http://127.0.0.1/horseisle.swf?SERVER=" + serverIp + "&PORT=" + serverPort.ToString();
#elif OS_LINUX
clientProcess.StartInfo.FileName = Path.Combine(Directory.GetCurrentDirectory(), "flashplayer", "LINUX", "flash.elf");
#else
MessageBox.Show(null,"ERROR: No path for flash projector specified on this platform", "Porting error", MessageBoxButtons.Ok);
#endif
#if OS_LINUX
clientProcess.StartInfo.Arguments = "http://"+cs.ipaddr+":"+cs.portnum+"/horseisle_mapfix.swf?SERVER=" + serverIp + "&PORT=" + serverPort.ToString();
#else
clientProcess.StartInfo.Arguments = "http://"+cs.ipaddr+":"+cs.portnum+"/horseisle.swf?SERVER=" + serverIp + "&PORT=" + serverPort.ToString();
#endif
clientProcess.StartInfo.RedirectStandardOutput = true;
clientProcess.StartInfo.RedirectStandardError = true;
@ -191,27 +204,41 @@ namespace MPN00BS
public static void SetBaseDir()
{
#if OS_WINDOWS
string hispFolder = Environment.GetEnvironmentVariable("APPDATA");
if (hispFolder == null)
return;
BaseDir = Path.Combine(hispFolder, "HISP", "N00BS");
Directory.CreateDirectory(BaseDir);
#elif OS_LINUX
string hispFolder = Environment.GetEnvironmentVariable("HOME");
if (hispFolder == null)
return;
BaseDir = Path.Combine(hispFolder, ".HISP", "N00BS");
#endif
}
public static void StartHttpServer()
{
SetBaseDir();
try
{
cs = new ContentServer("127.0.0.1");
string[] fileList = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "client"), "*", SearchOption.AllDirectories);
foreach (string file in fileList)
#if OS_LINUX
cs = new ContentServer("127.0.0.1", 12322);
#else
cs = new ContentServer("127.0.0.1", 80);
#endif
string clientFolder = Path.Combine(Directory.GetCurrentDirectory(), "client");
string[] fileList = Directory.GetFiles(clientFolder, "*", SearchOption.AllDirectories);
foreach (string file in fileList){
addToList(file);
}
}
catch (Exception e)
{
MessageBox.Show(null, "Web server failed to start: " + e.Message, "Error starting web server", MessageBoxButtons.Ok);
MessageBox.Show(null, "Web server failed to start: "+ e.GetType().Name + " " + e.Message, "Error starting web server", MessageBoxButtons.Ok);
return;
}

Binary file not shown.

0
HorseIsleServer/MPN00BS/flashplayer/WINDOWS/flash.exe Normal file → Executable file
View file

0
HorseIsleServer/MPN00BS/icon.ico Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Before After
Before After

View file

@ -0,0 +1,99 @@
# =======================
# Horse Isle Server Configuration
# =======================
#
# HISP was Created and Developed by SilicaAndPina
# However it is NOT COPYRIGHTED! This software is in the Public Domain!
#
# Ip address the server will bind to (default: 0.0.0.0 ALL INTERFACES)
ip=0.0.0.0
# Port the server will bind to defaults: (on beta.horseisle.com: 12321, on pinto.horseisle.com: 443)
# Though, 443 is likely to interfere with TLS, if you happen to have a web server or something
# running on the same port, so i prefer 12321.
port=12321
# MariaDB Database Information
# For best performance, the database should be hosted on the SAME MACHINE as the HISP server.
# Or atleast, on a local network.
db_ip=127.0.0.1
db_name=game1
db_username=root
db_password=test123
db_port=3306
# Connect to a sqllite database instead of a sql server.
sql_lite=false
# File that contains the map tile data
# the default was downloaded from the original server
map=HI1.MAP
# This folder contains all definitions in the game
# such as items, horses. and quest data.
# NOTE: This can be a folder or a file.
gamedata=gamedata
# =======================
# Security
# =======================
# Adobe Flash; Cross-Domain Policy File. (see: https://web.archive.org/web/20170610235331if_/http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html)
# The default file, just allows all domains access to all ports.
crossdomain=CrossDomainPolicy.xml
# =======================
# Chat Filter Settings
# =======================
# Wether to block 'bad' words
# ex 'Fuck You!' gets blocked
enable_word_filter=true
# Wether to expand slang.
# ex 'lol' becomes '*laughing out loud!*'
# (NOTE: This feature is also used to filter some less-'bad' words disabling it will allow users to say them!)
enable_corrections=true
# Include non-violations
# stuff like blocking you from saying your password in chat
# and FULL CAPS messages.
enable_non_violation_check=true
# Limits ad and global chat
# to just a few messages every minute
# by each user
enable_spam_filter=true
# =======================
# Misc Settings.
# =======================
# Should the server consider all users "Subscribers"
# (warning: makes ranches be in use forever.)
all_users_subscribed=false
# Red Text Stating "Todays Note:"
# Default is "April 11, 2020. New breed, Camarillo White Horse. Two new quests."
motd=April 11, 2020. New breed, Camarillo White Horse. Two new quests.
# Equation is: BANK_BALANCE * (1/INTREST_RATE);
# on All servers except Black its 3333, on black its 1000.
# but of course you can make it whatever you want
intrest_rate=3333
# Should i fix bugs all the bugs
# That were in the original Horse Isle Game??
# (eg training, special treat, ranch descriptions, etc)
fix_offical_bugs=false
# Should print extra debug logs
# 0 - no logs
# 1 - errors only
# 2 - errors, warnings
# 3 - errors, warnings, hackers
# 4 - errors, warnings, hackers, info,
# 5 - debug, errors, warnings, info, hackers
log_level=4