MCPcopy Create free account
hub / github.com/DFHack/dfhack / DEFINE_VMETHOD_INTERPOSE

Method DEFINE_VMETHOD_INTERPOSE

plugins/add-spatter.cpp:168–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166 typedef df::item_constructed interpose_base;
167
168 DEFINE_VMETHOD_INTERPOSE(bool, isImprovable, (df::job *job, int16_t mat_type, int32_t mat_index))
169 {
170 ReactionInfo *info;
171
172 if (job && job->job_type == job_type::CustomReaction &&
173 (info = find_reaction(job->reaction_name)) != NULL)
174 {
175 if (!contaminants || contaminants->empty())
176 return true;
177
178 item_table table;
179 index_items(table, job, info);
180
181 for (size_t i = 0; i < info->products.size(); i++)
182 {
183 auto &product = info->products[i];
184
185 int mattype, matindex;
186 auto material = find_item(info->products[i].material, table);
187
188 find_material(&mattype, &matindex, material, product.material);
189
190 if (mattype < 0 || has_contaminant(this, mattype, matindex) >= 50)
191 return false;
192 }
193
194 return true;
195 }
196
197 return INTERPOSE_NEXT(isImprovable)(job, mat_type, mat_index);
198 }
199};
200
201IMPLEMENT_VMETHOD_INTERPOSE(item_hook, isImprovable);

Callers

nothing calls this directly

Calls 7

find_reactionFunction · 0.85
index_itemsFunction · 0.85
find_itemFunction · 0.85
find_materialFunction · 0.85
has_contaminantFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected