add nil checks for inventory id, slot index to inventory slot related functions

This commit is contained in:
MihailRis 2025-08-18 23:56:46 +03:00
parent 31cd7912ec
commit abc937769d

View File

@ -45,6 +45,12 @@ namespace {
template <SlotFunc func>
int wrap_slot(lua::State* L) {
if (lua::isnoneornil(L, 1)) {
throw std::runtime_error("inventory id is nil");
}
if (lua::isnoneornil(L, 2)) {
throw std::runtime_error("slot index is nil");
}
auto invid = lua::tointeger(L, 1);
auto slotid = lua::tointeger(L, 2);
auto& inv = get_inventory(invid);