From 155348ba00b4aed5b4dfa0761a2e1592a4c963ee Mon Sep 17 00:00:00 2001 From: Jan Weigelt Date: Sat, 16 Mar 2024 18:28:18 +0100 Subject: [PATCH 01/28] Add automatic /bf2 launch args for Aspyr release --- SWBF2Admin/Gameserver/ServerManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SWBF2Admin/Gameserver/ServerManager.cs b/SWBF2Admin/Gameserver/ServerManager.cs index 09ec36d..302345c 100644 --- a/SWBF2Admin/Gameserver/ServerManager.cs +++ b/SWBF2Admin/Gameserver/ServerManager.cs @@ -163,6 +163,7 @@ public void Start() ProcessArgs = ServerArgs; if (serverType == GameserverType.Aspyr) { + ProcessArgs += " /bf2"; ProcessArgs += " /netregion \"" + Core.Server.Settings.NetRegion + "\""; if (!string.IsNullOrEmpty(Core.Server.Settings.Password)) { From 0ca7b91cecbda19e1598b6682b8208b01a2a8a73 Mon Sep 17 00:00:00 2001 From: Jan Weigelt Date: Sat, 16 Mar 2024 18:39:01 +0100 Subject: [PATCH 02/28] Add notes regarding 2024 Aspyr release to readme --- readme.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index c29c0ea..8775d0a 100644 --- a/readme.md +++ b/readme.md @@ -25,6 +25,7 @@ Open `./cfg/core.xml` and adjust `ServerType` to match your target platform: your_platform ``` Available platforms: +- `Aspyr` for the 2024 `Battlefront Classic Collection` release - `GoG` for the 2017 `BattlefrontII Classic` release - `Gamespy` for the original 2005 `Star Wars BattlefrontII` release @@ -43,7 +44,7 @@ If you have any active firewall, the web admin port (8080 TCP in this case) has If you prefer to use an encrypted connection, you may change the protocol specified in `WebAdminPrefix` from `http://` to `https://`. Note that when using HTTPS, a matching SSL certificate has to be installed into your machine's certificate store. #### Optional: enabling runtime managament - +*Do not enable runtime management when running the 2024 Aspyr `Battlefront Classic Collection` release.* If you want to use features like ingame commands or announce broadcasts, runtime management has be enabled. To enable runtime management, open `./cfg/core.xml`, set @@ -59,6 +60,27 @@ To enable runtime management, open `./cfg/core.xml`, set Follow one of the following guides below that matches your target platform. +#### 2024 Aspyr Release (Battlefront Classic Collection) +*Using the 2024 Aspyr Release requires one bought copy of the game for each server you are planning to host. It is only possible to run a single dedicated server per host machine. Player based permissions are currently not supported.* + +**1. Preparing Game Files**
+Install and download the `Battlefront Classic Collection`. Keep the Steam client application open. Copy the contents of the `./server` folder supplied with `SWBF2Admin` to the game's installation directory. By default the game will be installed to `C:\Program Files (x86)\Steam\steamapps\common\Battle`.
+ +**2. Set Installation Paths**
+Open `./settings/core.xml` and adjust +```xml + your_game_path +``` +to match the game's installation folder. The default installation folder is +`C:\Program Files (x86)\Steam\steamapps\common\Battle`. +Adjust +```xml + your_steam_path +``` +to match Steam's installation folder. Steam's default installation path is +`C:\Program Files (x86)\Steam`. + + #### 2017 GoG Release (BattlefrontII Classic) *Neither the GOG communications server nor GOG Galaxy works over Windows Remote Desktop. You can use tools like VNC, Chrome Remote Desktop or a physical KVM instead. Launching any part of the server over Windows Remote Desktop causes it to not show up in the server listing.* From 5066335ca018f31e0f98c1479f21758bc9c47ded Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:02:25 -0400 Subject: [PATCH 03/28] Add New Maps --- DebugFiles/SWBF2Admin.sqlite | Bin 24576 -> 24576 bytes .../{Windows.pubxml => win-x64.pubxml} | 0 .../Properties/PublishProfiles/win-x86.pubxml | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+) rename DllLoader/Properties/PublishProfiles/{Windows.pubxml => win-x64.pubxml} (100%) create mode 100644 DllLoader/Properties/PublishProfiles/win-x86.pubxml diff --git a/DebugFiles/SWBF2Admin.sqlite b/DebugFiles/SWBF2Admin.sqlite index 7f0acae0112cd612819055ce2d755f216633125a..5e161868abddf31121b1d8b9fd472bdbbd756d0d 100644 GIT binary patch delta 587 zcmXBQJ4nM&7>3~_KLJ5U4{B2(qN56FYcE=Ft=DS3V7*Op)Toh~6cP(XO4UuL3WA%1 z;G|1&bE=!0gWyu!1P2kp&CN95^uWt^{^1-~#p9}2Rz%;0KPmf!-uYr>`@B)ye)wr* z4RJrk1^T03`l1hdr#E_`XL_PXdZ2r{rE9vPGM&*W9g#x^v_l)TMvIi9B*iNyHL)aq zGDRxzytdBshN*^{WkC>MS(|j|aBbP)IezG+Dr=VM@YEY<1kQ zvwERPai3p$+0-)Jbd0>NPOo_DB2z>=$74%5zNM?NE_bur@Oy&apu T5CLJ(2SOkS0zmV)X`T89=Gkv$ delta 581 zcmXxhJ#W)c6vlD;Tv^FYpoG!7GU15Vm0h+_RTI z^qJW;G^YS5PU&-;hOt+*jr^`M7ZQo|P~sR9+pu;Nt${>YIY7yI7&F^&Itth4SoXQ_ zI-!VInkzW%{~Xf;jAb}w-s5L#wWYYAi!nC$$Jl3HvzUK0TUaBrM$vjWC!)^k8P&B@ z&DvgIEyLOzA1ttvVMSs7{$i14NQ>9*DY^w?9?_>f3WevR5SSxZ?;6_7S%DaPyR6w9QZsy?u!j+c3))ZGZ#X#sTl)Fh^{v>?ZX2gtqu35q + + + + Debug + Any CPU + bin\Debug\net8.0\publish\win-x86\ + FileSystem + <_TargetId>Folder + net8.0 + win-x86 + false + true + false + + \ No newline at end of file From c61979f1bbfabdf6591c0b10df6a4148f7b8c0c8 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:30:03 -0400 Subject: [PATCH 04/28] Accidently deleted maps --- DebugFiles/SWBF2Admin.sqlite | Bin 24576 -> 24576 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/DebugFiles/SWBF2Admin.sqlite b/DebugFiles/SWBF2Admin.sqlite index 5e161868abddf31121b1d8b9fd472bdbbd756d0d..f67994758fe83a92370f93c45a37a6a27c03fee3 100644 GIT binary patch delta 791 zcmYk4y>HV%6u^CFwL+>z+t^2&x)H7#geqF0b4$PY=y#fu1|j+(F)+L&*VwA#i+txw zo>GKZ5d#w=6B8<8hwg}#zX2HF4`AW!q`*zS-|xM5=lAaP9G#w{v!4TK_rtG&+@%$q z*Tzvv(|_n+^-uac{k8sFkM){f)tB^Zx`}_I5_*Eapaj3gFK~bl@G71`uWjy|Ka z_fPv#hurJa$RrYNpnGkoGv_g!_+fEuMd2x3;n^;(fbfzeIo4ik`8DOPr*5I^N-T)$ zJ}5O-R_X>$;Dly%oVjIZpS9Wnvq*k7Etxv^uUqRxEQIlq@rrUcapZ;WBaem7AwiZLD?5`~`p=djs`1Dw4DTqJ$2BJ0btc+=Xqfn!W)b`UTUcaxI}3{?&;to= zh%I84`m_!yU>OGIf7Awu zowjdjbVEfuGLk7Q3d*rB}q?v_aCb(>~6pIKQf*vbJVh=2Vj=W0I@3 zs%3Uh=?#e%uiRD9leo2H{>zdwOViQNg@|En0z=A99OaUQmc2k4u{VNWq-X@|uj( zZN@_`e4$RgrJ#+ESU`Kv!yo zrLQ@_nDorsrZP-N*r+0^-o^m$k_%Q|U9j?otz?94iy*mMzj#YUHbpi(FS3@^K}y4Y?S~2 From 24c5f64c658a6d5adf1421821b7661eefa78ddc5 Mon Sep 17 00:00:00 2001 From: Jan Weigelt Date: Mon, 18 Mar 2024 01:13:38 +0100 Subject: [PATCH 05/28] Remove experimental netcode patches for Aspyr release --- rconserver-aspyr/bf2server.cpp | 2 +- rconserver-aspyr/bf2server.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/rconserver-aspyr/bf2server.cpp b/rconserver-aspyr/bf2server.cpp index 5c1b28f..c223189 100644 --- a/rconserver-aspyr/bf2server.cpp +++ b/rconserver-aspyr/bf2server.cpp @@ -9,7 +9,7 @@ void bf2server_init() { while(!(moduleBase = (LPVOID)GetModuleHandleW(L"Battlefront2.dll"))) { Sleep(10); } - bf2server_patch_netupdate(); + //bf2server_patch_netupdate(); bf2server_patch_chatcrash(); } diff --git a/rconserver-aspyr/bf2server.h b/rconserver-aspyr/bf2server.h index c6801e5..b2664e0 100644 --- a/rconserver-aspyr/bf2server.h +++ b/rconserver-aspyr/bf2server.h @@ -2,9 +2,6 @@ #include #include #include "Logger.h" -#include "config.h" - - typedef DWORD windows_ptr_t; /* From b14c48733fc7317e0a8f1379dbbba16661569683 Mon Sep 17 00:00:00 2001 From: Jan Weigelt Date: Mon, 18 Mar 2024 01:46:35 +0100 Subject: [PATCH 06/28] Update AssemblyInfo --- SWBF2Admin/SWBF2Admin.csproj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SWBF2Admin/SWBF2Admin.csproj b/SWBF2Admin/SWBF2Admin.csproj index ffd82a8..1912f2f 100644 --- a/SWBF2Admin/SWBF2Admin.csproj +++ b/SWBF2Admin/SWBF2Admin.csproj @@ -3,6 +3,7 @@ net8.0 Exe True + en-US bin\x64\Debug\ @@ -47,10 +48,10 @@ REM xcopy "$(SolutionDir)DebugFiles" "$(TargetDir)" /S /D SWBF2Admin SWBF2 server manager - LeKeks, Yoni, AsLan + SWBF2Admin Contributors SWBF2Admin Copyright © 2017-2019 Jan Weigelt - 1.2.0.0 - 1.2.0.0 + 1.3.0.0 + 1.3.0.0 \ No newline at end of file From 8849e8368d75c2dcc806190fb9477505de95bb82 Mon Sep 17 00:00:00 2001 From: Jan Weigelt Date: Mon, 18 Mar 2024 01:47:23 +0100 Subject: [PATCH 07/28] Fix CMakeLists.txt for galaxy rconserver build --- rconserver-galaxy/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rconserver-galaxy/CMakeLists.txt b/rconserver-galaxy/CMakeLists.txt index 520c1ed..362b5fd 100644 --- a/rconserver-galaxy/CMakeLists.txt +++ b/rconserver-galaxy/CMakeLists.txt @@ -15,4 +15,4 @@ set(SOURCES add_library(rconserver_32 SHARED ${SOURCES}) target_compile_definitions(rconserver_32 PRIVATE RCONSERVER_EXPORTS _WINDOWS _USRDLL) -set_property(TARGET rconserver PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedRelease") \ No newline at end of file +set_property(TARGET rconserver_32 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedRelease") \ No newline at end of file From daba6da6562c17f91c9a3068b110d3b3ac0f9818 Mon Sep 17 00:00:00 2001 From: Jan Weigelt Date: Mon, 18 Mar 2024 01:53:23 +0100 Subject: [PATCH 08/28] Fix crash on empty string input --- SWBF2Admin/AdminCore.cs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/SWBF2Admin/AdminCore.cs b/SWBF2Admin/AdminCore.cs index 359d105..0f0c64e 100644 --- a/SWBF2Admin/AdminCore.cs +++ b/SWBF2Admin/AdminCore.cs @@ -1,5 +1,5 @@ /* - * This file is part of SWBF2Admin (https://github.com/jweigelt/swbf2admin). + * This file is part of SWBF2Admin (https://github.com/jweigelt/swbf2admin). * Copyright(C) 2017, 2018 Jan Weigelt * * SWBF2Admin is free software: you can redistribute it and/or modify @@ -15,9 +15,9 @@ * You should have received a copy of the GNU General Public License * along with SWBF2Admin. If not, see. */ + using System; using System.Collections.Generic; - using SWBF2Admin.Utility; using SWBF2Admin.Config; using SWBF2Admin.Web; @@ -25,7 +25,6 @@ using SWBF2Admin.Gameserver; using SWBF2Admin.Scheduler; using SWBF2Admin.Structures; - using SWBF2Admin.Runtime.Players; using SWBF2Admin.Runtime.Rcon; using SWBF2Admin.Runtime.Game; @@ -33,7 +32,6 @@ using SWBF2Admin.Runtime.Commands; using SWBF2Admin.Runtime.ApplyMods; using SWBF2Admin.Runtime.Watchdog; - using SWBF2Admin.Plugins; namespace SWBF2Admin @@ -43,7 +41,12 @@ public class AdminCore private const string ARG_RESET_WEBUSER = "--reset-webcredentials"; private CoreConfiguration config; - public CoreConfiguration Config { get { return config; } } + + public CoreConfiguration Config + { + get { return config; } + } + public FileHandler Files { get; } = new FileHandler(); public TaskScheduler Scheduler { get; } = new TaskScheduler(); @@ -98,7 +101,8 @@ public AdminCore() public void Run(string[] args) { - Logger.Log(LogLevel.Info, Log.CORE_START, Util.GetProductName(), Util.GetProductVersion(), Util.GetProductAuthor()); + Logger.Log(LogLevel.Info, Log.CORE_START, Util.GetProductName(), Util.GetProductVersion(), + Util.GetProductAuthor()); Logger.Log(LogLevel.Verbose, Log.CORE_READ_CONFIG); config = Files.ReadConfig(); Logger.Log(LogLevel.Info, Log.CORE_READ_CONFIG_OK); @@ -168,6 +172,11 @@ public void Run(string[] args) while ((cmd = Console.ReadLine()) != "quit") { + if (string.IsNullOrEmpty(cmd)) + { + continue; + } + if (cmd == "import maps") { Database.ImportMaps(ServerMap.ReadServerMapConfig(this)); @@ -185,9 +194,9 @@ public void Run(string[] args) #region "Events" + private void Server_Started(object sender, EventArgs e) { - Logger.Log(LogLevel.Verbose, "Starting runtime management..."); Scheduler.PushDelayedTask(() => { @@ -214,7 +223,7 @@ private void Server_Stopped(object sender, EventArgs e) Logger.Log(LogLevel.Verbose, "Restarting server..."); Server.Start(); } - } + } } private void Server_Crashed(object sender, EventArgs e) @@ -229,18 +238,17 @@ private void Server_Crashed(object sender, EventArgs e) private void Rcon_Disconnected(object sender, EventArgs e) { - } private void Rcon_Chat(object sender, EventArgs e) { - } private void Announce_Broadcast(object sender, EventArgs e) { Rcon.Say(((AnnounceEventArgs)e).Announce.ParseMessage(this)); } + #endregion } } \ No newline at end of file From 8ff9dccbe24f1309772f22e92ff1f9b252f16a74 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Sun, 17 Mar 2024 21:09:22 -0400 Subject: [PATCH 09/28] Don't track build artifacts --- .gitignore | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 1edb077..30b5e68 100644 --- a/.gitignore +++ b/.gitignore @@ -7,15 +7,13 @@ SWBF2Admin/bin SWBF2Admin/obj IngameControllerServer/bin IngameControllerServer/obj -RconServer/Debug -RconServer/Release -RconServer/x64 -RconServer/x86 RconServer/out +rconserver-aspyr/out +rconserver-galaxy/out packages .vs .tmp .idea *.user cmake-build-debug -cmake-build-release \ No newline at end of file +cmake-build-release From 841569bc0b81ee0239ba4e78371528d454dcdd24 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Mon, 18 Mar 2024 11:35:03 -0400 Subject: [PATCH 10/28] Update publish profiles --- .../Properties/PublishProfiles/win-x64.pubxml | 4 ++-- .../Properties/PublishProfiles/win-x86.pubxml | 4 ++-- .../PublishProfiles/linux-x64.pubxml | 18 ++++++++++++++++++ .../{Windows.pubxml => win-x64.pubxml} | 5 +++-- .../Properties/PublishProfiles/win-x86.pubxml | 19 +++++++++++++++++++ 5 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 SWBF2Admin/Properties/PublishProfiles/linux-x64.pubxml rename SWBF2Admin/Properties/PublishProfiles/{Windows.pubxml => win-x64.pubxml} (72%) create mode 100644 SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml diff --git a/DllLoader/Properties/PublishProfiles/win-x64.pubxml b/DllLoader/Properties/PublishProfiles/win-x64.pubxml index b1db3b2..49eb151 100644 --- a/DllLoader/Properties/PublishProfiles/win-x64.pubxml +++ b/DllLoader/Properties/PublishProfiles/win-x64.pubxml @@ -4,9 +4,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - Debug + Release Any CPU - bin\Debug\net8.0\publish\win-x64\ + bin\Release\net8.0\publish\win-x64\ FileSystem <_TargetId>Folder net8.0 diff --git a/DllLoader/Properties/PublishProfiles/win-x86.pubxml b/DllLoader/Properties/PublishProfiles/win-x86.pubxml index 5139ab2..fbe976e 100644 --- a/DllLoader/Properties/PublishProfiles/win-x86.pubxml +++ b/DllLoader/Properties/PublishProfiles/win-x86.pubxml @@ -4,9 +4,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - Debug + Release Any CPU - bin\Debug\net8.0\publish\win-x86\ + bin\Release\net8.0\publish\win-x86\ FileSystem <_TargetId>Folder net8.0 diff --git a/SWBF2Admin/Properties/PublishProfiles/linux-x64.pubxml b/SWBF2Admin/Properties/PublishProfiles/linux-x64.pubxml new file mode 100644 index 0000000..38680ee --- /dev/null +++ b/SWBF2Admin/Properties/PublishProfiles/linux-x64.pubxml @@ -0,0 +1,18 @@ + + + + + Release + Any CPU + bin\Release\net8.0\publish\linux-x64\ + FileSystem + <_TargetId>Folder + net8.0 + linux-x64 + false + true + true + + \ No newline at end of file diff --git a/SWBF2Admin/Properties/PublishProfiles/Windows.pubxml b/SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml similarity index 72% rename from SWBF2Admin/Properties/PublishProfiles/Windows.pubxml rename to SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml index b1db3b2..4c31c2d 100644 --- a/SWBF2Admin/Properties/PublishProfiles/Windows.pubxml +++ b/SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml @@ -4,9 +4,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - Debug + Release Any CPU - bin\Debug\net8.0\publish\win-x64\ + bin\Release\net8.0\publish\win-x64\ FileSystem <_TargetId>Folder net8.0 @@ -14,5 +14,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121. false true false + true \ No newline at end of file diff --git a/SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml b/SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml new file mode 100644 index 0000000..a91bcb4 --- /dev/null +++ b/SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml @@ -0,0 +1,19 @@ + + + + + Release + Any CPU + bin\Release\net8.0\publish\win-x86\ + FileSystem + <_TargetId>Folder + net8.0 + win-x86 + false + true + false + true + + \ No newline at end of file From 90afa7a2422801a1515804d32770f96a755705b7 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Mon, 18 Mar 2024 17:45:56 -0400 Subject: [PATCH 11/28] Update dependencies --- SWBF2Admin/SWBF2Admin.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SWBF2Admin/SWBF2Admin.csproj b/SWBF2Admin/SWBF2Admin.csproj index 1912f2f..5141e06 100644 --- a/SWBF2Admin/SWBF2Admin.csproj +++ b/SWBF2Admin/SWBF2Admin.csproj @@ -26,19 +26,19 @@ - - + + - + - + - + From 0d04e0679d3582097340402f951e94ad5f4e7550 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Tue, 19 Mar 2024 00:50:23 -0400 Subject: [PATCH 12/28] Fix legacy hash issue with MySQL --- SWBF2Admin/Database/SQLHandler.cs | 34 +++++++++++++++++--------- SWBF2Admin/Gameserver/ServerManager.cs | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/SWBF2Admin/Database/SQLHandler.cs b/SWBF2Admin/Database/SQLHandler.cs index 35a93cc..3cd3630 100644 --- a/SWBF2Admin/Database/SQLHandler.cs +++ b/SWBF2Admin/Database/SQLHandler.cs @@ -916,28 +916,40 @@ public WebUser GetWebUser(string username, string password) "prefix_web_users " + "WHERE user_name = @username"; + string hash; + WebUser user; + bool update_user = false; + using (DbDataReader reader = Query(sql, "@username", username)) { if (reader.Read()) { - var hash = RS(reader, "user_password"); + hash = RS(reader, "user_password"); //update legacy hash if (hash.Length == 32) { hash = PBKDF2.HashPassword(hash); - UpdateWebUser( - new WebUser(RL(reader, "id"), RS(reader, "user_name"), hash, GetDateTime(RU(reader, "user_lastvisit"))), - true); + update_user = true; } - if (PBKDF2.VerifyPassword(password, hash)) - { - return new WebUser(RL(reader, "id"), RS(reader, "user_name"), hash, GetDateTime(RU(reader, "user_lastvisit"))); - } + user = new WebUser(RL(reader, "id"), RS(reader, "user_name"), hash, GetDateTime(RU(reader, "user_lastvisit"))); + } else + { + return null; } } + if (update_user) + { + UpdateWebUser(user, true); + } + + if (PBKDF2.VerifyPassword(password, hash)) + { + return user; + } + return null; } public void UpdateLastSeen(WebUser user) @@ -971,9 +983,9 @@ public void InsertWebUser(WebUser user) public void UpdateWebUser(WebUser user, bool updatePwd) { string sql = "UPDATE prefix_web_users SET " + - "user_name = @username "; - if (updatePwd) sql += ",user_password = @password "; - sql += "WHERE id = @user_id"; + "user_name = @username"; + if (updatePwd) sql += ", user_password = @password"; + sql += " WHERE id = @user_id"; NonQuery(sql, "@username", user.Username, "@password", user.PasswordHash, "@user_id", user.Id); } diff --git a/SWBF2Admin/Gameserver/ServerManager.cs b/SWBF2Admin/Gameserver/ServerManager.cs index 302345c..0b29bd9 100644 --- a/SWBF2Admin/Gameserver/ServerManager.cs +++ b/SWBF2Admin/Gameserver/ServerManager.cs @@ -164,7 +164,7 @@ public void Start() if (serverType == GameserverType.Aspyr) { ProcessArgs += " /bf2"; - ProcessArgs += " /netregion \"" + Core.Server.Settings.NetRegion + "\""; + #ProcessArgs += " /netregion \"" + Core.Server.Settings.NetRegion + "\""; if (!string.IsNullOrEmpty(Core.Server.Settings.Password)) { ProcessArgs += " /password \"" + Core.Server.Settings.Password + "\""; From 0c5973eecc451aa7edec7b996c3cd33e59bd9332 Mon Sep 17 00:00:00 2001 From: Jan Weigelt Date: Tue, 19 Mar 2024 14:40:06 +0100 Subject: [PATCH 13/28] Fix netreg comment --- SWBF2Admin/Gameserver/ServerManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SWBF2Admin/Gameserver/ServerManager.cs b/SWBF2Admin/Gameserver/ServerManager.cs index 0b29bd9..9c3af2b 100644 --- a/SWBF2Admin/Gameserver/ServerManager.cs +++ b/SWBF2Admin/Gameserver/ServerManager.cs @@ -164,7 +164,7 @@ public void Start() if (serverType == GameserverType.Aspyr) { ProcessArgs += " /bf2"; - #ProcessArgs += " /netregion \"" + Core.Server.Settings.NetRegion + "\""; + //ProcessArgs += " /netregion \"" + Core.Server.Settings.NetRegion + "\""; if (!string.IsNullOrEmpty(Core.Server.Settings.Password)) { ProcessArgs += " /password \"" + Core.Server.Settings.Password + "\""; From 6f342d03bea9d197fbbfabfc32746626cb00313a Mon Sep 17 00:00:00 2001 From: Jan Weigelt Date: Tue, 19 Mar 2024 14:41:47 +0100 Subject: [PATCH 14/28] Remove dll injector for aspyr build --- SWBF2Admin/Gameserver/ServerManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SWBF2Admin/Gameserver/ServerManager.cs b/SWBF2Admin/Gameserver/ServerManager.cs index 9c3af2b..d174999 100644 --- a/SWBF2Admin/Gameserver/ServerManager.cs +++ b/SWBF2Admin/Gameserver/ServerManager.cs @@ -269,7 +269,7 @@ private void ServerProcess_Exited(object sender, EventArgs e) private void InjectRconDllIfRequired() { - if (serverType == GameserverType.GoG || serverType == GameserverType.Steam || serverType == GameserverType.Aspyr) + if (serverType == GameserverType.GoG || serverType == GameserverType.Steam) { string loader; string dll; From 06b6ac89237baf45f5df1feb9ddf66c19592c7b9 Mon Sep 17 00:00:00 2001 From: Jan Weigelt Date: Tue, 19 Mar 2024 15:34:00 +0100 Subject: [PATCH 15/28] Use steam_appid.txt instead of steam launcher --- SWBF2Admin/Gameserver/ServerManager.cs | 11 ++++++++--- SWBF2Admin/Resources/cfg/core.xml | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/SWBF2Admin/Gameserver/ServerManager.cs b/SWBF2Admin/Gameserver/ServerManager.cs index d174999..758aae3 100644 --- a/SWBF2Admin/Gameserver/ServerManager.cs +++ b/SWBF2Admin/Gameserver/ServerManager.cs @@ -76,8 +76,13 @@ public override void Configure(CoreConfiguration config) } if (serverType == GameserverType.Aspyr) { - ServerExecutable = config.SteamPath + "/steam.exe"; - ServerArgs = "-applaunch 2446550 " + config.ServerArgs; + ServerExecutable = config.ServerPath + "/Battlefront.exe"; + //ServerArgs = "-applaunch 2446550 " + config.ServerArgs; + var appid_txt = Path.GetFullPath(ServerPath + "/steam_appid.txt"); + if (!File.Exists(appid_txt)) + { + Core.Files.WriteFileText(appid_txt, "2446550"); + } ServerProcessName = "Battlefront"; } else @@ -182,7 +187,7 @@ public void Start() }; //if we're in steam mode, steam will start a launcher exe prior to the actual game - if (serverType == GameserverType.Steam || serverType == GameserverType.Aspyr) + if (serverType == GameserverType.Steam) { InvokeEvent(SteamServerStarting, this, new EventArgs()); steamLaunchRetryCount = 0; diff --git a/SWBF2Admin/Resources/cfg/core.xml b/SWBF2Admin/Resources/cfg/core.xml index 2fa0292..0dc0460 100644 --- a/SWBF2Admin/Resources/cfg/core.xml +++ b/SWBF2Admin/Resources/cfg/core.xml @@ -25,10 +25,11 @@ path to server's GameData folder - use ./ for file access relative to swbf2admin.exe --> - C:\Program Files (x86)\Steam\steamapps\common\Battle + ./server + C:\Program Files (x86)\Steam - - + + false true From 4ad8517aeee540a8a1a0c96572ae7326e6472e8e Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Fri, 22 Mar 2024 00:42:13 -0400 Subject: [PATCH 16/28] Add hex edit mods for Aspyr version --- SWBF2Admin/Config/FileHandler.cs | 13 +- SWBF2Admin/Gameserver/ServerManager.cs | 2 +- SWBF2Admin/Resources/cfg/mods.aspyr.xml | 268 ++++++++++++++++++ SWBF2Admin/Resources/cfg/mods.xml | 166 ++++++----- SWBF2Admin/Runtime/ApplyMods/HexEdit.cs | 14 +- SWBF2Admin/Runtime/ApplyMods/LvlMod.cs | 8 +- SWBF2Admin/Runtime/ApplyMods/LvlWriter.cs | 29 +- .../Runtime/ApplyMods/LvlWriterConfig.cs | 2 +- SWBF2Admin/SWBF2Admin.csproj | 1 + 9 files changed, 406 insertions(+), 97 deletions(-) create mode 100644 SWBF2Admin/Resources/cfg/mods.aspyr.xml diff --git a/SWBF2Admin/Config/FileHandler.cs b/SWBF2Admin/Config/FileHandler.cs index 6d198cf..71a2f9c 100644 --- a/SWBF2Admin/Config/FileHandler.cs +++ b/SWBF2Admin/Config/FileHandler.cs @@ -175,7 +175,7 @@ public void UnpackConfigDefault() /// T's standard constructor /// /// - public T ReadConfig(string fileName = "") + public T ReadConfig(string fileName = "", string template = "") { if (fileName == "") { @@ -184,8 +184,15 @@ public T ReadConfig(string fileName = "") } else { - if (!File.Exists(fileName)) - WriteConfigDefault(fileName); + if (template == "") + { + if (!File.Exists(fileName)) + WriteConfigDefault(fileName); + } + else + { + UnpackResource(fileName, template); + } } return ReadXmlFile(fileName); } diff --git a/SWBF2Admin/Gameserver/ServerManager.cs b/SWBF2Admin/Gameserver/ServerManager.cs index 758aae3..f0faf22 100644 --- a/SWBF2Admin/Gameserver/ServerManager.cs +++ b/SWBF2Admin/Gameserver/ServerManager.cs @@ -60,7 +60,7 @@ public class ServerManager : ComponentBase private string ProcessArgs; private int steamLaunchRetryCount = 0; - GameserverType serverType; + private GameserverType serverType; public ServerManager(AdminCore core) : base(core) { } diff --git a/SWBF2Admin/Resources/cfg/mods.aspyr.xml b/SWBF2Admin/Resources/cfg/mods.aspyr.xml new file mode 100644 index 0000000..7ddfaca --- /dev/null +++ b/SWBF2Admin/Resources/cfg/mods.aspyr.xml @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SWBF2Admin/Resources/cfg/mods.xml b/SWBF2Admin/Resources/cfg/mods.xml index d1ba605..f0bdbac 100644 --- a/SWBF2Admin/Resources/cfg/mods.xml +++ b/SWBF2Admin/Resources/cfg/mods.xml @@ -8,11 +8,11 @@ - - - - - + + + + + @@ -20,12 +20,12 @@ @@ -33,31 +33,29 @@ - + - + - + - + - - - + - + - + @@ -66,125 +64,137 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - - + - - - - - - - - + + - - - + + + + + - - - - - - - - - + + + + + + + + + + + + - + @@ -209,7 +219,7 @@ - + @@ -234,7 +244,7 @@ - + @@ -259,9 +269,9 @@ - + - + @@ -286,7 +296,7 @@ - + diff --git a/SWBF2Admin/Runtime/ApplyMods/HexEdit.cs b/SWBF2Admin/Runtime/ApplyMods/HexEdit.cs index 56ef88e..0de22bc 100644 --- a/SWBF2Admin/Runtime/ApplyMods/HexEdit.cs +++ b/SWBF2Admin/Runtime/ApplyMods/HexEdit.cs @@ -29,6 +29,9 @@ public class HexEdit [XmlAttribute] public string FileName { get; set; } + [XmlAttribute] + public string LevelDir { get; set; } = ""; + [XmlAttribute] public string StartAddress { @@ -72,16 +75,17 @@ private void WriteHex(FileHandler io, byte[] buf, string levelDir) io.WriteBytes(stream, startAddress, buf); } } - - public void Revert(FileHandler io, string levelDir) + public void Revert(FileHandler io, string serverDir) { - WriteHex(io, OriginalBytes, levelDir); + serverDir += LevelDir; + WriteHex(io, OriginalBytes, serverDir); } - public void Apply(FileHandler io, string levelDir) + public void Apply(FileHandler io, string serverDir) { - WriteHex(io, PatchedBytes, levelDir); + serverDir += LevelDir; + WriteHex(io, PatchedBytes, serverDir); } } } \ No newline at end of file diff --git a/SWBF2Admin/Runtime/ApplyMods/LvlMod.cs b/SWBF2Admin/Runtime/ApplyMods/LvlMod.cs index e684c28..0c4fc14 100644 --- a/SWBF2Admin/Runtime/ApplyMods/LvlMod.cs +++ b/SWBF2Admin/Runtime/ApplyMods/LvlMod.cs @@ -43,16 +43,16 @@ public class LvlMod private bool active = false; [MoonSharpHidden] - public void Revert(FileHandler io, string levelDir) + public void Revert(FileHandler io, string serverDir) { - foreach (HexEdit he in HexEdits) he.Revert(io, levelDir); + foreach (HexEdit he in HexEdits) he.Revert(io, serverDir); active = false; } [MoonSharpHidden] - public void Apply(FileHandler io, string levelDir) + public void Apply(FileHandler io, string serverDir) { - foreach (HexEdit he in HexEdits) he.Apply(io, levelDir); + foreach (HexEdit he in HexEdits) he.Apply(io, serverDir); active = true; } } diff --git a/SWBF2Admin/Runtime/ApplyMods/LvlWriter.cs b/SWBF2Admin/Runtime/ApplyMods/LvlWriter.cs index f186130..cbe38ac 100644 --- a/SWBF2Admin/Runtime/ApplyMods/LvlWriter.cs +++ b/SWBF2Admin/Runtime/ApplyMods/LvlWriter.cs @@ -24,15 +24,34 @@ namespace SWBF2Admin.Runtime.ApplyMods { public class LvlWriter : ComponentBase { - private string levelDir; + private string serverDir; private LvlWriterConfig config; public LvlWriter(AdminCore core) : base(core) { } public virtual List Mods { get { return config.Mods; } } public override void Configure(CoreConfiguration config) { - this.config = Core.Files.ReadConfig(); - levelDir = Core.Files.ParseFileName(config.ServerPath) + this.config.LvlDir; + if (config.ServerType == GameserverType.Aspyr) + { + //Unpack the Aspyr mods + this.config = Core.Files.ReadConfig("./cfg/mods.aspyr.xml", "SWBF2Admin.Resources.cfg.mods.aspyr.xml"); + } else + { + this.config = Core.Files.ReadConfig(); + } + serverDir = Core.Files.ParseFileName(config.ServerPath); + + //Handle legacy mods.xml + foreach (LvlMod mod in this.config.Mods) + { + foreach (HexEdit he in mod.HexEdits) + { + if (string.IsNullOrEmpty(he.LevelDir)) + { + he.LevelDir = this.config.LvlDir; + } + } + } } public override void OnInit() @@ -53,7 +72,7 @@ public void ApplyMod(LvlMod mod) { try { - mod.Apply(Core.Files, levelDir); + mod.Apply(Core.Files, serverDir); } catch (Exception e) { @@ -65,7 +84,7 @@ public void RevertMod(LvlMod mod) { try { - mod.Revert(Core.Files, levelDir); + mod.Revert(Core.Files, serverDir); } catch (Exception e) { diff --git a/SWBF2Admin/Runtime/ApplyMods/LvlWriterConfig.cs b/SWBF2Admin/Runtime/ApplyMods/LvlWriterConfig.cs index c558b89..3ba3c67 100644 --- a/SWBF2Admin/Runtime/ApplyMods/LvlWriterConfig.cs +++ b/SWBF2Admin/Runtime/ApplyMods/LvlWriterConfig.cs @@ -20,7 +20,7 @@ namespace SWBF2Admin.Runtime.ApplyMods { [ConfigFileInfo(fileName: "./cfg/mods.xml", template: "SWBF2Admin.Resources.cfg.mods.xml")] - public class LvlWriterConfig + public class LvlWriterConfig { public List Mods { get; set; } = new List(); public string LvlDir { get; set; } = "/data/_lvl_pc"; diff --git a/SWBF2Admin/SWBF2Admin.csproj b/SWBF2Admin/SWBF2Admin.csproj index 5141e06..3f02740 100644 --- a/SWBF2Admin/SWBF2Admin.csproj +++ b/SWBF2Admin/SWBF2Admin.csproj @@ -18,6 +18,7 @@ + From abd9c8d40cc0850fc4362b1a53d5da3eb5b95cbe Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Fri, 22 Mar 2024 01:38:04 -0400 Subject: [PATCH 17/28] Add alias bans for Aspyr --- DebugFiles/web/bans.htm | 7 +++- DebugFiles/web/res/bans.js | 8 ++++- SWBF2Admin/Database/SQLHandler.cs | 5 +-- .../Runtime/Commands/Admin/CmdAliasBan.cs | 32 +++++++++++++++++ .../Runtime/Commands/Admin/CmdTempAliasBan.cs | 35 +++++++++++++++++++ .../Runtime/Commands/Admin/CmdTempIpBan.cs | 4 +-- .../Runtime/Commands/Admin/CmdTempban.cs | 6 ++-- .../Runtime/Commands/CommandDispatcher.cs | 18 ++++++++-- SWBF2Admin/Structures/PlayerBan.cs | 3 +- 9 files changed, 105 insertions(+), 13 deletions(-) create mode 100644 SWBF2Admin/Runtime/Commands/Admin/CmdAliasBan.cs create mode 100644 SWBF2Admin/Runtime/Commands/Admin/CmdTempAliasBan.cs diff --git a/DebugFiles/web/bans.htm b/DebugFiles/web/bans.htm index 66af73b..ea5c358 100644 --- a/DebugFiles/web/bans.htm +++ b/DebugFiles/web/bans.htm @@ -17,7 +17,12 @@

Bans

youtube_searched_for - + diff --git a/DebugFiles/web/res/bans.js b/DebugFiles/web/res/bans.js index da8f977..ca9aa6f 100644 --- a/DebugFiles/web/res/bans.js +++ b/DebugFiles/web/res/bans.js @@ -1,6 +1,12 @@ var BansUrl = "/db/bans"; var BansFilterTimeout = 300; +var BanTypes = [ + "Key", + "IP", + "Alias" +] + function Bans() { var base = this; this.quickAdminId = null; @@ -73,7 +79,7 @@ function Bans() { "" + (b.Duration < 0 ? "permanent" : b.Duration) + "" + "" + b.PlayerKeyhash + "" + "" + b.PlayerIPAddress + "" + - "" + (b.TypeId == 0 ? "Key" : "IP") + "" + + "" + BanTypes[b.TypeId] + "" + ""; i++; legend |= b.Expired; diff --git a/SWBF2Admin/Database/SQLHandler.cs b/SWBF2Admin/Database/SQLHandler.cs index 3cd3630..25123fb 100644 --- a/SWBF2Admin/Database/SQLHandler.cs +++ b/SWBF2Admin/Database/SQLHandler.cs @@ -500,10 +500,11 @@ public bool IsBanned(Player player) "INNER JOIN swbf_players ON prefix_bans.player_id = prefix_players.id " + "WHERE " + "((player_keyhash = @keyhash AND ban_type = " + ((int)BanType.Keyhash).ToString() + ") " + - "OR (player_last_ip = @ip AND ban_type = " + ((int)BanType.IPAddress).ToString() + ")) " + + "OR (player_last_ip = @ip AND ban_type = " + ((int)BanType.IPAddress).ToString() + ") " + + "OR (player_last_name = @name AND ban_type = " + ((int)BanType.Alias).ToString() + ")) " + "AND ((ban_timestamp + ban_duration) > @timestamp OR ban_duration < 0)"; - return (HasRows(Query(sql, "@keyhash", player.KeyHash, "@ip", player.RemoteAddressStr, "@timestamp", GetTimestamp()))); + return (HasRows(Query(sql, "@keyhash", player.KeyHash, "@ip", player.RemoteAddressStr, "@name", player.Name, "@timestamp", GetTimestamp()))); } public void InsertBan(PlayerBan ban) { diff --git a/SWBF2Admin/Runtime/Commands/Admin/CmdAliasBan.cs b/SWBF2Admin/Runtime/Commands/Admin/CmdAliasBan.cs new file mode 100644 index 0000000..914b7d4 --- /dev/null +++ b/SWBF2Admin/Runtime/Commands/Admin/CmdAliasBan.cs @@ -0,0 +1,32 @@ +/* + * This file is part of SWBF2Admin (https://github.com/jweigelt/swbf2admin). + * Copyright(C) 2017, 2018 Jan Weigelt + * + * SWBF2Admin is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * SWBF2Admin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with SWBF2Admin. If not, see. + */ +using SWBF2Admin.Structures; +using SWBF2Admin.Config; +namespace SWBF2Admin.Runtime.Commands.Admin +{ + [ConfigFileInfo(fileName: "./cfg/cmd/aliasban.xml"/*, template: "SWBF2Admin.Resources.cfg.cmd.ban.xml"*/)] + public class CmdAliasBan : CmdBan + { + public CmdAliasBan() : base("aliasban", "ban") { } + public override void BanPlayer(Player p, Player admin, string reason = "") + { + PlayerBan b = new PlayerBan(p.Name, p.KeyHash, p.RemoteAddressStr, admin.Name, reason, BanType.Alias, p.DatabaseId, admin.DatabaseId); + Core.Database.InsertBan(b); + } + } +} \ No newline at end of file diff --git a/SWBF2Admin/Runtime/Commands/Admin/CmdTempAliasBan.cs b/SWBF2Admin/Runtime/Commands/Admin/CmdTempAliasBan.cs new file mode 100644 index 0000000..a005155 --- /dev/null +++ b/SWBF2Admin/Runtime/Commands/Admin/CmdTempAliasBan.cs @@ -0,0 +1,35 @@ +/* + * This file is part of SWBF2Admin (https://github.com/jweigelt/swbf2admin). + * Copyright(C) 2017, 2018 Jan Weigelt + * + * SWBF2Admin is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * SWBF2Admin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with SWBF2Admin. If not, see. + */ +using System; +using SWBF2Admin.Structures; +using SWBF2Admin.Config; + +namespace SWBF2Admin.Runtime.Commands.Admin +{ + [ConfigFileInfo(fileName: "./cfg/cmd/tempaliasban.xml"/*, template: "SWBF2Admin.Resources.cfg.cmd.kick.xml"*/)] + public class CmdTempAliasBan : CmdTempBan + { + public CmdTempAliasBan() : base("tempaliasban", "tempban") { } + + public override void BanPlayer(Player p, Player admin, TimeSpan duration, string reason = "") + { + PlayerBan b = new PlayerBan(p.Name, p.KeyHash, p.RemoteAddressStr, admin.Name, reason, duration, BanType.Alias, p.DatabaseId, admin.DatabaseId); + Core.Database.InsertBan(b); + } + } +} \ No newline at end of file diff --git a/SWBF2Admin/Runtime/Commands/Admin/CmdTempIpBan.cs b/SWBF2Admin/Runtime/Commands/Admin/CmdTempIpBan.cs index 3434d33..1761f14 100644 --- a/SWBF2Admin/Runtime/Commands/Admin/CmdTempIpBan.cs +++ b/SWBF2Admin/Runtime/Commands/Admin/CmdTempIpBan.cs @@ -22,9 +22,9 @@ namespace SWBF2Admin.Runtime.Commands.Admin { [ConfigFileInfo(fileName: "./cfg/cmd/tempipban.xml"/*, template: "SWBF2Admin.Resources.cfg.cmd.kick.xml"*/)] - public class CmdTempIpBan : CmdTempban + public class CmdTempIpBan : CmdTempBan { - public CmdTempIpBan() : base("tempipban", "tempipban") { } + public CmdTempIpBan() : base("tempipban", "tempban") { } public override void BanPlayer(Player p, Player admin, TimeSpan duration, string reason = "") { diff --git a/SWBF2Admin/Runtime/Commands/Admin/CmdTempban.cs b/SWBF2Admin/Runtime/Commands/Admin/CmdTempban.cs index 47a0e36..83acb84 100644 --- a/SWBF2Admin/Runtime/Commands/Admin/CmdTempban.cs +++ b/SWBF2Admin/Runtime/Commands/Admin/CmdTempban.cs @@ -22,7 +22,7 @@ namespace SWBF2Admin.Runtime.Commands.Admin { [ConfigFileInfo(fileName: "./cfg/cmd/tempban.xml"/*, template: "SWBF2Admin.Resources.cfg.cmd.kick.xml"*/)] - public class CmdTempban : PlayerCommand + public class CmdTempBan : PlayerCommand { public string OnNoTimeSpan { get; set; } = "No timespan specified. Usage: {usage}"; public string OnInvalidTimeSpan { get; set; } = "Invalid input {input}. Expecting valid integer."; @@ -42,9 +42,9 @@ public string DurationFormat } public string DefaultReason { get; set; } = ""; - public CmdTempban() : base("tempban", "tempban") { } + public CmdTempBan() : base("tempban", "tempban") { } - public CmdTempban(string alias, string permission) : base(alias, permission) { } + public CmdTempBan(string alias, string permission) : base(alias, permission) { } public override bool AffectPlayer(Player affectedPlayer, Player player, string commandLine, string[] parameters, int paramIdx) { diff --git a/SWBF2Admin/Runtime/Commands/CommandDispatcher.cs b/SWBF2Admin/Runtime/Commands/CommandDispatcher.cs index c85c6a2..0257bd0 100644 --- a/SWBF2Admin/Runtime/Commands/CommandDispatcher.cs +++ b/SWBF2Admin/Runtime/Commands/CommandDispatcher.cs @@ -42,12 +42,14 @@ public class CommandDispatcher : ComponentBase private List commandList = new List(); private string commandPrefix; private bool enableDynamic; + private GameserverType serverType; public CommandDispatcher(AdminCore core) : base(core) { } public override void Configure(CoreConfiguration config) { commandPrefix = config.CommandPrefix; enableDynamic = config.CommandEnableDynamic; + serverType = config.ServerType; } public override void OnInit() { @@ -55,9 +57,19 @@ public override void OnInit() RegisterCommand(); RegisterCommand(); RegisterCommand(); - RegisterCommand(); - RegisterCommand(); - RegisterCommand(); + RegisterCommand(); + + if (serverType == GameserverType.Gamespy) + { + //IP bans only work on GameSpy + RegisterCommand(); + RegisterCommand(); + } else if (serverType == GameserverType.Aspyr) + { + //Keyhash bans don't work on Aspyr + RegisterCommand(); + RegisterCommand(); + } RegisterCommand(); RegisterCommand(); diff --git a/SWBF2Admin/Structures/PlayerBan.cs b/SWBF2Admin/Structures/PlayerBan.cs index c93f8ef..0ed07ce 100644 --- a/SWBF2Admin/Structures/PlayerBan.cs +++ b/SWBF2Admin/Structures/PlayerBan.cs @@ -25,7 +25,8 @@ public enum BanType { ShowAll = -1, //only used for webadmin Keyhash = 0, - IPAddress = 1 + IPAddress = 1, + Alias = 2 } [MoonSharpUserData] From d062fe08e201a49f139ebd457258ffc7698c8749 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Fri, 22 Mar 2024 02:25:28 -0400 Subject: [PATCH 18/28] Add alias ban to WebAdmin --- DebugFiles/web/players.htm | 1 + SWBF2Admin/Config/FileHandler.cs | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/DebugFiles/web/players.htm b/DebugFiles/web/players.htm index e52a0f2..881183d 100644 --- a/DebugFiles/web/players.htm +++ b/DebugFiles/web/players.htm @@ -44,6 +44,7 @@

Players

diff --git a/SWBF2Admin/Config/FileHandler.cs b/SWBF2Admin/Config/FileHandler.cs index 71a2f9c..d925d51 100644 --- a/SWBF2Admin/Config/FileHandler.cs +++ b/SWBF2Admin/Config/FileHandler.cs @@ -184,14 +184,16 @@ public T ReadConfig(string fileName = "", string template = "") } else { - if (template == "") + if (!File.Exists(fileName)) { - if (!File.Exists(fileName)) + if (template == "") + { WriteConfigDefault(fileName); - } - else - { - UnpackResource(fileName, template); + } + else + { + UnpackResource(fileName, template); + } } } return ReadXmlFile(fileName); From 10fb6737ec13a3b9f9cae6df1e5d304b2219dd03 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Fri, 22 Mar 2024 02:40:37 -0400 Subject: [PATCH 19/28] Fix map codes for KAS and NAB --- DebugFiles/SWBF2Admin.sqlite | Bin 24576 -> 24576 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/DebugFiles/SWBF2Admin.sqlite b/DebugFiles/SWBF2Admin.sqlite index f67994758fe83a92370f93c45a37a6a27c03fee3..c3cf398a616b30ca9f885877043d1f58d86d59ec 100644 GIT binary patch delta 32 ocmZoTz}Rqrae_3X^h6nFM(K?SN5mL~C##CvFbZ!@5})S*0HyT_h5!Hn delta 32 ocmZoTz}Rqrae_3X)I=F)MyZVnN5mKfCaa3uFbZr=5})S*0Hu}*egFUf From 786a4b21c66b81ea157cff4c6a0f5096eac993e3 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:36:02 -0400 Subject: [PATCH 20/28] Start game minimized --- DllLoader/Program.cs | 5 ----- SWBF2Admin/Gameserver/ServerManager.cs | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/DllLoader/Program.cs b/DllLoader/Program.cs index 227b3c6..00571b7 100644 --- a/DllLoader/Program.cs +++ b/DllLoader/Program.cs @@ -51,11 +51,6 @@ static void Main(string[] args) Console.WriteLine("ERROR"); Console.WriteLine(e.ToString()); } - -#if DEBUG - Console.WriteLine("Press [return] to exit."); - Console.ReadLine(); -#endif } } } \ No newline at end of file diff --git a/SWBF2Admin/Gameserver/ServerManager.cs b/SWBF2Admin/Gameserver/ServerManager.cs index f0faf22..812717f 100644 --- a/SWBF2Admin/Gameserver/ServerManager.cs +++ b/SWBF2Admin/Gameserver/ServerManager.cs @@ -197,6 +197,8 @@ public void Start() serverProcess.EnableRaisingEvents = true; serverProcess.Exited += new EventHandler(ServerProcess_Exited); serverProcess.PriorityClass = ProcessPriorityClass.High; + //Start game minimized because of mouse locking on Aspyr version + serverProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; } , 5000); status = ServerStatus.SteamPending; From 98382f0d20ec7c49d38f262f1f9c82be45227a7b Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Mon, 1 Apr 2024 15:29:49 -0400 Subject: [PATCH 21/28] Fix no_powerups mod for Aspyr --- .../Properties/PublishProfiles/win-x64.pubxml | 2 +- .../Properties/PublishProfiles/win-x86.pubxml | 2 +- SWBF2Admin/Resources/cfg/mods.aspyr.xml | 242 +++++++++--------- 3 files changed, 123 insertions(+), 123 deletions(-) diff --git a/SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml b/SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml index 4c31c2d..f322b45 100644 --- a/SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml +++ b/SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml @@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. win-x64 false true - false true + true
\ No newline at end of file diff --git a/SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml b/SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml index a91bcb4..6910c4f 100644 --- a/SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml +++ b/SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml @@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. win-x86 false true - false true + true
\ No newline at end of file diff --git a/SWBF2Admin/Resources/cfg/mods.aspyr.xml b/SWBF2Admin/Resources/cfg/mods.aspyr.xml index 7ddfaca..183ce8b 100644 --- a/SWBF2Admin/Resources/cfg/mods.aspyr.xml +++ b/SWBF2Admin/Resources/cfg/mods.aspyr.xml @@ -136,132 +136,132 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + From 90f8aba71dc3292a7db134a23f22f22354cd5e86 Mon Sep 17 00:00:00 2001 From: Markus Date: Wed, 3 Apr 2024 03:15:26 +0200 Subject: [PATCH 22/28] Add auto restart delay config --- SWBF2Admin/AdminCore.cs | 2 +- SWBF2Admin/Config/CoreConfiguration.cs | 1 + SWBF2Admin/Resources/cfg/core.xml | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/SWBF2Admin/AdminCore.cs b/SWBF2Admin/AdminCore.cs index 0f0c64e..4b329e0 100644 --- a/SWBF2Admin/AdminCore.cs +++ b/SWBF2Admin/AdminCore.cs @@ -232,7 +232,7 @@ private void Server_Crashed(object sender, EventArgs e) if (Config.AutoRestartServer) { Logger.Log(LogLevel.Info, "Automatic restart is enabled. Restarting server..."); - Scheduler.PushDelayedTask(() => Server.Start(), 90000); + Scheduler.PushDelayedTask(() => Server.Start(), Config.AutoRestartDelay); } } diff --git a/SWBF2Admin/Config/CoreConfiguration.cs b/SWBF2Admin/Config/CoreConfiguration.cs index 69e3212..c3e7231 100644 --- a/SWBF2Admin/Config/CoreConfiguration.cs +++ b/SWBF2Admin/Config/CoreConfiguration.cs @@ -41,6 +41,7 @@ public class CoreConfiguration #region Gameserver public bool AutoLaunchServer { get; set; } = false; public bool AutoRestartServer { get; set; } = true; + public int AutoRestartDelay { get; set; } = 30000; public string ServerPath { get; set; } = @"C:\Program Files (x86)\Steam\steamapps\common\Battle"; public string ServerArgs { get; set; } = "/win /norender /nosound /nointro /autonet dedicated /resolution 640 480"; diff --git a/SWBF2Admin/Resources/cfg/core.xml b/SWBF2Admin/Resources/cfg/core.xml index 0dc0460..ac035fc 100644 --- a/SWBF2Admin/Resources/cfg/core.xml +++ b/SWBF2Admin/Resources/cfg/core.xml @@ -29,12 +29,14 @@ C:\Program Files (x86)\Steam - + false true + + 30000 - + true 3600 From 7d83856eb8041868ac6318d8dc604319bf1ab716 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Fri, 5 Apr 2024 22:30:09 -0400 Subject: [PATCH 23/28] Add new mods --- SWBF2Admin/Resources/cfg/mods.xml | 77 ++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/SWBF2Admin/Resources/cfg/mods.xml b/SWBF2Admin/Resources/cfg/mods.xml index f0bdbac..9284fb2 100644 --- a/SWBF2Admin/Resources/cfg/mods.xml +++ b/SWBF2Admin/Resources/cfg/mods.xml @@ -96,6 +96,25 @@ + + + + + + + + + + + + + + + + + + + @@ -191,7 +210,7 @@ - + @@ -323,5 +342,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e29f4a1e39757a80eac7e607c6895c8284057b68 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Sun, 7 Apr 2024 00:19:21 -0400 Subject: [PATCH 24/28] Add nerfed_rocket mod --- SWBF2Admin/Resources/cfg/mods.xml | 75 +++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/SWBF2Admin/Resources/cfg/mods.xml b/SWBF2Admin/Resources/cfg/mods.xml index 9284fb2..0b7741c 100644 --- a/SWBF2Admin/Resources/cfg/mods.xml +++ b/SWBF2Admin/Resources/cfg/mods.xml @@ -39,6 +39,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -349,29 +375,30 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -384,7 +411,7 @@ - + From 96a4243acaeb4f1b7ab9a194e90eb5b71f2df24a Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Fri, 17 May 2024 01:10:23 -0400 Subject: [PATCH 25/28] Code refactor --- .gitignore | 4 +- DllLoader/DllLoader.csproj | 7 ++- DllLoader/Properties/AssemblyInfo.cs | 13 +++++ .../Properties/PublishProfiles/win-x64.pubxml | 18 ------- .../Properties/PublishProfiles/win-x86.pubxml | 18 ------- SWBF2Admin/AdminCore.cs | 3 +- SWBF2Admin/Gameserver/ServerManager.cs | 24 +++++---- .../PublishProfiles/linux-x64.pubxml | 18 ------- .../Properties/PublishProfiles/win-x64.pubxml | 19 ------- .../Properties/PublishProfiles/win-x86.pubxml | 19 ------- SWBF2Admin/Resources/cfg/core.xml | 2 +- SWBF2Admin/Resources/cfg/mods.xml | 51 ++++++++++--------- .../Runtime/Commands/Admin/CmdTempAliasBan.cs | 2 +- .../Runtime/Commands/Admin/CmdTempIpBan.cs | 2 +- .../Runtime/Commands/Admin/CmdTempban.cs | 6 +-- .../Runtime/Commands/CommandDispatcher.cs | 2 +- .../Runtime/Rcon/Packets/PlayerListPacket.cs | 1 - .../Runtime/Rcon/Packets/StatusPacket.cs | 4 +- SWBF2Admin/SWBF2Admin.csproj | 21 ++++---- SWBF2Admin/Utility/Util.cs | 2 +- rconserver-aspyr/CMakeLists.txt | 8 +-- rconserver-galaxy/CMakeLists.txt | 8 +-- rconserver-galaxy/bf2server.cpp | 2 +- 23 files changed, 90 insertions(+), 164 deletions(-) create mode 100644 DllLoader/Properties/AssemblyInfo.cs delete mode 100644 DllLoader/Properties/PublishProfiles/win-x64.pubxml delete mode 100644 DllLoader/Properties/PublishProfiles/win-x86.pubxml delete mode 100644 SWBF2Admin/Properties/PublishProfiles/linux-x64.pubxml delete mode 100644 SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml delete mode 100644 SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml diff --git a/.gitignore b/.gitignore index 30b5e68..108439e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,6 @@ DllLoader/bin DllLoader/obj SWBF2Admin/bin SWBF2Admin/obj -IngameControllerServer/bin -IngameControllerServer/obj RconServer/out rconserver-aspyr/out rconserver-galaxy/out @@ -16,4 +14,4 @@ packages .idea *.user cmake-build-debug -cmake-build-release +cmake-build-release \ No newline at end of file diff --git a/DllLoader/DllLoader.csproj b/DllLoader/DllLoader.csproj index a4040f8..b180f9a 100644 --- a/DllLoader/DllLoader.csproj +++ b/DllLoader/DllLoader.csproj @@ -2,7 +2,12 @@ net8.0 Exe - True + false + DllLoader + DllLoader + Copyright © 2018 + 1.3.0.0 + 1.0.0.0 diff --git a/DllLoader/Properties/AssemblyInfo.cs b/DllLoader/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fbef5bf --- /dev/null +++ b/DllLoader/Properties/AssemblyInfo.cs @@ -0,0 +1,13 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e6f07cf4-2b80-4134-8d0d-52562fa16b8f")] diff --git a/DllLoader/Properties/PublishProfiles/win-x64.pubxml b/DllLoader/Properties/PublishProfiles/win-x64.pubxml deleted file mode 100644 index 49eb151..0000000 --- a/DllLoader/Properties/PublishProfiles/win-x64.pubxml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Release - Any CPU - bin\Release\net8.0\publish\win-x64\ - FileSystem - <_TargetId>Folder - net8.0 - win-x64 - false - true - false - - \ No newline at end of file diff --git a/DllLoader/Properties/PublishProfiles/win-x86.pubxml b/DllLoader/Properties/PublishProfiles/win-x86.pubxml deleted file mode 100644 index fbe976e..0000000 --- a/DllLoader/Properties/PublishProfiles/win-x86.pubxml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Release - Any CPU - bin\Release\net8.0\publish\win-x86\ - FileSystem - <_TargetId>Folder - net8.0 - win-x86 - false - true - false - - \ No newline at end of file diff --git a/SWBF2Admin/AdminCore.cs b/SWBF2Admin/AdminCore.cs index 4b329e0..69824e3 100644 --- a/SWBF2Admin/AdminCore.cs +++ b/SWBF2Admin/AdminCore.cs @@ -101,8 +101,7 @@ public AdminCore() public void Run(string[] args) { - Logger.Log(LogLevel.Info, Log.CORE_START, Util.GetProductName(), Util.GetProductVersion(), - Util.GetProductAuthor()); + Logger.Log(LogLevel.Info, Log.CORE_START, Util.GetProductName(), Util.GetProductVersion(), Util.GetProductAuthor()); Logger.Log(LogLevel.Verbose, Log.CORE_READ_CONFIG); config = Files.ReadConfig(); Logger.Log(LogLevel.Info, Log.CORE_READ_CONFIG_OK); diff --git a/SWBF2Admin/Gameserver/ServerManager.cs b/SWBF2Admin/Gameserver/ServerManager.cs index 812717f..5f42007 100644 --- a/SWBF2Admin/Gameserver/ServerManager.cs +++ b/SWBF2Admin/Gameserver/ServerManager.cs @@ -36,8 +36,8 @@ public enum ServerStatus public class ServerManager : ComponentBase { - private const string DLLLOADER_FILENAME_32 = "dllloader_32.exe"; - private const string DLLLOADER_FILENAME_64 = "dllloader_64.exe"; + private const string DLLLOADER_FILENAME_32 = "DllLoader_32.exe"; + private const string DLLLOADER_FILENAME_64 = "DllLoader_64.exe"; private const int STEAMMODE_PDECT_TIMEOUT = 1000; private const int STEAMMODE_MAX_RETRY = 30; @@ -72,7 +72,7 @@ public override void Configure(CoreConfiguration config) if (serverType == GameserverType.Steam) { ServerExecutable = ServerPath + "/BattlefrontII.exe"; - ServerArgs = string.Empty; + ServerArgs = ""; } if (serverType == GameserverType.Aspyr) { @@ -90,7 +90,6 @@ public override void Configure(CoreConfiguration config) ServerExecutable = ServerPath + "/BattlefrontII.exe"; ServerArgs = config.ServerArgs; } - UpdateInterval = STEAMMODE_PDECT_TIMEOUT; //updates for detecting steam startup } @@ -196,9 +195,10 @@ public void Start() serverProcess = Process.Start(startInfo); serverProcess.EnableRaisingEvents = true; serverProcess.Exited += new EventHandler(ServerProcess_Exited); - serverProcess.PriorityClass = ProcessPriorityClass.High; - //Start game minimized because of mouse locking on Aspyr version - serverProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; + if (Core.Config.EnableHighPriority) + { + serverProcess.PriorityClass = ProcessPriorityClass.High; + } } , 5000); status = ServerStatus.SteamPending; @@ -208,7 +208,10 @@ public void Start() serverProcess = Process.Start(startInfo); serverProcess.EnableRaisingEvents = true; serverProcess.Exited += new EventHandler(ServerProcess_Exited); - serverProcess.PriorityClass = ProcessPriorityClass.High; + if (Core.Config.EnableHighPriority) + { + serverProcess.PriorityClass = ProcessPriorityClass.High; + } status = ServerStatus.Online; InvokeEvent(ServerStarted, this, new StartEventArgs(false)); @@ -276,6 +279,7 @@ private void ServerProcess_Exited(object sender, EventArgs e) private void InjectRconDllIfRequired() { + //Add GameserverType.Aspyr if using RconServer if (serverType == GameserverType.GoG || serverType == GameserverType.Steam) { string loader; @@ -283,12 +287,12 @@ private void InjectRconDllIfRequired() if (serverType == GameserverType.Aspyr) { loader = $"{Core.Files.ParseFileName(Core.Config.ServerPath)}/{DLLLOADER_FILENAME_64}"; - dll = "rconserver_64.dll"; + dll = "RconServer_64.dll"; } else { loader = $"{Core.Files.ParseFileName(Core.Config.ServerPath)}/{DLLLOADER_FILENAME_32}"; - dll = "rconserver_32.dll"; + dll = "RconServer_32.dll"; } if (File.Exists(loader)) diff --git a/SWBF2Admin/Properties/PublishProfiles/linux-x64.pubxml b/SWBF2Admin/Properties/PublishProfiles/linux-x64.pubxml deleted file mode 100644 index 38680ee..0000000 --- a/SWBF2Admin/Properties/PublishProfiles/linux-x64.pubxml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Release - Any CPU - bin\Release\net8.0\publish\linux-x64\ - FileSystem - <_TargetId>Folder - net8.0 - linux-x64 - false - true - true - - \ No newline at end of file diff --git a/SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml b/SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml deleted file mode 100644 index f322b45..0000000 --- a/SWBF2Admin/Properties/PublishProfiles/win-x64.pubxml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Release - Any CPU - bin\Release\net8.0\publish\win-x64\ - FileSystem - <_TargetId>Folder - net8.0 - win-x64 - false - true - true - true - - \ No newline at end of file diff --git a/SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml b/SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml deleted file mode 100644 index 6910c4f..0000000 --- a/SWBF2Admin/Properties/PublishProfiles/win-x86.pubxml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Release - Any CPU - bin\Release\net8.0\publish\win-x86\ - FileSystem - <_TargetId>Folder - net8.0 - win-x86 - false - true - true - true - - \ No newline at end of file diff --git a/SWBF2Admin/Resources/cfg/core.xml b/SWBF2Admin/Resources/cfg/core.xml index ac035fc..47a742b 100644 --- a/SWBF2Admin/Resources/cfg/core.xml +++ b/SWBF2Admin/Resources/cfg/core.xml @@ -44,7 +44,7 @@ 30000 - /win /norender /nosound /nointro /autonet dedicated /resolution 640 480 + /win /norender /nosound /nointro /autonet dedicated /resolution 640 480 - + @@ -375,31 +375,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SWBF2Admin/Runtime/Commands/Admin/CmdTempAliasBan.cs b/SWBF2Admin/Runtime/Commands/Admin/CmdTempAliasBan.cs index a005155..eaca5ab 100644 --- a/SWBF2Admin/Runtime/Commands/Admin/CmdTempAliasBan.cs +++ b/SWBF2Admin/Runtime/Commands/Admin/CmdTempAliasBan.cs @@ -22,7 +22,7 @@ namespace SWBF2Admin.Runtime.Commands.Admin { [ConfigFileInfo(fileName: "./cfg/cmd/tempaliasban.xml"/*, template: "SWBF2Admin.Resources.cfg.cmd.kick.xml"*/)] - public class CmdTempAliasBan : CmdTempBan + public class CmdTempAliasBan : CmdTempban { public CmdTempAliasBan() : base("tempaliasban", "tempban") { } diff --git a/SWBF2Admin/Runtime/Commands/Admin/CmdTempIpBan.cs b/SWBF2Admin/Runtime/Commands/Admin/CmdTempIpBan.cs index 1761f14..92e26f4 100644 --- a/SWBF2Admin/Runtime/Commands/Admin/CmdTempIpBan.cs +++ b/SWBF2Admin/Runtime/Commands/Admin/CmdTempIpBan.cs @@ -22,7 +22,7 @@ namespace SWBF2Admin.Runtime.Commands.Admin { [ConfigFileInfo(fileName: "./cfg/cmd/tempipban.xml"/*, template: "SWBF2Admin.Resources.cfg.cmd.kick.xml"*/)] - public class CmdTempIpBan : CmdTempBan + public class CmdTempIpBan : CmdTempban { public CmdTempIpBan() : base("tempipban", "tempban") { } diff --git a/SWBF2Admin/Runtime/Commands/Admin/CmdTempban.cs b/SWBF2Admin/Runtime/Commands/Admin/CmdTempban.cs index 83acb84..47a0e36 100644 --- a/SWBF2Admin/Runtime/Commands/Admin/CmdTempban.cs +++ b/SWBF2Admin/Runtime/Commands/Admin/CmdTempban.cs @@ -22,7 +22,7 @@ namespace SWBF2Admin.Runtime.Commands.Admin { [ConfigFileInfo(fileName: "./cfg/cmd/tempban.xml"/*, template: "SWBF2Admin.Resources.cfg.cmd.kick.xml"*/)] - public class CmdTempBan : PlayerCommand + public class CmdTempban : PlayerCommand { public string OnNoTimeSpan { get; set; } = "No timespan specified. Usage: {usage}"; public string OnInvalidTimeSpan { get; set; } = "Invalid input {input}. Expecting valid integer."; @@ -42,9 +42,9 @@ public string DurationFormat } public string DefaultReason { get; set; } = ""; - public CmdTempBan() : base("tempban", "tempban") { } + public CmdTempban() : base("tempban", "tempban") { } - public CmdTempBan(string alias, string permission) : base(alias, permission) { } + public CmdTempban(string alias, string permission) : base(alias, permission) { } public override bool AffectPlayer(Player affectedPlayer, Player player, string commandLine, string[] parameters, int paramIdx) { diff --git a/SWBF2Admin/Runtime/Commands/CommandDispatcher.cs b/SWBF2Admin/Runtime/Commands/CommandDispatcher.cs index 0257bd0..6564708 100644 --- a/SWBF2Admin/Runtime/Commands/CommandDispatcher.cs +++ b/SWBF2Admin/Runtime/Commands/CommandDispatcher.cs @@ -57,7 +57,7 @@ public override void OnInit() RegisterCommand(); RegisterCommand(); RegisterCommand(); - RegisterCommand(); + RegisterCommand(); if (serverType == GameserverType.Gamespy) { diff --git a/SWBF2Admin/Runtime/Rcon/Packets/PlayerListPacket.cs b/SWBF2Admin/Runtime/Rcon/Packets/PlayerListPacket.cs index bad04da..7dbedba 100644 --- a/SWBF2Admin/Runtime/Rcon/Packets/PlayerListPacket.cs +++ b/SWBF2Admin/Runtime/Rcon/Packets/PlayerListPacket.cs @@ -48,7 +48,6 @@ public override void HandleResponse(string response) rows.Add(response.Substring(i, 89)); } - /*1 "KJC_Obi-Wan" Rep 0 0 0 83 d9728d39-737d-47cd7c51bef0c7417274098ee3f90807fe*/ /*1 "KJC_Obi-Wan" Rep 0 0 0 75 2116af44-2850-44951a72af3bd99b904e663ecbbe5d71b9*/ foreach (string r in rows) diff --git a/SWBF2Admin/Runtime/Rcon/Packets/StatusPacket.cs b/SWBF2Admin/Runtime/Rcon/Packets/StatusPacket.cs index 73e4b60..868bf1c 100644 --- a/SWBF2Admin/Runtime/Rcon/Packets/StatusPacket.cs +++ b/SWBF2Admin/Runtime/Rcon/Packets/StatusPacket.cs @@ -47,7 +47,7 @@ public StatusPacket() : base("status") * Tickets : 0/0 * FF enabled : yes * Heroes : no - **/ + **/ /** * Server name : LeKeks test * Server IP : 192.168.188.93 @@ -61,7 +61,7 @@ public StatusPacket() : base("status") * Tickets : 450/450 * FF enabled : no * Heroes : no - */ + **/ public override void HandleResponse(string response) { string[] rows = response.Split('\n'); diff --git a/SWBF2Admin/SWBF2Admin.csproj b/SWBF2Admin/SWBF2Admin.csproj index 3f02740..83bed1b 100644 --- a/SWBF2Admin/SWBF2Admin.csproj +++ b/SWBF2Admin/SWBF2Admin.csproj @@ -3,7 +3,6 @@ net8.0 Exe True - en-US bin\x64\Debug\ @@ -18,7 +17,7 @@ - + @@ -26,15 +25,15 @@ + - - + - + - - + + @@ -43,16 +42,16 @@ - + - REM xcopy "$(SolutionDir)DebugFiles" "$(TargetDir)" /S /D SWBF2Admin - SWBF2 server manager + SWBF2 Server Manager SWBF2Admin Contributors SWBF2Admin - Copyright © 2017-2019 Jan Weigelt + Copyright © 2017-2024 Jan Weigelt 1.3.0.0 1.3.0.0 + en-US \ No newline at end of file diff --git a/SWBF2Admin/Utility/Util.cs b/SWBF2Admin/Utility/Util.cs index 7fa8cf4..9126e91 100644 --- a/SWBF2Admin/Utility/Util.cs +++ b/SWBF2Admin/Utility/Util.cs @@ -131,7 +131,7 @@ public static string GetProductVersion() public static string GetProductAuthor() { - return "LeKeks, Yoni, AsLan"; + return "LeKeks, Yoni, AsLan, Alpha"; } public static List SegmentString(string str, int maxSegmentSize) diff --git a/rconserver-aspyr/CMakeLists.txt b/rconserver-aspyr/CMakeLists.txt index ff521ff..086939a 100644 --- a/rconserver-aspyr/CMakeLists.txt +++ b/rconserver-aspyr/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(rconserver_64) +project(RconServer_64) set(CMAKE_BUILD_TYPE Release) set(CMAKE_GENERATOR_PLATFORM amd64) @@ -10,9 +10,9 @@ set(SOURCES Logger.cpp ) -add_library(rconserver_64 SHARED ${SOURCES}) -target_compile_definitions(rconserver_64 PRIVATE RCONSERVER_EXPORTS _WINDOWS _USRDLL) -set_property(TARGET rconserver_64 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedRelease") +add_library(RconServer_64 SHARED ${SOURCES}) +target_compile_definitions(RconServer_64 PRIVATE RCONSERVER_EXPORTS _WINDOWS _USRDLL) +set_property(TARGET RconServer_64 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedRelease") if (CMAKE_SIZEOF_VOID_P EQUAL 8) message(STATUS "Compiling for 64-bit architecture") diff --git a/rconserver-galaxy/CMakeLists.txt b/rconserver-galaxy/CMakeLists.txt index 362b5fd..a2fee45 100644 --- a/rconserver-galaxy/CMakeLists.txt +++ b/rconserver-galaxy/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(rconserver_32) +project(RconServer_32) set(CMAKE_BUILD_TYPE Release) set(CMAKE_GENERATOR_PLATFORM x86) @@ -13,6 +13,6 @@ set(SOURCES RconServer.cpp ) -add_library(rconserver_32 SHARED ${SOURCES}) -target_compile_definitions(rconserver_32 PRIVATE RCONSERVER_EXPORTS _WINDOWS _USRDLL) -set_property(TARGET rconserver_32 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedRelease") \ No newline at end of file +add_library(RconServer_32 SHARED ${SOURCES}) +target_compile_definitions(RconServer_32 PRIVATE RCONSERVER_EXPORTS _WINDOWS _USRDLL) +set_property(TARGET RconServer_32 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedRelease") \ No newline at end of file diff --git a/rconserver-galaxy/bf2server.cpp b/rconserver-galaxy/bf2server.cpp index 996aca8..b1a6ea6 100644 --- a/rconserver-galaxy/bf2server.cpp +++ b/rconserver-galaxy/bf2server.cpp @@ -29,7 +29,7 @@ void bf2server_init() { bf2server_patch_maphang(); bf2server_patch_dedicated(); bf2server_patch_distance_lag(); - //bf2server_patch_netupdate(); + bf2server_patch_netupdate(); chatCCAddr = reinterpret_cast(&bf2server_chat_cc); bf2server_set_chat_cc(); From 11cb6b7f7299f59f06f2011148366d7ab131c11f Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Fri, 17 May 2024 01:44:29 -0400 Subject: [PATCH 26/28] Fix RconServer compile errors --- rconserver-aspyr/CMakeLists.txt | 1 + rconserver-aspyr/bf2server.cpp | 12 ++++++------ rconserver-galaxy/CMakeLists.txt | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/rconserver-aspyr/CMakeLists.txt b/rconserver-aspyr/CMakeLists.txt index 086939a..a10c29e 100644 --- a/rconserver-aspyr/CMakeLists.txt +++ b/rconserver-aspyr/CMakeLists.txt @@ -3,6 +3,7 @@ project(RconServer_64) set(CMAKE_BUILD_TYPE Release) set(CMAKE_GENERATOR_PLATFORM amd64) +set(CMAKE_SHARED_LIBRARY_PREFIX "") set(SOURCES dllmain.cpp diff --git a/rconserver-aspyr/bf2server.cpp b/rconserver-aspyr/bf2server.cpp index c223189..fbcf42e 100644 --- a/rconserver-aspyr/bf2server.cpp +++ b/rconserver-aspyr/bf2server.cpp @@ -23,7 +23,7 @@ void bf2server_patch_netupdate() 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; - bf2server_patch_asm(0x000000018022B6A0-0x0000000180000000, + bf2server_patch_asm(0x000000018022B6A0 - 0x0000000180000000, reinterpret_cast(send_window_patch), sizeof(send_window_patch)); @@ -34,7 +34,7 @@ void bf2server_patch_netupdate() 0x90, 0x90 }; - bf2server_patch_asm(0x00000001803818EE-0x0000000180000000, + bf2server_patch_asm(0x00000001803818EE - 0x0000000180000000, reinterpret_cast(pipe_full_patch), sizeof(pipe_full_patch)); @@ -45,7 +45,7 @@ void bf2server_patch_netupdate() //.text:0000000180238EEB FF C1 inc ecx 0xFF, 0xC1 }; - bf2server_patch_asm(0x0000000180238EEB-0x0000000180000000, + bf2server_patch_asm(0x0000000180238EEB - 0x0000000180000000, reinterpret_cast(send_update_patch), sizeof(send_update_patch)); @@ -57,16 +57,16 @@ void bf2server_patch_netupdate() 0xb8, 0x40, 0x00, 0x00, 0x00, 0x90, 0x90 }; *(DWORD*)&cur_players_patch[1] = 1024; - bf2server_patch_asm(0x00000001802380F8-0x0000000180000000, + bf2server_patch_asm(0x00000001802380F8 - 0x0000000180000000, reinterpret_cast(cur_players_patch), sizeof(cur_players_patch)); BYTE distance_lag_fix[] = { //.text:000000018024156C C7 44 24 30 05 00 00 00 mov [rsp+2C8h+var_298], 5 - 0xC7, 0x44, 0x24 ,0x30 ,0x20, 0x00, 0x00, 0x00 + 0xC7, 0x44, 0x24, 0x30, 0x20, 0x00, 0x00, 0x00 }; - bf2server_patch_asm(0x000000018024156C-0x0000000180000000, + bf2server_patch_asm(0x000000018024156C - 0x0000000180000000, reinterpret_cast(distance_lag_fix), sizeof(distance_lag_fix)); } diff --git a/rconserver-galaxy/CMakeLists.txt b/rconserver-galaxy/CMakeLists.txt index a2fee45..29315c8 100644 --- a/rconserver-galaxy/CMakeLists.txt +++ b/rconserver-galaxy/CMakeLists.txt @@ -3,6 +3,7 @@ project(RconServer_32) set(CMAKE_BUILD_TYPE Release) set(CMAKE_GENERATOR_PLATFORM x86) +set(CMAKE_STATIC_LIBRARY_PREFIX "") set(SOURCES dllmain.cpp From c7e0594bbd0da36c49c1597778dae3a807b3fe48 Mon Sep 17 00:00:00 2001 From: Alpha <22331737+Alpha5k@users.noreply.github.com> Date: Tue, 21 May 2024 00:38:56 -0400 Subject: [PATCH 27/28] Add process affinity support --- SWBF2Admin/Config/CoreConfiguration.cs | 2 ++ SWBF2Admin/Gameserver/ServerManager.cs | 10 +++++++++- SWBF2Admin/Resources/cfg/core.xml | 8 ++++++++ SWBF2Admin/Runtime/Rcon/RconClient.cs | 3 ++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/SWBF2Admin/Config/CoreConfiguration.cs b/SWBF2Admin/Config/CoreConfiguration.cs index c3e7231..5eb1d1d 100644 --- a/SWBF2Admin/Config/CoreConfiguration.cs +++ b/SWBF2Admin/Config/CoreConfiguration.cs @@ -48,6 +48,8 @@ public class CoreConfiguration public string SteamPath { get; set; } = @"C:\Program Files (x86)\Steam"; public bool EnableHighPriority { get; set; } = true; + public bool SetAffinity { get; set; } = false; + public int ProcessAffinity { get; set; } = 0x0; public bool EnableRuntime { get; set; } = false; public GameserverType ServerType { get; set; } = GameserverType.Aspyr; diff --git a/SWBF2Admin/Gameserver/ServerManager.cs b/SWBF2Admin/Gameserver/ServerManager.cs index 5f42007..7a12116 100644 --- a/SWBF2Admin/Gameserver/ServerManager.cs +++ b/SWBF2Admin/Gameserver/ServerManager.cs @@ -77,7 +77,7 @@ public override void Configure(CoreConfiguration config) if (serverType == GameserverType.Aspyr) { ServerExecutable = config.ServerPath + "/Battlefront.exe"; - //ServerArgs = "-applaunch 2446550 " + config.ServerArgs; + ServerArgs = config.ServerArgs; var appid_txt = Path.GetFullPath(ServerPath + "/steam_appid.txt"); if (!File.Exists(appid_txt)) { @@ -155,6 +155,14 @@ private bool Attach(bool starting) { serverProcess.PriorityClass = ProcessPriorityClass.High; } + if (Core.Config.SetAffinity) + { + var threads = serverProcess.Threads; + foreach (ProcessThread thread in threads) + { + thread.ProcessorAffinity = Core.Config.ProcessAffinity; + } + } return true; } return false; diff --git a/SWBF2Admin/Resources/cfg/core.xml b/SWBF2Admin/Resources/cfg/core.xml index 47a742b..d894966 100644 --- a/SWBF2Admin/Resources/cfg/core.xml +++ b/SWBF2Admin/Resources/cfg/core.xml @@ -51,6 +51,14 @@ - improve performance by reducing cpu latency on slow machines --> false + + + false + + 0