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

Method find_plantable_plants

plugins/autofarm.cpp:160–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158
159public:
160 void find_plantable_plants()
161 {
162 plantable_plants.clear();
163
164 std::map<int, int> counts;
165
166 const uint32_t bad_flags{
167#define F(x) (df::item_flags::Mask::mask_##x)
168 F(dump) | F(forbid) | F(garbage_collect) |
169 F(hostile) | F(on_fire) | F(rotten) | F(trader) |
170 F(in_building) | F(construction) | F(artifact)
171#undef F
172 };
173
174 for (auto& ii : world->items.other[df::items_other_id::SEEDS])
175 {
176 auto i = virtual_cast<df::item_seedsst>(ii);
177 if (i && (i->flags.whole & bad_flags) == 0)
178 counts[i->mat_index] += i->stack_size;
179 }
180
181 for (auto& ci : counts)
182 {
183 df::plant_raw* plant = world->raws.plants.all[ci.first];
184 if (is_plantable(plant))
185 for (auto& flagmap : biomeFlagMap)
186 if (plant->flags.is_set(flagmap.first))
187 plantable_plants[plant->index].insert(flagmap.second);
188 }
189 }
190
191 std::string get_plant_name(int plant_id)
192 {

Callers

nothing calls this directly

Calls 3

is_setMethod · 0.80
clearMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected