本文整理汇总了C++中IRollbackManager::reportAction方法的典型用法代码示例。如果您正苦于以下问题:C++ IRollbackManager::reportAction方法的具体用法?C++ IRollbackManager::reportAction怎么用?C++ IRollbackManager::reportAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRollbackManager
的用法示例。
在下文中一共展示了IRollbackManager::reportAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
//.........这里部分代码省略.........
int src_can_take_count = take_count;
// Source is detached
if(from_inv.type == InventoryLocation::DETACHED)
{
ItemStack src_item = list_from->getItem(from_i);
src_item.count = take_count;
src_can_take_count = PLAYER_TO_SA(player)->detached_inventory_AllowTake(
from_inv.name, from_list, from_i, src_item, player);
}
// Source is nodemeta
if(from_inv.type == InventoryLocation::NODEMETA)
{
ItemStack src_item = list_from->getItem(from_i);
src_item.count = take_count;
src_can_take_count = PLAYER_TO_SA(player)->nodemeta_inventory_AllowTake(
from_inv.p, from_list, from_i, src_item, player);
}
if(src_can_take_count != -1 && src_can_take_count < take_count)
take_count = src_can_take_count;
int actually_dropped_count = 0;
ItemStack src_item = list_from->getItem(from_i);
// Drop the item
ItemStack item1 = list_from->getItem(from_i);
item1.count = take_count;
if(PLAYER_TO_SA(player)->item_OnDrop(item1, player,
player->getBasePosition() + v3f(0,1,0)))
{
actually_dropped_count = take_count - item1.count;
if(actually_dropped_count == 0){
infostream<<"Actually dropped no items"<<std::endl;
return;
}
// If source isn't infinite
if(src_can_take_count != -1){
// Take item from source list
ItemStack item2 = list_from->takeItem(from_i, actually_dropped_count);
if(item2.count != actually_dropped_count)
errorstream<<"Could not take dropped count of items"<<std::endl;
mgr->setInventoryModified(from_inv, false);
}
}
infostream<<"IDropAction::apply(): dropped "
<<" from inv=\""<<from_inv.dump()<<"\""
<<" list=\""<<from_list<<"\""
<<" i="<<from_i
<<std::endl;
src_item.count = actually_dropped_count;
/*
Report drop to endpoints
*/
// Source is detached
if(from_inv.type == InventoryLocation::DETACHED)
{
PLAYER_TO_SA(player)->detached_inventory_OnTake(
from_inv.name, from_list, from_i, src_item, player);
}
// Source is nodemeta
if(from_inv.type == InventoryLocation::NODEMETA)
{
PLAYER_TO_SA(player)->nodemeta_inventory_OnTake(
from_inv.p, from_list, from_i, src_item, player);
}
/*
Record rollback information
*/
if(!ignore_src_rollback && gamedef->rollback())
{
IRollbackManager *rollback = gamedef->rollback();
// If source is not infinite, record item take
if(src_can_take_count != -1){
RollbackAction action;
std::string loc;
{
std::ostringstream os(std::ios::binary);
from_inv.serialize(os);
loc = os.str();
}
action.setModifyInventoryStack(loc, from_list, from_i,
false, src_item);
rollback->reportAction(action);
}
}
}