diff --git a/src/pc/lua/smlua_cobject.c b/src/pc/lua/smlua_cobject.c index 9a5d04cae..8e6367c17 100644 --- a/src/pc/lua/smlua_cobject.c +++ b/src/pc/lua/smlua_cobject.c @@ -84,7 +84,7 @@ static int smlua__get_field(lua_State* L) { return 0; } - u8* p = ((u8*)pointer) + data->valueOffset; + u8* p = ((u8*)(intptr_t)pointer) + data->valueOffset; switch (data->valueType) { case LVT_BOOL: lua_pushboolean(L, *(u8* )p); break; case LVT_U8: lua_pushinteger(L, *(u8* )p); break; @@ -150,7 +150,7 @@ static int smlua__set_field(lua_State* L) { return 0; } - u8* p = ((u8*)pointer) + data->valueOffset; + u8* p = ((u8*)(intptr_t)pointer) + data->valueOffset; switch (data->valueType) { case LVT_BOOL:*(u8*) p = smlua_to_boolean(L, -1); break; case LVT_U8: *(u8*) p = smlua_to_integer(L, -1); break; diff --git a/src/pc/lua/smlua_utils.c b/src/pc/lua/smlua_utils.c index 8919401f1..0ac7ab0eb 100644 --- a/src/pc/lua/smlua_utils.c +++ b/src/pc/lua/smlua_utils.c @@ -109,13 +109,13 @@ void* smlua_to_cobject(lua_State* L, int index, u16 lot) { // get pointer lua_getfield(L, index, "_pointer"); - void* pointer = (void*)smlua_to_integer(L, -1); + void* pointer = (void*)(intptr_t)smlua_to_integer(L, -1); lua_pop(L, 1); if (!gSmLuaConvertSuccess) { return NULL; } // check allowlist - if (!smlua_cobject_allowlist_contains(lot, (u64)pointer)) { - LOG_LUA("smlua_to_cobject received a pointer not in allow list. '%u', '%llu", lot, (u64)pointer); + if (!smlua_cobject_allowlist_contains(lot, (u64)(intptr_t)pointer)) { + LOG_LUA("smlua_to_cobject received a pointer not in allow list. '%u', '%llu", lot, (u64)(intptr_t)pointer); gSmLuaConvertSuccess = false; return NULL; } @@ -197,12 +197,12 @@ void smlua_push_object(lua_State* L, u16 lot, void* p) { return; } // add to allowlist - smlua_cobject_allowlist_add(lot, (u64)p); + smlua_cobject_allowlist_add(lot, (u64)(intptr_t)p); lua_newtable(L); int t = lua_gettop(L); smlua_push_integer_field(t, "_lot", lot); - smlua_push_integer_field(t, "_pointer", (u64)p); + smlua_push_integer_field(t, "_pointer", (u64)(intptr_t)p); lua_pushglobaltable(L); lua_getfield(gLuaState, -1, "_CObject"); lua_setmetatable(L, -3);