(svn r7477) -Fix (7451): Allocate(Industry|Town) get called twice when trying to build an industry/town via a command, thus incrementing the number of towns/industries twice when created via a command.
authorrubidium
Mon, 11 Dec 2006 12:37:57 +0000
changeset 5319 37f1411c79e7
parent 5318 e02e5b76b355
child 5320 8b883bfa9b32
(svn r7477) -Fix (7451): Allocate(Industry|Town) get called twice when trying to build an industry/town via a command, thus incrementing the number of towns/industries twice when created via a command.
industry_cmd.c
town_cmd.c
--- a/industry_cmd.c	Mon Dec 11 12:32:23 2006 +0000
+++ b/industry_cmd.c	Mon Dec 11 12:37:57 2006 +0000
@@ -1362,8 +1362,6 @@
 
 		if (IsValidIndustry(i)) continue;
 
-		_total_industries++;
-
 		memset(i, 0, sizeof(*i));
 		i->index = index;
 
@@ -1380,6 +1378,7 @@
 	uint32 r;
 	int j;
 
+	_total_industries++;
 	i->xy = tile;
 	i->width = i->height = 0;
 	i->type = type;
--- a/town_cmd.c	Mon Dec 11 12:32:23 2006 +0000
+++ b/town_cmd.c	Mon Dec 11 12:37:57 2006 +0000
@@ -915,6 +915,7 @@
 	i = t->index;
 	memset(t, 0, sizeof(Town));
 	t->index = i;
+	_total_towns++;
 
 	t->xy = tile;
 	t->num_houses = 0;
@@ -984,8 +985,6 @@
 		if (!IsValidTown(t)) {
 			TownID index = t->index;
 
-			_total_towns++;
-
 			memset(t, 0, sizeof(Town));
 			t->index = index;