(svn r13166) -Codechange: CmdSetRoadDriveSide belongs in road_cmd.cpp, not settings_gui.cpp.
authorrubidium
Sun, 18 May 2008 17:40:13 +0000
changeset 9298 c758dcefb1f2
parent 9297 1cb8d7bbdc8a
child 9299 258be16ef2bd
(svn r13166) -Codechange: CmdSetRoadDriveSide belongs in road_cmd.cpp, not settings_gui.cpp.
src/road_cmd.cpp
src/settings_gui.cpp
--- a/src/road_cmd.cpp	Sun May 18 16:51:44 2008 +0000
+++ b/src/road_cmd.cpp	Sun May 18 17:40:13 2008 +0000
@@ -43,6 +43,37 @@
 #include "table/sprites.h"
 #include "table/strings.h"
 
+
+bool RoadVehiclesAreBuilt()
+{
+	const Vehicle* v;
+
+	FOR_ALL_VEHICLES(v) {
+		if (v->type == VEH_ROAD) return true;
+	}
+	return false;
+}
+
+/**
+ * Change the side of the road vehicles drive on (server only).
+ * @param tile unused
+ * @param flags operation to perform
+ * @param p1 the side of the road; 0 = left side and 1 = right side
+ * @param p2 unused
+ */
+CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+{
+	/* Check boundaries and you can only change this if NO vehicles have been built yet,
+	 * except in the intro-menu where of course it's always possible to do so. */
+	if (p1 > 1 || (_game_mode != GM_MENU && RoadVehiclesAreBuilt())) return CMD_ERROR;
+
+	if (flags & DC_EXEC) {
+		_opt_ptr->road_side = p1;
+		InvalidateWindow(WC_GAME_OPTIONS, 0);
+	}
+	return CommandCost();
+}
+
 #define M(x) (1 << (x))
 /* Level crossings may only be built on these slopes */
 static const uint32 VALID_LEVEL_CROSSING_SLOPES = (M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT));
--- a/src/settings_gui.cpp	Sun May 18 16:51:44 2008 +0000
+++ b/src/settings_gui.cpp	Sun May 18 17:40:13 2008 +0000
@@ -20,7 +20,6 @@
 #include "strings_func.h"
 #include "functions.h"
 #include "window_func.h"
-#include "vehicle_base.h"
 #include "core/alloc_func.hpp"
 #include "string_func.h"
 #include "gfx_func.h"
@@ -102,17 +101,6 @@
 	return i;
 }
 
-static inline bool RoadVehiclesAreBuilt()
-{
-	const Vehicle* v;
-
-	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_ROAD) return true;
-	}
-	return false;
-}
-
-
 enum GameOptionsWidgets {
 	GAMEOPT_CURRENCY_BTN    =  4,
 	GAMEOPT_DISTANCE_BTN    =  6,
@@ -199,6 +187,7 @@
 
 			case GAMEOPT_ROADSIDE_BTN: { // Setup road-side dropdown
 				int i = 0;
+				extern bool RoadVehiclesAreBuilt();
 
 				/* You can only change the drive side if you are in the menu or ingame with
 				 * no vehicles present. In a networking game only the server can change it */
@@ -323,25 +312,6 @@
 	}
 };
 
-/** Change the side of the road vehicles drive on (server only).
- * @param tile unused
- * @param flags operation to perform
- * @param p1 the side of the road; 0 = left side and 1 = right side
- * @param p2 unused
- */
-CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
-{
-	/* Check boundaries and you can only change this if NO vehicles have been built yet,
-	 * except in the intro-menu where of course it's always possible to do so. */
-	if (p1 > 1 || (_game_mode != GM_MENU && RoadVehiclesAreBuilt())) return CMD_ERROR;
-
-	if (flags & DC_EXEC) {
-		_opt_ptr->road_side = p1;
-		InvalidateWindow(WC_GAME_OPTIONS, 0);
-	}
-	return CommandCost();
-}
-
 static const Widget _game_options_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   369,     0,    13, STR_00B1_GAME_OPTIONS,             STR_018C_WINDOW_TITLE_DRAG_THIS},