equal
deleted
inserted
replaced
83 { |
83 { |
84 uint32 used = 0; // bitmap of used waypoint numbers, sliding window with 'next' as base |
84 uint32 used = 0; // bitmap of used waypoint numbers, sliding window with 'next' as base |
85 uint32 next = 0; // first waypoint number in the bitmap |
85 uint32 next = 0; // first waypoint number in the bitmap |
86 WaypointID idx = 0; // index where we will stop |
86 WaypointID idx = 0; // index where we will stop |
87 |
87 |
88 wp->town_index = ClosestTownFromTile(wp->xy, (uint)-1)->index; |
88 wp->town_index = ClosestTownFromTile(wp->xy, UINT_MAX)->index; |
89 |
89 |
90 /* Find first unused waypoint number belonging to this town. This can never fail, |
90 /* Find first unused waypoint number belonging to this town. This can never fail, |
91 * as long as there can be at most 65535 waypoints in total. |
91 * as long as there can be at most 65535 waypoints in total. |
92 * |
92 * |
93 * This does 'n * m' search, but with 32bit 'used' bitmap, it needs at most 'n * (1 + ceil(m / 32))' |
93 * This does 'n * m' search, but with 32bit 'used' bitmap, it needs at most 'n * (1 + ceil(m / 32))' |
470 { |
470 { |
471 Waypoint *wp; |
471 Waypoint *wp; |
472 |
472 |
473 /* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */ |
473 /* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */ |
474 FOR_ALL_WAYPOINTS(wp) { |
474 FOR_ALL_WAYPOINTS(wp) { |
475 wp->town_index = ClosestTownFromTile(wp->xy, (uint)-1)->index; |
475 wp->town_index = ClosestTownFromTile(wp->xy, UINT_MAX)->index; |
476 wp->town_cn = 0; |
476 wp->town_cn = 0; |
477 if (wp->string & 0xC000) { |
477 if (wp->string & 0xC000) { |
478 wp->town_cn = wp->string & 0x3F; |
478 wp->town_cn = wp->string & 0x3F; |
479 wp->string = STR_NULL; |
479 wp->string = STR_NULL; |
480 } |
480 } |