station_cmd.c
changeset 3812 e6fc916c17ab
parent 3789 c50647c927e4
child 3873 20861d17b162
equal deleted inserted replaced
3811:8f2b44f6b709 3812:e6fc916c17ab
   493 	}
   493 	}
   494 
   494 
   495 	st->random_bits = Random();
   495 	st->random_bits = Random();
   496 	st->waiting_triggers = 0;
   496 	st->waiting_triggers = 0;
   497 
   497 
   498 	_global_station_sort_dirty = true; // build a new station
       
   499 }
   498 }
   500 
   499 
   501 // Update the virtual coords needed to draw the station sign.
   500 // Update the virtual coords needed to draw the station sign.
   502 // st = Station to update for.
   501 // st = Station to update for.
   503 static void UpdateStationVirtCoord(Station *st)
   502 static void UpdateStationVirtCoord(Station *st)
   767 // deleted after a little while.
   766 // deleted after a little while.
   768 static void DeleteStationIfEmpty(Station* st)
   767 static void DeleteStationIfEmpty(Station* st)
   769 {
   768 {
   770 	if (st->facilities == 0) {
   769 	if (st->facilities == 0) {
   771 		st->delete_ctr = 0;
   770 		st->delete_ctr = 0;
       
   771 		RebuildStationLists();
   772 		InvalidateWindow(WC_STATION_LIST, st->owner);
   772 		InvalidateWindow(WC_STATION_LIST, st->owner);
   773 	}
   773 	}
   774 }
   774 }
   775 
   775 
   776 static int32 ClearTile_Station(TileIndex tile, byte flags);
   776 static int32 ClearTile_Station(TileIndex tile, byte flags);
  1117 			tile_org += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
  1117 			tile_org += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
  1118 		} while (--numtracks);
  1118 		} while (--numtracks);
  1119 
  1119 
  1120 		UpdateStationVirtCoordDirty(st);
  1120 		UpdateStationVirtCoordDirty(st);
  1121 		UpdateStationAcceptance(st, false);
  1121 		UpdateStationAcceptance(st, false);
       
  1122 		RebuildStationLists();
  1122 		InvalidateWindow(WC_STATION_LIST, st->owner);
  1123 		InvalidateWindow(WC_STATION_LIST, st->owner);
  1123 	}
  1124 	}
  1124 
  1125 
  1125 	return cost;
  1126 	return cost;
  1126 }
  1127 }
  1463 
  1464 
  1464 		MakeRoadStop(tile, st->owner, st->index, type, p1);
  1465 		MakeRoadStop(tile, st->owner, st->index, type, p1);
  1465 
  1466 
  1466 		UpdateStationVirtCoordDirty(st);
  1467 		UpdateStationVirtCoordDirty(st);
  1467 		UpdateStationAcceptance(st, false);
  1468 		UpdateStationAcceptance(st, false);
       
  1469 		RebuildStationLists();
  1468 		InvalidateWindow(WC_STATION_LIST, st->owner);
  1470 		InvalidateWindow(WC_STATION_LIST, st->owner);
  1469 	}
  1471 	}
  1470 	return cost;
  1472 	return cost;
  1471 }
  1473 }
  1472 
  1474 
  1701 			} END_TILE_LOOP(tile_cur, w, h, tile)
  1703 			} END_TILE_LOOP(tile_cur, w, h, tile)
  1702 		}
  1704 		}
  1703 
  1705 
  1704 		UpdateStationVirtCoordDirty(st);
  1706 		UpdateStationVirtCoordDirty(st);
  1705 		UpdateStationAcceptance(st, false);
  1707 		UpdateStationAcceptance(st, false);
       
  1708 		RebuildStationLists();
  1706 		InvalidateWindow(WC_STATION_LIST, st->owner);
  1709 		InvalidateWindow(WC_STATION_LIST, st->owner);
  1707 	}
  1710 	}
  1708 
  1711 
  1709 	return cost;
  1712 	return cost;
  1710 }
  1713 }
  1787 		st->build_date = _date;
  1790 		st->build_date = _date;
  1788 
  1791 
  1789 		MakeBuoy(tile, st->index);
  1792 		MakeBuoy(tile, st->index);
  1790 
  1793 
  1791 		UpdateStationVirtCoordDirty(st);
  1794 		UpdateStationVirtCoordDirty(st);
  1792 
       
  1793 		UpdateStationAcceptance(st, false);
  1795 		UpdateStationAcceptance(st, false);
       
  1796 		RebuildStationLists();
  1794 		InvalidateWindow(WC_STATION_LIST, st->owner);
  1797 		InvalidateWindow(WC_STATION_LIST, st->owner);
  1795 	}
  1798 	}
  1796 
  1799 
  1797 	return _price.build_dock;
  1800 	return _price.build_dock;
  1798 }
  1801 }
  1944 
  1947 
  1945 		MakeDock(tile, st->owner, st->index, direction);
  1948 		MakeDock(tile, st->owner, st->index, direction);
  1946 
  1949 
  1947 		UpdateStationVirtCoordDirty(st);
  1950 		UpdateStationVirtCoordDirty(st);
  1948 		UpdateStationAcceptance(st, false);
  1951 		UpdateStationAcceptance(st, false);
       
  1952 		RebuildStationLists();
  1949 		InvalidateWindow(WC_STATION_LIST, st->owner);
  1953 		InvalidateWindow(WC_STATION_LIST, st->owner);
  1950 	}
  1954 	}
  1951 	return _price.build_dock;
  1955 	return _price.build_dock;
  1952 }
  1956 }
  1953 
  1957 
  2318 	Vehicle *v;
  2322 	Vehicle *v;
  2319 	st->xy = 0;
  2323 	st->xy = 0;
  2320 
  2324 
  2321 	DeleteName(st->string_id);
  2325 	DeleteName(st->string_id);
  2322 	MarkStationDirty(st);
  2326 	MarkStationDirty(st);
  2323 	_global_station_sort_dirty = true; // delete station, remove sign
  2327 	RebuildStationLists();
  2324 	InvalidateWindowClasses(WC_STATION_LIST);
  2328 	InvalidateWindowClasses(WC_STATION_LIST);
  2325 
  2329 
  2326 	index = st->index;
  2330 	index = st->index;
  2327 	DeleteWindowById(WC_STATION_VIEW, index);
  2331 	DeleteWindowById(WC_STATION_VIEW, index);
  2328 
  2332 
  2555 		StringID old_str = st->string_id;
  2559 		StringID old_str = st->string_id;
  2556 
  2560 
  2557 		st->string_id = str;
  2561 		st->string_id = str;
  2558 		UpdateStationVirtCoord(st);
  2562 		UpdateStationVirtCoord(st);
  2559 		DeleteName(old_str);
  2563 		DeleteName(old_str);
  2560 		_station_sort_dirty[st->owner] = true; // rename a station
  2564 		ResortStationLists();
  2561 		MarkWholeScreenDirty();
  2565 		MarkWholeScreenDirty();
  2562 	} else {
  2566 	} else {
  2563 		DeleteName(str);
  2567 		DeleteName(str);
  2564 	}
  2568 	}
  2565 
  2569 
  2774 	if (new_player != OWNER_SPECTATOR) {
  2778 	if (new_player != OWNER_SPECTATOR) {
  2775 		Station* st = GetStationByTile(tile);
  2779 		Station* st = GetStationByTile(tile);
  2776 
  2780 
  2777 		SetTileOwner(tile, new_player);
  2781 		SetTileOwner(tile, new_player);
  2778 		st->owner = new_player;
  2782 		st->owner = new_player;
  2779 		_global_station_sort_dirty = true; // transfer ownership of station to another player
  2783 		RebuildStationLists();
  2780 		InvalidateWindowClasses(WC_STATION_LIST);
  2784 		InvalidateWindowClasses(WC_STATION_LIST);
  2781 	} else {
  2785 	} else {
  2782 		DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
  2786 		DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
  2783 	}
  2787 	}
  2784 }
  2788 }
  2828 	CleanPool(&_roadstop_pool);
  2832 	CleanPool(&_roadstop_pool);
  2829 	AddBlockToPool(&_roadstop_pool);
  2833 	AddBlockToPool(&_roadstop_pool);
  2830 
  2834 
  2831 	_station_tick_ctr = 0;
  2835 	_station_tick_ctr = 0;
  2832 
  2836 
  2833 	// set stations to be sorted on load of savegame
       
  2834 	memset(_station_sort_dirty, true, sizeof(_station_sort_dirty));
       
  2835 	_global_station_sort_dirty = true; // load of savegame
       
  2836 }
  2837 }
  2837 
  2838 
  2838 
  2839 
  2839 void AfterLoadStations(void)
  2840 void AfterLoadStations(void)
  2840 {
  2841 {