Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions .vscode/launch.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
27 changes: 27 additions & 0 deletions gamedir/addons/amxmodx/scripting/bhl_api_example.sma
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <amxmodx>
#include <bugfixedapi>

#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");
}
}
2 changes: 1 addition & 1 deletion gamedir/addons/amxmodx/scripting/include/bugfixedapi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 4 additions & 11 deletions src/bugfixedapi_amxx/bhl_api.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cassert>
#include "bhl_api.h"
#include "amxxmodule.h"

namespace
{
Expand All @@ -26,17 +27,9 @@ 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);
LOG_DEVELOPER(PLID, "Server DLL path: %s", pszModule);

g_pServerModule = Sys_LoadModule(pszModule);

if (!g_pServerModule)
Expand Down
8 changes: 4 additions & 4 deletions src/public/vinterface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 1 addition & 3 deletions src/public/vinterface/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@

#if !defined(_WIN32)

#include <tier0/platform.h>
#include <dlfcn.h> // dlopen,dlclose, et al
#include <unistd.h>

#define HMODULE void *
#define GetProcAddress dlsym

#define _snprintf snprintf

#endif
Expand Down
Loading