town_cmd.c
changeset 835 a22d6bc16a51
parent 830 8114845804c9
child 836 2874738bce7c
equal deleted inserted replaced
834:5486b7740f33 835:a22d6bc16a51
   169 			return true;
   169 			return true;
   170 	}
   170 	}
   171 	return false;
   171 	return false;
   172 }
   172 }
   173 
   173 
       
   174 static void MarkTownSignDirty(Town *t)
       
   175 {
       
   176 	MarkAllViewportsDirty(
       
   177 		t->sign.left-6,
       
   178 		t->sign.top-3,
       
   179 		t->sign.left+t->sign.width_1*4+12,
       
   180 		t->sign.top + 45
       
   181 	);
       
   182 }
       
   183 
       
   184 void UpdateTownVirtCoord(Town *t)
       
   185 {
       
   186 	MarkTownSignDirty(t);
       
   187 	Point pt = RemapCoords2(GET_TILE_X(t->xy)*16, GET_TILE_Y(t->xy)*16);
       
   188 	SetDParam(0, t->townnametype);
       
   189 	SetDParam(1, t->townnameparts);
       
   190 	SetDParam(2, t->population);
       
   191 	UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24, _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_2001);
       
   192 	MarkTownSignDirty(t);
       
   193 }
   174 
   194 
   175 static void ChangePopulation(Town *t, int mod)
   195 static void ChangePopulation(Town *t, int mod)
   176 {
   196 {
   177 	t->population += mod;
   197 	t->population += mod;
   178 	InvalidateWindow(WC_TOWN_VIEW, t->index);
   198 	InvalidateWindow(WC_TOWN_VIEW, t->index);
       
   199 	UpdateTownVirtCoord(t);
   179 
   200 
   180 	if (_town_sort_order & 2) _town_sort_dirty = true;
   201 	if (_town_sort_order & 2) _town_sort_dirty = true;
   181 }
   202 }
   182 
   203 
   183 static void MakeSingleHouseBigger(uint tile)
   204 static void MakeSingleHouseBigger(uint tile)
   454 					goto no_slope;
   475 					goto no_slope;
   455 			}
   476 			}
   456 			return false;
   477 			return false;
   457 		}
   478 		}
   458 
   479 
   459 		tile = TILE_ADD(tile, _roadblock_tileadd[dir]);
   480 		/* Can somebody explain for what this is needed? :s */
       
   481 		// tile = TILE_ADD(tile, _roadblock_tileadd[dir]);
       
   482 		return true;
   460 	}
   483 	}
   461 }
   484 }
   462 
   485 
   463 static bool TerraformTownTile(uint tile, int edges, int dir)
   486 static bool TerraformTownTile(uint tile, int edges, int dir)
   464 {
   487 {
   812 		t->radius[4] = mass * 3;
   835 		t->radius[4] = mass * 3;
   813 		//debug("%d (->%d): %d %d %d %d\n", t->num_houses, mass, t->radius[0], t->radius[1], t->radius[3], t->radius[4]);
   836 		//debug("%d (->%d): %d %d %d %d\n", t->num_houses, mass, t->radius[0], t->radius[1], t->radius[3], t->radius[4]);
   814 	}
   837 	}
   815 }
   838 }
   816 
   839 
   817 static void UpdateTownVirtCoord(Town *t)
       
   818 {
       
   819 	Point pt = RemapCoords2(GET_TILE_X(t->xy)*16, GET_TILE_Y(t->xy)*16);
       
   820 	SetDParam(0, t->townnameparts);
       
   821 	UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24, t->townnametype);
       
   822 }
       
   823 
       
   824 static void CreateTownName(Town *t1)
   840 static void CreateTownName(Town *t1)
   825 {
   841 {
   826 	Town *t2;
   842 	Town *t2;
   827 	char buf1[64];
   843 	char buf1[64];
   828 	char buf2[64];
   844 	char buf2[64];
  1405 {
  1421 {
  1406 	int amount, n;
  1422 	int amount, n;
  1407 
  1423 
  1408 	_generating_world = true;
  1424 	_generating_world = true;
  1409 
  1425 
  1410 	amount = ((int)Random()&3) + 3;
  1426 	/* The more houses, the faster we grow */
       
  1427 	amount = RandomRange(t->num_houses / 10) + 3;
  1411 	t->num_houses += amount;
  1428 	t->num_houses += amount;
  1412 	UpdateTownRadius(t);
  1429 	UpdateTownRadius(t);
  1413 
  1430 
  1414 	n = amount * 4;
  1431 	n = amount * 10;
  1415 	do GrowTown(t); while (--n);
  1432 	do GrowTown(t); while (--n);
  1416 
  1433 
  1417 	t->num_houses -= amount;
  1434 	t->num_houses -= amount;
  1418 	UpdateTownRadius(t);
  1435 	UpdateTownRadius(t);
  1419 
  1436