mirror of
https://github.com/minetest/minetest.git
synced 2025-07-05 01:10:22 +02:00
Replace Optional with std::optional
This commit is contained in:
@ -59,7 +59,7 @@ bool ScriptApiItem::item_OnDrop(ItemStack &item,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScriptApiItem::item_OnPlace(Optional<ItemStack> &ret_item,
|
||||
bool ScriptApiItem::item_OnPlace(std::optional<ItemStack> &ret_item,
|
||||
ServerActiveObject *placer, const PointedThing &pointed)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
@ -88,13 +88,13 @@ bool ScriptApiItem::item_OnPlace(Optional<ItemStack> &ret_item,
|
||||
throw WRAP_LUAERROR(e, "item=" + item.name);
|
||||
}
|
||||
} else {
|
||||
ret_item = nullopt;
|
||||
ret_item = std::nullopt;
|
||||
}
|
||||
lua_pop(L, 2); // Pop item and error handler
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScriptApiItem::item_OnUse(Optional<ItemStack> &ret_item,
|
||||
bool ScriptApiItem::item_OnUse(std::optional<ItemStack> &ret_item,
|
||||
ServerActiveObject *user, const PointedThing &pointed)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
@ -118,13 +118,13 @@ bool ScriptApiItem::item_OnUse(Optional<ItemStack> &ret_item,
|
||||
throw WRAP_LUAERROR(e, "item=" + item.name);
|
||||
}
|
||||
} else {
|
||||
ret_item = nullopt;
|
||||
ret_item = std::nullopt;
|
||||
}
|
||||
lua_pop(L, 2); // Pop item and error handler
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScriptApiItem::item_OnSecondaryUse(Optional<ItemStack> &ret_item,
|
||||
bool ScriptApiItem::item_OnSecondaryUse(std::optional<ItemStack> &ret_item,
|
||||
ServerActiveObject *user, const PointedThing &pointed)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
@ -146,7 +146,7 @@ bool ScriptApiItem::item_OnSecondaryUse(Optional<ItemStack> &ret_item,
|
||||
throw WRAP_LUAERROR(e, "item=" + item.name);
|
||||
}
|
||||
} else {
|
||||
ret_item = nullopt;
|
||||
ret_item = std::nullopt;
|
||||
}
|
||||
lua_pop(L, 2); // Pop item and error handler
|
||||
return true;
|
||||
|
@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
#include "cpp_api/s_base.h"
|
||||
#include "irr_v3d.h"
|
||||
#include "util/Optional.h"
|
||||
#include <optional>
|
||||
|
||||
struct PointedThing;
|
||||
struct ItemStack;
|
||||
@ -37,7 +37,7 @@ class ScriptApiItem
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* Functions with Optional<ItemStack> are for callbacks where Lua may
|
||||
* Functions with std::optional<ItemStack> are for callbacks where Lua may
|
||||
* want to prevent the engine from modifying the inventory after it's done.
|
||||
* This has a longer backstory where on_use may need to empty the player's
|
||||
* inventory without the engine interfering (see issue #6546).
|
||||
@ -45,11 +45,11 @@ public:
|
||||
|
||||
bool item_OnDrop(ItemStack &item,
|
||||
ServerActiveObject *dropper, v3f pos);
|
||||
bool item_OnPlace(Optional<ItemStack> &item,
|
||||
bool item_OnPlace(std::optional<ItemStack> &item,
|
||||
ServerActiveObject *placer, const PointedThing &pointed);
|
||||
bool item_OnUse(Optional<ItemStack> &item,
|
||||
bool item_OnUse(std::optional<ItemStack> &item,
|
||||
ServerActiveObject *user, const PointedThing &pointed);
|
||||
bool item_OnSecondaryUse(Optional<ItemStack> &item,
|
||||
bool item_OnSecondaryUse(std::optional<ItemStack> &item,
|
||||
ServerActiveObject *user, const PointedThing &pointed);
|
||||
bool item_OnCraft(ItemStack &item, ServerActiveObject *user,
|
||||
const InventoryList *old_craft_grid, const InventoryLocation &craft_inv);
|
||||
|
Reference in New Issue
Block a user