MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MultiSendInventoryRemoveItem

Function MultiSendInventoryRemoveItem

Descent3/multi.cpp:7326–7362  ·  view source on GitHub ↗

Tell the clients to remove an item from a player's inventory

Source from the content-addressed store, hash-verified

7324
7325// Tell the clients to remove an item from a player's inventory
7326void MultiSendInventoryRemoveItem(int slot, int type, int id) {
7327 if (id == -1) {
7328 mprintf(0, "Telling clients to remove objnum %d from %d\n", OBJNUM(ObjGet(type)), slot);
7329 } else {
7330 mprintf(0, "Telling clients to remove inven item T=%d ID=%d from %d\n", type, id, slot);
7331 }
7332
7333 int size = 0;
7334 uint8_t data[MAX_GAME_DATA_SIZE];
7335 int count = 0;
7336
7337 if (id == -1) {
7338 object *o = ObjGet(type);
7339 ASSERT(o);
7340 if (o) {
7341 int objnum = OBJNUM(o);
7342
7343 MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER);
7344 size = START_DATA(MP_REMOVE_INVENTORY_ITEM, data, &count, 1);
7345 MultiAddUshort(objnum, data, &count);
7346 MultiAddUint(0xFFFFFFFF, data, &count);
7347 MultiAddByte(slot, data, &count);
7348 END_DATA(count, data, size);
7349 MultiSendReliablyToAllExcept(Player_num, data, count, false);
7350 }
7351
7352 } else {
7353 // type/id
7354 MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER);
7355 size = START_DATA(MP_REMOVE_INVENTORY_ITEM, data, &count, 1);
7356 MultiAddUshort((uint16_t)type, data, &count);
7357 MultiAddUint(MultiGetMatchChecksum(type, id), data, &count);
7358 MultiAddByte(slot, data, &count);
7359 END_DATA(count, data, size);
7360 MultiSendReliablyToAllExcept(Player_num, data, count, false);
7361 }
7362}
7363
7364void MultiSetAudioTauntTime(float time, int to_who) {
7365 MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER);

Callers 3

UseInventoryItemFunction · 0.85
UseCountermeasureFunction · 0.85

Calls 8

ObjGetFunction · 0.85
START_DATAFunction · 0.85
MultiAddUshortFunction · 0.85
MultiAddUintFunction · 0.85
MultiAddByteFunction · 0.85
END_DATAFunction · 0.85
MultiGetMatchChecksumFunction · 0.85

Tested by

no test coverage detected