| 33 | }; |
| 34 | |
| 35 | bool TryModifyMiscCount(LaraInfo & lara, GAME_OBJECT_ID objectID, std::optional<int> amount, ModificationType modType) |
| 36 | { |
| 37 | // If adding, replace the small/large waterskin with one of the requested |
| 38 | // capacity. If removing, only remove the waterskin if it contains the given |
| 39 | // capacity. |
| 40 | |
| 41 | bool add = ModificationType::Add == modType || ((ModificationType::Set == modType) && amount != 0); |
| 42 | |
| 43 | auto modifyWaterSkinAmount = [&](byte& currentFlag, byte newFlag) |
| 44 | { |
| 45 | if (add) |
| 46 | currentFlag = newFlag; |
| 47 | else |
| 48 | { |
| 49 | if (currentFlag == newFlag) |
| 50 | currentFlag = 0; |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | auto modifyBeetleCount = [&](int bit) |
| 55 | { |
| 56 | if (add) |
| 57 | lara.Inventory.BeetleComponents |= 1 << bit; |
| 58 | else |
| 59 | lara.Inventory.BeetleComponents &= ~(1 << bit); |
| 60 | }; |
| 61 | |
| 62 | switch (objectID) |
| 63 | { |
| 64 | case ID_SILENCER_ITEM: |
| 65 | lara.Inventory.HasSilencer = add && !SilencerIsEquipped(lara); |
| 66 | break; |
| 67 | |
| 68 | case ID_LASERSIGHT_ITEM: |
| 69 | lara.Inventory.HasLasersight = add && !LaserSightIsEquipped(lara); |
| 70 | break; |
| 71 | |
| 72 | case ID_BINOCULARS_ITEM: |
| 73 | lara.Inventory.HasBinoculars = add; |
| 74 | break; |
| 75 | |
| 76 | case ID_CROWBAR_ITEM: |
| 77 | lara.Inventory.HasCrowbar = add; |
| 78 | break; |
| 79 | |
| 80 | case ID_DIARY_ITEM: |
| 81 | lara.Inventory.HasDiary = add; |
| 82 | break; |
| 83 | |
| 84 | case ID_PC_LOAD_INV_ITEM: |
| 85 | lara.Inventory.HasLoad = add; |
| 86 | break; |
| 87 | |
| 88 | case ID_PC_SAVE_INV_ITEM: |
| 89 | lara.Inventory.HasSave = add; |
| 90 | break; |
| 91 | |
| 92 | case ID_STOPWATCH_ITEM: |
no test coverage detected