mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-03-26 21:11:43 +00:00
explicitly allow setting cobjects to nil
This commit is contained in:
parent
83c967457f
commit
2dd17af4e1
2 changed files with 10 additions and 2 deletions
|
|
@ -430,6 +430,10 @@ static bool smlua_set_field(lua_State* L, u8* p, struct LuaObjectField *data) {
|
|||
case LVT_U64: *(s64*)p = smlua_to_integer(L, 3); break;
|
||||
|
||||
case LVT_COBJECT_P:
|
||||
if (lua_isnil(L, 3)) {
|
||||
*(u8**)p = NULL;
|
||||
break;
|
||||
}
|
||||
valuePointer = smlua_to_cobject(L, 3, data->lot);
|
||||
if (gSmLuaConvertSuccess) {
|
||||
*(u8**)p = valuePointer;
|
||||
|
|
@ -450,6 +454,10 @@ static bool smlua_set_field(lua_State* L, u8* p, struct LuaObjectField *data) {
|
|||
case LVT_OBJECTANIMPOINTER_P:
|
||||
case LVT_COLLISION_P:
|
||||
case LVT_TRAJECTORY_P:
|
||||
if (lua_isnil(L, 3)) {
|
||||
*(u8**)p = NULL;
|
||||
break;
|
||||
}
|
||||
valuePointer = smlua_to_cpointer(L, 3, data->valueType);
|
||||
if (gSmLuaConvertSuccess) {
|
||||
*(u8**)p = valuePointer;
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ void* smlua_to_cobject(lua_State* L, int index, u16 lot) {
|
|||
if (indexType != LUA_TUSERDATA) {
|
||||
LOG_LUA_LINE("smlua_to_cobject received improper type '%s'", lua_typename(L, indexType));
|
||||
gSmLuaConvertSuccess = false;
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CObject *cobject = luaL_checkudata(L, index, "CObject");
|
||||
|
|
@ -179,7 +179,7 @@ void* smlua_to_cpointer(lua_State* L, int index, u16 lvt) {
|
|||
if (indexType != LUA_TUSERDATA) {
|
||||
LOG_LUA_LINE("smlua_to_cpointer received improper type '%s'", lua_typename(L, indexType));
|
||||
gSmLuaConvertSuccess = false;
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CPointer *cpointer = luaL_checkudata(L, index, "CPointer");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue