* @brief Adds an item to a player's InvGrid array * @param player The player reference * @param invGridIndex Item's position in InvGrid (this should be the item's topleft grid tile) * @param invListIndex The item's InvList index (it's expected this already has +1 added to it since InvGrid can't store a 0 index) * @param itemSize Size of item */
| 134 | * @param itemSize Size of item |
| 135 | */ |
| 136 | void AddItemToInvGrid(Player &player, int invGridIndex, int invListIndex, Size itemSize) |
| 137 | { |
| 138 | const int pitch = 10; |
| 139 | for (int y = 0; y < itemSize.height; y++) { |
| 140 | int rowGridIndex = invGridIndex + pitch * y; |
| 141 | for (int x = 0; x < itemSize.width; x++) { |
| 142 | if (x == 0 && y == itemSize.height - 1) |
| 143 | player.InvGrid[rowGridIndex + x] = invListIndex; |
| 144 | else |
| 145 | player.InvGrid[rowGridIndex + x] = -invListIndex; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | if (&player == MyPlayer) { |
| 150 | NetSendCmdChInvItem(false, invGridIndex); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * @brief Checks whether the given item can fit in a belt slot (i.e. the item's size in inventory cells is 1x1). |
no test coverage detected