town_cmd.c
changeset 534 306bc86eb23e
parent 516 035c53a7da94
child 543 946badd71033
equal deleted inserted replaced
533:404f9e37bff1 534:306bc86eb23e
   289 	_cleared_town_rating += rating;
   289 	_cleared_town_rating += rating;
   290 	_cleared_town = t = ClosestTownFromTile(tile, (uint)-1);
   290 	_cleared_town = t = ClosestTownFromTile(tile, (uint)-1);
   291 
   291 
   292 	if (_current_player < MAX_PLAYERS) {
   292 	if (_current_player < MAX_PLAYERS) {
   293 		if (rating > t->ratings[_current_player] && !(flags & DC_NO_TOWN_RATING) && !_cheats.magic_bulldozer.value) {
   293 		if (rating > t->ratings[_current_player] && !(flags & DC_NO_TOWN_RATING) && !_cheats.magic_bulldozer.value) {
   294 			SET_DPARAM16(0, t->index);
   294 			SetDParam(0, t->index);
   295 			return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES);
   295 			return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES);
   296 		}
   296 		}
   297 	}
   297 	}
   298 
   298 
   299 	if (flags & DC_EXEC) {
   299 	if (flags & DC_EXEC) {
   316 
   316 
   317 static void GetTileDesc_Town(uint tile, TileDesc *td)
   317 static void GetTileDesc_Town(uint tile, TileDesc *td)
   318 {
   318 {
   319 	td->str = _town_tile_names[_map2[tile]];
   319 	td->str = _town_tile_names[_map2[tile]];
   320 	if ((_map3_lo[tile] & 0xC0) != 0xC0) {
   320 	if ((_map3_lo[tile] & 0xC0) != 0xC0) {
   321 		SET_DPARAMX16(td->dparam, 0, td->str);
   321 		SetDParamX(td->dparam, 0, td->str);
   322 		td->str = STR_2058_UNDER_CONSTRUCTION;
   322 		td->str = STR_2058_UNDER_CONSTRUCTION;
   323 	}
   323 	}
   324 
   324 
   325 	td->owner = OWNER_TOWN;
   325 	td->owner = OWNER_TOWN;
   326 }
   326 }
   813 }
   813 }
   814 
   814 
   815 static void UpdateTownVirtCoord(Town *t)
   815 static void UpdateTownVirtCoord(Town *t)
   816 {
   816 {
   817 	Point pt = RemapCoords2(GET_TILE_X(t->xy)*16, GET_TILE_Y(t->xy)*16);
   817 	Point pt = RemapCoords2(GET_TILE_X(t->xy)*16, GET_TILE_Y(t->xy)*16);
   818 	SET_DPARAM32(0, t->townnameparts);
   818 	SetDParam(0, t->townnameparts);
   819 	UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24, t->townnametype);
   819 	UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24, t->townnametype);
   820 }
   820 }
   821 
   821 
   822 static void CreateTownName(Town *t1)
   822 static void CreateTownName(Town *t1)
   823 {
   823 {
   830 
   830 
   831 	for(;;) {
   831 	for(;;) {
   832 restart:
   832 restart:
   833 		r = Random();
   833 		r = Random();
   834 
   834 
   835 		SET_DPARAM32(0, r);
   835 		SetDParam(0, r);
   836 		GetString(buf1, t1->townnametype);
   836 		GetString(buf1, t1->townnametype);
   837 
   837 
   838 		// Check size and width
   838 		// Check size and width
   839 		if (strlen(buf1) >= 31 || GetStringWidth(buf1) > 130)
   839 		if (strlen(buf1) >= 31 || GetStringWidth(buf1) > 130)
   840 			continue;
   840 			continue;
   841 
   841 
   842 		FOR_ALL_TOWNS(t2) {
   842 		FOR_ALL_TOWNS(t2) {
   843 			if (t2->xy != 0) {
   843 			if (t2->xy != 0) {
   844 				SET_DPARAM32(0, t2->townnameparts);
   844 				SetDParam(0, t2->townnameparts);
   845 				GetString(buf2, t2->townnametype);
   845 				GetString(buf2, t2->townnametype);
   846 				if (str_eq(buf1, buf2))
   846 				if (str_eq(buf1, buf2))
   847 					goto restart;
   847 					goto restart;
   848 			}
   848 			}
   849 		}
   849 		}
  1438 {
  1438 {
  1439 	Player *p;
  1439 	Player *p;
  1440 
  1440 
  1441 	t->road_build_months = 6;
  1441 	t->road_build_months = 6;
  1442 
  1442 
  1443 	SET_DPARAM16(0, t->index);
  1443 	SetDParam(0, t->index);
  1444 
  1444 
  1445 	p = DEREF_PLAYER(_current_player);
  1445 	p = DEREF_PLAYER(_current_player);
  1446 	SET_DPARAM16(1, p->name_1);
  1446 	SetDParam(1, p->name_1);
  1447 	SET_DPARAM32(2, p->name_2);
  1447 	SetDParam(2, p->name_2);
  1448 
  1448 
  1449 	AddNewsItem(STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING,
  1449 	AddNewsItem(STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING,
  1450 		NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_GENERAL, 0), t->xy, 0);
  1450 		NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_GENERAL, 0), t->xy, 0);
  1451 }
  1451 }
  1452 
  1452 
  1702 
  1702 
  1703 	if (t->ratings[_current_player] > -200)
  1703 	if (t->ratings[_current_player] > -200)
  1704 		return true;
  1704 		return true;
  1705 
  1705 
  1706 	_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
  1706 	_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
  1707 	SET_DPARAM16(0, t->index);
  1707 	SetDParam(0, t->index);
  1708 
  1708 
  1709 	return false;
  1709 	return false;
  1710 }
  1710 }
  1711 
  1711 
  1712 
  1712 
  1776 	 *	difficulty setting. Minimum town rating selected by difficulty level
  1776 	 *	difficulty setting. Minimum town rating selected by difficulty level
  1777 	 */
  1777 	 */
  1778 	modemod = _default_rating_settings[_opt_mod_ptr->diff.town_council_tolerance][type];
  1778 	modemod = _default_rating_settings[_opt_mod_ptr->diff.town_council_tolerance][type];
  1779 
  1779 
  1780 	if (t->ratings[_current_player] < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
  1780 	if (t->ratings[_current_player] < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
  1781 		SET_DPARAM16(0, t->index);
  1781 		SetDParam(0, t->index);
  1782 		_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
  1782 		_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
  1783 		return false;
  1783 		return false;
  1784 	}
  1784 	}
  1785 
  1785 
  1786 	return true;
  1786 	return true;