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

Function printMats

plugins/prospector.cpp:188–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186
187template <typename T, template <typename> class P>
188void printMats(color_ostream &con, MatMap &mat, std::vector<T*> &materials, const prospect_options &options)
189{
190 unsigned int total = 0;
191 MatSorter sorting_vector;
192 for (MatMap::const_iterator it = mat.begin(); it != mat.end(); ++it)
193 {
194 sorting_vector.push_back(*it);
195 }
196 std::sort(sorting_vector.begin(), sorting_vector.end(),
197 compare_pair_second<P>());
198 for (MatSorter::const_iterator it = sorting_vector.begin();
199 it != sorting_vector.end(); ++it)
200 {
201 if(size_t(it->first) >= materials.size())
202 {
203 con << "Bad index: " << it->first << " out of "
204 << materials.size() << std::endl;
205 continue;
206 }
207 T* mat = materials[it->first];
208 // Somewhat of a hack, but it works because df::inorganic_raw and df::plant_raw both have a field named "id"
209 con << std::setw(25) << mat->id << " : ";
210 if (options.value)
211 con << std::setw(3) << getValue(*mat) << " : ";
212 printMatdata(con, it->second);
213 total += it->second.count;
214 }
215
216 con << ">>> TOTAL = " << total << std::endl << std::endl;
217}
218
219void printVeins(color_ostream &con, MatMap &mat_map,
220 const prospect_options &options)

Callers

nothing calls this directly

Calls 6

sortFunction · 0.85
getValueFunction · 0.85
printMatdataFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected