aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hayden K <imaciidz@gmail.com> 2025-05-29 17:29:21 -0400
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-10-05 18:36:46 +0100
commite25081952acd2e6ff40af1390f6a8de71de8a6a3 (patch)
tree793b5ec59ea89ecd7321bb0587e339c3b6a17243
parentde2a003cd9041c3e711147a4fe3a96a5b0564842 (diff)
downloadsst-e25081952acd2e6ff40af1390f6a8de71de8a6a3.tar.gz
sst-e25081952acd2e6ff40af1390f6a8de71de8a6a3.zip
Fix OE dropping coloured logs early in startup
Not perfect, because if something fails extremely early, we won't see it, but that'll never be fully solvable. This is good enough to see what features succeed and fail in normal autoload conditions where we don't expect the plugin to blow up immediately.
-rw-r--r--src/con_.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/con_.c b/src/con_.c
index 896faea..c316318 100644
--- a/src/con_.c
+++ b/src/con_.c
@@ -610,8 +610,28 @@ bool con_detect(int pluginver) {
return false;
}
+static int *find_host_initialized() {
+ const uchar *insns = colourmsgf;
+ for (const uchar *p = insns; p - insns < 32;) {
+ // cmp byte ptr [<pointer>], <value>
+ if (p[0] == X86_ALUMI8 && p[1] == X86_MODRM(0, 7, 5)) {
+ return mem_loadptr(p + 2);
+ }
+ NEXT_INSN(p, "host_initialized variable");
+ }
+ return 0;
+}
+
void con_init() {
- if (!GAMETYPE_MATCHES(OE)) {
+ if (GAMETYPE_MATCHES(OE)) {
+ // if we're autoloaded, we have to set host_initialized early or colour
+ // log output (including error output!) won't be visible, for some inane
+ // reason. *as far as we know* this doesn't have any bad side effects.
+ // note: if this fails, too bad. not like we can log a warning.
+ int *host_initialized = find_host_initialized();
+ if (host_initialized && *host_initialized == 0) *host_initialized = 1;
+ }
+ else {
colourmsgf = coniface->vtable[vtidx_ConsoleColorPrintf];
dllid = AllocateDLLIdentifier(coniface);
}