From ea034cb96093560d2178bb872b077c85b07db734 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Tue, 21 Oct 2025 09:04:29 -0500 Subject: [PATCH] chore(ui): prefer lua_tostring macro --- src/ui/CScriptObjectScript.cpp | 2 +- src/ui/CScriptRegionScript.cpp | 12 ++++++------ src/ui/CSimpleButtonScript.cpp | 12 ++++++------ src/ui/CSimpleFontStringScript.cpp | 4 ++-- src/ui/CSimpleFrameScript.cpp | 2 +- src/ui/CSimpleHTMLScript.cpp | 2 +- src/ui/CSimpleModelScript.cpp | 2 +- src/ui/CSimpleTextureScript.cpp | 2 +- src/ui/FrameScript.cpp | 12 ++++++------ src/ui/ScriptFunctionsCharSelect.cpp | 4 ++-- src/ui/ScriptFunctionsGlueScriptEvents.cpp | 6 +++--- src/ui/ScriptFunctionsSimpleFrame.cpp | 12 ++++++------ src/util/StringTo.cpp | 2 +- 13 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/ui/CScriptObjectScript.cpp b/src/ui/CScriptObjectScript.cpp index ec30c07..93d699d 100644 --- a/src/ui/CScriptObjectScript.cpp +++ b/src/ui/CScriptObjectScript.cpp @@ -20,7 +20,7 @@ int32_t CScriptObject_IsObjectType(lua_State* L) { return luaL_error(L, "Usage: %s:IsObjectType(\"type\")", name); } - auto type = lua_tolstring(L, 2, nullptr); + auto type = lua_tostring(L, 2); if (object->IsA(type)) { lua_pushnumber(L, 1.0); diff --git a/src/ui/CScriptRegionScript.cpp b/src/ui/CScriptRegionScript.cpp index 6a3233e..cba1ad2 100644 --- a/src/ui/CScriptRegionScript.cpp +++ b/src/ui/CScriptRegionScript.cpp @@ -200,7 +200,7 @@ int32_t CScriptRegion_SetPoint(lua_State* L) { auto relative = region->GetLayoutParent(); - const char* pointStr = lua_tolstring(L, 2, 0); + const char* pointStr = lua_tostring(L, 2); FRAMEPOINT point; if (!StringToFramePoint(pointStr, point)) { @@ -210,7 +210,7 @@ int32_t CScriptRegion_SetPoint(lua_State* L) { int32_t argsIndex = 3; if (lua_type(L, 3) == LUA_TSTRING) { - const char* name = lua_tolstring(L, 3, 0); + const char* name = lua_tostring(L, 3); relative = region->GetLayoutFrameByName(name); argsIndex++; @@ -230,7 +230,7 @@ int32_t CScriptRegion_SetPoint(lua_State* L) { } if (!relative) { - const char* name = lua_tolstring(L, 3, 0); + const char* name = lua_tostring(L, 3); return luaL_error(L, "%s:SetPoint(): Couldn't find region named '%s'", region->GetDisplayName(), name); } @@ -245,7 +245,7 @@ int32_t CScriptRegion_SetPoint(lua_State* L) { FRAMEPOINT relativePoint = point; if (lua_type(L, argsIndex) == LUA_TSTRING) { - const char* relativePointStr = lua_tolstring(L, argsIndex, 0); + const char* relativePointStr = lua_tostring(L, argsIndex); if (!StringToFramePoint(relativePointStr, relativePoint)) { return luaL_error(L, "%s:SetPoint(): Unknown region point", region->GetDisplayName()); @@ -289,7 +289,7 @@ int32_t CScriptRegion_SetAllPoints(lua_State* L) { auto relative = region->GetLayoutParent(); if (lua_isstring(L, 2)) { - const char* name = lua_tolstring(L, 2, 0); + const char* name = lua_tostring(L, 2); relative = region->GetLayoutFrameByName(name); } else if (lua_type(L, 2) == LUA_TTABLE) { lua_rawgeti(L, 2, 0); @@ -303,7 +303,7 @@ int32_t CScriptRegion_SetAllPoints(lua_State* L) { } if (!relative) { - const char* name = lua_tolstring(L, 2, 0); + const char* name = lua_tostring(L, 2); return luaL_error(L, "%s:SetAllPoints(): Couldn't find region named '%s'", region->GetDisplayName(), name); } diff --git a/src/ui/CSimpleButtonScript.cpp b/src/ui/CSimpleButtonScript.cpp index 46a2420..66bcb29 100644 --- a/src/ui/CSimpleButtonScript.cpp +++ b/src/ui/CSimpleButtonScript.cpp @@ -28,7 +28,7 @@ int32_t CSimpleButton_SetStateTexture(lua_State* L, CSimpleButtonState state, co button->SetStateTexture(state, texture); } else if (lua_isstring(L, 2)) { - auto texFile = lua_tolstring(L, 2, nullptr); + auto texFile = lua_tostring(L, 2); button->SetStateTexture(state, texFile); } else if (lua_type(L, 2) == LUA_TNIL) { @@ -135,7 +135,7 @@ int32_t CSimpleButton_SetText(lua_State* L) { auto type = CSimpleButton::GetObjectType(); auto button = static_cast(FrameScript_GetObjectThis(L, type)); - const char* text = lua_tolstring(L, 2, 0); + const char* text = lua_tostring(L, 2); button->SetText(text); return 0; @@ -190,7 +190,7 @@ int32_t CSimpleButton_SetHighlightTexture(lua_State* L) { EGxBlend blendMode = GxBlend_Add; if (lua_isstring(L, 3)) { - auto blendString = lua_tolstring(L, 3, nullptr); + auto blendString = lua_tostring(L, 3); StringToBlendMode(blendString, blendMode); } @@ -210,7 +210,7 @@ int32_t CSimpleButton_SetHighlightTexture(lua_State* L) { button->SetHighlight(texture, blendMode); } else if (lua_isstring(L, 2)) { - auto texFile = lua_tolstring(L, 2, nullptr); + auto texFile = lua_tostring(L, 2); button->SetHighlight(texFile, blendMode); } else if (lua_type(L, 2) == LUA_TNIL) { @@ -277,7 +277,7 @@ int32_t CSimpleButton_RegisterForClicks(lua_State* L) { uint64_t action = 0; for (int32_t i = 2; lua_isstring(L, i); i++) { - auto actionStr = lua_tolstring(L, i, nullptr); + auto actionStr = lua_tostring(L, i); action |= StringToClickAction(actionStr); } @@ -292,7 +292,7 @@ int32_t CSimpleButton_Click(lua_State* L) { auto inputButton = "LeftButton"; if (lua_isstring(L, 2)) { - inputButton = lua_tolstring(L, 2, nullptr); + inputButton = lua_tostring(L, 2); } auto v6 = StringToBOOL(L, 3, 0); diff --git a/src/ui/CSimpleFontStringScript.cpp b/src/ui/CSimpleFontStringScript.cpp index 6058864..a570857 100644 --- a/src/ui/CSimpleFontStringScript.cpp +++ b/src/ui/CSimpleFontStringScript.cpp @@ -86,7 +86,7 @@ int32_t CSimpleFontString_SetFontObject(lua_State* L) { luaL_error(L, "%s:SetFontObject(): Wrong object type, expected font", string->GetDisplayName()); } } else if (lua_type(L, 2) == LUA_TSTRING) { - auto fontName = lua_tolstring(L, 2, nullptr); + auto fontName = lua_tostring(L, 2); font = CSimpleFont::GetFont(fontName, 0); if (!font) { @@ -125,7 +125,7 @@ int32_t CSimpleFontString_SetText(lua_State* L) { luaL_error(L, "%s:SetText(): Font not set", string->GetDisplayName()); } - const char* text = lua_tolstring(L, 2, 0); + const char* text = lua_tostring(L, 2); string->SetText(text, 1); return 0; diff --git a/src/ui/CSimpleFrameScript.cpp b/src/ui/CSimpleFrameScript.cpp index 3baf126..48ec762 100644 --- a/src/ui/CSimpleFrameScript.cpp +++ b/src/ui/CSimpleFrameScript.cpp @@ -144,7 +144,7 @@ int32_t CSimpleFrame_RegisterEvent(lua_State* L) { return luaL_error(L, "Usage: %s:RegisterEvent(\"event\")", frame->GetDisplayName()); } - const char* event = lua_tolstring(L, 2, 0); + const char* event = lua_tostring(L, 2); frame->RegisterScriptEvent(event); diff --git a/src/ui/CSimpleHTMLScript.cpp b/src/ui/CSimpleHTMLScript.cpp index d2c843b..d56eab7 100644 --- a/src/ui/CSimpleHTMLScript.cpp +++ b/src/ui/CSimpleHTMLScript.cpp @@ -80,7 +80,7 @@ int32_t CSimpleHTML_SetText(lua_State* L) { auto type = CSimpleHTML::GetObjectType(); auto html = static_cast(FrameScript_GetObjectThis(L, type)); - auto text = lua_tolstring(L, 2, nullptr); + auto text = lua_tostring(L, 2); html->SetText(text, nullptr); return 0; diff --git a/src/ui/CSimpleModelScript.cpp b/src/ui/CSimpleModelScript.cpp index f0d93ed..5069035 100644 --- a/src/ui/CSimpleModelScript.cpp +++ b/src/ui/CSimpleModelScript.cpp @@ -12,7 +12,7 @@ int32_t CSimpleModel_SetModel(lua_State* L) { return luaL_error(L, "Usage: %s:SetModel(\"file\")", model->GetDisplayName()); } - const char* file = lua_tolstring(L, 2, 0); + const char* file = lua_tostring(L, 2); model->SetModel(file); diff --git a/src/ui/CSimpleTextureScript.cpp b/src/ui/CSimpleTextureScript.cpp index c5536db..b4b066b 100644 --- a/src/ui/CSimpleTextureScript.cpp +++ b/src/ui/CSimpleTextureScript.cpp @@ -132,7 +132,7 @@ int32_t CSimpleTexture_SetTexture(lua_State* L) { bool v5 = lua_toboolean(L, 3); bool v6 = lua_toboolean(L, 3); - const char* v7 = lua_tolstring(L, 2, 0); + const char* v7 = lua_tostring(L, 2); if (texture->SetTexture(v7, v6, v5, CSimpleTexture::s_textureFilterMode, ImageMode_UI)) { lua_pushnumber(L, 1.0); diff --git a/src/ui/FrameScript.cpp b/src/ui/FrameScript.cpp index 79b15a3..da2aad6 100644 --- a/src/ui/FrameScript.cpp +++ b/src/ui/FrameScript.cpp @@ -122,7 +122,7 @@ int32_t FrameScript_CompileFunction(const char* name, const char* wrapper, const if (luaL_loadbuffer(L, function, SStrLen(function), name)) { if (status) { - const char* v10 = lua_tolstring(L, -1, 0); + const char* v10 = lua_tostring(L, -1); status->Add(STATUS_ERROR, "%s", v10); } @@ -133,7 +133,7 @@ int32_t FrameScript_CompileFunction(const char* name, const char* wrapper, const return -1; } else if (lua_pcall(L, 0, 1, -2)) { if (status) { - const char* v13 = lua_tolstring(L, -1, 0); + const char* v13 = lua_tostring(L, -1); status->Add(STATUS_ERROR, "%s", v13); } @@ -329,7 +329,7 @@ int32_t FrameScript_ExecuteBuffer(const char* buffer, size_t bufferBytes, const if (luaL_loadbuffer(L, buffer, bufferBytes, bufferName)) { if (status) { - const char* v7 = lua_tolstring(L, -1, 0); + const char* v7 = lua_tostring(L, -1); status->Add(STATUS_ERROR, "%s", v7); } @@ -349,7 +349,7 @@ int32_t FrameScript_ExecuteBuffer(const char* buffer, size_t bufferBytes, const if (lua_pcall(L, v9, 0, -2 - v9)) { if (status) { - const char* v11 = lua_tolstring(L, -1, 0); + const char* v11 = lua_tostring(L, -1); status->Add(STATUS_ERROR, "%s", v11); } @@ -577,7 +577,7 @@ int32_t FrameScript_GetVariable(const char* a1, const char** a2) { if (lua_isstring(L, -1)) { v3 = 1; - *a2 = lua_tolstring(L, -1, 0); + *a2 = lua_tostring(L, -1); } lua_settop(L, -2); @@ -591,7 +591,7 @@ int32_t FrameScript_HandleError(lua_State* L) { lua_insert(L, -1); } - const char* v1 = lua_tolstring(L, -1, 0); + const char* v1 = lua_tostring(L, -1); const char* v2 = SStrStr(v1, "*:"); const char* objName = FrameScript_GetCurrentObject(L, 1); diff --git a/src/ui/ScriptFunctionsCharSelect.cpp b/src/ui/ScriptFunctionsCharSelect.cpp index 66940e2..72bc793 100644 --- a/src/ui/ScriptFunctionsCharSelect.cpp +++ b/src/ui/ScriptFunctionsCharSelect.cpp @@ -14,7 +14,7 @@ int32_t Script_SetCharSelectModelFrame(lua_State* L) { } auto type = CSimpleModel::GetObjectType(); - auto name = lua_tolstring(L, 1, nullptr); + auto name = lua_tostring(L, 1); auto frame = CScriptObject::GetScriptObjectByName(name, type); if (frame) { @@ -29,7 +29,7 @@ int32_t Script_SetCharSelectBackground(lua_State* L) { return luaL_error(L, "Usage: SetCharSelectBackground(\"filename\")"); } - auto modelPath = lua_tolstring(L, 1, nullptr); + auto modelPath = lua_tostring(L, 1); CCharacterSelection::SetBackgroundModel(modelPath); return 0; diff --git a/src/ui/ScriptFunctionsGlueScriptEvents.cpp b/src/ui/ScriptFunctionsGlueScriptEvents.cpp index 3888a81..60d0a98 100644 --- a/src/ui/ScriptFunctionsGlueScriptEvents.cpp +++ b/src/ui/ScriptFunctionsGlueScriptEvents.cpp @@ -68,7 +68,7 @@ int32_t Script_SetCurrentScreen(lua_State* L) { return luaL_error(L, "Usage: SetCurrentScreen(\"screen\")"); } - auto screen = lua_tolstring(L, 1, nullptr); + auto screen = lua_tostring(L, 1); CGlueMgr::UpdateCurrentScreen(screen); // TODO @@ -200,8 +200,8 @@ int32_t Script_DefaultServerLogin(lua_State* L) { luaL_error(L, "Usage: DefaultServerLogin(\"accountName\", \"password\")"); } - auto accountName = lua_tolstring(L, 1, nullptr); - auto password = lua_tolstring(L, 2, nullptr); + auto accountName = lua_tostring(L, 1); + auto password = lua_tostring(L, 2); CGlueMgr::LoginServerLogin(accountName, password); diff --git a/src/ui/ScriptFunctionsSimpleFrame.cpp b/src/ui/ScriptFunctionsSimpleFrame.cpp index 24517df..ad060d3 100644 --- a/src/ui/ScriptFunctionsSimpleFrame.cpp +++ b/src/ui/ScriptFunctionsSimpleFrame.cpp @@ -30,9 +30,9 @@ int32_t Script_CreateFrame(lua_State* L) { return luaL_error(L, "Usage: CreateFrame(\"frameType\" [, \"name\"] [, parent] [, \"template\"] [, id])"); } - const char* v21 = lua_tolstring(L, 1, 0); - const char* v3 = lua_tolstring(L, 2, 0); - const char* inherits = lua_tolstring(L, 4, 0); + const char* v21 = lua_tostring(L, 1); + const char* v3 = lua_tostring(L, 2); + const char* inherits = lua_tostring(L, 4); CSimpleFrame* parent = nullptr; @@ -55,7 +55,7 @@ int32_t Script_CreateFrame(lua_State* L) { // If inherits argument is provided, ensure all inherited nodes exist if (lua_type(L, 4) == LUA_TSTRING) { - inherits = lua_tolstring(L, 4, 0); + inherits = lua_tostring(L, 4); char inheritName[1024]; const char* unk1; @@ -79,7 +79,7 @@ int32_t Script_CreateFrame(lua_State* L) { FrameXML_ReleaseHashNode(inheritName); } while (*inheritName); - inherits = lua_tolstring(L, 4, 0); + inherits = lua_tostring(L, 4); } // Build an XMLNode simulating the arguments to CreateFrame() @@ -100,7 +100,7 @@ int32_t Script_CreateFrame(lua_State* L) { } if (lua_isstring(L, 5)) { - const char* idStr = lua_tolstring(L, 5, nullptr); + const char* idStr = lua_tostring(L, 5); frameNode.SetAttribute("id", idStr); } else if (lua_isnumber(L, 5)) { int32_t idNum = lua_tointeger(L, 5); diff --git a/src/util/StringTo.cpp b/src/util/StringTo.cpp index f7b9f02..cacc394 100644 --- a/src/util/StringTo.cpp +++ b/src/util/StringTo.cpp @@ -99,7 +99,7 @@ bool StringToBOOL(lua_State* L, int32_t idx, int32_t def) { break; case LUA_TSTRING: - str = lua_tolstring(L, idx, 0); + str = lua_tostring(L, idx); result = StringToBOOL(str, def); break;