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

Function df_deramp

plugins/deramp.cpp:42–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42command_result df_deramp (color_ostream &out, vector <string> & parameters)
43{
44 if (!parameters.empty())
45 return CR_WRONG_USAGE;
46
47 if (!Maps::IsValid())
48 {
49 out.printerr("Map is not available!\n");
50 return CR_FAILURE;
51 }
52
53 int count = 0;
54 int countbad = 0;
55
56 df::job_list_link* next;
57 for (df::job_list_link* jl = world->jobs.list.next;jl; jl = next) {
58 next = jl->next;
59 df::job* job = jl->item;
60 if (job->job_type != df::job_type::RemoveStairs)
61 continue;
62 df::map_block *block = Maps::getTileBlock(job->pos);
63 df::coord2d bpos = job->pos - block->map_pos;
64 df::tiletype oldT = block->tiletype[bpos.x][bpos.y];
65 if (tileShape(oldT) != tiletype_shape::RAMP)
66 continue;
67 df::map_block *above = Maps::getTileBlock(job->pos + df::coord(0,0,1));
68 doDeramp(block, above, bpos.x, bpos.y, oldT);
69 count++;
70 Job::removeJob(job);
71 }
72
73 int blocks_total = world->map.map_blocks.size();
74 for (int i = 0; i < blocks_total; i++)
75 {
76 df::map_block *block = world->map.map_blocks[i];
77 df::map_block *above = Maps::getTileBlock(block->map_pos + df::coord(0,0,1));
78
79 for (int x = 0; x < 16; x++)
80 {
81 for (int y = 0; y < 16; y++)
82 {
83 df::tiletype oldT = block->tiletype[x][y];
84 if ((tileShape(oldT) == tiletype_shape::RAMP) &&
85 (block->designation[x][y].bits.dig == tile_dig_designation::Default))
86 {
87 doDeramp(block, above, x, y, oldT);
88 count++;
89 }
90 // ramp fixer
91 else if ((tileShape(oldT) != tiletype_shape::RAMP)
92 && (above) && (tileShape(above->tiletype[x][y]) == tiletype_shape::RAMP_TOP))
93 {
94 above->tiletype[x][y] = tiletype::OpenSpace; // open space
95 countbad++;
96 }
97 }
98 }
99 }

Callers

nothing calls this directly

Calls 6

getTileBlockFunction · 0.85
tileShapeFunction · 0.85
doDerampFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected