MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / SetSlotsBlocked

Method SetSlotsBlocked

ogsr_engine/xrGame/Inventory.cpp:1117–1174  ·  view source on GitHub ↗

call this only via Actor()->SetWeaponHideState()

Source from the content-addressed store, hash-verified

1115
1116// call this only via Actor()->SetWeaponHideState()
1117void CInventory::SetSlotsBlocked(u16 mask, bool bBlock, bool now)
1118{
1119 bool bChanged = false;
1120 for (int i = 0; i < SLOTS_TOTAL; ++i)
1121 {
1122 if (mask & (1 << i))
1123 {
1124 bool bCanBeActivated = m_slots[i].CanBeActivated();
1125 if (bBlock)
1126 {
1127 ++m_slots[i].m_blockCounter;
1128 VERIFY2(m_slots[i].m_blockCounter < 5, "block slots overflow");
1129 }
1130 else
1131 {
1132 --m_slots[i].m_blockCounter;
1133 VERIFY2(m_slots[i].m_blockCounter > -5, "block slots underflow");
1134 }
1135 if (bCanBeActivated != m_slots[i].CanBeActivated())
1136 bChanged = true;
1137 }
1138 }
1139 if (bChanged)
1140 {
1141 u32 ActiveSlot = GetActiveSlot();
1142 u32 PrevActiveSlot = GetPrevActiveSlot();
1143
1144 if (PrevActiveSlot == NO_ACTIVE_SLOT)
1145 {
1146 if (GetNextActiveSlot() != NO_ACTIVE_SLOT && m_slots[GetNextActiveSlot()].m_pIItem && m_slots[GetNextActiveSlot()].m_pIItem->cast_hud_item() &&
1147 m_slots[GetNextActiveSlot()].m_pIItem->cast_hud_item()->IsShowing())
1148 {
1149 ActiveSlot = GetNextActiveSlot();
1150 SetActiveSlot(GetNextActiveSlot());
1151 m_slots[ActiveSlot].m_pIItem->Activate(true);
1152 }
1153 }
1154 else if (m_slots[PrevActiveSlot].m_pIItem && m_slots[PrevActiveSlot].m_pIItem->cast_hud_item() && m_slots[PrevActiveSlot].m_pIItem->cast_hud_item()->IsHiding())
1155 {
1156 m_slots[PrevActiveSlot].m_pIItem->Deactivate(true);
1157 ActiveSlot = NO_ACTIVE_SLOT;
1158 SetActiveSlot(NO_ACTIVE_SLOT);
1159 }
1160
1161 if (ActiveSlot == NO_ACTIVE_SLOT)
1162 { // try to restore hidden weapon
1163 if (PrevActiveSlot != NO_ACTIVE_SLOT && m_slots[PrevActiveSlot].CanBeActivated())
1164 if (Activate(PrevActiveSlot, eGeneral, false, now))
1165 SetPrevActiveSlot(NO_ACTIVE_SLOT);
1166 }
1167 else
1168 { // try to hide active weapon
1169 if (!m_slots[ActiveSlot].CanBeActivated())
1170 if (Activate(NO_ACTIVE_SLOT, eGeneral, false, now))
1171 SetPrevActiveSlot(ActiveSlot);
1172 }
1173 }
1174}

Callers 5

SetWeaponHideStateMethod · 0.80
initializeMethod · 0.80
show_hudMethod · 0.80
deactivateMethod · 0.80
death_glide_startMethod · 0.80

Calls 6

CanBeActivatedMethod · 0.80
cast_hud_itemMethod · 0.45
IsShowingMethod · 0.45
ActivateMethod · 0.45
IsHidingMethod · 0.45
DeactivateMethod · 0.45

Tested by

no test coverage detected