equal
deleted
inserted
replaced
452 } |
452 } |
453 |
453 |
454 static RoadBits GetTownRoadMask(TileIndex tile) |
454 static RoadBits GetTownRoadMask(TileIndex tile) |
455 { |
455 { |
456 TrackBits b = GetAnyRoadTrackBits(tile); |
456 TrackBits b = GetAnyRoadTrackBits(tile); |
457 RoadBits r = 0; |
457 RoadBits r = ROAD_NONE; |
458 |
458 |
459 if (b & TRACK_BIT_X) r |= ROAD_X; |
459 if (b & TRACK_BIT_X) r |= ROAD_X; |
460 if (b & TRACK_BIT_Y) r |= ROAD_Y; |
460 if (b & TRACK_BIT_Y) r |= ROAD_Y; |
461 if (b & TRACK_BIT_UPPER) r |= ROAD_NE | ROAD_NW; |
461 if (b & TRACK_BIT_UPPER) r |= ROAD_NE | ROAD_NW; |
462 if (b & TRACK_BIT_LOWER) r |= ROAD_SE | ROAD_SW; |
462 if (b & TRACK_BIT_LOWER) r |= ROAD_SE | ROAD_SW; |
600 return; |
600 return; |
601 |
601 |
602 // That means that the road is only allowed if there is a house |
602 // That means that the road is only allowed if there is a house |
603 // at any side of the new road. |
603 // at any side of the new road. |
604 } |
604 } |
605 rcmd = (1 << a) + (1 << b); |
605 rcmd = (RoadBits)((1 << a) + (1 << b)); |
606 |
606 |
607 } else if (block < 5 && !HASBIT(mask,block^2)) { |
607 } else if (block < 5 && !HASBIT(mask,block^2)) { |
608 // Continue building on a partial road. |
608 // Continue building on a partial road. |
609 // Always OK. |
609 // Always OK. |
610 _grow_town_result = 0; |
610 _grow_town_result = 0; |
611 rcmd = 1 << (block ^ 2); |
611 rcmd = (RoadBits)(1 << (block ^ 2)); |
612 } else { |
612 } else { |
613 int i; |
613 int i; |
614 |
614 |
615 // Reached a tunnel/bridge? Then continue at the other side of it. |
615 // Reached a tunnel/bridge? Then continue at the other side of it. |
616 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
616 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
647 } |
647 } |
648 return; |
648 return; |
649 } |
649 } |
650 |
650 |
651 _grow_town_result = 0; |
651 _grow_town_result = 0; |
652 rcmd = 1 << i; |
652 rcmd = (RoadBits)(1 << i); |
653 } |
653 } |
654 |
654 |
655 // Return if a water tile |
655 // Return if a water tile |
656 if (IsClearWaterTile(tile)) return; |
656 if (IsClearWaterTile(tile)) return; |
657 |
657 |
719 // Try to grow the town from this point |
719 // Try to grow the town from this point |
720 GrowTownInTile(&tile,mask,block,t); |
720 GrowTownInTile(&tile,mask,block,t); |
721 |
721 |
722 // Exclude the source position from the bitmask |
722 // Exclude the source position from the bitmask |
723 // and return if no more road blocks available |
723 // and return if no more road blocks available |
724 CLRBIT(mask, (block ^ 2)); |
724 mask = ClrBitT(mask, (block ^ 2)); |
725 if (mask == 0) |
725 if (mask == 0) |
726 return _grow_town_result; |
726 return _grow_town_result; |
727 |
727 |
728 // Select a random bit from the blockmask, walk a step |
728 // Select a random bit from the blockmask, walk a step |
729 // and continue the search from there. |
729 // and continue the search from there. |
755 { |
755 { |
756 uint32 r = Random(); |
756 uint32 r = Random(); |
757 uint a = GB(r, 0, 2); |
757 uint a = GB(r, 0, 2); |
758 uint b = GB(r, 8, 2); |
758 uint b = GB(r, 8, 2); |
759 if (a == b) b ^= 2; |
759 if (a == b) b ^= 2; |
760 return (1 << a) + (1 << b); |
760 return (RoadBits)((1 << a) + (1 << b)); |
761 } |
761 } |
762 |
762 |
763 // Grow the town |
763 // Grow the town |
764 // Returns true if a house was built, or no if the build failed. |
764 // Returns true if a house was built, or no if the build failed. |
765 static bool GrowTown(Town *t) |
765 static bool GrowTown(Town *t) |
792 tile = t->xy; |
792 tile = t->xy; |
793 for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) { |
793 for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) { |
794 if (GetAnyRoadTrackBits(tile) != 0) { |
794 if (GetAnyRoadTrackBits(tile) != 0) { |
795 int r = GrowTownAtRoad(t, tile); |
795 int r = GrowTownAtRoad(t, tile); |
796 _current_player = old_player; |
796 _current_player = old_player; |
797 return r; |
797 return r != 0; |
798 } |
798 } |
799 tile = TILE_ADD(tile, ToTileIndexDiff(*ptr)); |
799 tile = TILE_ADD(tile, ToTileIndexDiff(*ptr)); |
800 } |
800 } |
801 |
801 |
802 // No road available, try to build a random road block by |
802 // No road available, try to build a random road block by |
947 |
947 |
948 for (i = 0; i != MAX_PLAYERS; i++) |
948 for (i = 0; i != MAX_PLAYERS; i++) |
949 t->ratings[i] = 500; |
949 t->ratings[i] = 500; |
950 |
950 |
951 t->have_ratings = 0; |
951 t->have_ratings = 0; |
952 t->exclusivity = (byte)-1; |
952 t->exclusivity = INVALID_PLAYER; |
953 t->exclusive_counter = 0; |
953 t->exclusive_counter = 0; |
954 t->statues = 0; |
954 t->statues = 0; |
955 |
955 |
956 t->townnametype = SPECSTR_TOWNNAME_START + _opt.town_name; |
956 t->townnametype = SPECSTR_TOWNNAME_START + _opt.town_name; |
957 t->townnameparts = townnameparts; |
957 t->townnameparts = townnameparts; |
1421 |
1421 |
1422 UpdateTownMaxPass(t); |
1422 UpdateTownMaxPass(t); |
1423 _generating_world = false; |
1423 _generating_world = false; |
1424 } |
1424 } |
1425 |
1425 |
1426 const byte _town_action_costs[8] = { |
1426 extern const byte _town_action_costs[8] = { |
1427 2, 4, 9, 35, 48, 53, 117, 175 |
1427 2, 4, 9, 35, 48, 53, 117, 175 |
1428 }; |
1428 }; |
1429 |
1429 |
1430 static void TownActionAdvertiseSmall(Town* t) |
1430 static void TownActionAdvertiseSmall(Town* t) |
1431 { |
1431 { |
1806 |
1806 |
1807 FOR_ALL_TOWNS(t) { |
1807 FOR_ALL_TOWNS(t) { |
1808 if (t->road_build_months != 0) t->road_build_months--; |
1808 if (t->road_build_months != 0) t->road_build_months--; |
1809 |
1809 |
1810 if (t->exclusive_counter != 0) |
1810 if (t->exclusive_counter != 0) |
1811 if (--t->exclusive_counter == 0) t->exclusivity = (byte)-1; |
1811 if (--t->exclusive_counter == 0) t->exclusivity = INVALID_PLAYER; |
1812 |
1812 |
1813 UpdateTownGrowRate(t); |
1813 UpdateTownGrowRate(t); |
1814 UpdateTownAmounts(t); |
1814 UpdateTownAmounts(t); |
1815 UpdateTownUnwanted(t); |
1815 UpdateTownUnwanted(t); |
1816 } |
1816 } |
1832 _cur_town_iter = 0; |
1832 _cur_town_iter = 0; |
1833 _total_towns = 0; |
1833 _total_towns = 0; |
1834 _town_sort_dirty = true; |
1834 _town_sort_dirty = true; |
1835 } |
1835 } |
1836 |
1836 |
1837 const TileTypeProcs _tile_type_town_procs = { |
1837 extern const TileTypeProcs _tile_type_town_procs = { |
1838 DrawTile_Town, /* draw_tile_proc */ |
1838 DrawTile_Town, /* draw_tile_proc */ |
1839 GetSlopeZ_Town, /* get_slope_z_proc */ |
1839 GetSlopeZ_Town, /* get_slope_z_proc */ |
1840 ClearTile_Town, /* clear_tile_proc */ |
1840 ClearTile_Town, /* clear_tile_proc */ |
1841 GetAcceptedCargo_Town, /* get_accepted_cargo_proc */ |
1841 GetAcceptedCargo_Town, /* get_accepted_cargo_proc */ |
1842 GetTileDesc_Town, /* get_tile_desc_proc */ |
1842 GetTileDesc_Town, /* get_tile_desc_proc */ |
1958 } |
1958 } |
1959 _town_sort_dirty = true; |
1959 _town_sort_dirty = true; |
1960 } |
1960 } |
1961 |
1961 |
1962 |
1962 |
1963 const ChunkHandler _town_chunk_handlers[] = { |
1963 extern const ChunkHandler _town_chunk_handlers[] = { |
1964 { 'CITY', Save_TOWN, Load_TOWN, CH_ARRAY | CH_LAST}, |
1964 { 'CITY', Save_TOWN, Load_TOWN, CH_ARRAY | CH_LAST}, |
1965 }; |
1965 }; |