inventory.deSerialize(is);
- if (inventory.getList("craftpreview") == NULL) {
+ if (!inventory.getList("craftpreview") && inventory.getList("craftresult")) {
// Convert players without craftpreview
inventory.addList("craftpreview", 1);
const InventoryList *old_craft_grid, const InventoryLocation &craft_inv)
{
SCRIPTAPI_PRECHECKHEADER
-
+ sanity_check(old_craft_grid);
int error_handler = PUSH_ERROR_HANDLER(L);
lua_getglobal(L, "core");
void Server::UpdateCrafting(RemotePlayer *player)
{
+ InventoryList *clist = player->inventory.getList("craft");
+ if (!clist || clist->getSize() == 0)
+ return;
+
// Get a preview for crafting
ItemStack preview;
InventoryLocation loc;
std::vector<ItemStack> output_replacements;
getCraftingResult(&player->inventory, preview, output_replacements, false, this);
m_env->getScriptIface()->item_CraftPredict(preview, player->getPlayerSAO(),
- (&player->inventory)->getList("craft"), loc);
+ clist, loc);
- // Put the new preview in
InventoryList *plist = player->inventory.getList("craftpreview");
- sanity_check(plist);
- sanity_check(plist->getSize() >= 1);
- plist->changeItem(0, preview);
+ if (plist && plist->getSize() >= 1) {
+ // Put the new preview in
+ plist->changeItem(0, preview);
+ }
}
void Server::handleChatInterfaceEvent(ChatEvent *evt)