From 8e9abf990639c7b5099371bb3c5d4514c4228cbf Mon Sep 17 00:00:00 2001 From: Will Xyen Date: Fri, 24 Jul 2020 08:47:25 -0700 Subject: [PATCH] launcher: Set soft_id_code before calling init as some games use it then --- src/main/launcher/ea3-config.c | 20 ++++++++++++++++++-- src/main/util/mem.c | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/launcher/ea3-config.c b/src/main/launcher/ea3-config.c index c57fa77..650e1bc 100644 --- a/src/main/launcher/ea3-config.c +++ b/src/main/launcher/ea3-config.c @@ -97,13 +97,29 @@ bool ea3_ident_invoke_module_init( ident->rev, ident->ext); + /* Set up long-form sidcode env var */ + + str_format( + sidcode_long, + lengthof(sidcode_long), + "%s:%s:%s:%s:%s", + ident->model, + ident->dest, + ident->spec, + ident->rev, + ident->ext); + + /* Set this up beforehand, as certain games require it in dll_entry_init */ + + std_setenv("/env/profile/soft_id_code", sidcode_long); + ok = module_context_invoke_init(module, sidcode_short, app_config); if (!ok) { return false; } - /* Back-propagate sidcode */ + /* Back-propagate sidcode, as some games modify it during init */ memcpy(ident->model, sidcode_short + 0, sizeof(ident->model) - 1); ident->dest[0] = sidcode_short[3]; @@ -111,7 +127,7 @@ bool ea3_ident_invoke_module_init( ident->rev[0] = sidcode_short[5]; memcpy(ident->ext, sidcode_short + 6, sizeof(ident->ext)); - /* Set up long-form sidcode env var */ + /* Set up long-form sidcode env var again */ str_format( sidcode_long, diff --git a/src/main/util/mem.c b/src/main/util/mem.c index bf674dd..53e84ff 100644 --- a/src/main/util/mem.c +++ b/src/main/util/mem.c @@ -16,7 +16,7 @@ void *xcalloc(size_t nbytes) mem = calloc(nbytes, 1); if (mem == NULL) { - log_fatal("xmalloc(%u) failed", (uint32_t) nbytes); + log_fatal("xcalloc(%u) failed", (uint32_t) nbytes); return NULL; } @@ -31,7 +31,7 @@ void *xmalloc(size_t nbytes) mem = malloc(nbytes); if (mem == NULL) { - log_fatal("xcalloc(%u) failed", (uint32_t) nbytes); + log_fatal("xmalloc(%u) failed", (uint32_t) nbytes); return NULL; }