waypoint.c
changeset 4390 6e00adba300d
parent 4389 e4555522d257
child 4393 1e3d47fcdab6
equal deleted inserted replaced
4389:e4555522d257 4390:6e00adba300d
    93 	FOR_ALL_WAYPOINTS(wp) {
    93 	FOR_ALL_WAYPOINTS(wp) {
    94 		UpdateWaypointSign(wp);
    94 		UpdateWaypointSign(wp);
    95 	}
    95 	}
    96 }
    96 }
    97 
    97 
       
    98 /* Internal handler to delete a waypoint */
       
    99 void DestroyWaypoint(Waypoint *wp)
       
   100 {
       
   101 	RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, (DestinationID)wp->index);
       
   102 
       
   103 	if (wp->string != STR_NULL) DeleteName(wp->string);
       
   104 
       
   105 	RedrawWaypointSign(wp);
       
   106 }
       
   107 
    98 /* Set the default name for a waypoint */
   108 /* Set the default name for a waypoint */
    99 static void MakeDefaultWaypointName(Waypoint* wp)
   109 static void MakeDefaultWaypointName(Waypoint* wp)
   100 {
   110 {
   101 	Waypoint *local_wp;
   111 	Waypoint *local_wp;
   102 	bool used_waypoint[MAX_WAYPOINTS_PER_TOWN];
   112 	bool used_waypoint[MAX_WAYPOINTS_PER_TOWN];
   242 	}
   252 	}
   243 
   253 
   244 	return _price.build_train_depot;
   254 	return _price.build_train_depot;
   245 }
   255 }
   246 
   256 
   247 /* Internal handler to delete a waypoint */
       
   248 static void DoDeleteWaypoint(Waypoint *wp)
       
   249 {
       
   250 	wp->xy = 0;
       
   251 
       
   252 	RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, (DestinationID)wp->index);
       
   253 
       
   254 	if (wp->string != STR_NULL) DeleteName(wp->string);
       
   255 
       
   256 	RedrawWaypointSign(wp);
       
   257 }
       
   258 
       
   259 /* Daily loop for waypoints */
   257 /* Daily loop for waypoints */
   260 void WaypointsDailyLoop(void)
   258 void WaypointsDailyLoop(void)
   261 {
   259 {
   262 	Waypoint *wp;
   260 	Waypoint *wp;
   263 
   261 
   264 	/* Check if we need to delete a waypoint */
   262 	/* Check if we need to delete a waypoint */
   265 	FOR_ALL_WAYPOINTS(wp) {
   263 	FOR_ALL_WAYPOINTS(wp) {
   266 		if (wp->deleted != 0 && --wp->deleted == 0) DoDeleteWaypoint(wp);
   264 		if (wp->deleted != 0 && --wp->deleted == 0) DestroyWaypoint(wp);
   267 	}
   265 	}
   268 }
   266 }
   269 
   267 
   270 /* Remove a waypoint */
   268 /* Remove a waypoint */
   271 int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
   269 int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)