src/station_gui.cpp
changeset 8040 92c69fcd0d61
parent 8016 1c7062ad5f50
child 8041 9483d3e46b3e
equal deleted inserted replaced
8039:fa18f4352154 8040:92c69fcd0d61
   226 
   226 
   227 	if (!(sl->flags & SL_REBUILD)) return;
   227 	if (!(sl->flags & SL_REBUILD)) return;
   228 
   228 
   229 	/* Create array for sorting */
   229 	/* Create array for sorting */
   230 	const Station** station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1);
   230 	const Station** station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1);
   231 	if (station_sort == NULL) error("Could not allocate memory for the station-sorting-list");
       
   232 
   231 
   233 	DEBUG(misc, 3, "Building station list for player %d", owner);
   232 	DEBUG(misc, 3, "Building station list for player %d", owner);
   234 
   233 
   235 	FOR_ALL_STATIONS(st) {
   234 	FOR_ALL_STATIONS(st) {
   236 		if (st->owner == owner) {
   235 		if (st->owner == owner) {
   253 		}
   252 		}
   254 	}
   253 	}
   255 
   254 
   256 	free((void*)sl->sort_list);
   255 	free((void*)sl->sort_list);
   257 	sl->sort_list = MallocT<const Station*>(n);
   256 	sl->sort_list = MallocT<const Station*>(n);
   258 	if (n != 0 && sl->sort_list == NULL) error("Could not allocate memory for the station-sorting-list");
       
   259 	sl->list_length = n;
   257 	sl->list_length = n;
   260 
   258 
   261 	for (uint i = 0; i < n; ++i) sl->sort_list[i] = station_sort[i];
   259 	for (uint i = 0; i < n; ++i) sl->sort_list[i] = station_sort[i];
   262 
   260 
   263 	sl->flags &= ~SL_REBUILD;
   261 	sl->flags &= ~SL_REBUILD;