#include "environment.h"
#include "scripting_game.h"
#include "serverobject.h"
-#include "main.h" // for g_settings
#include "settings.h"
#include "craftdef.h"
#include "rollback_interface.h"
+#include "strfnd.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
os<<"detached:"<<name;
break;
default:
- assert(0);
+ FATAL_ERROR("Unhandled inventory location type");
}
}
*/
if(!ignore_rollback && gamedef->rollback())
{
- IRollbackReportSink *rollback = gamedef->rollback();
+ IRollbackManager *rollback = gamedef->rollback();
// If source is not infinite, record item take
if(src_can_take_count != -1){
loc = os.str();
}
action.setModifyInventoryStack(loc, from_list, from_i, false,
- src_item.getItemString());
+ src_item);
rollback->reportAction(action);
}
// If destination is not infinite, record item put
loc = os.str();
}
action.setModifyInventoryStack(loc, to_list, to_i, true,
- src_item.getItemString());
+ src_item);
rollback->reportAction(action);
}
}
}
}
- mgr->setInventoryModified(from_inv);
+ mgr->setInventoryModified(from_inv, false);
if(inv_from != inv_to)
- mgr->setInventoryModified(to_inv);
+ mgr->setInventoryModified(to_inv, false);
}
void IMoveAction::clientApply(InventoryManager *mgr, IGameDef *gamedef)
if(item2.count != actually_dropped_count)
errorstream<<"Could not take dropped count of items"<<std::endl;
- mgr->setInventoryModified(from_inv);
+ mgr->setInventoryModified(from_inv, false);
}
}
*/
if(!ignore_src_rollback && gamedef->rollback())
{
- IRollbackReportSink *rollback = gamedef->rollback();
+ IRollbackManager *rollback = gamedef->rollback();
// If source is not infinite, record item take
if(src_can_take_count != -1){
loc = os.str();
}
action.setModifyInventoryStack(loc, from_list, from_i,
- false, src_item.getItemString());
+ false, src_item);
rollback->reportAction(action);
}
}
}
ItemStack crafted;
+ ItemStack craftresultitem;
int count_remaining = count;
- bool found = getCraftingResult(inv_craft, crafted, false, gamedef);
+ getCraftingResult(inv_craft, crafted, false, gamedef);
+ PLAYER_TO_SA(player)->item_CraftPredict(crafted, player, list_craft, craft_inv);
+ bool found = !crafted.empty();
while(found && list_craftresult->itemFits(0, crafted))
{
+ InventoryList saved_craft_list = *list_craft;
+
// Decrement input and add crafting output
getCraftingResult(inv_craft, crafted, true, gamedef);
+ PLAYER_TO_SA(player)->item_OnCraft(crafted, player, &saved_craft_list, craft_inv);
list_craftresult->addItem(0, crafted);
mgr->setInventoryModified(craft_inv);
// Get next crafting result
found = getCraftingResult(inv_craft, crafted, false, gamedef);
+ PLAYER_TO_SA(player)->item_CraftPredict(crafted, player, list_craft, craft_inv);
+ found = !crafted.empty();
}
infostream<<"ICraftAction::apply(): crafted "