adds a special cased CounterMeasure into the inventory
| 526 | |
| 527 | // adds a special cased CounterMeasure into the inventory |
| 528 | bool Inventory::AddCounterMeasure(int id, int aux_type, int aux_id, int flags, const char *description) { |
| 529 | // make sure we can fit another object |
| 530 | if (count >= MAX_UNIQUE_INVEN_ITEMS) { |
| 531 | mprintf(0, "Hit max unique in counter measure add\n"); |
| 532 | return false; |
| 533 | } |
| 534 | |
| 535 | inven_item *current = root, *prev = root, *newnode; |
| 536 | |
| 537 | if (count == 0) { |
| 538 | // there are no items in the list...time to add |
| 539 | root = new inven_item; |
| 540 | newnode = root; |
| 541 | root->next = root; |
| 542 | root->prev = root; |
| 543 | newnode->count = 1; |
| 544 | } else { |
| 545 | newnode = FindItem(OBJ_WEAPON, id); |
| 546 | |
| 547 | if (!newnode) { |
| 548 | // NEEDTODO: adjust so it adds in order |
| 549 | |
| 550 | newnode = new inven_item; |
| 551 | |
| 552 | prev = root->prev; |
| 553 | |
| 554 | newnode->prev = prev; |
| 555 | prev->next = newnode; |
| 556 | newnode->next = root; |
| 557 | root->prev = newnode; |
| 558 | |
| 559 | newnode->count = 1; |
| 560 | } else { |
| 561 | // there is an item of that type/id already, just increase it's count |
| 562 | newnode->count++; |
| 563 | // mprintf(0,"Inventory: Item #%d (%s) Count increased to %d\n",count,newnode->name,newnode->count); |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | // its a new item type/id, so fill in its info |
| 568 | if (newnode->count == 1) { |
| 569 | newnode->type = OBJ_WEAPON; |
| 570 | newnode->id = id; |
| 571 | newnode->flags = 0; |
| 572 | newnode->iflags = 0; |
| 573 | newnode->otype = aux_type; |
| 574 | newnode->oid = aux_id; |
| 575 | |
| 576 | if ((aux_type != -1) && (aux_id != -1) && (Object_info[aux_id].description)) { |
| 577 | newnode->description = mem_strdup(Object_info[aux_id].description); |
| 578 | } else { |
| 579 | newnode->description = mem_strdup(Weapons[id].name); |
| 580 | } |
| 581 | |
| 582 | newnode->iflags |= INVF_SELECTABLE | INVF_USEABLE | INVF_MISSIONITEM | INVF_TIMEOUTONSPEW; |
| 583 | |
| 584 | newnode->icon_name = |
| 585 | (char *)mem_malloc(strlen(GameBitmaps[GameTextures[Weapons[id].icon_handle].bm_handle].name) + 1); |
no outgoing calls
no test coverage detected