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

Function changelayer

plugins/changelayer.cpp:55–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53static bool warned = false;
54
55command_result changelayer (color_ostream &out, std::vector <std::string> & parameters)
56{
57 string material;
58 bool force = false;
59 bool all_biomes = false;
60 bool all_layers = false;
61 bool verbose = false;
62 warned = false;
63
64 for(size_t i = 0; i < parameters.size();i++)
65 {
66 if(parameters[i] == "help" || parameters[i] == "?")
67 {
68 return CR_WRONG_USAGE;
69 }
70 if(parameters[i] == "force")
71 force = true;
72 if(parameters[i] == "all_biomes")
73 all_biomes = true;
74 if(parameters[i] == "all_layers")
75 all_layers = true;
76 if(parameters[i] == "verbose")
77 verbose = true;
78 }
79
80 if (!Maps::IsValid())
81 {
82 out.printerr("Map is not available!\n");
83 return CR_FAILURE;
84 }
85
86 if (parameters.empty())
87 {
88 out.printerr("You need to specify a material!\n");
89 return CR_WRONG_USAGE;
90 }
91
92 material = parameters[0];
93
94 MaterialInfo mat_new;
95 if (!mat_new.findInorganic(material))
96 {
97 out.printerr("No such material!\n");
98 return CR_FAILURE;
99 }
100
101 // check if specified material is stone or gem or soil
102 if (mat_new.inorganic->material.flags.is_set(material_flags::IS_METAL) ||
103 mat_new.inorganic->material.flags.is_set(material_flags::NO_STONE_STOCKPILE))
104 {
105 out.printerr("Invalid material - you must select a type of stone or gem or soil.\n");
106 return CR_FAILURE;
107 }
108
109
110 int32_t regionX, regionY, regionZ;
111 Maps::getPosition(regionX,regionY,regionZ);
112

Callers

nothing calls this directly

Calls 12

getTileBlockFunction · 0.85
getTileDesignationFunction · 0.85
conversionAllowedFunction · 0.85
findInorganicMethod · 0.80
is_setMethod · 0.80
findFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45
decodeMethod · 0.45
getTokenMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected