File diff r4608:cbac9c94e467 → r4609:43908f0c2b9c
town_cmd.c
Show inline comments
 
@@ -868,49 +868,49 @@ static void UpdateTownRadius(Town *t)
 
static bool CreateTownName(uint32 *townnameparts)
 
{
 
	Town *t2;
 
	char buf1[64];
 
	char buf2[64];
 
	uint32 r;
 
	/* Do not set too low tries, since when we run out of names, we loop
 
	 * for #tries only one time anyway - then we stop generating more
 
	 * towns. Do not show it too high neither, since looping through all
 
	 * the other towns may take considerable amount of time (10000 is
 
	 * too much). */
 
	int tries = 1000;
 
	uint16 townnametype = SPECSTR_TOWNNAME_START + _opt.town_name;
 

	
 
	assert(townnameparts);
 

	
 
	for (;;) {
 
restart:
 
		r = Random();
 

	
 
		SetDParam(0, r);
 
		GetString(buf1, townnametype);
 

	
 
		// Check size and width
 
		if (strlen(buf1) >= 31 || GetStringWidth(buf1) > 130) continue;
 
		if (strlen(buf1) >= 31 || GetStringBoundingBox(buf1).width > 130) continue;
 

	
 
		FOR_ALL_TOWNS(t2) {
 
			// We can't just compare the numbers since
 
			// several numbers may map to a single name.
 
			SetDParam(0, t2->index);
 
			GetString(buf2, STR_TOWN);
 
			if (strcmp(buf1, buf2) == 0) {
 
				if (tries-- < 0) return false;
 
				goto restart;
 
			}
 
		}
 
		*townnameparts = r;
 
		return true;
 
	}
 
}
 

	
 
void UpdateTownMaxPass(Town *t)
 
{
 
	t->max_pass = t->population >> 3;
 
	t->max_mail = t->population >> 4;
 
}
 

	
 
static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, uint size_mode)
 
{