]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/inventorymanager.cpp
Noise: Fix interpolation at negative coordinates
[dragonfireclient.git] / src / inventorymanager.cpp
index c81f7a19e6515e1e71a8a10fb2a50f9c781cbe5d..c3a9576f90ef2111998d3f9c8665c74e6d67778f 100644 (file)
@@ -22,10 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #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<<")"
 
@@ -61,7 +61,7 @@ void InventoryLocation::serialize(std::ostream &os) const
                os<<"detached:"<<name;
                break;
        default:
-               assert(0);
+               FATAL_ERROR("Unhandled inventory location type");
        }
 }
 
@@ -367,7 +367,7 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
        */
        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){
@@ -379,7 +379,7 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
                                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
@@ -392,7 +392,7 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
                                loc = os.str();
                        }
                        action.setModifyInventoryStack(loc, to_list, to_i, true,
-                                       src_item.getItemString());
+                                       src_item);
                        rollback->reportAction(action);
                }
        }
@@ -454,9 +454,9 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
                }
        }
        
-       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)
@@ -596,7 +596,7 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
                        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);
                }
        }
 
@@ -631,7 +631,7 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
        */
        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){
@@ -643,7 +643,7 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
                                loc = os.str();
                        }
                        action.setModifyInventoryStack(loc, from_list, from_i,
-                                       false, src_item.getItemString());
+                                       false, src_item);
                        rollback->reportAction(action);
                }
        }
@@ -724,13 +724,19 @@ void ICraftAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGam
        }
 
        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);
 
@@ -747,6 +753,8 @@ void ICraftAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGam
 
                // 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 "