1
0
Fork 0

(svn r21628) -Codechange: Remove local variables that just point to global _thd.

release/1.1
alberth 2010-12-24 17:51:46 +00:00
parent 852e647bcc
commit 96906c1a45
2 changed files with 41 additions and 43 deletions

View File

@ -360,11 +360,10 @@ static void DoRailroadTrack(int mode)
static void HandleAutodirPlacement() static void HandleAutodirPlacement()
{ {
TileHighlightData *thd = &_thd; int trackstat = _thd.drawstyle & HT_DIR_MASK; // 0..5
int trackstat = thd->drawstyle & HT_DIR_MASK; // 0..5
if (thd->drawstyle & HT_RAIL) { // one tile case if (_thd.drawstyle & HT_RAIL) { // one tile case
GenericPlaceRail(TileVirtXY(thd->selend.x, thd->selend.y), trackstat); GenericPlaceRail(TileVirtXY(_thd.selend.x, _thd.selend.y), trackstat);
return; return;
} }
@ -379,11 +378,10 @@ static void HandleAutodirPlacement()
*/ */
static void HandleAutoSignalPlacement() static void HandleAutoSignalPlacement()
{ {
TileHighlightData *thd = &_thd; uint32 p2 = GB(_thd.drawstyle, 0, 3); // 0..5
uint32 p2 = GB(thd->drawstyle, 0, 3); // 0..5
if ((thd->drawstyle & HT_DRAG_MASK) == HT_RECT) { // one tile case if ((_thd.drawstyle & HT_DRAG_MASK) == HT_RECT) { // one tile case
GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y)); GenericPlaceSignals(TileVirtXY(_thd.selend.x, _thd.selend.y));
return; return;
} }
@ -406,7 +404,7 @@ static void HandleAutoSignalPlacement()
/* _settings_client.gui.drag_signals_density is given as a parameter such that each user /* _settings_client.gui.drag_signals_density is given as a parameter such that each user
* in a network game can specify his/her own signal density */ * in a network game can specify his/her own signal density */
DoCommandP(TileVirtXY(thd->selstart.x, thd->selstart.y), TileVirtXY(thd->selend.x, thd->selend.y), p2, DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), p2,
_remove_button_clicked ? _remove_button_clicked ?
CMD_REMOVE_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM) : CMD_REMOVE_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM) :
CMD_BUILD_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE), CMD_BUILD_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE),

View File

@ -2406,29 +2406,29 @@ static void CheckOverflow(int &test, int &other, int max, int mult)
} }
/** while dragging */ /** while dragging */
static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int method) static void CalcRaildirsDrawstyle(int x, int y, int method)
{ {
HighLightStyle b; HighLightStyle b;
int dx = thd->selstart.x - (thd->selend.x & ~TILE_UNIT_MASK); int dx = _thd.selstart.x - (_thd.selend.x & ~TILE_UNIT_MASK);
int dy = thd->selstart.y - (thd->selend.y & ~TILE_UNIT_MASK); int dy = _thd.selstart.y - (_thd.selend.y & ~TILE_UNIT_MASK);
uint w = abs(dx) + TILE_SIZE; uint w = abs(dx) + TILE_SIZE;
uint h = abs(dy) + TILE_SIZE; uint h = abs(dy) + TILE_SIZE;
if (method & ~(VPM_RAILDIRS | VPM_SIGNALDIRS)) { if (method & ~(VPM_RAILDIRS | VPM_SIGNALDIRS)) {
/* We 'force' a selection direction; first four rail buttons. */ /* We 'force' a selection direction; first four rail buttons. */
method &= ~(VPM_RAILDIRS | VPM_SIGNALDIRS); method &= ~(VPM_RAILDIRS | VPM_SIGNALDIRS);
int raw_dx = thd->selstart.x - thd->selend.x; int raw_dx = _thd.selstart.x - _thd.selend.x;
int raw_dy = thd->selstart.y - thd->selend.y; int raw_dy = _thd.selstart.y - _thd.selend.y;
switch (method) { switch (method) {
case VPM_FIX_X: case VPM_FIX_X:
b = HT_LINE | HT_DIR_Y; b = HT_LINE | HT_DIR_Y;
x = thd->selstart.x; x = _thd.selstart.x;
break; break;
case VPM_FIX_Y: case VPM_FIX_Y:
b = HT_LINE | HT_DIR_X; b = HT_LINE | HT_DIR_X;
y = thd->selstart.y; y = _thd.selstart.y;
break; break;
case VPM_FIX_HORIZONTAL: case VPM_FIX_HORIZONTAL:
@ -2445,8 +2445,8 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
* a vertical line from the selected end point intersect and * a vertical line from the selected end point intersect and
* use that point as the end point. */ * use that point as the end point. */
int offset = (raw_dx - raw_dy) / 2; int offset = (raw_dx - raw_dy) / 2;
x = thd->selstart.x - (offset & ~TILE_UNIT_MASK); x = _thd.selstart.x - (offset & ~TILE_UNIT_MASK);
y = thd->selstart.y + (offset & ~TILE_UNIT_MASK); y = _thd.selstart.y + (offset & ~TILE_UNIT_MASK);
/* 'Build' the last half rail tile if needed */ /* 'Build' the last half rail tile if needed */
if ((offset & TILE_UNIT_MASK) > (TILE_SIZE / 2)) { if ((offset & TILE_UNIT_MASK) > (TILE_SIZE / 2)) {
@ -2480,8 +2480,8 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
* a horizontal line from the selected end point intersect and * a horizontal line from the selected end point intersect and
* use that point as the end point. */ * use that point as the end point. */
int offset = (raw_dx + raw_dy + (int)TILE_SIZE) / 2; int offset = (raw_dx + raw_dy + (int)TILE_SIZE) / 2;
x = thd->selstart.x - (offset & ~TILE_UNIT_MASK); x = _thd.selstart.x - (offset & ~TILE_UNIT_MASK);
y = thd->selstart.y - (offset & ~TILE_UNIT_MASK); y = _thd.selstart.y - (offset & ~TILE_UNIT_MASK);
/* 'Build' the last half rail tile if needed */ /* 'Build' the last half rail tile if needed */
if ((offset & TILE_UNIT_MASK) > (TILE_SIZE / 2)) { if ((offset & TILE_UNIT_MASK) > (TILE_SIZE / 2)) {
@ -2504,7 +2504,7 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
default: default:
NOT_REACHED(); NOT_REACHED();
} }
} else if (TileVirtXY(thd->selstart.x, thd->selstart.y) == TileVirtXY(x, y)) { // check if we're only within one tile } else if (TileVirtXY(_thd.selstart.x, _thd.selstart.y) == TileVirtXY(x, y)) { // check if we're only within one tile
if (method & VPM_RAILDIRS) { if (method & VPM_RAILDIRS) {
b = GetAutorailHT(x, y); b = GetAutorailHT(x, y);
} else { // rect for autosignals on one tile } else { // rect for autosignals on one tile
@ -2518,7 +2518,7 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
} else { } else {
b = HT_LINE | HT_DIR_X; b = HT_LINE | HT_DIR_X;
} }
y = thd->selstart.y; y = _thd.selstart.y;
} else if (w == TILE_SIZE) { // Or Y direction? } else if (w == TILE_SIZE) { // Or Y direction?
if (dy == (int)TILE_SIZE) { // 2x1 special handling if (dy == (int)TILE_SIZE) { // 2x1 special handling
b = (Check2x1AutoRail(1)) | HT_LINE; b = (Check2x1AutoRail(1)) | HT_LINE;
@ -2527,29 +2527,29 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
} else { } else {
b = HT_LINE | HT_DIR_Y; b = HT_LINE | HT_DIR_Y;
} }
x = thd->selstart.x; x = _thd.selstart.x;
} else if (w > h * 2) { // still count as x dir? } else if (w > h * 2) { // still count as x dir?
b = HT_LINE | HT_DIR_X; b = HT_LINE | HT_DIR_X;
y = thd->selstart.y; y = _thd.selstart.y;
} else if (h > w * 2) { // still count as y dir? } else if (h > w * 2) { // still count as y dir?
b = HT_LINE | HT_DIR_Y; b = HT_LINE | HT_DIR_Y;
x = thd->selstart.x; x = _thd.selstart.x;
} else { // complicated direction } else { // complicated direction
int d = w - h; int d = w - h;
thd->selend.x = thd->selend.x & ~TILE_UNIT_MASK; _thd.selend.x = _thd.selend.x & ~TILE_UNIT_MASK;
thd->selend.y = thd->selend.y & ~TILE_UNIT_MASK; _thd.selend.y = _thd.selend.y & ~TILE_UNIT_MASK;
/* four cases. */ /* four cases. */
if (x > thd->selstart.x) { if (x > _thd.selstart.x) {
if (y > thd->selstart.y) { if (y > _thd.selstart.y) {
/* south */ /* south */
if (d == 0) { if (d == 0) {
b = (x & TILE_UNIT_MASK) > (y & TILE_UNIT_MASK) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR; b = (x & TILE_UNIT_MASK) > (y & TILE_UNIT_MASK) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR;
} else if (d >= 0) { } else if (d >= 0) {
x = thd->selstart.x + h; x = _thd.selstart.x + h;
b = HT_LINE | HT_DIR_VL; b = HT_LINE | HT_DIR_VL;
} else { } else {
y = thd->selstart.y + w; y = _thd.selstart.y + w;
b = HT_LINE | HT_DIR_VR; b = HT_LINE | HT_DIR_VR;
} }
} else { } else {
@ -2557,23 +2557,23 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
if (d == 0) { if (d == 0) {
b = (x & TILE_UNIT_MASK) + (y & TILE_UNIT_MASK) >= TILE_SIZE ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU; b = (x & TILE_UNIT_MASK) + (y & TILE_UNIT_MASK) >= TILE_SIZE ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU;
} else if (d >= 0) { } else if (d >= 0) {
x = thd->selstart.x + h; x = _thd.selstart.x + h;
b = HT_LINE | HT_DIR_HL; b = HT_LINE | HT_DIR_HL;
} else { } else {
y = thd->selstart.y - w; y = _thd.selstart.y - w;
b = HT_LINE | HT_DIR_HU; b = HT_LINE | HT_DIR_HU;
} }
} }
} else { } else {
if (y > thd->selstart.y) { if (y > _thd.selstart.y) {
/* east */ /* east */
if (d == 0) { if (d == 0) {
b = (x & TILE_UNIT_MASK) + (y & TILE_UNIT_MASK) >= TILE_SIZE ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU; b = (x & TILE_UNIT_MASK) + (y & TILE_UNIT_MASK) >= TILE_SIZE ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU;
} else if (d >= 0) { } else if (d >= 0) {
x = thd->selstart.x - h; x = _thd.selstart.x - h;
b = HT_LINE | HT_DIR_HU; b = HT_LINE | HT_DIR_HU;
} else { } else {
y = thd->selstart.y + w; y = _thd.selstart.y + w;
b = HT_LINE | HT_DIR_HL; b = HT_LINE | HT_DIR_HL;
} }
} else { } else {
@ -2581,10 +2581,10 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
if (d == 0) { if (d == 0) {
b = (x & TILE_UNIT_MASK) > (y & TILE_UNIT_MASK) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR; b = (x & TILE_UNIT_MASK) > (y & TILE_UNIT_MASK) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR;
} else if (d >= 0) { } else if (d >= 0) {
x = thd->selstart.x - h; x = _thd.selstart.x - h;
b = HT_LINE | HT_DIR_VR; b = HT_LINE | HT_DIR_VR;
} else { } else {
y = thd->selstart.y - w; y = _thd.selstart.y - w;
b = HT_LINE | HT_DIR_VL; b = HT_LINE | HT_DIR_VL;
} }
} }
@ -2592,7 +2592,7 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
} }
if (_settings_client.gui.measure_tooltip) { if (_settings_client.gui.measure_tooltip) {
TileIndex t0 = TileVirtXY(thd->selstart.x, thd->selstart.y); TileIndex t0 = TileVirtXY(_thd.selstart.x, _thd.selstart.y);
TileIndex t1 = TileVirtXY(x, y); TileIndex t1 = TileVirtXY(x, y);
uint distance = DistanceManhattan(t0, t1) + 1; uint distance = DistanceManhattan(t0, t1) + 1;
byte index = 0; byte index = 0;
@ -2614,9 +2614,9 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
ShowMeasurementTooltips(measure_strings_length[index], index, params); ShowMeasurementTooltips(measure_strings_length[index], index, params);
} }
thd->selend.x = x; _thd.selend.x = x;
thd->selend.y = y; _thd.selend.y = y;
thd->next_drawstyle = b; _thd.next_drawstyle = b;
} }
/** /**
@ -2640,7 +2640,7 @@ void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
if (method & (VPM_RAILDIRS | VPM_SIGNALDIRS)) { if (method & (VPM_RAILDIRS | VPM_SIGNALDIRS)) {
_thd.selend.x = x; _thd.selend.x = x;
_thd.selend.y = y; _thd.selend.y = y;
CalcRaildirsDrawstyle(&_thd, x, y, method); CalcRaildirsDrawstyle(x, y, method);
return; return;
} }