From a725ae09f2147b84f6619d1287eba2d9344e13de Mon Sep 17 00:00:00 2001 From: tmp64 Date: Sun, 5 Oct 2025 12:13:42 +0700 Subject: [PATCH 1/5] VS Code: Add server launch example --- .vscode/launch.example.json | 57 +++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.example.json b/.vscode/launch.example.json index ef71676d..0cc95db3 100644 --- a/.vscode/launch.example.json +++ b/.vscode/launch.example.json @@ -2,7 +2,7 @@ "version": "0.2.0", "configurations": [ { - "name": "Half-Life (Windows)", + "name": "Client (Windows)", "type": "cppvsdbg", "request": "launch", "program": "C:/Program Files/Steam/steamapps/common/Half-Life/hl.exe", @@ -15,7 +15,7 @@ "cwd": "C:/Program Files/Steam/steamapps/common/Half-Life", }, { - "name": "Half-Life (Linux)", + "name": "Client (Linux)", "type": "lldb", "request": "launch", "program": "${env:HOME}/.local/share/Steam/steamapps/common/Half-Life/hl_linux", @@ -33,6 +33,59 @@ "SteamEnv": "1", }, }, + { + "name": "Server (Windows)", + "type": "cppvsdbg", + "request": "launch", + "program": "C:/HLDS/hlds.exe", + "args": [ + "-dev", + "-console", + "-game", "valve", + "-insecure", + "+log", "on", + "+sv_lan", "1", + "+maxplayers", "32", + "+map", "crossfire", + ], + "cwd": "C:/HLDS", + }, + { + "name": "Server (Linux, LLDB)", + "type": "lldb", + "request": "launch", + "program": "${env:HOME}/hlds/hlds_linux", + "args": [ + "-dev", + "-console", + "-game", "valve", + "-insecure", + "+localinfo", "mm_gamedll", "dlls/hl.so", + "+log", "on", + "+sv_lan", "1", + "+maxplayers", "32", + "+map", "crossfire", + ], + "cwd": "${env:HOME}/hlds", + }, + { + "name": "Server (Linux, GDB)", + "type": "cppdbg", + "request": "launch", + "program": "${env:HOME}/hlds/hlds_linux", + "args": [ + "-dev", + "-console", + "-game", "valve", + "-insecure", + "+localinfo", "mm_gamedll", "dlls/hl.so", + "+log", "on", + "+sv_lan", "1", + "+maxplayers", "32", + "+map", "crossfire", + ], + "cwd": "${env:HOME}/hlds", + }, { "name": "lldb: Attach", "type": "lldb", From 1c6230434b52dc8fc886ae3479558fb2260e7032 Mon Sep 17 00:00:00 2001 From: tmp64 Date: Sun, 5 Oct 2025 12:22:43 +0700 Subject: [PATCH 2/5] vinterface: Fix incompatibility with tier0 --- src/public/vinterface/interface.cpp | 8 ++++---- src/public/vinterface/interface.h | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/public/vinterface/interface.cpp b/src/public/vinterface/interface.cpp index 29d8cdd4..5df75d2c 100644 --- a/src/public/vinterface/interface.cpp +++ b/src/public/vinterface/interface.cpp @@ -154,13 +154,13 @@ CSysModule *Sys_LoadModule(const char *pModuleName) _snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName); - hDLL = dlopen(szAbsoluteModuleName, RTLD_NOW); + hDLL = (HMODULE)dlopen(szAbsoluteModuleName, RTLD_NOW); } } else { _snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s", pModuleName); - hDLL = dlopen(pModuleName, RTLD_NOW); + hDLL = (HMODULE)dlopen(pModuleName, RTLD_NOW); } #endif @@ -177,7 +177,7 @@ CSysModule *Sys_LoadModule(const char *pModuleName) #else printf("Error:%s\n", dlerror()); _snprintf(str, sizeof(str), "%s.so", szAbsoluteModuleName); - hDLL = dlopen(str, RTLD_NOW); + hDLL = (HMODULE)dlopen(str, RTLD_NOW); #endif } @@ -224,7 +224,7 @@ CreateInterfaceFn Sys_GetFactory(CSysModule *pModule) //pointer-to-function and pointer-to-object // // so lets get around it :) - return (CreateInterfaceFn)(GetProcAddress(hDLL, CREATEINTERFACE_PROCNAME)); + return (CreateInterfaceFn)(GetProcAddress((void *)hDLL, CREATEINTERFACE_PROCNAME)); #endif } diff --git a/src/public/vinterface/interface.h b/src/public/vinterface/interface.h index cb3b2474..93017357 100644 --- a/src/public/vinterface/interface.h +++ b/src/public/vinterface/interface.h @@ -23,12 +23,10 @@ #if !defined(_WIN32) +#include #include // dlopen,dlclose, et al #include -#define HMODULE void * -#define GetProcAddress dlsym - #define _snprintf snprintf #endif From 7adf0fc740e43a92ad1275f66b52df1778495873 Mon Sep 17 00:00:00 2001 From: tmp64 Date: Sun, 5 Oct 2025 12:23:08 +0700 Subject: [PATCH 3/5] AMXX: Use DLL path from Metamod --- src/bugfixedapi_amxx/bhl_api.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/bugfixedapi_amxx/bhl_api.cpp b/src/bugfixedapi_amxx/bhl_api.cpp index b5368777..ab151aad 100644 --- a/src/bugfixedapi_amxx/bhl_api.cpp +++ b/src/bugfixedapi_amxx/bhl_api.cpp @@ -1,5 +1,6 @@ #include #include "bhl_api.h" +#include "amxxmodule.h" namespace { @@ -26,17 +27,7 @@ bhl::E_ApiInitResult bhl::InitServerApi() { assert(!IsServerApiReady()); - // Load module -#if defined(_WIN32) - const char *pszModule = "hl.dll"; -#elif defined(__APPLE__) || defined(PLATFORM_MACOS) - const char *pszModule = "hl.dylib"; -#elif defined(LINUX) || defined(PLATFORM_LINUX) - const char *pszModule = "hl.so"; -#else -#error Platform not supported: no module name -#endif - + const char* pszModule = gpMetaUtilFuncs->pfnGetGameInfo(PLID, GINFO_DLL_FULLPATH); g_pServerModule = Sys_LoadModule(pszModule); if (!g_pServerModule) From 542113f3a096a89e2545a07355aff59ab0995264 Mon Sep 17 00:00:00 2001 From: tmp64 Date: Sun, 5 Oct 2025 12:23:16 +0700 Subject: [PATCH 4/5] AMXX: Add example plugin --- .../amxmodx/scripting/bhl_api_example.sma | 27 +++++++++++++++++++ .../amxmodx/scripting/include/bugfixedapi.inc | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gamedir/addons/amxmodx/scripting/bhl_api_example.sma diff --git a/gamedir/addons/amxmodx/scripting/bhl_api_example.sma b/gamedir/addons/amxmodx/scripting/bhl_api_example.sma new file mode 100644 index 00000000..16296d3c --- /dev/null +++ b/gamedir/addons/amxmodx/scripting/bhl_api_example.sma @@ -0,0 +1,27 @@ +#include +#include + +#pragma semicolon 1 +#pragma ctrlchar '\' + +#define PLUGIN "BHL API Example" +#define VERSION "1.0.0" +#define AUTHOR "BHL" + +public plugin_init() +{ + register_plugin(PLUGIN, VERSION, AUTHOR); + + new is_ready = bhl_is_api_ready(); + server_print("[BHL API] Is Ready = %d", is_ready); + + if (is_ready) + { + new major, minor, patch; + + if (bhl_get_server_version(major, minor, patch)) + server_print("[BHL API] Version = %d.%d.%d", major, minor, patch); + else + server_print("[BHL API] Version get failed"); + } +} diff --git a/gamedir/addons/amxmodx/scripting/include/bugfixedapi.inc b/gamedir/addons/amxmodx/scripting/include/bugfixedapi.inc index 7a454d75..e4f067b1 100644 --- a/gamedir/addons/amxmodx/scripting/include/bugfixedapi.inc +++ b/gamedir/addons/amxmodx/scripting/include/bugfixedapi.inc @@ -91,7 +91,7 @@ native bhl_get_client_version_commit(idx, buf[], size = sizeof(buf)); * @param idx Player's index * @return 0 or 1 */ -native bhl_is_client_version_valid(idx) +native bhl_is_client_version_valid(idx); /** * @see bhl_set_automatic_motd From e70f997afb4870fd0a65a9ae979e7e7a2fe7c11b Mon Sep 17 00:00:00 2001 From: tmp64 Date: Sun, 5 Oct 2025 12:35:52 +0700 Subject: [PATCH 5/5] AMXX: Log DLL path --- src/bugfixedapi_amxx/bhl_api.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bugfixedapi_amxx/bhl_api.cpp b/src/bugfixedapi_amxx/bhl_api.cpp index ab151aad..95dbb95d 100644 --- a/src/bugfixedapi_amxx/bhl_api.cpp +++ b/src/bugfixedapi_amxx/bhl_api.cpp @@ -27,7 +27,9 @@ bhl::E_ApiInitResult bhl::InitServerApi() { assert(!IsServerApiReady()); - const char* pszModule = gpMetaUtilFuncs->pfnGetGameInfo(PLID, GINFO_DLL_FULLPATH); + const char *pszModule = gpMetaUtilFuncs->pfnGetGameInfo(PLID, GINFO_DLL_FULLPATH); + LOG_DEVELOPER(PLID, "Server DLL path: %s", pszModule); + g_pServerModule = Sys_LoadModule(pszModule); if (!g_pServerModule)