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

Function find_match

library/TileTypes.cpp:48–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46static df::tiletype tile_to_mat[NUM_CVTABLES][NUM_TILETYPES];
47
48static df::tiletype find_match(
49 df::tiletype_material mat, df::tiletype_shape shape, df::tiletype_special special,
50 std::string dir, df::tiletype_variant variant, bool warn
51) {
52 using namespace df::enums::tiletype_shape;
53 using namespace df::enums::tiletype_special;
54
55 if (mat < 0 || mat >= NUM_MATERIALS)
56 return tiletype::Void;
57
58 auto &sh_map = tile_table[mat];
59
60 if (!sh_map.count(shape))
61 {
62 if (warn)
63 {
64 fmt::print(
65 stderr, "NOTE: No shape {} in {}.\n",
66 enum_item_key(shape), enum_item_key(mat)
67 );
68 }
69
70 switch (shape)
71 {
72 case BROOK_BED:
73 if (sh_map.count(FORTIFICATION)) { shape = FORTIFICATION; break; }
74
75 case FORTIFICATION:
76 if (sh_map.count(WALL)) { shape = WALL; break; }
77 return tiletype::Void;
78
79 case BROOK_TOP:
80 case BOULDER:
81 case PEBBLES:
82 if (sh_map.count(FLOOR)) { shape = FLOOR; break; }
83 return tiletype::Void;
84
85 default:
86 return tiletype::Void;
87 };
88 }
89
90 auto &sp_map = sh_map[shape];
91
92 if (!sp_map.count(special))
93 {
94 if (warn)
95 {
96 fmt::print(
97 stderr, "NOTE: No special {} in {}:{}.\n",
98 enum_item_key(special), enum_item_key(mat),
99 enum_item_key(shape)
100 );
101 }
102
103 switch (special)
104 {
105 case TRACK:

Callers 1

FOR_ENUM_ITEMSFunction · 0.85

Calls 4

enum_item_keyFunction · 0.85
printFunction · 0.50
countMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected