mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
add nil checks for inventory id, slot index to inventory slot related functions
This commit is contained in:
parent
31cd7912ec
commit
abc937769d
1 changed files with 6 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue