Handle a remove item from inventory
| 7276 | |
| 7277 | // Handle a remove item from inventory |
| 7278 | void MultiDoClientInventoryRemoveItem(int slot, uint8_t *data) { |
| 7279 | int count = 0; |
| 7280 | int type; |
| 7281 | int id; |
| 7282 | uint32_t hash; |
| 7283 | int pnum; |
| 7284 | |
| 7285 | // Only the server receives this |
| 7286 | MULTI_ASSERT_NOMESSAGE(Netgame.local_role != LR_SERVER); |
| 7287 | SKIP_HEADER(data, &count); |
| 7288 | |
| 7289 | type = MultiGetUshort(data, &count); |
| 7290 | hash = MultiGetUint(data, &count); |
| 7291 | pnum = MultiGetByte(data, &count); |
| 7292 | |
| 7293 | if (hash == 0xFFFFFFFF) { |
| 7294 | // object given |
| 7295 | id = -1; |
| 7296 | |
| 7297 | // convert server objnum to a local objnum |
| 7298 | type = Server_object_list[type]; |
| 7299 | |
| 7300 | // the objnum coming in better be in our object list |
| 7301 | ASSERT(type >= 0 && type < MAX_OBJECTS); |
| 7302 | ASSERT(Objects[type].type != OBJ_NONE); |
| 7303 | |
| 7304 | mprintf(0, "Server is telling me to remove objnum %d\n", type); |
| 7305 | |
| 7306 | // convert type to objhandle |
| 7307 | type = Objects[type].handle; |
| 7308 | |
| 7309 | Players[pnum].inventory.Remove(type, id); |
| 7310 | |
| 7311 | } else { |
| 7312 | |
| 7313 | if (type == OBJ_WEAPON) { |
| 7314 | id = MultiMatchWeapon(hash); |
| 7315 | mprintf(0, "Server is telling me to remove T=%d ID=%d from %d\n", type, id, pnum); |
| 7316 | Players[pnum].counter_measures.Remove(type, id); |
| 7317 | } else { |
| 7318 | id = MultiMatchGeneric(hash); |
| 7319 | mprintf(0, "Server is telling me to remove T=%d ID=%d from %d\n", type, id, pnum); |
| 7320 | Players[pnum].inventory.Remove(type, id); |
| 7321 | } |
| 7322 | } |
| 7323 | } |
| 7324 | |
| 7325 | // Tell the clients to remove an item from a player's inventory |
| 7326 | void MultiSendInventoryRemoveItem(int slot, int type, int id) { |
no test coverage detected