diff options
author | rubidium <rubidium@openttd.org> | 2006-12-09 14:14:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2006-12-09 14:14:51 +0000 |
commit | 5b5b1d1514080cb4d1659507987681eede0a212b (patch) | |
tree | e0df6d79e90152d1b3508be213f07fe29b04698e /town_cmd.c | |
parent | 38edab372b48c7fb5addcfab88ead01a6bb4a760 (diff) | |
download | openttd-5b5b1d1514080cb4d1659507987681eede0a212b.tar.xz |
(svn r7451) -Fix (7372): GetNum(Towns|Industries) should return the actual number of towns and industries.
-Fix (6055): GetMax(Town|Industry)Index should not return the number of towns or industries - 1, but the size of the pool - 1.
Diffstat (limited to 'town_cmd.c')
-rw-r--r-- | town_cmd.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/town_cmd.c b/town_cmd.c index c56e01b98..98a563e89 100644 --- a/town_cmd.c +++ b/town_cmd.c @@ -54,6 +54,7 @@ void DestroyTown(Town *t) * and remove from list of sorted towns */ DeleteWindowById(WC_TOWN_VIEW, t->index); _town_sort_dirty = true; + _total_towns--; /* Delete all industries belonging to the town */ FOR_ALL_INDUSTRIES(i) if (i->town == t) DeleteIndustry(i); @@ -983,7 +984,7 @@ static Town *AllocateTown(void) if (!IsValidTown(t)) { TownID index = t->index; - if (t->index >= _total_towns) _total_towns = t->index + 1; + _total_towns++; memset(t, 0, sizeof(Town)); t->index = index; @@ -1932,7 +1933,7 @@ static void Load_TOWN(void) t = GetTown(index); SlObject(t, _town_desc); - if ((uint)index >= _total_towns) _total_towns = index + 1; + _total_towns++; } /* This is to ensure all pointers are within the limits of |