openvibers/source.openvibe.games Commits
Crash-safe client JS logging + menu override
Changes
@@@ -22,7 +22,7 @@ snd_mute_losefocus 0mat_dxlevel 90r_3dsky 0--// Don't auto-open the HTML menu on startup: it was auto-navigating to--// openvibe://join?mode=hub, firing an ov_join to a (often-down) hub server and--// showing "Connection failed" over the world. Open it manually with ov_menu.--ov_menu_auto_open 0++// Auto-open the custom HTML menu so it covers the stock HL2 main menu (which++// freezes) — this is the menu override. The menu only joins a server on an++// explicit user click, so it won't auto-connect on its own.++ov_menu_auto_open 1@@@ -34,9 +34,28 @@ static bool OVC_IsSafeModPath( const char *p )return true;}--static void OVC_log( const char *m ) { Msg( "[OV JS/client] %s\n", m ); }--static void OVC_warn( const char *m ) { Warning( "[OV JS/client] %s\n", m ); }--static void OVC_error( const char *m ){ Warning( "[OV JS/client ERROR] %s\n", m ); }++// Crash-safe logger: Msg() -> console.log is buffered under Proton, so lines++// right before a crash are lost. Also append each line to a MOD file that we++// flush (Open/Write/Close) every call, guaranteeing the last line before any++// crash is on disk. This is the reliable end-to-end client JS log.++static void OVC_LogLine( const char *tag, const char *m )++{++ Msg( "[OV JS/client]%s %s\n", tag, m );++ if ( filesystem )++ {++ FileHandle_t f = filesystem->Open( "ovjs_client.log", "a", "MOD" );++ if ( f )++ {++ char line[8192];++ int n = Q_snprintf( line, sizeof( line ), "[OV JS/client]%s %s\n", tag, m );++ if ( n > 0 ) filesystem->Write( line, n, f );++ filesystem->Close( f ); // close each line = flush to disk++ }++ }++}++static void OVC_log( const char *m ) { OVC_LogLine( "", m ); }++static void OVC_warn( const char *m ) { OVC_LogLine( " WARN", m ); }++static void OVC_error( const char *m ){ OVC_LogLine( " ERROR", m ); }static char *OVC_readFile( const char *path ){@@@ -154,6 +173,8 @@ void OpenVibeJS_Client_Init()Msg( "[OV JS/client] disabled by ov_client_js_enabled=0\n" );return;}++ // Fresh crash-safe log each init.++ if ( filesystem ) { FileHandle_t f = filesystem->Open( "ovjs_client.log", "w", "MOD" ); if ( f ) filesystem->Close( f ); }g_pClientCore = ovjs_create( &g_ClientHost, 0 /*client*/, ov_client_mode.GetString() );if ( g_pClientCore ){@@@ -219,6 +219,7 @@ static int OVJS_LoadFile(OVJSCore *c, const char *path)if (!c->host || !c->host->readFile) return 0;if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: loading %s", path); c->host->log(b); }char *code = c->host->readFile(path);++ if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: readFile %s -> %s", path, code ? "ok" : "NULL"); c->host->log(b); }if (!code) {if (c->host->warn) {char buf[512];@@@ -227,7 +228,9 @@ static int OVJS_LoadFile(OVJSCore *c, const char *path)}return 0;}++ if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: eval begin %s", path); c->host->log(b); }int ok = ovjs_eval(c, code, path);++ if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: eval done %s ok=%d", path, ok); c->host->log(b); }OVJS_HostFree(c->host, code);return ok;}
@@ -22,7 +22,7 @@ snd_mute_losefocus 0
@@ -22,7 +22,7 @@ snd_mute_losefocus 0
mat_dxlevel 90
mat_dxlevel 90
r_3dsky 0
r_3dsky 0
-// Don't auto-open the HTML menu on startup: it was auto-navigating to
-// openvibe://join?mode=hub, firing an ov_join to a (often-down) hub server and
-// showing "Connection failed" over the world. Open it manually with ov_menu.
-ov_menu_auto_open 0
+// Auto-open the custom HTML menu so it covers the stock HL2 main menu (which
+// freezes) — this is the menu override. The menu only joins a server on an
+// explicit user click, so it won't auto-connect on its own.
+ov_menu_auto_open 1
@@ -34,9 +34,28 @@ static bool OVC_IsSafeModPath( const char *p )
@@ -34,9 +34,28 @@ static bool OVC_IsSafeModPath( const char *p )
return true;
return true;
}
}
-static void OVC_log( const char *m ) { Msg( "[OV JS/client] %s\n", m ); }
-static void OVC_warn( const char *m ) { Warning( "[OV JS/client] %s\n", m ); }
-static void OVC_error( const char *m ){ Warning( "[OV JS/client ERROR] %s\n", m ); }
+// Crash-safe logger: Msg() -> console.log is buffered under Proton, so lines
+// right before a crash are lost. Also append each line to a MOD file that we
+// flush (Open/Write/Close) every call, guaranteeing the last line before any
+// crash is on disk. This is the reliable end-to-end client JS log.
+static void OVC_LogLine( const char *tag, const char *m )
+{
+ Msg( "[OV JS/client]%s %s\n", tag, m );
+ if ( filesystem )
+ {
+ FileHandle_t f = filesystem->Open( "ovjs_client.log", "a", "MOD" );
+ if ( f )
+ {
+ char line[8192];
+ int n = Q_snprintf( line, sizeof( line ), "[OV JS/client]%s %s\n", tag, m );
+ if ( n > 0 ) filesystem->Write( line, n, f );
+ filesystem->Close( f ); // close each line = flush to disk
+ }
+ }
+}
+static void OVC_log( const char *m ) { OVC_LogLine( "", m ); }
+static void OVC_warn( const char *m ) { OVC_LogLine( " WARN", m ); }
+static void OVC_error( const char *m ){ OVC_LogLine( " ERROR", m ); }
static char *OVC_readFile( const char *path )
static char *OVC_readFile( const char *path )
{
{
@@ -154,6 +173,8 @@ void OpenVibeJS_Client_Init()
@@ -154,6 +173,8 @@ void OpenVibeJS_Client_Init()
Msg( "[OV JS/client] disabled by ov_client_js_enabled=0\n" );
Msg( "[OV JS/client] disabled by ov_client_js_enabled=0\n" );
return;
return;
}
}
+ // Fresh crash-safe log each init.
+ if ( filesystem ) { FileHandle_t f = filesystem->Open( "ovjs_client.log", "w", "MOD" ); if ( f ) filesystem->Close( f ); }
g_pClientCore = ovjs_create( &g_ClientHost, 0 /*client*/, ov_client_mode.GetString() );
g_pClientCore = ovjs_create( &g_ClientHost, 0 /*client*/, ov_client_mode.GetString() );
if ( g_pClientCore )
if ( g_pClientCore )
{
{
@@ -219,6 +219,7 @@ static int OVJS_LoadFile(OVJSCore *c, const char *path)
@@ -219,6 +219,7 @@ static int OVJS_LoadFile(OVJSCore *c, const char *path)
if (!c->host || !c->host->readFile) return 0;
if (!c->host || !c->host->readFile) return 0;
if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: loading %s", path); c->host->log(b); }
if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: loading %s", path); c->host->log(b); }
char *code = c->host->readFile(path);
char *code = c->host->readFile(path);
+ if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: readFile %s -> %s", path, code ? "ok" : "NULL"); c->host->log(b); }
if (!code) {
if (!code) {
if (c->host->warn) {
if (c->host->warn) {
char buf[512];
char buf[512];
@@ -227,7 +228,9 @@ static int OVJS_LoadFile(OVJSCore *c, const char *path)
@@ -227,7 +228,9 @@ static int OVJS_LoadFile(OVJSCore *c, const char *path)
}
}
return 0;
return 0;
}
}
+ if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: eval begin %s", path); c->host->log(b); }
int ok = ovjs_eval(c, code, path);
int ok = ovjs_eval(c, code, path);
+ if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: eval done %s ok=%d", path, ok); c->host->log(b); }
OVJS_HostFree(c->host, code);
OVJS_HostFree(c->host, code);
return ok;
return ok;
}
}