Fix exclamation boxes again (#540)

Hopefully for the last time for this method
This commit is contained in:
Sunk 2023-11-24 17:57:55 -05:00 committed by GitHub
parent aa3e5fad12
commit f237fc1781
1 changed files with 5 additions and 5 deletions

View File

@ -1777,7 +1777,7 @@ int smlua_hook_exclamation_box(lua_State* L) {
return 0;
}
if (sHookedBehaviorsCount > MAX_HOOKED_EXCLAMATION_BOXES) {
if (sHookedExclamationBoxesCount > MAX_HOOKED_EXCLAMATION_BOXES) {
LOG_LUA_LINE("hook_exclamation_box() calls exceeded maximum references");
return 0;
}
@ -1814,7 +1814,7 @@ int smlua_hook_exclamation_box(lua_State* L) {
hooked->mod = gLuaActiveMod;
if (!gSmLuaConvertSuccess) { return 0; }
sHookedBehaviorsCount++;
sHookedExclamationBoxesCount++;
return 1;
}
@ -1822,7 +1822,7 @@ int smlua_hook_exclamation_box(lua_State* L) {
struct Object* smlua_call_exclamation_box_hook(struct Object* obj, bool write) {
lua_State* L = gLuaState;
if (L == NULL) { return NULL; }
for (int i = 0; i < sHookedBehaviorsCount; i++) {
for (int i = 0; i < sHookedExclamationBoxesCount; i++) {
struct LuaHookedExclamationBox* hook = &sHookedExclamationBoxes[i];
// Push 2 potential callbacks
@ -1840,9 +1840,9 @@ struct Object* smlua_call_exclamation_box_hook(struct Object* obj, bool write) {
// output the return value
struct Object* returnObject = NULL;
if (write) {
if (write && reference != 0) {
returnObject = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
if (!gSmLuaConvertSuccess || returnObject == NULL) {
if (lua_type(L, 1) != LUA_TTABLE || !gSmLuaConvertSuccess) {
LOG_LUA("Return value type is invalid for writeFunction: %d", lua_type(L, 1));
continue;
}