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

Function find_engines

plugins/steam-engine.cpp:820–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818 */
819
820static bool find_engines(color_ostream &out)
821{
822 engines.clear();
823
824 auto &wslist = world->raws.buildings.workshops;
825
826 for (size_t i = 0; i < wslist.size(); i++)
827 {
828 if (strstr(wslist[i]->code.c_str(), "STEAM_ENGINE") == NULL)
829 continue;
830
831 steam_engine_workshop ws;
832 ws.def = wslist[i];
833 ws.id = ws.def->id;
834
835 int bs = ws.def->build_stages;
836 for (int x = 0; x < ws.def->dim_x; x++)
837 {
838 for (int y = 0; y < ws.def->dim_y; y++)
839 {
840 switch (ws.def->tile[bs][x][y])
841 {
842 case 15:
843 ws.gear_tiles.push_back(df::coord2d(x,y));
844 break;
845 case 19:
846 ws.hearth_tile = df::coord2d(x,y);
847 break;
848 }
849
850 if (ws.def->tile_color[2][bs][x][y])
851 {
852 switch (ws.def->tile_color[0][bs][x][y])
853 {
854 case 1:
855 ws.water_tile = df::coord2d(x,y);
856 break;
857 case 4:
858 ws.magma_tile = df::coord2d(x,y);
859 break;
860 }
861 }
862 }
863 }
864
865 ws.is_magma = ws.def->needs_magma;
866 ws.max_power = ws.is_magma ? 5 : 3;
867 ws.max_capacity = ws.is_magma ? 10 : 6;
868 ws.wear_temp = ws.is_magma ? 12000 : 11000;
869
870 if (!ws.gear_tiles.empty())
871 engines.push_back(ws);
872 else
873 out.printerr("{} has no gear tiles - ignoring.\n", wslist[i]->code);
874 }
875
876 return !engines.empty();
877}

Callers 1

Calls 4

c_strMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected