summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2007-05-23 12:45:56 +0000
committermaedhros <maedhros@openttd.org>2007-05-23 12:45:56 +0000
commitca5c578d0f51724d9c4e5b1101b81b442c049341 (patch)
tree6595e32b2d16537c3647b01f1ff39b07b4d0f57a /src
parent9f148789c8ddb64bdc098d24a87aad3293d034b2 (diff)
downloadopenttd-ca5c578d0f51724d9c4e5b1101b81b442c049341.tar.xz
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
Diffstat (limited to 'src')
-rw-r--r--src/airport_gui.cpp4
-rw-r--r--src/dock_gui.cpp18
-rw-r--r--src/gui.h17
-rw-r--r--src/main_gui.cpp10
-rw-r--r--src/misc_gui.cpp4
-rw-r--r--src/rail_gui.cpp77
-rw-r--r--src/road_gui.cpp56
-rw-r--r--src/terraform_gui.cpp44
-rw-r--r--src/viewport.cpp10
-rw-r--r--src/viewport.h6
-rw-r--r--src/window.h3
11 files changed, 134 insertions, 115 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index 92697b963..888d26112 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -39,7 +39,7 @@ static void PlaceAirport(TileIndex tile)
static void PlaceAir_DemolishArea(TileIndex tile)
{
- VpStartPlaceSizing(tile, 4);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_None);
}
@@ -91,7 +91,7 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
break;
case WE_PLACE_DRAG:
- VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata);
+ VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
break;
case WE_PLACE_MOUSEUP:
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index a4a57d14b..8cd977928 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -53,12 +53,12 @@ static void PlaceDocks_Buoy(TileIndex tile)
static void PlaceDocks_DemolishArea(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_DemolishArea);
}
static void PlaceDocks_BuildCanal(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_OR_Y);
+ VpStartPlaceSizing(tile, VPM_X_OR_Y, GUI_PlaceProc_None);
}
static void PlaceDocks_BuildLock(TileIndex tile)
@@ -147,16 +147,20 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
break;
case WE_PLACE_DRAG: {
- VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata);
+ VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
return;
}
case WE_PLACE_MOUSEUP:
if (e->we.place.pt.x != -1) {
- if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
- GUIPlaceProcDragXY(e);
- } else if (e->we.place.userdata == VPM_X_OR_Y) {
- DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
+ switch (e->we.place.select_method) {
+ case VPM_X_AND_Y:
+ GUIPlaceProcDragXY(e);
+ break;
+ case VPM_X_OR_Y:
+ DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
+ break;
+ default: break;
}
}
break;
diff --git a/src/gui.h b/src/gui.h
index 199410635..281f1b9cb 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -68,14 +68,15 @@ void PlaceProc_DemolishArea(TileIndex tile);
void PlaceProc_LevelLand(TileIndex tile);
bool GUIPlaceProcDragXY(const WindowEvent *e);
-enum { // max 32 - 4 = 28 types
- GUI_PlaceProc_DemolishArea = 0 << 4,
- GUI_PlaceProc_LevelArea = 1 << 4,
- GUI_PlaceProc_DesertArea = 2 << 4,
- GUI_PlaceProc_WaterArea = 3 << 4,
- GUI_PlaceProc_ConvertRailArea = 4 << 4,
- GUI_PlaceProc_RockyArea = 5 << 4,
- GUI_PlaceProc_RemoveFromStation = 6 << 4,
+enum {
+ GUI_PlaceProc_None,
+ GUI_PlaceProc_DemolishArea,
+ GUI_PlaceProc_LevelArea,
+ GUI_PlaceProc_DesertArea,
+ GUI_PlaceProc_WaterArea,
+ GUI_PlaceProc_ConvertRailArea,
+ GUI_PlaceProc_RockyArea,
+ GUI_PlaceProc_RemoveFromStation,
};
/* misc_gui.cpp */
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 94b6829a3..806069775 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -1131,7 +1131,7 @@ static void PlaceProc_LowerBigLand(TileIndex tile)
static void PlaceProc_RockyArea(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_RockyArea);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_RockyArea);
}
static void PlaceProc_LightHouse(TileIndex tile)
@@ -1158,12 +1158,12 @@ static void PlaceProc_Transmitter(TileIndex tile)
static void PlaceProc_DesertArea(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DesertArea);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_DesertArea);
}
static void PlaceProc_WaterArea(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_WaterArea);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_WaterArea);
}
static const Widget _scen_edit_land_gen_widgets[] = {
@@ -1377,12 +1377,12 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
_place_proc(e->we.place.tile);
break;
case WE_PLACE_DRAG:
- VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF);
+ VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
break;
case WE_PLACE_MOUSEUP:
if (e->we.place.pt.x != -1) {
- if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) // dragged actions
+ if (e->we.place.select_method == VPM_X_AND_Y) // dragged actions
GUIPlaceProcDragXY(e);
}
break;
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 2336d5332..380b8fc38 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -382,12 +382,12 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
} break;
case WE_PLACE_OBJ:
- VpStartPlaceSizing(e->we.place.tile, VPM_X_AND_Y_LIMITED);
+ VpStartPlaceSizing(e->we.place.tile, VPM_X_AND_Y_LIMITED, GUI_PlaceProc_None);
VpSetPlaceSizingLimit(20);
break;
case WE_PLACE_DRAG:
- VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata);
+ VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
return;
case WE_PLACE_MOUSEUP:
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 18fd4e0f6..fe829deed 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -72,7 +72,7 @@ static void PlaceRail_N(TileIndex tile)
static void PlaceRail_NE(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_FIX_Y);
+ VpStartPlaceSizing(tile, VPM_FIX_Y, GUI_PlaceProc_None);
}
static void PlaceRail_E(TileIndex tile)
@@ -83,12 +83,12 @@ static void PlaceRail_E(TileIndex tile)
static void PlaceRail_NW(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_FIX_X);
+ VpStartPlaceSizing(tile, VPM_FIX_X, GUI_PlaceProc_None);
}
static void PlaceRail_AutoRail(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_RAILDIRS);
+ VpStartPlaceSizing(tile, VPM_RAILDIRS, GUI_PlaceProc_None);
}
static void PlaceExtraDepotRail(TileIndex tile, uint16 extra)
@@ -151,9 +151,9 @@ void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceRail_Station(TileIndex tile)
{
if (_remove_button_clicked) {
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_RemoveFromStation);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_RemoveFromStation);
} else if (_railstation.dragdrop) {
- VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, GUI_PlaceProc_None);
VpSetPlaceSizingLimit(_patches.station_spread);
} else {
DoCommandP(tile,
@@ -197,7 +197,7 @@ static void GenericPlaceSignals(TileIndex tile)
static void PlaceRail_Bridge(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_OR_Y);
+ VpStartPlaceSizing(tile, VPM_X_OR_Y, GUI_PlaceProc_None);
}
void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
@@ -223,12 +223,12 @@ void PlaceProc_BuyLand(TileIndex tile)
static void PlaceRail_ConvertRail(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_ConvertRailArea);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_ConvertRailArea);
}
static void PlaceRail_AutoSignals(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_SIGNALDIRS);
+ VpStartPlaceSizing(tile, VPM_SIGNALDIRS, GUI_PlaceProc_None);
}
@@ -492,7 +492,7 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
return;
case WE_PLACE_DRAG: {
- VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF);
+ VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
return;
}
@@ -501,30 +501,45 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
TileIndex start_tile = e->we.place.starttile;
TileIndex end_tile = e->we.place.tile;
- if (e->we.place.userdata == VPM_X_OR_Y) {
- ResetObjectToPlace();
- ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
- } else if (e->we.place.userdata == VPM_RAILDIRS) {
- bool old = _remove_button_clicked;
- if (_ctrl_pressed) _remove_button_clicked = true;
- HandleAutodirPlacement();
- _remove_button_clicked = old;
- } else if (e->we.place.userdata == VPM_SIGNALDIRS) {
- HandleAutoSignalPlacement();
- } else if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) {
- if (GUIPlaceProcDragXY(e)) break;
-
- if ((e->we.place.userdata >> 4) == GUI_PlaceProc_RemoveFromStation >> 4) {
- DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
+ switch (e->we.place.select_method) {
+ case VPM_X_OR_Y:
+ ResetObjectToPlace();
+ ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
+ break;
+
+ case VPM_RAILDIRS: {
+ bool old = _remove_button_clicked;
+ if (_ctrl_pressed) _remove_button_clicked = true;
+ HandleAutodirPlacement();
+ _remove_button_clicked = old;
+ break;
}
- if ((e->we.place.userdata >> 4) == GUI_PlaceProc_ConvertRailArea >> 4) {
- DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
- }
- } else if (e->we.place.userdata == VPM_X_AND_Y_LIMITED) {
- HandleStationPlacement(start_tile, end_tile);
- } else {
- DoRailroadTrack(e->we.place.userdata & 1);
+ case VPM_SIGNALDIRS:
+ HandleAutoSignalPlacement();
+ break;
+
+ case VPM_X_AND_Y:
+ if (GUIPlaceProcDragXY(e)) break;
+
+ switch (e->we.place.select_proc) {
+ case GUI_PlaceProc_RemoveFromStation:
+ DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
+ break;
+
+ case GUI_PlaceProc_ConvertRailArea:
+ DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
+ break;
+ }
+ break;
+
+ case VPM_X_AND_Y_LIMITED:
+ HandleStationPlacement(start_tile, end_tile);
+ break;
+
+ default:
+ DoRailroadTrack(e->we.place.select_method == VPM_FIX_Y ? TRACK_X : TRACK_Y);
+ break;
}
}
break;
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 9253de427..189a93c6a 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -45,18 +45,18 @@ void CcPlaySound1D(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceRoad_NE(TileIndex tile)
{
_place_road_flag = (_tile_fract_coords.y >= 8) + 4;
- VpStartPlaceSizing(tile, VPM_FIX_X);
+ VpStartPlaceSizing(tile, VPM_FIX_X, GUI_PlaceProc_None);
}
static void PlaceRoad_NW(TileIndex tile)
{
_place_road_flag = (_tile_fract_coords.x >= 8) + 0;
- VpStartPlaceSizing(tile, VPM_FIX_Y);
+ VpStartPlaceSizing(tile, VPM_FIX_Y, GUI_PlaceProc_None);
}
static void PlaceRoad_Bridge(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_OR_Y);
+ VpStartPlaceSizing(tile, VPM_X_OR_Y, GUI_PlaceProc_None);
}
@@ -134,7 +134,7 @@ static void PlaceRoad_TruckStation(TileIndex tile)
static void PlaceRoad_DemolishArea(TileIndex tile)
{
- VpStartPlaceSizing(tile, 4);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_None);
}
@@ -270,47 +270,41 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
if (w != NULL) WP(w, def_d).close = true;
break;
- case WE_PLACE_DRAG: {
- int sel_method;
- switch (e->we.place.userdata) {
- case 1:
- sel_method = VPM_FIX_X;
+ case WE_PLACE_DRAG:
+ switch (e->we.place.select_method) {
+ case VPM_FIX_X:
_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.y & 8) >> 2);
break;
- case 2:
- sel_method = VPM_FIX_Y;
+ case VPM_FIX_Y:
_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.x & 8) >> 2);
break;
-
- case 4:
- sel_method = VPM_X_AND_Y;
- break;
-
- default:
- sel_method = VPM_X_OR_Y;
- break;
}
- VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, sel_method);
+ VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
return;
- }
case WE_PLACE_MOUSEUP:
if (e->we.place.pt.x != -1) {
TileIndex start_tile = e->we.place.starttile;
TileIndex end_tile = e->we.place.tile;
- if (e->we.place.userdata == 0) {
- ResetObjectToPlace();
- ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype));
- } else if (e->we.place.userdata != 4) {
- DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3), CcPlaySound1D,
- _remove_button_clicked ?
- CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) :
- CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE));
- } else {
- DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
+ switch (e->we.place.select_method) {
+ case VPM_X_OR_Y:
+ ResetObjectToPlace();
+ ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype));
+ break;
+
+ case VPM_X_AND_Y:
+ DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
+ break;
+
+ default:
+ DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3), CcPlaySound1D,
+ _remove_button_clicked ?
+ CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) :
+ CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE));
+ break;
}
}
break;
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index cb3c2aa81..99def0e85 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -104,23 +104,24 @@ bool GUIPlaceProcDragXY(const WindowEvent *e)
TileIndex start_tile = e->we.place.starttile;
TileIndex end_tile = e->we.place.tile;
- switch (e->we.place.userdata >> 4) {
- case GUI_PlaceProc_DemolishArea >> 4:
- DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
- break;
- case GUI_PlaceProc_LevelArea >> 4:
- DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
- break;
- case GUI_PlaceProc_RockyArea >> 4:
- GenerateRockyArea(end_tile, start_tile);
- break;
- case GUI_PlaceProc_DesertArea >> 4:
- GenerateDesertArea(end_tile, start_tile);
- break;
- case GUI_PlaceProc_WaterArea >> 4:
- DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
- break;
- default: return false;
+ switch (e->we.place.select_proc) {
+ case GUI_PlaceProc_DemolishArea:
+ DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
+ break;
+ case GUI_PlaceProc_LevelArea:
+ DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
+ break;
+ case GUI_PlaceProc_RockyArea:
+ GenerateRockyArea(end_tile, start_tile);
+ break;
+ case GUI_PlaceProc_DesertArea:
+ GenerateDesertArea(end_tile, start_tile);
+ break;
+ case GUI_PlaceProc_WaterArea:
+ DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
+ break;
+ default:
+ return false;
}
return true;
@@ -140,7 +141,7 @@ static const uint16 _terraform_keycodes[] = {
void PlaceProc_DemolishArea(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_DemolishArea);
}
static void PlaceProc_RaiseLand(TileIndex tile)
@@ -161,7 +162,7 @@ static void PlaceProc_LowerLand(TileIndex tile)
void PlaceProc_LevelLand(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_LevelArea);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_LevelArea);
}
static void TerraformClick_Lower(Window *w)
@@ -239,12 +240,11 @@ static void TerraformToolbWndProc(Window *w, WindowEvent *e)
return;
case WE_PLACE_DRAG:
- VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF);
+ VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
break;
case WE_PLACE_MOUSEUP:
- if (e->we.place.pt.x != -1 &&
- (e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
+ if (e->we.place.pt.x != -1 && e->we.place.select_method == VPM_X_AND_Y) {
GUIPlaceProcDragXY(e);
}
break;
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 68b9a947f..a40dd2777 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1985,9 +1985,10 @@ void UpdateTileSelection()
}
/** highlighting tiles while only going over them with the mouse */
-void VpStartPlaceSizing(TileIndex tile, int user)
+void VpStartPlaceSizing(TileIndex tile, byte method, byte process)
{
- _thd.userdata = user;
+ _thd.select_method = method;
+ _thd.select_proc = process;
_thd.selend.x = TileX(tile) * TILE_SIZE;
_thd.selstart.x = TileX(tile) * TILE_SIZE;
_thd.selend.y = TileY(tile) * TILE_SIZE;
@@ -2445,7 +2446,8 @@ bool VpHandlePlaceSizingDrag()
if (_special_mouse_mode != WSM_SIZING) return true;
- e.we.place.userdata = _thd.userdata;
+ e.we.place.select_method = _thd.select_method;
+ e.we.place.select_proc = _thd.select_proc;
/* stop drag mode if the window has been closed */
w = FindWindowById(_thd.window_class, _thd.window_number);
@@ -2467,7 +2469,7 @@ bool VpHandlePlaceSizingDrag()
_special_mouse_mode = WSM_NONE;
if (_thd.next_drawstyle == HT_RECT) {
_thd.place_mode = VHM_RECT;
- } else if ((e.we.place.userdata & 0xF) == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik
+ } else if (e.we.place.select_method == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik
_thd.place_mode = VHM_RECT;
} else if (_thd.next_drawstyle & HT_LINE) {
_thd.place_mode = VHM_RAIL;
diff --git a/src/viewport.h b/src/viewport.h
index e69690e20..be5d8feb4 100644
--- a/src/viewport.h
+++ b/src/viewport.h
@@ -62,7 +62,7 @@ void SetRedErrorSquare(TileIndex tile);
void SetTileSelectSize(int w, int h);
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
-void VpStartPlaceSizing(TileIndex tile, int user);
+void VpStartPlaceSizing(TileIndex tile, byte method, byte process);
void VpSetPresizeRange(uint from, uint to);
void VpSetPlaceSizingLimit(int limit);
@@ -137,7 +137,9 @@ struct TileHighlightData {
WindowClass window_class;
WindowNumber window_number;
- int userdata;
+ byte select_method;
+ byte select_proc;
+
TileIndex redsq;
};
diff --git a/src/window.h b/src/window.h
index 0f59be1b6..b33990420 100644
--- a/src/window.h
+++ b/src/window.h
@@ -135,7 +135,8 @@ struct WindowEvent {
Point pt;
TileIndex tile;
TileIndex starttile;
- int userdata;
+ byte select_method;
+ byte select_proc;
} place;
struct {