MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / CreateItem

Method CreateItem

src/SB/Core/x/xFactory.cpp:101–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101xFactoryInst* xFactory::CreateItem(S32 typeID, void* userdata, RyzMemGrow* callerzgrow)
102{
103 S32 idx;
104 xFactoryInst* item;
105 XGOFTypeInfo pattern = {};
106 XGOFTypeInfo* darec = NULL;
107 RyzMemGrow* grow = callerzgrow;
108
109 pattern.tid = typeID;
110
111 idx = XOrdLookup(&infolist, &pattern, OrdTest_infotype);
112
113 if (idx >= 0)
114 {
115 darec = (XGOFTypeInfo*)infolist.list[idx];
116 }
117
118 if (!darec)
119 {
120 return NULL;
121 }
122
123 if (!darec->creator)
124 {
125 return NULL;
126 }
127
128 if (!darec->destroyer)
129 {
130 return NULL;
131 }
132
133 if (!grow && growContextData.IsEnabled())
134 {
135 grow = &growContextData;
136 }
137
138 item = darec->creator(darec->tid, grow, userdata);
139
140 if (!item)
141 {
142 return item;
143 }
144
145 item->itemType = darec->tid;
146 item->prevprod = NULL;
147 item->nextprod = NULL;
148
149 if (products)
150 {
151 item->nextprod = products;
152 products->prevprod = item;
153 products = item;
154 }
155 else
156 {
157 products = item;
158 }

Callers 2

CreateNPCMethod · 0.80
AddGoalMethod · 0.80

Calls 2

IsEnabledMethod · 0.80
XOrdLookupFunction · 0.70

Tested by

no test coverage detected