From 8bfc599697b88a68e758f56923710e7b4c780655 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sat, 28 Mar 2026 10:35:05 +0100 Subject: [PATCH] Guard against EfunctionAdd() from outside MOD_TEST. As this can keep someone busy for half an hour wondering why things crash... --- src/api-efunctions.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api-efunctions.c b/src/api-efunctions.c index 3b87dc8d8..5f5108bf3 100644 --- a/src/api-efunctions.c +++ b/src/api-efunctions.c @@ -202,6 +202,15 @@ Efunction *EfunctionAddMain(Module *module, EfunctionType eftype, int (*func)(), module->errorcode = MODERR_INVALID; return NULL; } + + if (loop.config_status != CONFIG_STATUS_TEST) + { + unreal_log(ULOG_ERROR, "module", "BUG_EFUNCTIONADD_NOT_MOD_TEST", NULL, + "[BUG] EfunctionAdd() called by module '$module_name' outside of MOD_TEST().", + log_data_string("module_name", module->header->name)); + module->errorcode = MODERR_INVALID; + return NULL; + } p = safe_alloc(sizeof(Efunction)); if (func)