Bulk clearing of whitespace
This commit is contained in:
@@ -27,7 +27,7 @@ cInventory::cInventory(cPlayer & a_Owner) :
|
||||
m_ArmorSlots.AddListener(*this);
|
||||
m_InventorySlots.AddListener(*this);
|
||||
m_HotbarSlots.AddListener(*this);
|
||||
|
||||
|
||||
SetEquippedSlotNum(0);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
res += m_InventorySlots.AddItem(ToAdd, a_AllowNewStacks);
|
||||
return res;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ bool cInventory::RemoveOneEquippedItem(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
m_HotbarSlots.ChangeSlotCount(m_EquippedSlotNum, -1);
|
||||
return true;
|
||||
}
|
||||
@@ -416,7 +416,7 @@ bool cInventory::DamageItem(int a_SlotNum, short a_Amount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int GridSlotNum = 0;
|
||||
cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum);
|
||||
if (Grid == nullptr)
|
||||
@@ -430,7 +430,7 @@ bool cInventory::DamageItem(int a_SlotNum, short a_Amount)
|
||||
SendSlot(a_SlotNum);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// The item has broken, remove it:
|
||||
Grid->EmptySlot(GridSlotNum);
|
||||
return true;
|
||||
@@ -600,7 +600,7 @@ void cInventory::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value.append(EmptyItemJson);
|
||||
}
|
||||
|
||||
|
||||
// The 4 armor slots follow:
|
||||
for (int i = 0; i < invArmorCount; i++)
|
||||
{
|
||||
@@ -633,24 +633,24 @@ void cInventory::SaveToJson(Json::Value & a_Value)
|
||||
bool cInventory::LoadFromJson(Json::Value & a_Value)
|
||||
{
|
||||
int SlotIdx = 0;
|
||||
|
||||
|
||||
for (Json::Value::iterator itr = a_Value.begin(); itr != a_Value.end(); ++itr, SlotIdx++)
|
||||
{
|
||||
cItem Item;
|
||||
Item.FromJson(*itr);
|
||||
|
||||
|
||||
// The JSON originally included the 4 crafting slots and the result slot, so we need to skip the first 5 items:
|
||||
if (SlotIdx < 5)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// If we loaded all the slots, stop now, even if the JSON has more:
|
||||
if (SlotIdx - 5 >= invNumSlots)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
int GridSlotNum = 0;
|
||||
cItemGrid * Grid = GetGridForSlotNum(SlotIdx - 5, GridSlotNum);
|
||||
ASSERT(Grid != nullptr);
|
||||
@@ -666,7 +666,7 @@ bool cInventory::LoadFromJson(Json::Value & a_Value)
|
||||
const cItemGrid * cInventory::GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum) const
|
||||
{
|
||||
ASSERT(a_SlotNum >= 0);
|
||||
|
||||
|
||||
if (a_SlotNum < invArmorCount)
|
||||
{
|
||||
a_GridSlotNum = a_SlotNum;
|
||||
@@ -689,7 +689,7 @@ const cItemGrid * cInventory::GetGridForSlotNum(int a_SlotNum, int & a_GridSlotN
|
||||
cItemGrid * cInventory::GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum)
|
||||
{
|
||||
ASSERT(a_SlotNum >= 0);
|
||||
|
||||
|
||||
if (a_SlotNum < invArmorCount)
|
||||
{
|
||||
a_GridSlotNum = a_SlotNum;
|
||||
@@ -712,13 +712,13 @@ cItemGrid * cInventory::GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum)
|
||||
void cInventory::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
|
||||
{
|
||||
// Send the neccessary updates to whoever needs them
|
||||
|
||||
|
||||
if (m_Owner.IsDestroyed())
|
||||
{
|
||||
// Owner is not (yet) valid, skip for now
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Armor update needs broadcast to other players:
|
||||
cWorld * World = m_Owner.GetWorld();
|
||||
if ((a_ItemGrid == &m_ArmorSlots) && (World != nullptr))
|
||||
@@ -734,7 +734,7 @@ void cInventory::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
|
||||
{
|
||||
m_Owner.GetWorld()->BroadcastEntityEquipment(m_Owner, 0, GetEquippedItem(), m_Owner.GetClientHandle());
|
||||
}
|
||||
|
||||
|
||||
// Convert the grid-local a_SlotNum to our global SlotNum:
|
||||
int Base = 0;
|
||||
if (a_ItemGrid == &m_ArmorSlots)
|
||||
@@ -754,7 +754,7 @@ void cInventory::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
|
||||
ASSERT(!"Unknown ItemGrid calling OnSlotChanged()");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SendSlot(Base + a_SlotNum);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user