src/town_gui.cpp
branchNewGRF_ports
changeset 6872 1c4a4a609f85
parent 6871 5a9dc001e1ad
child 6878 7d1ff2f621c7
--- a/src/town_gui.cpp	Mon Dec 03 23:39:38 2007 +0000
+++ b/src/town_gui.cpp	Tue Jan 22 21:00:30 2008 +0000
@@ -5,20 +5,25 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "strings.h"
+#include "town.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
+#include "gui.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
+#include "command_func.h"
+#include "player_func.h"
+#include "player_base.h"
+#include "player_gui.h"
+#include "network/network.h"
+#include "variables.h"
+#include "strings_func.h"
+#include "economy_func.h"
+#include "core/alloc_func.hpp"
+#include "settings_type.h"
+
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "town.h"
-#include "window.h"
-#include "gfx.h"
-#include "viewport.h"
-#include "gui.h"
-#include "command.h"
-#include "player.h"
-#include "network/network.h"
-#include "variables.h"
-#include "helpers.hpp"
 
 enum TownAuthorityWidget {
 	TWA_CLOSEBOX = 0,
@@ -140,8 +145,8 @@
 
 		SetVScrollCount(w, numact + 1);
 
-		if (WP(w,def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1))
-			WP(w,def_d).data_1 = -1;
+		if (WP(w, def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1))
+			WP(w, def_d).data_1 = -1;
 
 		w->SetWidgetDisabledState(6, WP(w, def_d).data_1 == -1);
 
@@ -206,7 +211,7 @@
 		}
 
 		{
-			int i = WP(w,def_d).data_1;
+			int i = WP(w, def_d).data_1;
 
 			if (i != -1) {
 				SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]);
@@ -228,7 +233,7 @@
 
 			y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + w->vscroll.pos - 1);
 			if (y >= 0) {
-				WP(w,def_d).data_1 = y;
+				WP(w, def_d).data_1 = y;
 				SetWindowDirty(w);
 			}
 			/* Fall through to clicking in case we are double-clicked */
@@ -236,7 +241,7 @@
 		}
 
 		case TWA_EXECUTE: {
-			DoCommandP(GetTown(w->window_number)->xy, w->window_number, WP(w,def_d).data_1, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
+			DoCommandP(GetTown(w->window_number)->xy, w->window_number, WP(w, def_d).data_1, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
 			break;
 		}
 		}
@@ -262,7 +267,7 @@
 
 	if (w != NULL) {
 		w->vscroll.cap = 5;
-		WP(w,def_d).data_1 = -1;
+		WP(w, def_d).data_1 = -1;
 	}
 }
 
@@ -449,7 +454,6 @@
 
 	/* Create array for sorting */
 	_town_sort = ReallocT(_town_sort, GetMaxTownIndex() + 1);
-	if (_town_sort == NULL) error("Could not allocate memory for the town-sorting-list");
 
 	FOR_ALL_TOWNS(t) _town_sort[n++] = t;
 
@@ -474,7 +478,7 @@
 		SetVScrollCount(w, _num_town_sort);
 
 		DrawWindowWidgets(w);
-		DoDrawString(_town_sort_order & 1 ? DOWNARROW : UPARROW, (_town_sort_order <= 1) ? 88 : 187, 15, TC_BLACK);
+		DrawSortButtonState(w, (_town_sort_order <= 1) ? 3 : 4, _town_sort_order & 1 ? SBS_DOWN : SBS_UP);
 
 		{
 			int n = 0;