summaryrefslogtreecommitdiff
path: root/town_gui.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-28 17:50:17 +0000
committertruelight <truelight@openttd.org>2004-12-28 17:50:17 +0000
commit6735bffd39f0b1f68f55a4132d404ff41c510ab5 (patch)
treea2fe0f33cee4641d2ccfa72c118208b4ae912066 /town_gui.c
parente6a59be8c03998195cb87592231399fb5786234b (diff)
downloadopenttd-6735bffd39f0b1f68f55a4132d404ff41c510ab5.tar.xz
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
Diffstat (limited to 'town_gui.c')
-rw-r--r--town_gui.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/town_gui.c b/town_gui.c
index 652899c11..2df24ad13 100644
--- a/town_gui.c
+++ b/town_gui.c
@@ -352,11 +352,11 @@ static const Widget _town_directory_widgets[] = {
// used to get a sorted list of the towns
-static byte _town_sort[lengthof(_towns)];
+static uint16 _town_sort[lengthof(_towns)];
static uint _num_town_sort;
static char _bufcache[64];
-static byte _last_town_idx;
+static uint16 _last_town_idx;
static int CDECL TownNameSorter(const void *a, const void *b)
{
@@ -365,11 +365,11 @@ static int CDECL TownNameSorter(const void *a, const void *b)
byte val;
int r;
- t = DEREF_TOWN(*(const byte*)a);
+ t = DEREF_TOWN(*(const uint16*)a);
SetDParam(0, t->townnameparts);
GetString(buf1, t->townnametype);
- if ( (val=*(const byte*)b) != _last_town_idx) {
+ if ( (val=*(const uint16*)b) != _last_town_idx) {
_last_town_idx = val;
t = DEREF_TOWN(val);
SetDParam(0, t->townnameparts);
@@ -383,8 +383,8 @@ static int CDECL TownNameSorter(const void *a, const void *b)
static int CDECL TownPopSorter(const void *a, const void *b)
{
- const Town *ta = DEREF_TOWN(*(const byte*)a);
- const Town *tb = DEREF_TOWN(*(const byte*)b);
+ const Town *ta = DEREF_TOWN(*(const uint16*)a);
+ const Town *tb = DEREF_TOWN(*(const uint16*)b);
int r = ta->population - tb->population;
if (_town_sort_order & 1) r = -r;
return r;
@@ -394,7 +394,10 @@ static void MakeSortedTownList()
{
Town *t;
int n = 0;
- FOR_ALL_TOWNS(t) if(t->xy) _town_sort[n++] = t->index;
+ FOR_ALL_TOWNS(t)
+ if(t->xy)
+ _town_sort[n++] = t->index;
+
_num_town_sort = n;
_last_town_idx = 0; // used for "cache"