| 189 | |
| 190 | |
| 191 | void cInventory::SetSlot(int a_SlotNum, const cItem & a_Item) |
| 192 | { |
| 193 | if ((a_SlotNum < 0) || (a_SlotNum >= invNumSlots)) |
| 194 | { |
| 195 | LOGWARNING("%s: requesting an invalid slot index: %d out of %d. Ignoring.", __FUNCTION__, a_SlotNum, invNumSlots - 1); |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | int GridSlotNum = 0; |
| 200 | cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum); |
| 201 | if (Grid == NULL) |
| 202 | { |
| 203 | LOGWARNING("%s(%d): requesting an invalid itemgrid. Ignoring.", __FUNCTION__, a_SlotNum); |
| 204 | return; |
| 205 | } |
| 206 | Grid->SetSlot(GridSlotNum, a_Item); |
| 207 | |
| 208 | // Broadcast the Equipped Item, if the Slot is changed. |
| 209 | if ((Grid == &m_HotbarSlots) && (m_EquippedSlotNum == (a_SlotNum - invHotbarOffset))) |
| 210 | { |
| 211 | m_Owner.GetWorld()->BroadcastEntityEquipment(m_Owner, 0, a_Item, m_Owner.GetClientHandle()); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | |
| 216 |
no test coverage detected