equal
deleted
inserted
replaced
267 */ |
267 */ |
268 int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
268 int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
269 { |
269 { |
270 TileIndex tile; |
270 TileIndex tile; |
271 uint tileh; |
271 uint tileh; |
272 uint m5; /* XXX: Used only as a cache, should probably be removed? */ |
|
273 Track track = (Track)p2; |
272 Track track = (Track)p2; |
274 TrackBits trackbit; |
273 TrackBits trackbit; |
275 int32 cost = 0; |
274 int32 cost = 0; |
276 int32 ret; |
275 int32 ret; |
277 |
276 |
278 if (!ValParamRailtype(p1) || !ValParamTrackOrientation(track)) return CMD_ERROR; |
277 if (!ValParamRailtype(p1) || !ValParamTrackOrientation(track)) return CMD_ERROR; |
279 |
278 |
280 tile = TileVirtXY(x, y); |
279 tile = TileVirtXY(x, y); |
281 tileh = GetTileSlope(tile, NULL); |
280 tileh = GetTileSlope(tile, NULL); |
282 m5 = _m[tile].m5; |
|
283 trackbit = TrackToTrackBits(track); |
281 trackbit = TrackToTrackBits(track); |
284 |
282 |
285 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
283 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
286 |
284 |
287 switch (GetTileType(tile)) { |
285 switch (GetTileType(tile)) { |
324 if (CmdFailed(ret)) return ret; |
322 if (CmdFailed(ret)) return ret; |
325 cost += ret; |
323 cost += ret; |
326 |
324 |
327 if (flags & DC_EXEC) { |
325 if (flags & DC_EXEC) { |
328 _m[tile].m2 &= ~RAIL_MAP2LO_GROUND_MASK; // Bare land |
326 _m[tile].m2 &= ~RAIL_MAP2LO_GROUND_MASK; // Bare land |
329 _m[tile].m5 = m5 | trackbit; |
327 _m[tile].m5 |= trackbit; |
330 } |
328 } |
331 break; |
329 break; |
332 |
330 |
333 case MP_STREET: |
331 case MP_STREET: |
334 #define M(x) (1 << (x)) |
332 #define M(x) (1 << (x)) |
339 #undef M |
337 #undef M |
340 |
338 |
341 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
339 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
342 |
340 |
343 if (GetRoadType(tile) == ROAD_NORMAL && ( |
341 if (GetRoadType(tile) == ROAD_NORMAL && ( |
344 (track == TRACK_X && m5 == ROAD_Y) || |
342 (track == TRACK_X && GetRoadBits(tile) == ROAD_Y) || |
345 (track == TRACK_Y && m5 == ROAD_X) // correct direction? |
343 (track == TRACK_Y && GetRoadBits(tile) == ROAD_X) |
346 )) { |
344 )) { |
347 if (flags & DC_EXEC) { |
345 if (flags & DC_EXEC) { |
348 MakeRoadCrossing(tile, GetTileOwner(tile), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), p1, _m[tile].m2); |
346 MakeRoadCrossing(tile, GetTileOwner(tile), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), p1, _m[tile].m2); |
349 } |
347 } |
350 break; |
348 break; |