openvibers/source.openvibe.games Commits

Next phase

CO Copilot committed 29 Jun 2026 · 5198342401 · 11 files, +241 −1043


Changes

ddiff --git a/.gitignore b/.gitignore
iindex c7e3701..d6bc4be 100644
---- a/.gitignore
++++ b/.gitignore
@@@ -33,3 +33,9 @@ steam_appid.txt
# node_modules are tracked via package-lock.json; exclude the installed version to reduce repo size
launcher/node_modules/
backend/node_modules/
++
++# OpenVibe local/generated build junk
++.tmp/
++*.bak.*
++tools/*.bak.*
++engine/source-sdk-2013/src/game/shared/openvibe/third_party/quickjs/build/
ddiff --git a/.tmp/quickjs-smoke/smoke-quickjs b/.tmp/quickjs-smoke/smoke-quickjs
ddeleted file mode 100755
iindex e5fdd1a..0000000
BBinary files a/.tmp/quickjs-smoke/smoke-quickjs and /dev/null differ
ddiff --git a/tools/apply-openvibe-sdk.sh b/tools/apply-openvibe-sdk.sh
iindex cbe2219..437187e 100755
---- a/tools/apply-openvibe-sdk.sh
++++ b/tools/apply-openvibe-sdk.sh
@@@ -207,17 +207,10 @@ QJS_SHIM
patch_openvibe_quickjs_after_apply
--echo "[openvibe-sdk] Source SDK OpenVibe patch applied"
--
--
--# Link prebuilt QuickJS C static library. QuickJS must be compiled as C, not C++.
--if ! grep -q 'libquickjs_openvibe.a' "$SERVER_VPC"; then
-- perl -0pi -e 's/(\$File\s+"hl2mp\\openvibe_js_server\.cpp"\n)/$1\t\t\t\$Lib\t"..\\shared\\openvibe\\third_party\\quickjs\\build\\libquickjs_openvibe.a"\n/s' "$SERVER_VPC"
-- echo "[openvibe-sdk] linked QuickJS static library"
--fi
--
--# OPENVIBE_REMOVE_DIRECT_QUICKJS_C
++# OPENVIBE_FIX_QUICKJS_LINK_FINAL_V2
++# QuickJS is C, so do not compile its .c files through Source SDK/VPC C++.
++# We build libquickjs_openvibe.a with cc and link it as a library.
if [[ -f "$SERVER_VPC" ]]; then
perl -0pi -e '
s/^.*quickjs\\quickjs\.c.*\n//mg;
@@@ -228,7 +221,20 @@ if [[ -f "$SERVER_VPC" ]]; then
s/^.*quickjs\\libbf\.c.*\n//mg;
' "$SERVER_VPC"
-- if ! grep -q 'libquickjs_openvibe.a' "$SERVER_VPC"; then
-- perl -0pi -e 's/(\$File\s+"hl2mp\\openvibe_js_server\.cpp"\n)/$1\t\t\t\$Lib\t"..\\shared\\openvibe\\third_party\\quickjs\\build\\libquickjs_openvibe.a"\n/s' "$SERVER_VPC"
-- fi
++ perl -0pi -e 's/^.*libquickjs_openvibe(?:\.a)?".*\n//mg' "$SERVER_VPC"
++
++ perl -0pi -e 's/(\$File\s+"hl2mp\\openvibe_js_server\.cpp"\n)/$1\t\t\t\$Lib\t"..\\shared\\openvibe\\third_party\\quickjs\\build\\libquickjs_openvibe"\n/s' "$SERVER_VPC"
++
++ echo "[openvibe-sdk] linked QuickJS static library"
++fi
++
++echo "[openvibe-sdk] Source SDK OpenVibe patch applied"
++
++
++# Link prebuilt QuickJS C static library. QuickJS must be compiled as C, not C++.
++if ! grep -q 'libquickjs_openvibe' "$SERVER_VPC"; then
++ perl -0pi -e 's/(\$File\s+"hl2mp\\openvibe_js_server\.cpp"\n)/$1\t\t\t\$Lib\t"..\\shared\\openvibe\\third_party\\quickjs\\build\\libquickjs_openvibe"\n/s' "$SERVER_VPC"
++ echo "[openvibe-sdk] linked QuickJS static library"
fi
++
++
ddiff --git a/tools/apply-openvibe-sdk.sh.bak.20260628-200219 b/tools/apply-openvibe-sdk.sh.bak.20260628-200219
ddeleted file mode 100755
iindex 57dfdd3..0000000
---- a/tools/apply-openvibe-sdk.sh.bak.20260628-200219
++++ /dev/null
@@@ -1,79 +0,0 @@
--#!/usr/bin/env bash
--set -euo pipefail
--
--ROOT="${OPENVIBE_ROOT:-$HOME/src/openvibe-source}"
--SDK="${OPENVIBE_SDK:-$ROOT/engine/source-sdk-2013}"
--
--if [[ ! -d "$SDK/src/game/client/hl2mp" || ! -d "$SDK/src/game/server/hl2mp" ]]; then
-- echo "Source SDK 2013 checkout not found at $SDK" >&2
-- echo "Set OPENVIBE_SDK=/path/to/source-sdk-2013 if it lives elsewhere." >&2
-- exit 1
--fi
--
--copy_file() {
-- local src="$1"
-- local dst="$2"
-- install -D -m 0644 "$src" "$dst"
-- echo "[openvibe-sdk] copied ${dst#$SDK/}"
--}
--
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/openvibe_client.cpp" \
-- "$SDK/src/game/client/hl2mp/openvibe_client.cpp"
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/vgui_openvibe_menu.cpp" \
-- "$SDK/src/game/client/hl2mp/vgui_openvibe_menu.cpp"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_server.cpp"
--
--CLIENT_VPC="$SDK/src/game/client/client_hl2mp.vpc"
--SERVER_VPC="$SDK/src/game/server/server_hl2mp.vpc"
--HL2MP_CLIENT="$SDK/src/game/server/hl2mp/hl2mp_client.cpp"
--HL2MP_CLIENTMODE="$SDK/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp"
--
--perl -0pi -e 's/^.*hl2mp\\openvibe_client\.cpp.*\n//mg; s/^.*hl2mp\\vgui_openvibe_menu\.cpp.*\n//mg; s/(\$File\s+"hl2mp\\clientmode_hl2mpnormal\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_client.cpp"\n\t\t\t\$File\t"hl2mp\\vgui_openvibe_menu.cpp"\n/s' "$CLIENT_VPC"
--echo "[openvibe-sdk] patched client_hl2mp.vpc"
--
--perl -0pi -e 's/^.*hl2mp\\openvibe_server\.cpp.*\n//mg; s/(\$File\s+"hl2mp\\hl2mp_player\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_server.cpp"\n/s' "$SERVER_VPC"
--echo "[openvibe-sdk] patched server_hl2mp.vpc"
--
--if ! grep -q 'OpenVibe_OnClientActive' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a void OpenVibe_OnClientActive( CHL2MP_Player *pPlayer );' "$HL2MP_CLIENT"
-- sed -i '/FinishClientPutInServer( pPlayer );/a \tOpenVibe_OnClientActive( pPlayer );' "$HL2MP_CLIENT"
-- echo "[openvibe-sdk] patched hl2mp_client.cpp arrival hook"
--fi
--
--perl -0pi -e 's/[^\S\r\n]*\x0boid OpenVibe_OnClientActive/void OpenVibe_OnClientActive/g; s/\\tOpenVibe_OnClientActive/\tOpenVibe_OnClientActive/g; s/^[ \t]*void OpenVibe_OnClientActive/void OpenVibe_OnClientActive/m' "$HL2MP_CLIENT"
--
--if ! grep -q 'OpenVibe_OnClientModeInit' "$HL2MP_CLIENTMODE"; then
-- sed -i '/#include "ienginevgui.h"/a void OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- sed -i '/BaseClass::Init();/a \ OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- echo "[openvibe-sdk] patched clientmode_hl2mpnormal.cpp OpenVibe menu hook"
--fi
--
--perl -0pi -e 's/^[ \t]*tOpenVibe_OnClientModeInit\(\);/ OpenVibe_OnClientModeInit();/m' "$HL2MP_CLIENTMODE"
--
--GAMEINTERFACE="$SDK/src/game/server/gameinterface.cpp"
--HL2MP_PLAYER="$SDK/src/game/server/hl2mp/hl2mp_player.cpp"
--
--if [[ -f "$GAMEINTERFACE" ]]; then
-- if ! grep -q 'OpenVibe_OnFrame' "$GAMEINTERFACE"; then
-- sed -i '/CServerGameDLL::GameFrame/i #ifdef HL2MP\nvoid OpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- sed -i '/VPROF( "CServerGameDLL::GameFrame" );/a #ifdef HL2MP\n\tOpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp frame hook"
-- fi
--
-- if ! grep -q 'OpenVibe_OnClientDisconnect' "$GAMEINTERFACE"; then
-- perl -pi -e 's/void CServerGameClients::ClientDisconnect/#ifdef HL2MP\nvoid OpenVibe_OnClientDisconnect( CBasePlayer *pPlayer );\n#endif\nvoid CServerGameClients::ClientDisconnect/' "$GAMEINTERFACE"
-- perl -0777 -pi -e 's/(void CServerGameClients::ClientDisconnect\( edict_t \*pEdict \)\s*\{\s*extern bool\s+g_fGameOver;\s*CBasePlayer \*player = \( CBasePlayer \* \)CBaseEntity::Instance\( pEdict \);)/$1\n#ifdef HL2MP\n\tif ( player ) { OpenVibe_OnClientDisconnect( player ); }\n#endif/g' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp disconnect hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_PLAYER" ]]; then
-- if ! grep -q 'OpenVibe_OnPlayerDeath' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Event_Killed/i void OpenVibe_OnPlayerDeath( CHL2MP_Player *pPlayer, CBaseEntity *pKiller );' "$HL2MP_PLAYER"
-- sed -i '/CTakeDamageInfo subinfo = info;/i \ OpenVibe_OnPlayerDeath( this, info.GetAttacker() );' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp death hook"
-- fi
--fi
--
--echo "[openvibe-sdk] Source SDK OpenVibe patch applied"
ddiff --git a/tools/apply-openvibe-sdk.sh.bak.20260628-200255 b/tools/apply-openvibe-sdk.sh.bak.20260628-200255
ddeleted file mode 100755
iindex d2e7a5c..0000000
---- a/tools/apply-openvibe-sdk.sh.bak.20260628-200255
++++ /dev/null
@@@ -1,173 +0,0 @@
--#!/usr/bin/env bash
--set -euo pipefail
--
--ROOT="${OPENVIBE_ROOT:-$HOME/src/openvibe-source}"
--SDK="${OPENVIBE_SDK:-$ROOT/engine/source-sdk-2013}"
--
--if [[ ! -d "$SDK/src/game/client/hl2mp" || ! -d "$SDK/src/game/server/hl2mp" ]]; then
-- echo "Source SDK 2013 checkout not found at $SDK" >&2
-- echo "Set OPENVIBE_SDK=/path/to/source-sdk-2013 if it lives elsewhere." >&2
-- exit 1
--fi
--
--copy_file() {
-- local src="$1"
-- local dst="$2"
-- install -D -m 0644 "$src" "$dst"
-- echo "[openvibe-sdk] copied ${dst#$SDK/}"
--}
--
--copy_tree() {
-- local src="$1"
-- local dst="$2"
-- mkdir -p "$dst"
-- rsync -a --delete "$src/" "$dst/"
-- echo "[openvibe-sdk] copied tree ${dst#$SDK/}"
--}
--
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/openvibe_client.cpp" \
-- "$SDK/src/game/client/hl2mp/openvibe_client.cpp"
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/vgui_openvibe_menu.cpp" \
-- "$SDK/src/game/client/hl2mp/vgui_openvibe_menu.cpp"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_server.cpp"
--
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_runtime.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_runtime.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_runtime.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_runtime.cpp"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_bindings.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_bindings.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_bindings.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_bindings.cpp"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_player.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_player.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_player.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_player.cpp"
--
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_js_server.h" \
-- "$SDK/src/game/server/hl2mp/openvibe_js_server.h"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_js_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_js_server.cpp"
--
--copy_tree "$ROOT/sdk/openvibe/third_party/quickjs" \
-- "$SDK/src/game/shared/openvibe/third_party/quickjs"
--
--QJS_C="$SDK/src/game/shared/openvibe/third_party/quickjs/quickjs.c"
--if [[ -f "$QJS_C" ]] && ! grep -q 'OPENVIBE_QUICKJS_CONFIG' "$QJS_C"; then
-- tmp="$(mktemp)"
-- cat > "$tmp" <<'QCFG'
--#ifndef OPENVIBE_QUICKJS_CONFIG
--#define OPENVIBE_QUICKJS_CONFIG
--#ifndef _GNU_SOURCE
--#define _GNU_SOURCE
--#endif
--#ifndef CONFIG_VERSION
--#define CONFIG_VERSION "openvibe"
--#endif
--#endif
--
--QCFG
-- cat "$QJS_C" >> "$tmp"
-- mv "$tmp" "$QJS_C"
--fi
--
--CLIENT_VPC="$SDK/src/game/client/client_hl2mp.vpc"
--SERVER_VPC="$SDK/src/game/server/server_hl2mp.vpc"
--HL2MP_CLIENT="$SDK/src/game/server/hl2mp/hl2mp_client.cpp"
--HL2MP_CLIENTMODE="$SDK/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp"
--GAMEINTERFACE="$SDK/src/game/server/gameinterface.cpp"
--HL2MP_PLAYER="$SDK/src/game/server/hl2mp/hl2mp_player.cpp"
--
--perl -0pi -e 's/^.*hl2mp\\openvibe_client\.cpp.*\n//mg; s/^.*hl2mp\\vgui_openvibe_menu\.cpp.*\n//mg; s/(\$File\s+"hl2mp\\clientmode_hl2mpnormal\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_client.cpp"\n\t\t\t\$File\t"hl2mp\\vgui_openvibe_menu.cpp"\n/s' "$CLIENT_VPC"
--echo "[openvibe-sdk] patched client_hl2mp.vpc"
--
--perl -0pi -e '
-- s/^.*hl2mp\\openvibe_server\.cpp.*\n//mg;
-- s/^.*hl2mp\\openvibe_js_server\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_runtime\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_bindings\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_player\.cpp.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\quickjs\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libregexp\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libunicode\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\cutils\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\dtoa\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libbf\.c.*\n//mg;
-- s/(\$File\s+"hl2mp\\hl2mp_player\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_server.cpp"\n\t\t\t\$File\t"hl2mp\\openvibe_js_server.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_runtime.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_bindings.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_player.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\quickjs.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\libregexp.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\libunicode.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\cutils.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\dtoa.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\libbf.c"\n/s;
--' "$SERVER_VPC"
--echo "[openvibe-sdk] patched server_hl2mp.vpc"
--
--if ! grep -q 'OpenVibe_OnClientActive' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a void OpenVibe_OnClientActive( CHL2MP_Player *pPlayer );' "$HL2MP_CLIENT"
-- sed -i '/FinishClientPutInServer( pPlayer );/a \ OpenVibe_OnClientActive( pPlayer );' "$HL2MP_CLIENT"
-- echo "[openvibe-sdk] patched hl2mp_client.cpp arrival hook"
--fi
--
--perl -0pi -e 's/[^\S\r\n]*\x0boid OpenVibe_OnClientActive/void OpenVibe_OnClientActive/g; s/\\tOpenVibe_OnClientActive/\tOpenVibe_OnClientActive/g; s/^[ \t]*void OpenVibe_OnClientActive/void OpenVibe_OnClientActive/m' "$HL2MP_CLIENT"
--
--if ! grep -q 'OpenVibe_OnClientModeInit' "$HL2MP_CLIENTMODE"; then
-- sed -i '/#include "ienginevgui.h"/a void OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- sed -i '/BaseClass::Init();/a \ OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- echo "[openvibe-sdk] patched clientmode_hl2mpnormal.cpp OpenVibe menu hook"
--fi
--
--perl -0pi -e 's/^[ \t]*tOpenVibe_OnClientModeInit\(\);/ OpenVibe_OnClientModeInit();/m' "$HL2MP_CLIENTMODE"
--
--if [[ -f "$GAMEINTERFACE" ]]; then
-- if ! grep -q 'OpenVibe_OnFrame' "$GAMEINTERFACE"; then
-- sed -i '/CServerGameDLL::GameFrame/i #ifdef HL2MP\nvoid OpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- sed -i '/VPROF( "CServerGameDLL::GameFrame" );/a #ifdef HL2MP\n\tOpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp frame hook"
-- fi
--
-- if ! grep -q 'OpenVibe_OnClientDisconnect' "$GAMEINTERFACE"; then
-- perl -pi -e 's/void CServerGameClients::ClientDisconnect/#ifdef HL2MP\nvoid OpenVibe_OnClientDisconnect( CBasePlayer *pPlayer );\n#endif\nvoid CServerGameClients::ClientDisconnect/' "$GAMEINTERFACE"
-- perl -0777 -pi -e 's/(void CServerGameClients::ClientDisconnect\( edict_t \*pEdict \)\s*\{\s*extern bool\s+g_fGameOver;\s*CBasePlayer \*player = \( CBasePlayer \* \)CBaseEntity::Instance\( pEdict \);)/$1\n#ifdef HL2MP\n\tif ( player ) { OpenVibe_OnClientDisconnect( player ); }\n#endif/g' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp disconnect hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_PLAYER" ]]; then
-- if ! grep -q 'OpenVibe_OnPlayerDeath' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Event_Killed/i void OpenVibe_OnPlayerDeath( CHL2MP_Player *pPlayer, CBaseEntity *pKiller );' "$HL2MP_PLAYER"
-- sed -i '/CTakeDamageInfo subinfo = info;/i \ OpenVibe_OnPlayerDeath( this, info.GetAttacker() );' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp death hook"
-- fi
--
-- if ! grep -q 'OpenVibeJS_Server_PlayerSpawn' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Spawn/i void OpenVibeJS_Server_PlayerSpawn( CHL2MP_Player *pPlayer );' "$HL2MP_PLAYER"
-- sed -i '0,/BaseClass::Spawn();/s//BaseClass::Spawn();\n\tOpenVibeJS_Server_PlayerSpawn( this );/' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp spawn hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_CLIENT" ]] && ! grep -q 'OpenVibeJS_Server_PlayerSay' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a bool OpenVibeJS_Server_PlayerSay( CHL2MP_Player *pPlayer, const char *pszText );' "$HL2MP_CLIENT"
-- python3 - "$HL2MP_CLIENT" <<'PY'
--from pathlib import Path
--import re, sys
--
--p = Path(sys.argv[1])
--s = p.read_text()
--
--# Best-effort patch for common Source SDK 2013 HL2MP Host_Say shape:
--# CHL2MP_Player *client = ...
--# const char *p = args.ArgS();
--if "OpenVibeJS_Server_PlayerSay( client," not in s:
-- s2 = re.sub(
-- r'(const char \*p\s*=\s*args\.ArgS\(\);\s*)',
-- r'\1\n\tif ( client && OpenVibeJS_Server_PlayerSay( client, p ) )\n\t\treturn;\n',
-- s,
-- count=1,
-- )
-- if s2 != s:
-- s = s2
-- print("[openvibe-sdk] patched hl2mp_client.cpp PlayerSay hook")
-- else:
-- print("[openvibe-sdk] WARNING: could not auto-patch Host_Say PlayerSay body")
--p.write_text(s)
--PY
--fi
--
--echo "[openvibe-sdk] Source SDK OpenVibe patch applied"
ddiff --git a/tools/apply-openvibe-sdk.sh.bak.20260628-200636 b/tools/apply-openvibe-sdk.sh.bak.20260628-200636
ddeleted file mode 100755
iindex d5007d6..0000000
---- a/tools/apply-openvibe-sdk.sh.bak.20260628-200636
++++ /dev/null
@@@ -1,173 +0,0 @@
--#!/usr/bin/env bash
--set -euo pipefail
--
--ROOT="${OPENVIBE_ROOT:-$HOME/src/openvibe-source}"
--SDK="${OPENVIBE_SDK:-$ROOT/engine/source-sdk-2013}"
--
--if [[ ! -d "$SDK/src/game/client/hl2mp" || ! -d "$SDK/src/game/server/hl2mp" ]]; then
-- echo "Source SDK 2013 checkout not found at $SDK" >&2
-- echo "Set OPENVIBE_SDK=/path/to/source-sdk-2013 if it lives elsewhere." >&2
-- exit 1
--fi
--
--copy_file() {
-- local src="$1"
-- local dst="$2"
-- install -D -m 0644 "$src" "$dst"
-- echo "[openvibe-sdk] copied ${dst#$SDK/}"
--}
--
--copy_tree() {
-- local src="$1"
-- local dst="$2"
-- mkdir -p "$dst"
-- rsync -a --delete "$src/" "$dst/"
-- echo "[openvibe-sdk] copied tree ${dst#$SDK/}"
--}
--
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/openvibe_client.cpp" \
-- "$SDK/src/game/client/hl2mp/openvibe_client.cpp"
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/vgui_openvibe_menu.cpp" \
-- "$SDK/src/game/client/hl2mp/vgui_openvibe_menu.cpp"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_server.cpp"
--
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_runtime.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_runtime.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_runtime.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_runtime.cpp"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_bindings.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_bindings.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_bindings.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_bindings.cpp"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_player.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_player.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_player.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_player.cpp"
--
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_js_server.h" \
-- "$SDK/src/game/server/hl2mp/openvibe_js_server.h"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_js_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_js_server.cpp"
--
--copy_tree "$ROOT/sdk/openvibe/third_party/quickjs" \
-- "$SDK/src/game/shared/openvibe/third_party/quickjs"
--
--QJS_C="$SDK/src/game/shared/openvibe/third_party/quickjs/quickjs.c"
--if [[ -f "$QJS_C" ]] && ! grep -q 'OPENVIBE_QUICKJS_CONFIG' "$QJS_C"; then
-- tmp="$(mktemp)"
-- cat > "$tmp" <<'QCFG'
--#ifndef OPENVIBE_QUICKJS_CONFIG
--#define OPENVIBE_QUICKJS_CONFIG
--#ifndef _GNU_SOURCE
--#define _GNU_SOURCE
--#endif
--#ifndef CONFIG_VERSION
--#define CONFIG_VERSION "openvibe"
--#endif
--#endif
--
--QCFG
-- cat "$QJS_C" >> "$tmp"
-- mv "$tmp" "$QJS_C"
--fi
--
--CLIENT_VPC="$SDK/src/game/client/client_hl2mp.vpc"
--SERVER_VPC="$SDK/src/game/server/server_hl2mp.vpc"
--HL2MP_CLIENT="$SDK/src/game/server/hl2mp/hl2mp_client.cpp"
--HL2MP_CLIENTMODE="$SDK/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp"
--GAMEINTERFACE="$SDK/src/game/server/gameinterface.cpp"
--HL2MP_PLAYER="$SDK/src/game/server/hl2mp/hl2mp_player.cpp"
--
--perl -0pi -e 's/^.*hl2mp\\openvibe_client\.cpp.*\n//mg; s/^.*hl2mp\\vgui_openvibe_menu\.cpp.*\n//mg; s/(\$File\s+"hl2mp\\clientmode_hl2mpnormal\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_client.cpp"\n\t\t\t\$File\t"hl2mp\\vgui_openvibe_menu.cpp"\n/s' "$CLIENT_VPC"
--echo "[openvibe-sdk] patched client_hl2mp.vpc"
--
--perl -0pi -e '
-- s/^.*hl2mp\\openvibe_server\.cpp.*\n//mg;
-- s/^.*hl2mp\\openvibe_js_server\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_runtime\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_bindings\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_player\.cpp.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\quickjs\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libregexp\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libunicode\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\cutils\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\dtoa\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libbf\.c.*\n//mg;
-- s/(\$File\s+"hl2mp\\hl2mp_player\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_server.cpp"\n\t\t\t\$File\t"hl2mp\\openvibe_js_server.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_runtime.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_bindings.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_player.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\quickjs.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\libregexp.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\libunicode.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\cutils.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\dtoa.c"\n/s;
--' "$SERVER_VPC"
--echo "[openvibe-sdk] patched server_hl2mp.vpc"
--
--if ! grep -q 'OpenVibe_OnClientActive' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a void OpenVibe_OnClientActive( CHL2MP_Player *pPlayer );' "$HL2MP_CLIENT"
-- sed -i '/FinishClientPutInServer( pPlayer );/a \ OpenVibe_OnClientActive( pPlayer );' "$HL2MP_CLIENT"
-- echo "[openvibe-sdk] patched hl2mp_client.cpp arrival hook"
--fi
--
--perl -0pi -e 's/[^\S\r\n]*\x0boid OpenVibe_OnClientActive/void OpenVibe_OnClientActive/g; s/\\tOpenVibe_OnClientActive/\tOpenVibe_OnClientActive/g; s/^[ \t]*void OpenVibe_OnClientActive/void OpenVibe_OnClientActive/m' "$HL2MP_CLIENT"
--
--if ! grep -q 'OpenVibe_OnClientModeInit' "$HL2MP_CLIENTMODE"; then
-- sed -i '/#include "ienginevgui.h"/a void OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- sed -i '/BaseClass::Init();/a \ OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- echo "[openvibe-sdk] patched clientmode_hl2mpnormal.cpp OpenVibe menu hook"
--fi
--
--perl -0pi -e 's/^[ \t]*tOpenVibe_OnClientModeInit\(\);/ OpenVibe_OnClientModeInit();/m' "$HL2MP_CLIENTMODE"
--
--if [[ -f "$GAMEINTERFACE" ]]; then
-- if ! grep -q 'OpenVibe_OnFrame' "$GAMEINTERFACE"; then
-- sed -i '/CServerGameDLL::GameFrame/i #ifdef HL2MP\nvoid OpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- sed -i '/VPROF( "CServerGameDLL::GameFrame" );/a #ifdef HL2MP\n\tOpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp frame hook"
-- fi
--
-- if ! grep -q 'OpenVibe_OnClientDisconnect' "$GAMEINTERFACE"; then
-- perl -pi -e 's/void CServerGameClients::ClientDisconnect/#ifdef HL2MP\nvoid OpenVibe_OnClientDisconnect( CBasePlayer *pPlayer );\n#endif\nvoid CServerGameClients::ClientDisconnect/' "$GAMEINTERFACE"
-- perl -0777 -pi -e 's/(void CServerGameClients::ClientDisconnect\( edict_t \*pEdict \)\s*\{\s*extern bool\s+g_fGameOver;\s*CBasePlayer \*player = \( CBasePlayer \* \)CBaseEntity::Instance\( pEdict \);)/$1\n#ifdef HL2MP\n\tif ( player ) { OpenVibe_OnClientDisconnect( player ); }\n#endif/g' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp disconnect hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_PLAYER" ]]; then
-- if ! grep -q 'OpenVibe_OnPlayerDeath' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Event_Killed/i void OpenVibe_OnPlayerDeath( CHL2MP_Player *pPlayer, CBaseEntity *pKiller );' "$HL2MP_PLAYER"
-- sed -i '/CTakeDamageInfo subinfo = info;/i \ OpenVibe_OnPlayerDeath( this, info.GetAttacker() );' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp death hook"
-- fi
--
-- if ! grep -q 'OpenVibeJS_Server_PlayerSpawn' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Spawn/i void OpenVibeJS_Server_PlayerSpawn( CHL2MP_Player *pPlayer );' "$HL2MP_PLAYER"
-- sed -i '0,/BaseClass::Spawn();/s//BaseClass::Spawn();\n\tOpenVibeJS_Server_PlayerSpawn( this );/' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp spawn hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_CLIENT" ]] && ! grep -q 'OpenVibeJS_Server_PlayerSay' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a bool OpenVibeJS_Server_PlayerSay( CHL2MP_Player *pPlayer, const char *pszText );' "$HL2MP_CLIENT"
-- python3 - "$HL2MP_CLIENT" <<'PY'
--from pathlib import Path
--import re, sys
--
--p = Path(sys.argv[1])
--s = p.read_text()
--
--# Best-effort patch for common Source SDK 2013 HL2MP Host_Say shape:
--# CHL2MP_Player *client = ...
--# const char *p = args.ArgS();
--if "OpenVibeJS_Server_PlayerSay( client," not in s:
-- s2 = re.sub(
-- r'(const char \*p\s*=\s*args\.ArgS\(\);\s*)',
-- r'\1\n\tif ( client && OpenVibeJS_Server_PlayerSay( client, p ) )\n\t\treturn;\n',
-- s,
-- count=1,
-- )
-- if s2 != s:
-- s = s2
-- print("[openvibe-sdk] patched hl2mp_client.cpp PlayerSay hook")
-- else:
-- print("[openvibe-sdk] WARNING: could not auto-patch Host_Say PlayerSay body")
--p.write_text(s)
--PY
--fi
--
--echo "[openvibe-sdk] Source SDK OpenVibe patch applied"
ddiff --git a/tools/apply-openvibe-sdk.sh.bak.20260628-202430 b/tools/apply-openvibe-sdk.sh.bak.20260628-202430
ddeleted file mode 100755
iindex d5007d6..0000000
---- a/tools/apply-openvibe-sdk.sh.bak.20260628-202430
++++ /dev/null
@@@ -1,173 +0,0 @@
--#!/usr/bin/env bash
--set -euo pipefail
--
--ROOT="${OPENVIBE_ROOT:-$HOME/src/openvibe-source}"
--SDK="${OPENVIBE_SDK:-$ROOT/engine/source-sdk-2013}"
--
--if [[ ! -d "$SDK/src/game/client/hl2mp" || ! -d "$SDK/src/game/server/hl2mp" ]]; then
-- echo "Source SDK 2013 checkout not found at $SDK" >&2
-- echo "Set OPENVIBE_SDK=/path/to/source-sdk-2013 if it lives elsewhere." >&2
-- exit 1
--fi
--
--copy_file() {
-- local src="$1"
-- local dst="$2"
-- install -D -m 0644 "$src" "$dst"
-- echo "[openvibe-sdk] copied ${dst#$SDK/}"
--}
--
--copy_tree() {
-- local src="$1"
-- local dst="$2"
-- mkdir -p "$dst"
-- rsync -a --delete "$src/" "$dst/"
-- echo "[openvibe-sdk] copied tree ${dst#$SDK/}"
--}
--
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/openvibe_client.cpp" \
-- "$SDK/src/game/client/hl2mp/openvibe_client.cpp"
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/vgui_openvibe_menu.cpp" \
-- "$SDK/src/game/client/hl2mp/vgui_openvibe_menu.cpp"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_server.cpp"
--
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_runtime.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_runtime.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_runtime.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_runtime.cpp"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_bindings.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_bindings.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_bindings.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_bindings.cpp"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_player.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_player.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_player.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_player.cpp"
--
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_js_server.h" \
-- "$SDK/src/game/server/hl2mp/openvibe_js_server.h"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_js_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_js_server.cpp"
--
--copy_tree "$ROOT/sdk/openvibe/third_party/quickjs" \
-- "$SDK/src/game/shared/openvibe/third_party/quickjs"
--
--QJS_C="$SDK/src/game/shared/openvibe/third_party/quickjs/quickjs.c"
--if [[ -f "$QJS_C" ]] && ! grep -q 'OPENVIBE_QUICKJS_CONFIG' "$QJS_C"; then
-- tmp="$(mktemp)"
-- cat > "$tmp" <<'QCFG'
--#ifndef OPENVIBE_QUICKJS_CONFIG
--#define OPENVIBE_QUICKJS_CONFIG
--#ifndef _GNU_SOURCE
--#define _GNU_SOURCE
--#endif
--#ifndef CONFIG_VERSION
--#define CONFIG_VERSION "openvibe"
--#endif
--#endif
--
--QCFG
-- cat "$QJS_C" >> "$tmp"
-- mv "$tmp" "$QJS_C"
--fi
--
--CLIENT_VPC="$SDK/src/game/client/client_hl2mp.vpc"
--SERVER_VPC="$SDK/src/game/server/server_hl2mp.vpc"
--HL2MP_CLIENT="$SDK/src/game/server/hl2mp/hl2mp_client.cpp"
--HL2MP_CLIENTMODE="$SDK/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp"
--GAMEINTERFACE="$SDK/src/game/server/gameinterface.cpp"
--HL2MP_PLAYER="$SDK/src/game/server/hl2mp/hl2mp_player.cpp"
--
--perl -0pi -e 's/^.*hl2mp\\openvibe_client\.cpp.*\n//mg; s/^.*hl2mp\\vgui_openvibe_menu\.cpp.*\n//mg; s/(\$File\s+"hl2mp\\clientmode_hl2mpnormal\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_client.cpp"\n\t\t\t\$File\t"hl2mp\\vgui_openvibe_menu.cpp"\n/s' "$CLIENT_VPC"
--echo "[openvibe-sdk] patched client_hl2mp.vpc"
--
--perl -0pi -e '
-- s/^.*hl2mp\\openvibe_server\.cpp.*\n//mg;
-- s/^.*hl2mp\\openvibe_js_server\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_runtime\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_bindings\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_player\.cpp.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\quickjs\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libregexp\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libunicode\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\cutils\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\dtoa\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libbf\.c.*\n//mg;
-- s/(\$File\s+"hl2mp\\hl2mp_player\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_server.cpp"\n\t\t\t\$File\t"hl2mp\\openvibe_js_server.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_runtime.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_bindings.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_player.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\quickjs.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\libregexp.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\libunicode.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\cutils.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\dtoa.c"\n/s;
--' "$SERVER_VPC"
--echo "[openvibe-sdk] patched server_hl2mp.vpc"
--
--if ! grep -q 'OpenVibe_OnClientActive' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a void OpenVibe_OnClientActive( CHL2MP_Player *pPlayer );' "$HL2MP_CLIENT"
-- sed -i '/FinishClientPutInServer( pPlayer );/a \ OpenVibe_OnClientActive( pPlayer );' "$HL2MP_CLIENT"
-- echo "[openvibe-sdk] patched hl2mp_client.cpp arrival hook"
--fi
--
--perl -0pi -e 's/[^\S\r\n]*\x0boid OpenVibe_OnClientActive/void OpenVibe_OnClientActive/g; s/\\tOpenVibe_OnClientActive/\tOpenVibe_OnClientActive/g; s/^[ \t]*void OpenVibe_OnClientActive/void OpenVibe_OnClientActive/m' "$HL2MP_CLIENT"
--
--if ! grep -q 'OpenVibe_OnClientModeInit' "$HL2MP_CLIENTMODE"; then
-- sed -i '/#include "ienginevgui.h"/a void OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- sed -i '/BaseClass::Init();/a \ OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- echo "[openvibe-sdk] patched clientmode_hl2mpnormal.cpp OpenVibe menu hook"
--fi
--
--perl -0pi -e 's/^[ \t]*tOpenVibe_OnClientModeInit\(\);/ OpenVibe_OnClientModeInit();/m' "$HL2MP_CLIENTMODE"
--
--if [[ -f "$GAMEINTERFACE" ]]; then
-- if ! grep -q 'OpenVibe_OnFrame' "$GAMEINTERFACE"; then
-- sed -i '/CServerGameDLL::GameFrame/i #ifdef HL2MP\nvoid OpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- sed -i '/VPROF( "CServerGameDLL::GameFrame" );/a #ifdef HL2MP\n\tOpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp frame hook"
-- fi
--
-- if ! grep -q 'OpenVibe_OnClientDisconnect' "$GAMEINTERFACE"; then
-- perl -pi -e 's/void CServerGameClients::ClientDisconnect/#ifdef HL2MP\nvoid OpenVibe_OnClientDisconnect( CBasePlayer *pPlayer );\n#endif\nvoid CServerGameClients::ClientDisconnect/' "$GAMEINTERFACE"
-- perl -0777 -pi -e 's/(void CServerGameClients::ClientDisconnect\( edict_t \*pEdict \)\s*\{\s*extern bool\s+g_fGameOver;\s*CBasePlayer \*player = \( CBasePlayer \* \)CBaseEntity::Instance\( pEdict \);)/$1\n#ifdef HL2MP\n\tif ( player ) { OpenVibe_OnClientDisconnect( player ); }\n#endif/g' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp disconnect hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_PLAYER" ]]; then
-- if ! grep -q 'OpenVibe_OnPlayerDeath' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Event_Killed/i void OpenVibe_OnPlayerDeath( CHL2MP_Player *pPlayer, CBaseEntity *pKiller );' "$HL2MP_PLAYER"
-- sed -i '/CTakeDamageInfo subinfo = info;/i \ OpenVibe_OnPlayerDeath( this, info.GetAttacker() );' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp death hook"
-- fi
--
-- if ! grep -q 'OpenVibeJS_Server_PlayerSpawn' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Spawn/i void OpenVibeJS_Server_PlayerSpawn( CHL2MP_Player *pPlayer );' "$HL2MP_PLAYER"
-- sed -i '0,/BaseClass::Spawn();/s//BaseClass::Spawn();\n\tOpenVibeJS_Server_PlayerSpawn( this );/' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp spawn hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_CLIENT" ]] && ! grep -q 'OpenVibeJS_Server_PlayerSay' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a bool OpenVibeJS_Server_PlayerSay( CHL2MP_Player *pPlayer, const char *pszText );' "$HL2MP_CLIENT"
-- python3 - "$HL2MP_CLIENT" <<'PY'
--from pathlib import Path
--import re, sys
--
--p = Path(sys.argv[1])
--s = p.read_text()
--
--# Best-effort patch for common Source SDK 2013 HL2MP Host_Say shape:
--# CHL2MP_Player *client = ...
--# const char *p = args.ArgS();
--if "OpenVibeJS_Server_PlayerSay( client," not in s:
-- s2 = re.sub(
-- r'(const char \*p\s*=\s*args\.ArgS\(\);\s*)',
-- r'\1\n\tif ( client && OpenVibeJS_Server_PlayerSay( client, p ) )\n\t\treturn;\n',
-- s,
-- count=1,
-- )
-- if s2 != s:
-- s = s2
-- print("[openvibe-sdk] patched hl2mp_client.cpp PlayerSay hook")
-- else:
-- print("[openvibe-sdk] WARNING: could not auto-patch Host_Say PlayerSay body")
--p.write_text(s)
--PY
--fi
--
--echo "[openvibe-sdk] Source SDK OpenVibe patch applied"
ddiff --git a/tools/apply-openvibe-sdk.sh.bak.20260628-202702 b/tools/apply-openvibe-sdk.sh.bak.20260628-202702
ddeleted file mode 100755
iindex cff52fc..0000000
---- a/tools/apply-openvibe-sdk.sh.bak.20260628-202702
++++ /dev/null
@@@ -1,214 +0,0 @@
--#!/usr/bin/env bash
--set -euo pipefail
--
--ROOT="${OPENVIBE_ROOT:-$HOME/src/openvibe-source}"
--SDK="${OPENVIBE_SDK:-$ROOT/engine/source-sdk-2013}"
--
--if [[ ! -d "$SDK/src/game/client/hl2mp" || ! -d "$SDK/src/game/server/hl2mp" ]]; then
-- echo "Source SDK 2013 checkout not found at $SDK" >&2
-- echo "Set OPENVIBE_SDK=/path/to/source-sdk-2013 if it lives elsewhere." >&2
-- exit 1
--fi
--
--copy_file() {
-- local src="$1"
-- local dst="$2"
-- install -D -m 0644 "$src" "$dst"
-- echo "[openvibe-sdk] copied ${dst#$SDK/}"
--}
--
--copy_tree() {
-- local src="$1"
-- local dst="$2"
-- mkdir -p "$dst"
-- rsync -a --delete "$src/" "$dst/"
-- echo "[openvibe-sdk] copied tree ${dst#$SDK/}"
--}
--
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/openvibe_client.cpp" \
-- "$SDK/src/game/client/hl2mp/openvibe_client.cpp"
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/vgui_openvibe_menu.cpp" \
-- "$SDK/src/game/client/hl2mp/vgui_openvibe_menu.cpp"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_server.cpp"
--
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_runtime.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_runtime.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_runtime.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_runtime.cpp"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_bindings.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_bindings.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_bindings.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_bindings.cpp"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_player.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_player.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_player.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_player.cpp"
--
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_js_server.h" \
-- "$SDK/src/game/server/hl2mp/openvibe_js_server.h"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_js_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_js_server.cpp"
--
--copy_tree "$ROOT/sdk/openvibe/third_party/quickjs" \
-- "$SDK/src/game/shared/openvibe/third_party/quickjs"
--
--QJS_C="$SDK/src/game/shared/openvibe/third_party/quickjs/quickjs.c"
--if [[ -f "$QJS_C" ]] && ! grep -q 'OPENVIBE_QUICKJS_CONFIG' "$QJS_C"; then
-- tmp="$(mktemp)"
-- cat > "$tmp" <<'QCFG'
--#ifndef OPENVIBE_QUICKJS_CONFIG
--#define OPENVIBE_QUICKJS_CONFIG
--#ifndef _GNU_SOURCE
--#define _GNU_SOURCE
--#endif
--#ifndef CONFIG_VERSION
--#define CONFIG_VERSION "openvibe"
--#endif
--#endif
--
--QCFG
-- cat "$QJS_C" >> "$tmp"
-- mv "$tmp" "$QJS_C"
--fi
--
--CLIENT_VPC="$SDK/src/game/client/client_hl2mp.vpc"
--SERVER_VPC="$SDK/src/game/server/server_hl2mp.vpc"
--HL2MP_CLIENT="$SDK/src/game/server/hl2mp/hl2mp_client.cpp"
--HL2MP_CLIENTMODE="$SDK/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp"
--GAMEINTERFACE="$SDK/src/game/server/gameinterface.cpp"
--HL2MP_PLAYER="$SDK/src/game/server/hl2mp/hl2mp_player.cpp"
--
--perl -0pi -e 's/^.*hl2mp\\openvibe_client\.cpp.*\n//mg; s/^.*hl2mp\\vgui_openvibe_menu\.cpp.*\n//mg; s/(\$File\s+"hl2mp\\clientmode_hl2mpnormal\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_client.cpp"\n\t\t\t\$File\t"hl2mp\\vgui_openvibe_menu.cpp"\n/s' "$CLIENT_VPC"
--echo "[openvibe-sdk] patched client_hl2mp.vpc"
--
--perl -0pi -e '
-- s/^.*hl2mp\\openvibe_server\.cpp.*\n//mg;
-- s/^.*hl2mp\\openvibe_js_server\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_runtime\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_bindings\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_player\.cpp.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\quickjs\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libregexp\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libunicode\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\cutils\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\dtoa\.c.*\n//mg;
-- s/^.*openvibe\\third_party\\quickjs\\libbf\.c.*\n//mg;
-- s/(\$File\s+"hl2mp\\hl2mp_player\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_server.cpp"\n\t\t\t\$File\t"hl2mp\\openvibe_js_server.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_runtime.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_bindings.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_player.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\quickjs.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\libregexp.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\libunicode.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\cutils.c"\n\t\t\t\$File\t"..\\shared\\openvibe\\third_party\\quickjs\\dtoa.c"\n/s;
--' "$SERVER_VPC"
--echo "[openvibe-sdk] patched server_hl2mp.vpc"
--
--if ! grep -q 'OpenVibe_OnClientActive' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a void OpenVibe_OnClientActive( CHL2MP_Player *pPlayer );' "$HL2MP_CLIENT"
-- sed -i '/FinishClientPutInServer( pPlayer );/a \ OpenVibe_OnClientActive( pPlayer );' "$HL2MP_CLIENT"
-- echo "[openvibe-sdk] patched hl2mp_client.cpp arrival hook"
--fi
--
--perl -0pi -e 's/[^\S\r\n]*\x0boid OpenVibe_OnClientActive/void OpenVibe_OnClientActive/g; s/\\tOpenVibe_OnClientActive/\tOpenVibe_OnClientActive/g; s/^[ \t]*void OpenVibe_OnClientActive/void OpenVibe_OnClientActive/m' "$HL2MP_CLIENT"
--
--if ! grep -q 'OpenVibe_OnClientModeInit' "$HL2MP_CLIENTMODE"; then
-- sed -i '/#include "ienginevgui.h"/a void OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- sed -i '/BaseClass::Init();/a \ OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- echo "[openvibe-sdk] patched clientmode_hl2mpnormal.cpp OpenVibe menu hook"
--fi
--
--perl -0pi -e 's/^[ \t]*tOpenVibe_OnClientModeInit\(\);/ OpenVibe_OnClientModeInit();/m' "$HL2MP_CLIENTMODE"
--
--if [[ -f "$GAMEINTERFACE" ]]; then
-- if ! grep -q 'OpenVibe_OnFrame' "$GAMEINTERFACE"; then
-- sed -i '/CServerGameDLL::GameFrame/i #ifdef HL2MP\nvoid OpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- sed -i '/VPROF( "CServerGameDLL::GameFrame" );/a #ifdef HL2MP\n\tOpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp frame hook"
-- fi
--
-- if ! grep -q 'OpenVibe_OnClientDisconnect' "$GAMEINTERFACE"; then
-- perl -pi -e 's/void CServerGameClients::ClientDisconnect/#ifdef HL2MP\nvoid OpenVibe_OnClientDisconnect( CBasePlayer *pPlayer );\n#endif\nvoid CServerGameClients::ClientDisconnect/' "$GAMEINTERFACE"
-- perl -0777 -pi -e 's/(void CServerGameClients::ClientDisconnect\( edict_t \*pEdict \)\s*\{\s*extern bool\s+g_fGameOver;\s*CBasePlayer \*player = \( CBasePlayer \* \)CBaseEntity::Instance\( pEdict \);)/$1\n#ifdef HL2MP\n\tif ( player ) { OpenVibe_OnClientDisconnect( player ); }\n#endif/g' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp disconnect hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_PLAYER" ]]; then
-- if ! grep -q 'OpenVibe_OnPlayerDeath' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Event_Killed/i void OpenVibe_OnPlayerDeath( CHL2MP_Player *pPlayer, CBaseEntity *pKiller );' "$HL2MP_PLAYER"
-- sed -i '/CTakeDamageInfo subinfo = info;/i \ OpenVibe_OnPlayerDeath( this, info.GetAttacker() );' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp death hook"
-- fi
--
-- if ! grep -q 'OpenVibeJS_Server_PlayerSpawn' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Spawn/i void OpenVibeJS_Server_PlayerSpawn( CHL2MP_Player *pPlayer );' "$HL2MP_PLAYER"
-- sed -i '0,/BaseClass::Spawn();/s//BaseClass::Spawn();\n\tOpenVibeJS_Server_PlayerSpawn( this );/' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp spawn hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_CLIENT" ]] && ! grep -q 'OpenVibeJS_Server_PlayerSay' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a bool OpenVibeJS_Server_PlayerSay( CHL2MP_Player *pPlayer, const char *pszText );' "$HL2MP_CLIENT"
-- python3 - "$HL2MP_CLIENT" <<'PY'
--from pathlib import Path
--import re, sys
--
--p = Path(sys.argv[1])
--s = p.read_text()
--
--# Best-effort patch for common Source SDK 2013 HL2MP Host_Say shape:
--# CHL2MP_Player *client = ...
--# const char *p = args.ArgS();
--if "OpenVibeJS_Server_PlayerSay( client," not in s:
-- s2 = re.sub(
-- r'(const char \*p\s*=\s*args\.ArgS\(\);\s*)',
-- r'\1\n\tif ( client && OpenVibeJS_Server_PlayerSay( client, p ) )\n\t\treturn;\n',
-- s,
-- count=1,
-- )
-- if s2 != s:
-- s = s2
-- print("[openvibe-sdk] patched hl2mp_client.cpp PlayerSay hook")
-- else:
-- print("[openvibe-sdk] WARNING: could not auto-patch Host_Say PlayerSay body")
--p.write_text(s)
--PY
--fi
--
--
--# OPENVIBE_CONTINUE_QUICKJS_POSTPATCH
--patch_openvibe_quickjs_after_apply() {
-- local qjs_dir="$SDK/src/game/shared/openvibe/third_party/quickjs"
-- local qjs_c="$qjs_dir/quickjs.c"
--
-- if [[ -f "$qjs_c" ]] && ! grep -q 'OPENVIBE_QUICKJS_STRICT_C_SHIM' "$qjs_c"; then
-- local tmp
-- tmp="$(mktemp)"
-- cat > "$tmp" <<'QJS_SHIM'
--#ifndef OPENVIBE_QUICKJS_STRICT_C_SHIM
--#define OPENVIBE_QUICKJS_STRICT_C_SHIM
--
--#ifndef _GNU_SOURCE
--#define _GNU_SOURCE
--#endif
--
--#ifndef CONFIG_VERSION
--#define CONFIG_VERSION "openvibe"
--#endif
--
--#if defined(__GNUC__) && !defined(__cplusplus) && defined(__STRICT_ANSI__) && !defined(asm)
--#define asm __asm__
--#endif
--
--#endif
--
--QJS_SHIM
-- cat "$qjs_c" >> "$tmp"
-- mv "$tmp" "$qjs_c"
-- echo "[openvibe-sdk] patched QuickJS strict-C shim"
-- fi
--
-- if [[ ! -f "$qjs_dir/libbf.c" ]]; then
-- perl -0pi -e 's/^.*openvibe\\\\third_party\\\\quickjs\\\\libbf\.c.*\n//mg; s/^.*openvibe\\third_party\\quickjs\\libbf\.c.*\n//mg' "$SERVER_VPC" || true
-- echo "[openvibe-sdk] libbf.c missing; removed libbf.c from server_hl2mp.vpc"
-- fi
--}
--
--patch_openvibe_quickjs_after_apply
--
--echo "[openvibe-sdk] Source SDK OpenVibe patch applied"
ddiff --git a/tools/apply-openvibe-sdk.sh.bak.20260628-202731 b/tools/apply-openvibe-sdk.sh.bak.20260628-202731
ddeleted file mode 100755
iindex 9e835bf..0000000
---- a/tools/apply-openvibe-sdk.sh.bak.20260628-202731
++++ /dev/null
@@@ -1,217 +0,0 @@
--#!/usr/bin/env bash
--set -euo pipefail
--
--ROOT="${OPENVIBE_ROOT:-$HOME/src/openvibe-source}"
--SDK="${OPENVIBE_SDK:-$ROOT/engine/source-sdk-2013}"
--
--if [[ ! -d "$SDK/src/game/client/hl2mp" || ! -d "$SDK/src/game/server/hl2mp" ]]; then
-- echo "Source SDK 2013 checkout not found at $SDK" >&2
-- echo "Set OPENVIBE_SDK=/path/to/source-sdk-2013 if it lives elsewhere." >&2
-- exit 1
--fi
--
--copy_file() {
-- local src="$1"
-- local dst="$2"
-- install -D -m 0644 "$src" "$dst"
-- echo "[openvibe-sdk] copied ${dst#$SDK/}"
--}
--
--copy_tree() {
-- local src="$1"
-- local dst="$2"
-- mkdir -p "$dst"
-- rsync -a --delete "$src/" "$dst/"
-- echo "[openvibe-sdk] copied tree ${dst#$SDK/}"
--}
--
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/openvibe_client.cpp" \
-- "$SDK/src/game/client/hl2mp/openvibe_client.cpp"
--copy_file "$ROOT/sdk/openvibe/client/hl2mp/vgui_openvibe_menu.cpp" \
-- "$SDK/src/game/client/hl2mp/vgui_openvibe_menu.cpp"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_server.cpp"
--
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_runtime.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_runtime.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_runtime.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_runtime.cpp"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_bindings.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_bindings.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_bindings.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_bindings.cpp"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_player.h" \
-- "$SDK/src/game/shared/openvibe/ov_js_player.h"
--copy_file "$ROOT/sdk/openvibe/shared/ov_js_player.cpp" \
-- "$SDK/src/game/shared/openvibe/ov_js_player.cpp"
--
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_js_server.h" \
-- "$SDK/src/game/server/hl2mp/openvibe_js_server.h"
--copy_file "$ROOT/sdk/openvibe/server/hl2mp/openvibe_js_server.cpp" \
-- "$SDK/src/game/server/hl2mp/openvibe_js_server.cpp"
--
--copy_tree "$ROOT/sdk/openvibe/third_party/quickjs" \
-- "$SDK/src/game/shared/openvibe/third_party/quickjs"
--
--"$ROOT/tools/build-quickjs-lib.sh"
--
--QJS_C="$SDK/src/game/shared/openvibe/third_party/quickjs/quickjs.c"
--if [[ -f "$QJS_C" ]] && ! grep -q 'OPENVIBE_QUICKJS_CONFIG' "$QJS_C"; then
-- tmp="$(mktemp)"
-- cat > "$tmp" <<'QCFG'
--#ifndef OPENVIBE_QUICKJS_CONFIG
--#define OPENVIBE_QUICKJS_CONFIG
--#ifndef _GNU_SOURCE
--#define _GNU_SOURCE
--#endif
--#ifndef CONFIG_VERSION
--#define CONFIG_VERSION "openvibe"
--#endif
--#endif
--
--QCFG
-- cat "$QJS_C" >> "$tmp"
-- mv "$tmp" "$QJS_C"
--fi
--
--CLIENT_VPC="$SDK/src/game/client/client_hl2mp.vpc"
--SERVER_VPC="$SDK/src/game/server/server_hl2mp.vpc"
--HL2MP_CLIENT="$SDK/src/game/server/hl2mp/hl2mp_client.cpp"
--HL2MP_CLIENTMODE="$SDK/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp"
--GAMEINTERFACE="$SDK/src/game/server/gameinterface.cpp"
--HL2MP_PLAYER="$SDK/src/game/server/hl2mp/hl2mp_player.cpp"
--
--perl -0pi -e 's/^.*hl2mp\\openvibe_client\.cpp.*\n//mg; s/^.*hl2mp\\vgui_openvibe_menu\.cpp.*\n//mg; s/(\$File\s+"hl2mp\\clientmode_hl2mpnormal\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_client.cpp"\n\t\t\t\$File\t"hl2mp\\vgui_openvibe_menu.cpp"\n/s' "$CLIENT_VPC"
--echo "[openvibe-sdk] patched client_hl2mp.vpc"
--
--perl -0pi -e '
-- s/^.*hl2mp\\openvibe_server\.cpp.*\n//mg;
-- s/^.*hl2mp\\openvibe_js_server\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_runtime\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_bindings\.cpp.*\n//mg;
-- s/^.*openvibe\\ov_js_player\.cpp.*\n//mg;
-- s/(\$File\s+"hl2mp\\hl2mp_player\.h"\n)/$1\t\t\t\$File\t"hl2mp\\openvibe_server.cpp"\n\t\t\t\$File\t"hl2mp\\openvibe_js_server.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_runtime.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_bindings.cpp"\n\t\t\t\$File\t"..\\shared\\openvibe\\ov_js_player.cpp"\n/s;
--' "$SERVER_VPC"
--echo "[openvibe-sdk] patched server_hl2mp.vpc"
--
--if ! grep -q 'OpenVibe_OnClientActive' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a void OpenVibe_OnClientActive( CHL2MP_Player *pPlayer );' "$HL2MP_CLIENT"
-- sed -i '/FinishClientPutInServer( pPlayer );/a \ OpenVibe_OnClientActive( pPlayer );' "$HL2MP_CLIENT"
-- echo "[openvibe-sdk] patched hl2mp_client.cpp arrival hook"
--fi
--
--perl -0pi -e 's/[^\S\r\n]*\x0boid OpenVibe_OnClientActive/void OpenVibe_OnClientActive/g; s/\\tOpenVibe_OnClientActive/\tOpenVibe_OnClientActive/g; s/^[ \t]*void OpenVibe_OnClientActive/void OpenVibe_OnClientActive/m' "$HL2MP_CLIENT"
--
--if ! grep -q 'OpenVibe_OnClientModeInit' "$HL2MP_CLIENTMODE"; then
-- sed -i '/#include "ienginevgui.h"/a void OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- sed -i '/BaseClass::Init();/a \ OpenVibe_OnClientModeInit();' "$HL2MP_CLIENTMODE"
-- echo "[openvibe-sdk] patched clientmode_hl2mpnormal.cpp OpenVibe menu hook"
--fi
--
--perl -0pi -e 's/^[ \t]*tOpenVibe_OnClientModeInit\(\);/ OpenVibe_OnClientModeInit();/m' "$HL2MP_CLIENTMODE"
--
--if [[ -f "$GAMEINTERFACE" ]]; then
-- if ! grep -q 'OpenVibe_OnFrame' "$GAMEINTERFACE"; then
-- sed -i '/CServerGameDLL::GameFrame/i #ifdef HL2MP\nvoid OpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- sed -i '/VPROF( "CServerGameDLL::GameFrame" );/a #ifdef HL2MP\n\tOpenVibe_OnFrame();\n#endif' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp frame hook"
-- fi
--
-- if ! grep -q 'OpenVibe_OnClientDisconnect' "$GAMEINTERFACE"; then
-- perl -pi -e 's/void CServerGameClients::ClientDisconnect/#ifdef HL2MP\nvoid OpenVibe_OnClientDisconnect( CBasePlayer *pPlayer );\n#endif\nvoid CServerGameClients::ClientDisconnect/' "$GAMEINTERFACE"
-- perl -0777 -pi -e 's/(void CServerGameClients::ClientDisconnect\( edict_t \*pEdict \)\s*\{\s*extern bool\s+g_fGameOver;\s*CBasePlayer \*player = \( CBasePlayer \* \)CBaseEntity::Instance\( pEdict \);)/$1\n#ifdef HL2MP\n\tif ( player ) { OpenVibe_OnClientDisconnect( player ); }\n#endif/g' "$GAMEINTERFACE"
-- echo "[openvibe-sdk] patched gameinterface.cpp disconnect hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_PLAYER" ]]; then
-- if ! grep -q 'OpenVibe_OnPlayerDeath' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Event_Killed/i void OpenVibe_OnPlayerDeath( CHL2MP_Player *pPlayer, CBaseEntity *pKiller );' "$HL2MP_PLAYER"
-- sed -i '/CTakeDamageInfo subinfo = info;/i \ OpenVibe_OnPlayerDeath( this, info.GetAttacker() );' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp death hook"
-- fi
--
-- if ! grep -q 'OpenVibeJS_Server_PlayerSpawn' "$HL2MP_PLAYER"; then
-- sed -i '/CHL2MP_Player::Spawn/i void OpenVibeJS_Server_PlayerSpawn( CHL2MP_Player *pPlayer );' "$HL2MP_PLAYER"
-- sed -i '0,/BaseClass::Spawn();/s//BaseClass::Spawn();\n\tOpenVibeJS_Server_PlayerSpawn( this );/' "$HL2MP_PLAYER"
-- echo "[openvibe-sdk] patched hl2mp_player.cpp spawn hook"
-- fi
--fi
--
--if [[ -f "$HL2MP_CLIENT" ]] && ! grep -q 'OpenVibeJS_Server_PlayerSay' "$HL2MP_CLIENT"; then
-- sed -i '/void Host_Say/a bool OpenVibeJS_Server_PlayerSay( CHL2MP_Player *pPlayer, const char *pszText );' "$HL2MP_CLIENT"
-- python3 - "$HL2MP_CLIENT" <<'PY'
--from pathlib import Path
--import re, sys
--
--p = Path(sys.argv[1])
--s = p.read_text()
--
--# Best-effort patch for common Source SDK 2013 HL2MP Host_Say shape:
--# CHL2MP_Player *client = ...
--# const char *p = args.ArgS();
--if "OpenVibeJS_Server_PlayerSay( client," not in s:
-- s2 = re.sub(
-- r'(const char \*p\s*=\s*args\.ArgS\(\);\s*)',
-- r'\1\n\tif ( client && OpenVibeJS_Server_PlayerSay( client, p ) )\n\t\treturn;\n',
-- s,
-- count=1,
-- )
-- if s2 != s:
-- s = s2
-- print("[openvibe-sdk] patched hl2mp_client.cpp PlayerSay hook")
-- else:
-- print("[openvibe-sdk] WARNING: could not auto-patch Host_Say PlayerSay body")
--p.write_text(s)
--PY
--fi
--
--
--# OPENVIBE_CONTINUE_QUICKJS_POSTPATCH
--patch_openvibe_quickjs_after_apply() {
-- local qjs_dir="$SDK/src/game/shared/openvibe/third_party/quickjs"
-- local qjs_c="$qjs_dir/quickjs.c"
--
-- if [[ -f "$qjs_c" ]] && ! grep -q 'OPENVIBE_QUICKJS_STRICT_C_SHIM' "$qjs_c"; then
-- local tmp
-- tmp="$(mktemp)"
-- cat > "$tmp" <<'QJS_SHIM'
--#ifndef OPENVIBE_QUICKJS_STRICT_C_SHIM
--#define OPENVIBE_QUICKJS_STRICT_C_SHIM
--
--#ifndef _GNU_SOURCE
--#define _GNU_SOURCE
--#endif
--
--#ifndef CONFIG_VERSION
--#define CONFIG_VERSION "openvibe"
--#endif
--
--#if defined(__GNUC__) && !defined(__cplusplus) && defined(__STRICT_ANSI__) && !defined(asm)
--#define asm __asm__
--#endif
--
--#endif
--
--QJS_SHIM
-- cat "$qjs_c" >> "$tmp"
-- mv "$tmp" "$qjs_c"
-- echo "[openvibe-sdk] patched QuickJS strict-C shim"
-- fi
--
-- if [[ ! -f "$qjs_dir/libbf.c" ]]; then
-- perl -0pi -e 's/^.*openvibe\\\\third_party\\\\quickjs\\\\libbf\.c.*\n//mg; s/^.*openvibe\\third_party\\quickjs\\libbf\.c.*\n//mg' "$SERVER_VPC" || true
-- echo "[openvibe-sdk] libbf.c missing; removed libbf.c from server_hl2mp.vpc"
-- fi
--}
--
--patch_openvibe_quickjs_after_apply
--
--echo "[openvibe-sdk] Source SDK OpenVibe patch applied"
--
--
--# Link prebuilt QuickJS C static library. QuickJS must be compiled as C, not C++.
--if ! grep -q 'libquickjs_openvibe.a' "$SERVER_VPC"; then
-- perl -0pi -e 's/(\$File\s+"hl2mp\\openvibe_js_server\.cpp"\n)/$1\t\t\t\$Lib\t"..\\shared\\openvibe\\third_party\\quickjs\\build\\libquickjs_openvibe.a"\n/s' "$SERVER_VPC"
-- echo "[openvibe-sdk] linked QuickJS static library"
--fi
ddiff --git a/tools/build-quickjs-lib.sh b/tools/build-quickjs-lib.sh
iindex b7bb918..fd42066 100755
---- a/tools/build-quickjs-lib.sh
++++ b/tools/build-quickjs-lib.sh
@@@ -16,7 +16,7 @@ fi
mkdir -p "$SDK_QJS"
--# Important: exclude build/ so rsync does not delete our object output dir.
++# Exclude build/ so rsync does not delete our .o/.a output dir.
rsync -a --delete --exclude='build/' "$SRC_QJS/" "$SDK_QJS/"
mkdir -p "$OUT"
ddiff --git a/tools/fix-vpc-libquickjs-name.sh b/tools/fix-vpc-libquickjs-name.sh
nnew file mode 100755
iindex 0000000..e735cd8
---- /dev/null
++++ b/tools/fix-vpc-libquickjs-name.sh
@@@ -0,0 +1,215 @@
++#!/usr/bin/env bash
++set -euo pipefail
++
++ROOT="${OPENVIBE_ROOT:-$HOME/src/openvibe-source}"
++SDK="${OPENVIBE_SDK:-$ROOT/engine/source-sdk-2013}"
++RUN_BUILD="${RUN_BUILD:-1}"
++STAMP="$(date +%Y%m%d-%H%M%S)"
++
++cd "$ROOT"
++
++backup_file() {
++ local file="$1"
++ [[ -f "$file" ]] && cp "$file" "$file.bak.$STAMP"
++}
++
++say() {
++ echo "[openvibe] $*"
++}
++
++say "fixing QuickJS static-library VPC link issue"
++
++mkdir -p tools
++
++# Clean accidentally tracked local/generated junk if it exists.
++say "cleaning accidental tracked junk if present"
++git rm -f .tmp/quickjs-smoke/smoke-quickjs 2>/dev/null || true
++git rm -f tools/apply-openvibe-sdk.sh.bak.* 2>/dev/null || true
++
++touch .gitignore
++if ! grep -qxF ".tmp/" .gitignore; then
++ cat >> .gitignore <<'GITIGNORE_ADD'
++
++# OpenVibe local/generated build junk
++.tmp/
++*.bak.*
++tools/*.bak.*
++engine/source-sdk-2013/src/game/shared/openvibe/third_party/quickjs/build/
++GITIGNORE_ADD
++fi
++
++say "writing tools/build-quickjs-lib.sh"
++
++cat > tools/build-quickjs-lib.sh <<'BUILDQJS'
++#!/usr/bin/env bash
++set -euo pipefail
++
++ROOT="${OPENVIBE_ROOT:-$HOME/src/openvibe-source}"
++SDK="${OPENVIBE_SDK:-$ROOT/engine/source-sdk-2013}"
++
++SRC_QJS="$ROOT/sdk/openvibe/third_party/quickjs"
++SDK_QJS="$SDK/src/game/shared/openvibe/third_party/quickjs"
++OUT="$SDK_QJS/build"
++
++if [[ ! -f "$SRC_QJS/quickjs.c" ]]; then
++ echo "Missing $SRC_QJS/quickjs.c" >&2
++ echo "Run: tools/vendor-quickjs.sh" >&2
++ exit 1
++fi
++
++mkdir -p "$SDK_QJS"
++
++# Exclude build/ so rsync does not delete our .o/.a output dir.
++rsync -a --delete --exclude='build/' "$SRC_QJS/" "$SDK_QJS/"
++
++mkdir -p "$OUT"
++
++sources=(
++ quickjs.c
++ libregexp.c
++ libunicode.c
++ cutils.c
++)
++
++[[ -f "$SDK_QJS/dtoa.c" ]] && sources+=(dtoa.c)
++[[ -f "$SDK_QJS/libbf.c" ]] && sources+=(libbf.c)
++
++rm -f "$OUT"/*.o "$OUT"/libquickjs_openvibe.a
++
++for src in "${sources[@]}"; do
++ obj="$OUT/${src%.c}.o"
++ echo "[openvibe-qjs] cc $src -> $obj"
++
++ cc \
++ -std=gnu11 \
++ -O2 \
++ -fPIC \
++ -D_GNU_SOURCE \
++ -DCONFIG_VERSION=\"openvibe\" \
++ -I"$SDK_QJS" \
++ -c "$SDK_QJS/$src" \
++ -o "$obj"
++done
++
++ar rcs "$OUT/libquickjs_openvibe.a" "$OUT"/*.o
++
++echo "[openvibe-qjs] built $OUT/libquickjs_openvibe.a"
++ls -lh "$OUT/libquickjs_openvibe.a"
++BUILDQJS
++
++chmod +x tools/build-quickjs-lib.sh
++
++say "patching tools/apply-openvibe-sdk.sh"
++
++if [[ ! -f tools/apply-openvibe-sdk.sh ]]; then
++ echo "Missing tools/apply-openvibe-sdk.sh" >&2
++ exit 1
++fi
++
++backup_file tools/apply-openvibe-sdk.sh
++
++python3 <<'PY'
++from pathlib import Path
++import re
++
++p = Path("tools/apply-openvibe-sdk.sh")
++s = p.read_text()
++
++# Remove older injected QuickJS final blocks so this script stays idempotent.
++patterns = [
++ r'\n# OPENVIBE_REMOVE_DIRECT_QUICKJS_C\n.*?(?=\n# OPENVIBE|\necho "\[openvibe-sdk\] Source SDK OpenVibe patch applied"|\Z)',
++ r'\n# OPENVIBE_LINK_QUICKJS_STATIC_LIB\n.*?(?=\n# OPENVIBE|\necho "\[openvibe-sdk\] Source SDK OpenVibe patch applied"|\Z)',
++ r'\n# OPENVIBE_FIX_QUICKJS_LINK_FINAL_V2\n.*?(?=\n# OPENVIBE|\necho "\[openvibe-sdk\] Source SDK OpenVibe patch applied"|\Z)',
++]
++for pat in patterns:
++ s = re.sub(pat, "\n", s, flags=re.S)
++
++# Do not allow a literal libquickjs_openvibe.a in any VPC $Lib line.
++# VPC appends .a itself, so ".a" here becomes ".a.a".
++s = s.replace("libquickjs_openvibe.a", "libquickjs_openvibe")
++
++# Ensure apply script calls the QuickJS static library builder.
++if '"$ROOT/tools/build-quickjs-lib.sh"' not in s:
++ needle = 'copy_tree "$ROOT/sdk/openvibe/third_party/quickjs" \\\n "$SDK/src/game/shared/openvibe/third_party/quickjs"'
++ if needle in s:
++ s = s.replace(needle, needle + '\n\n"$ROOT/tools/build-quickjs-lib.sh"')
++ else:
++ s += '\n\n"$ROOT/tools/build-quickjs-lib.sh"\n'
++
++final_block = r'''
++# OPENVIBE_FIX_QUICKJS_LINK_FINAL_V2
++# QuickJS is C, so do not compile its .c files through Source SDK/VPC C++.
++# We build libquickjs_openvibe.a with cc and link it as a library.
++if [[ -f "$SERVER_VPC" ]]; then
++ perl -0pi -e '
++ s/^.*quickjs\\quickjs\.c.*\n//mg;
++ s/^.*quickjs\\libregexp\.c.*\n//mg;
++ s/^.*quickjs\\libunicode\.c.*\n//mg;
++ s/^.*quickjs\\cutils\.c.*\n//mg;
++ s/^.*quickjs\\dtoa\.c.*\n//mg;
++ s/^.*quickjs\\libbf\.c.*\n//mg;
++ ' "$SERVER_VPC"
++
++ perl -0pi -e 's/^.*libquickjs_openvibe(?:\.a)?".*\n//mg' "$SERVER_VPC"
++
++ perl -0pi -e 's/(\$File\s+"hl2mp\\openvibe_js_server\.cpp"\n)/$1\t\t\t\$Lib\t"..\\shared\\openvibe\\third_party\\quickjs\\build\\libquickjs_openvibe"\n/s' "$SERVER_VPC"
++
++ echo "[openvibe-sdk] linked QuickJS static library"
++fi
++'''
++
++final_echo = 'echo "[openvibe-sdk] Source SDK OpenVibe patch applied"'
++if final_echo in s:
++ s = s.replace(final_echo, final_block + "\n" + final_echo)
++else:
++ s += "\n" + final_block + "\n"
++
++p.write_text(s)
++PY
++
++chmod +x tools/apply-openvibe-sdk.sh
++
++say "applying SDK patch"
++tools/apply-openvibe-sdk.sh
++
++SERVER_VPC="$SDK/src/game/server/server_hl2mp.vpc"
++
++say "force-fixing already-applied SDK server_hl2mp.vpc"
++
++if [[ -f "$SERVER_VPC" ]]; then
++ backup_file "$SERVER_VPC"
++
++ perl -0pi -e '
++ s/^.*quickjs\\quickjs\.c.*\n//mg;
++ s/^.*quickjs\\libregexp\.c.*\n//mg;
++ s/^.*quickjs\\libunicode\.c.*\n//mg;
++ s/^.*quickjs\\cutils\.c.*\n//mg;
++ s/^.*quickjs\\dtoa\.c.*\n//mg;
++ s/^.*quickjs\\libbf\.c.*\n//mg;
++ ' "$SERVER_VPC"
++
++ perl -0pi -e 's/^.*libquickjs_openvibe(?:\.a)?".*\n//mg' "$SERVER_VPC"
++ perl -0pi -e 's/(\$File\s+"hl2mp\\openvibe_js_server\.cpp"\n)/$1\t\t\t\$Lib\t"..\\shared\\openvibe\\third_party\\quickjs\\build\\libquickjs_openvibe"\n/s' "$SERVER_VPC"
++fi
++
++say "building QuickJS static lib"
++tools/build-quickjs-lib.sh
++
++say "VPC quickjs check"
++if [[ -f "$SERVER_VPC" ]]; then
++ grep -nE 'quickjs\\(quickjs|libregexp|libunicode|cutils|dtoa|libbf)\.c|libquickjs_openvibe' "$SERVER_VPC" || true
++else
++ echo "Missing $SERVER_VPC" >&2
++fi
++
++if [[ "$RUN_BUILD" = "1" ]]; then
++ say "running SDK build"
++ tools/build-sdk-linux.sh 2>&1 | tee "$HOME/ov-build.log"
++
++ say "build finished. Last lines:"
++ tail -80 "$HOME/ov-build.log"
++else
++ say "skipping build because RUN_BUILD=0"
++ echo "Run manually:"
++ echo " tools/build-sdk-linux.sh 2>&1 | tee ~/ov-build.log"
++fi