MCPcopy Create free account
hub / github.com/SimHacker/micropolis / connectTile

Method connectTile

MicropolisCore/src/MicropolisEngine/src/connect.cpp:122–201  ·  view source on GitHub ↗

* Perform the command, and fix wire/road/rail/zone connections around it. * Store modification in the \a effects object. * @param x X world position to perform the command. * @param y Y world position to perform the command. * @param cmd Command to perform. * @param effects Modification collecting object. * @return Tool result. */

Source from the content-addressed store, hash-verified

120 * @return Tool result.
121 */
122ToolResult Micropolis::connectTile(short x, short y,
123 ConnectTileCommand cmd, ToolEffects *effects)
124{
125 ToolResult result = TOOLRESULT_OK;
126
127 // Make sure the array subscripts are in bounds.
128 if (!testBounds(x, y)) {
129 return TOOLRESULT_FAILED;
130 }
131
132 // Perform auto-doze if appropriate.
133 switch (cmd) {
134
135 case CONNECT_TILE_ROAD:
136 case CONNECT_TILE_RAILROAD:
137 case CONNECT_TILE_WIRE:
138
139 // Silently skip auto-bulldoze if no money.
140 if (autoBulldoze) {
141
142 MapValue mapVal = effects->getMapValue(x, y);
143
144 if (mapVal & BULLBIT) {
145 mapVal &= LOMASK;
146 mapVal = neutralizeRoad(mapVal);
147
148 /* Maybe this should check BULLBIT instead of checking tile values? */
149 if ((mapVal >= TINYEXP && mapVal <= LASTTINYEXP) ||
150 (mapVal < HBRIDGE && mapVal != DIRT)) {
151
152 effects->addCost(1);
153
154 effects->setMapValue(x, y, DIRT);
155
156 }
157 }
158 }
159 break;
160
161 default:
162 // Do nothing.
163 break;
164
165 }
166
167 // Perform the command.
168 switch (cmd) {
169
170 case CONNECT_TILE_FIX: // Fix zone.
171 fixZone(x, y, effects);
172 break;
173
174 case CONNECT_TILE_BULLDOZE: // Bulldoze zone.
175 result = layDoze(x, y, effects);
176 fixZone(x, y, effects);
177 break;
178
179 case CONNECT_TILE_ROAD: // Lay road.

Callers

nothing calls this directly

Calls 5

testBoundsFunction · 0.85
neutralizeRoadFunction · 0.85
addCostMethod · 0.80
getMapValueMethod · 0.60
setMapValueMethod · 0.60

Tested by

no test coverage detected