179 if (trackstat != 0) { |
180 if (trackstat != 0) { |
180 for (; !(trackstat & 1); trackstat >>= 1) i++; |
181 for (; !(trackstat & 1); trackstat >>= 1) i++; |
181 } |
182 } |
182 |
183 |
183 if (!_remove_button_clicked) { |
184 if (!_remove_button_clicked) { |
184 DoCommandP(tile, i + (_ctrl_pressed ? 8 : 0), 0, CcPlaySound1E, |
185 uint32 p1 = _ctrl_pressed ? 8 : 0; |
|
186 if (!HasSignals(tile) && _cur_year < _patches.semaphore_build_before) { |
|
187 /* Reverse the logic, so semaphores are normally built, and light |
|
188 * signals can be built with ctrl held down. */ |
|
189 p1 = _ctrl_pressed ? 0 : 8; |
|
190 } |
|
191 DoCommandP(tile, i + p1, 0, CcPlaySound1E, |
185 CMD_BUILD_SIGNALS | CMD_AUTO | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE)); |
192 CMD_BUILD_SIGNALS | CMD_AUTO | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE)); |
186 } else { |
193 } else { |
187 DoCommandP(tile, i, 0, CcPlaySound1E, |
194 DoCommandP(tile, i, 0, CcPlaySound1E, |
188 CMD_REMOVE_SIGNALS | CMD_AUTO | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM)); |
195 CMD_REMOVE_SIGNALS | CMD_AUTO | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM)); |
189 } |
196 } |
358 |
365 |
359 static void HandleAutoSignalPlacement(void) |
366 static void HandleAutoSignalPlacement(void) |
360 { |
367 { |
361 TileHighlightData *thd = &_thd; |
368 TileHighlightData *thd = &_thd; |
362 byte trackstat = thd->drawstyle & 0xF; // 0..5 |
369 byte trackstat = thd->drawstyle & 0xF; // 0..5 |
|
370 byte semaphore = _ctrl_pressed ? 1 : 0; |
363 |
371 |
364 if (thd->drawstyle == HT_RECT) { // one tile case |
372 if (thd->drawstyle == HT_RECT) { // one tile case |
365 GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y)); |
373 GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y)); |
366 return; |
374 return; |
|
375 } |
|
376 |
|
377 if (!HasSignals(TileVirtXY(thd->selstart.x, thd->selstart.y)) && _cur_year < _patches.semaphore_build_before) { |
|
378 /* Reverse the logic, so semaphores are normally built, and light |
|
379 * signals can be built with ctrl held down. */ |
|
380 semaphore = _ctrl_pressed ? 0 : 1; |
367 } |
381 } |
368 |
382 |
369 // _patches.drag_signals_density is given as a parameter such that each user in a network |
383 // _patches.drag_signals_density is given as a parameter such that each user in a network |
370 // game can specify his/her own signal density |
384 // game can specify his/her own signal density |
371 DoCommandP( |
385 DoCommandP( |
372 TileVirtXY(thd->selstart.x, thd->selstart.y), |
386 TileVirtXY(thd->selstart.x, thd->selstart.y), |
373 TileVirtXY(thd->selend.x, thd->selend.y), |
387 TileVirtXY(thd->selend.x, thd->selend.y), |
374 (_ctrl_pressed ? 1 << 3 : 0) | (trackstat << 4) | (_patches.drag_signals_density << 24), |
388 (semaphore << 3) | (trackstat << 4) | (_patches.drag_signals_density << 24), |
375 CcPlaySound1E, |
389 CcPlaySound1E, |
376 _remove_button_clicked ? |
390 _remove_button_clicked ? |
377 CMD_REMOVE_SIGNAL_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) : |
391 CMD_REMOVE_SIGNAL_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) : |
378 CMD_BUILD_SIGNAL_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE) |
392 CMD_BUILD_SIGNAL_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE) |
379 ); |
393 ); |