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

Method Load

ogsr_engine/xrGame/inventory_item.cpp:79–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void CInventoryItem::Load(LPCSTR section)
80{
81 CHitImmunity::LoadImmunities(pSettings->r_string(section, "immunities_sect"), pSettings);
82 m_icon_params.Load(section);
83
84 ISpatial* self = smart_cast<ISpatial*>(this);
85 if (self)
86 self->spatial.type |= STYPE_VISIBLEFORAI;
87
88 m_name = CStringTable().translate(pSettings->r_string(section, "inv_name"));
89 m_nameShort = CStringTable().translate(pSettings->r_string(section, "inv_name_short"));
90
91 //. NameComplex ();
92 m_weight = pSettings->r_float(section, "inv_weight");
93 R_ASSERT(m_weight >= 0.f);
94
95 m_cost = pSettings->r_u32(section, "cost");
96
97 m_slots_sect = READ_IF_EXISTS(pSettings, r_string, section, "slot", "");
98 {
99 char buf[16];
100 const int count = _GetItemCount(m_slots_sect);
101 if (count)
102 m_slots.clear(); // full override!
103 for (int i = 0; i < count; ++i)
104 {
105 u8 slot = u8(atoi(_GetItem(m_slots_sect, i, buf)));
106 // вместо std::find(m_slots.begin(), m_slots.end(), slot) == m_slots.end() используется !IsPlaceable
107 if (slot < SLOTS_TOTAL && !IsPlaceable(slot, slot))
108 m_slots.push_back(slot);
109 }
110 if (count)
111 SetSlot(m_slots[0]);
112 }
113
114 if (Core.Features.test(xrCore::Feature::forcibly_equivalent_slots))
115 {
116 // В OGSR, первый и второй оружейные слоты принудительно
117 // равнозначны. Что бы сохранить совместимость с этим, если
118 // для предмета указан только один слот и это оружейный слот,
119 // добавим к нему соотв. второй оружейный слот.
120 if (GetSlotsCount() == 1)
121 {
122 if (m_slots[0] == FIRST_WEAPON_SLOT)
123 m_slots.push_back(SECOND_WEAPON_SLOT);
124 else if (m_slots[0] == SECOND_WEAPON_SLOT)
125 m_slots.push_back(FIRST_WEAPON_SLOT);
126 }
127 }
128
129 // Description
130 if (pSettings->line_exist(section, "description"))
131 m_Description = CStringTable().translate(pSettings->r_string(section, "description"));
132
133 m_flags.set(Fbelt, READ_IF_EXISTS(pSettings, r_bool, section, "belt", FALSE));
134 m_flags.set(FRuckDefault, READ_IF_EXISTS(pSettings, r_bool, section, "default_to_ruck", TRUE));
135 m_flags.set(FCanTake, READ_IF_EXISTS(pSettings, r_bool, section, "can_take", TRUE));
136 m_flags.set(FCanTrade, READ_IF_EXISTS(pSettings, r_bool, section, "can_trade", TRUE));

Callers

nothing calls this directly

Calls 12

CStringTableClass · 0.85
_GetItemCountFunction · 0.85
_GetItemFunction · 0.85
line_existMethod · 0.80
r_stringMethod · 0.45
translateMethod · 0.45
r_floatMethod · 0.45
r_u32Method · 0.45
clearMethod · 0.45
push_backMethod · 0.45
testMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected