Compare commits

..

3 Commits

Author SHA1 Message Date
Tristan 'Natrist' Cormier
2f4c4ed74a
Merge 44bee4cbd7 into 0163d91543 2026-07-25 02:38:16 +02:00
fallenoak
0163d91543 chore(util): tune up StringToDrawLayer
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
2026-07-24 13:29:07 -05:00
fallenoak
dd3a0f6a81 fix(util): fix improper handling of BOTTOM in StringToJustify 2026-07-24 13:21:36 -05:00

View File

@ -112,12 +112,12 @@ bool StringToBOOL(lua_State* L, int32_t idx, int32_t def) {
} }
int32_t StringToDrawLayer(const char* string, int32_t& layer) { int32_t StringToDrawLayer(const char* string, int32_t& layer) {
struct drawlayer { struct LayerEntry {
int32_t layer; int32_t layer;
const char* string; const char* string;
}; };
static drawlayer array_drawlayer[5] = { static LayerEntry layerMap[] = {
{ 0, "BACKGROUND" }, { 0, "BACKGROUND" },
{ 1, "BORDER" }, { 1, "BORDER" },
{ 2, "ARTWORK" }, { 2, "ARTWORK" },
@ -125,9 +125,9 @@ int32_t StringToDrawLayer(const char* string, int32_t& layer) {
{ 4, "HIGHLIGHT" } { 4, "HIGHLIGHT" }
}; };
for (int32_t i = 0; i < 5; i++) { for (const auto& entry : layerMap) {
if (!SStrCmpI(array_drawlayer[i].string, string, 0x7FFFFFFFu)) { if (!SStrCmpI(entry.string, string)) {
layer = array_drawlayer[i].layer; layer = entry.layer;
return 1; return 1;
} }
} }
@ -141,7 +141,7 @@ int32_t StringToJustify(const char* string, uint32_t& justify) {
const char* string; const char* string;
}; };
static JustifyEntry justifyMap[6] = { static JustifyEntry justifyMap[] = {
{ 0x1, "LEFT" }, { 0x1, "LEFT" },
{ 0x2, "CENTER" }, { 0x2, "CENTER" },
{ 0x4, "RIGHT" }, { 0x4, "RIGHT" },
@ -150,9 +150,9 @@ int32_t StringToJustify(const char* string, uint32_t& justify) {
{ 0x20, "BOTTOM" } { 0x20, "BOTTOM" }
}; };
for (int32_t i = 0; i < 5; i++) { for (const auto& entry : justifyMap) {
if (!SStrCmpI(justifyMap[i].string, string, 0x7FFFFFFFu)) { if (!SStrCmpI(entry.string, string)) {
justify = justifyMap[i].value; justify = entry.value;
return 1; return 1;
} }
} }