From 06b115a293b6b369646fdd31ebf9b2e6a0753cac Mon Sep 17 00:00:00 2001 From: "Marco Antonio J. Costa" Date: Thu, 30 Jul 2026 12:31:11 -0300 Subject: [PATCH] drop EvalLua and the commented-out Lua init leftovers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EvalLua had no callers anywhere in the tree — it converted a wide string to UTF-8, ran it as a chunk and printf'd the error, which was the hook for a developer console that is not wired up. It was the only user of stdio, MemMan and windows.h in this file. InitializeLua and ShutdownLua are live, called from InitOverhead and ShutdownOverhead. The calls in InitializeGame and ShutdownGame were commented out when they moved there; remove them, and the commented ACCESSOR_TABLE block in InitializeLua that refers to a macro no longer defined anywhere. Co-Authored-By: Claude Opus 5 --- Ja2/gameloop.cpp | 3 --- lua/Lua Interpreter.h | 1 - lua/lua.cpp | 40 ---------------------------------------- 3 files changed, 44 deletions(-) diff --git a/Ja2/gameloop.cpp b/Ja2/gameloop.cpp index 88c752f96..b0c04592c 100644 --- a/Ja2/gameloop.cpp +++ b/Ja2/gameloop.cpp @@ -100,7 +100,6 @@ BOOLEAN InitializeGame(void) giStartingMemValue = MemGetFree( ); - //InitializeLua(); is_networked = FALSE; is_client = FALSE; is_server = FALSE; @@ -211,8 +210,6 @@ void ShutdownGame(void) //Deletes all the Temp files in the Maps\Temp directory InitTacticalSave( FALSE ); - //ShutdownLua( ); - FreeGameExternalOptions(); } diff --git a/lua/Lua Interpreter.h b/lua/Lua Interpreter.h index bef02328a..215c09b78 100644 --- a/lua/Lua Interpreter.h +++ b/lua/Lua Interpreter.h @@ -18,7 +18,6 @@ typedef struct { } LuaAttrib; void InitializeLua( ); -int EvalLua (const wchar_t* buff) ; // The return value is whether to clear the input line, not whether the call succeeded. void ShutdownLua( ); extern luaL_Reg WStringMethods[]; diff --git a/lua/lua.cpp b/lua/lua.cpp index b3d1cb32b..721da9b30 100644 --- a/lua/lua.cpp +++ b/lua/lua.cpp @@ -1,9 +1,5 @@ -#include #include -#include #include "Lua Interpreter.h" -#include -#include "MemMan.h" lua_State *L; @@ -181,11 +177,6 @@ void InitializeLua( ) L = lua_open(); luaL_openlibs(L); - // Create the accessor metatable -// CreateLuaType( L, ACCESSOR_TABLE, LuaAccessors); -// lua_setglobal( L, ACCESSOR_TABLE); // We also want this class to be known to the script -// lua_pop(L, 1); - // Create a wide-character savvy string CreateLuaType( L, "wstring", WStringMethods); lua_setglobal( L, "wstring"); // We also want this class to be known to the script @@ -196,37 +187,6 @@ void InitializeLua( ) LuaEnvironmentSetup( L); } -int EvalLua (const wchar_t* buff) { - int error; - int newlen; - STR8 newstr = NULL; - - // Since we get wide chars coming in, we need to convert to UTF8 - newlen = WideCharToMultiByte( CP_UTF8, 0, buff, -1, newstr, 0, NULL, NULL); - newstr = (STR8) MemAlloc( newlen); - WideCharToMultiByte( CP_UTF8, 0, buff, -1, newstr, newlen, NULL, NULL); - - error = luaL_loadbuffer(L, newstr, newlen-1, "line") || - lua_pcall(L, 0, 0, 0); - - MemFree( newstr); - - if (error) { - const char *error = lua_tostring(L, -1); - int len = strlen( error); - if (len >= 7 && !strcmp( error + len - 7, "''")) - { - lua_pop(L, 1); /* pop error message from the stack */ - return FALSE; - } - printf( "%s\n", lua_tostring(L, -1)); - lua_pop(L, 1); /* pop error message from the stack */ - return TRUE; - } - - return TRUE; -} - void ShutdownLua( ) { if(L)