diff --git a/rail_cmd.c b/rail_cmd.c index cdb8ad6581..bb8736c67f 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -918,9 +918,9 @@ int32 CmdBuildSignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) /* If CmdBuildManySignals is called with copying signals, just copy the style of the first signal * given as parameter by CmdBuildManySignals */ switch (track) { - case 2: case 4: _map3_lo[tile] = (p2&0xC0) | _map3_lo[tile]&~0xC0; break; - case 3: case 5: _map3_lo[tile] = (p2&0x30) | _map3_lo[tile]&~0x30; break; - default : _map3_lo[tile] = (p2&0xF0) | _map3_lo[tile]&0xF; + case 2: case 4: _map3_lo[tile] = (p2&0xC0) | (_map3_lo[tile]&~0xC0); break; + case 3: case 5: _map3_lo[tile] = (p2&0x30) | (_map3_lo[tile]&~0x30); break; + default : _map3_lo[tile] = (p2&0xF0) | (_map3_lo[tile]&0xF); } // convert between signal<->semaphores when dragging HASBIT(p1, 3) ? SETBIT(_map3_hi[tile], 2) : CLRBIT(_map3_hi[tile], 2); @@ -936,10 +936,11 @@ int32 CmdBuildSignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) /* Build many signals by dragging: AutoSignals x,y= start tile p1 = end tile - p2 = (byte 0) - 0 = build, 1 = remove signals - p2 = (byte 3) - 0 = signals, 1 = semaphores - p2 = (byte 7-4) - track-orientation - p2 = (byte 8-) - track style + p2 = (byte 0) - 0 = build, 1 = remove signals + p2 = (byte 3) - 0 = signals, 1 = semaphores + p2 = (byte 7-4) - track-orientation + p2 = (byte 8-) - track style + p2 = (byte 24-31) - user defined signals_density */ int32 CmdBuildManySignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) { @@ -951,8 +952,8 @@ int32 CmdBuildManySignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) int mode = (p2 >> 4)&0xF; // for vertical/horizontal tracks, double the given signals density // since the original amount will be too dense (shorter tracks) - byte signal_density = (mode == 1 || mode == 2) ? _patches.drag_signals_density : _patches.drag_signals_density * 2; - byte signals = p2 >> 8; + byte signal_density = (mode == 1 || mode == 2) ? (p2 >> 24) : (p2 >> 24) * 2; + byte signals = (p2 >> 8)&0xFF; mode = p2 & 0x1; // build/remove signals /* unpack end tile */ @@ -974,13 +975,13 @@ int32 CmdBuildManySignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (_map3_lo[tile]&0x30) signals = _map3_lo[tile]&0x30; else - signals = 0x30 | _map3_lo[tile]&0xC0; + signals = 0x30 | (_map3_lo[tile]&0xC0); break; case 0x10: case 4: /* west corner (N-S), north corner (W-E) */ if (_map3_lo[tile]&0xC0) signals = _map3_lo[tile]&0xC0; else - signals = 0xC0 | _map3_lo[tile]&0x30; + signals = 0xC0 | (_map3_lo[tile]&0x30); break; } } diff --git a/rail_gui.c b/rail_gui.c index a2e830ec59..ae1e4dc54c 100644 --- a/rail_gui.c +++ b/rail_gui.c @@ -516,7 +516,7 @@ static void HandleAutodirPlacement() static void HandleAutoSignalPlacement() { TileHighlightData *thd = &_thd; - int mode; + int mode = 0; uint trackstat = 0; int dx = thd->selstart.x - (thd->selend.x&~0xF); @@ -541,8 +541,10 @@ static void HandleAutoSignalPlacement() trackstat = (thd->drawstyle & 1) ? 4 : 8; } + /* _patches.drag_signals_density is given as a parameter such that each user in a network + * game can specify his/her own signal density */ DoCommandP(TILE_FROM_XY(thd->selstart.x, thd->selstart.y), TILE_FROM_XY(thd->selend.x, thd->selend.y), - (mode << 4) | (_remove_button_clicked + (_ctrl_pressed ? 8 : 0)) | (trackstat << 8), + (mode << 4) | (_remove_button_clicked + (_ctrl_pressed ? 8 : 0)) | (trackstat << 8) | (_patches.drag_signals_density << 24), CcPlaySound1E, (_remove_button_clicked ? CMD_BUILD_MANY_SIGNALS | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) : CMD_BUILD_MANY_SIGNALS | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE) ) ); diff --git a/station_cmd.c b/station_cmd.c index 3422e5a9a2..17471e4191 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -63,8 +63,6 @@ static Station *GetStationAround(uint tile, int w, int h, int closest_station) TileIndex GetStationTileForVehicle(Vehicle *v, Station *st) { - TileIndex required_tile=0; - switch (v->type) { case VEH_Train: return st->train_tile; case VEH_Aircraft: return st->airport_tile;