src/station_cmd.cpp
changeset 6247 7d81e3a5d803
parent 6201 bee01dc45e39
child 6248 e4a2ed7e5613
equal deleted inserted replaced
6246:75451000349d 6247:7d81e3a5d803
   328 	SetDParam(1, st->facilities);
   328 	SetDParam(1, st->facilities);
   329 	UpdateViewportSignPos(&st->sign, pt.x, pt.y, STR_305C_0);
   329 	UpdateViewportSignPos(&st->sign, pt.x, pt.y, STR_305C_0);
   330 }
   330 }
   331 
   331 
   332 // Update the virtual coords needed to draw the station sign for all stations.
   332 // Update the virtual coords needed to draw the station sign for all stations.
   333 void UpdateAllStationVirtCoord(void)
   333 void UpdateAllStationVirtCoord()
   334 {
   334 {
   335 	Station* st;
   335 	Station* st;
   336 
   336 
   337 	FOR_ALL_STATIONS(st) {
   337 	FOR_ALL_STATIONS(st) {
   338 		UpdateStationVirtCoord(st);
   338 		UpdateStationVirtCoord(st);
  2297 	st->delete_ctr = b;
  2297 	st->delete_ctr = b;
  2298 
  2298 
  2299 	if (b == 0) UpdateStationRating(st);
  2299 	if (b == 0) UpdateStationRating(st);
  2300 }
  2300 }
  2301 
  2301 
  2302 void OnTick_Station(void)
  2302 void OnTick_Station()
  2303 {
  2303 {
  2304 	if (_game_mode == GM_EDITOR) return;
  2304 	if (_game_mode == GM_EDITOR) return;
  2305 
  2305 
  2306 	uint i = _station_tick_ctr;
  2306 	uint i = _station_tick_ctr;
  2307 	if (++_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0;
  2307 	if (++_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0;
  2310 
  2310 
  2311 	Station *st;
  2311 	Station *st;
  2312 	FOR_ALL_STATIONS(st) StationHandleSmallTick(st);
  2312 	FOR_ALL_STATIONS(st) StationHandleSmallTick(st);
  2313 }
  2313 }
  2314 
  2314 
  2315 void StationMonthlyLoop(void)
  2315 void StationMonthlyLoop()
  2316 {
  2316 {
  2317 }
  2317 }
  2318 
  2318 
  2319 
  2319 
  2320 void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius)
  2320 void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius)
  2641 	}
  2641 	}
  2642 
  2642 
  2643 	return CMD_ERROR;
  2643 	return CMD_ERROR;
  2644 }
  2644 }
  2645 
  2645 
  2646 void InitializeStations(void)
  2646 void InitializeStations()
  2647 {
  2647 {
  2648 	/* Clean the station pool and create 1 block in it */
  2648 	/* Clean the station pool and create 1 block in it */
  2649 	CleanPool(&_Station_pool);
  2649 	CleanPool(&_Station_pool);
  2650 	AddBlockToPool(&_Station_pool);
  2650 	AddBlockToPool(&_Station_pool);
  2651 
  2651 
  2656 	_station_tick_ctr = 0;
  2656 	_station_tick_ctr = 0;
  2657 
  2657 
  2658 }
  2658 }
  2659 
  2659 
  2660 
  2660 
  2661 void AfterLoadStations(void)
  2661 void AfterLoadStations()
  2662 {
  2662 {
  2663 	/* Update the speclists of all stations to point to the currently loaded custom stations. */
  2663 	/* Update the speclists of all stations to point to the currently loaded custom stations. */
  2664 	Station *st;
  2664 	Station *st;
  2665 	FOR_ALL_STATIONS(st) {
  2665 	FOR_ALL_STATIONS(st) {
  2666 		for (uint i = 0; i < st->num_specs; i++) {
  2666 		for (uint i = 0; i < st->num_specs; i++) {
  2812 			SlObject(&st->speclist[i], _station_speclist_desc);
  2812 			SlObject(&st->speclist[i], _station_speclist_desc);
  2813 		}
  2813 		}
  2814 	}
  2814 	}
  2815 }
  2815 }
  2816 
  2816 
  2817 static void Save_STNS(void)
  2817 static void Save_STNS()
  2818 {
  2818 {
  2819 	Station *st;
  2819 	Station *st;
  2820 	// Write the stations
  2820 	// Write the stations
  2821 	FOR_ALL_STATIONS(st) {
  2821 	FOR_ALL_STATIONS(st) {
  2822 		SlSetArrayIndex(st->index);
  2822 		SlSetArrayIndex(st->index);
  2823 		SlAutolength((AutolengthProc*)SaveLoad_STNS, st);
  2823 		SlAutolength((AutolengthProc*)SaveLoad_STNS, st);
  2824 	}
  2824 	}
  2825 }
  2825 }
  2826 
  2826 
  2827 static void Load_STNS(void)
  2827 static void Load_STNS()
  2828 {
  2828 {
  2829 	int index;
  2829 	int index;
  2830 	while ((index = SlIterateArray()) != -1) {
  2830 	while ((index = SlIterateArray()) != -1) {
  2831 		Station *st = new (index) Station();
  2831 		Station *st = new (index) Station();
  2832 
  2832 
  2845 
  2845 
  2846 	/* This is to ensure all pointers are within the limits of _stations_size */
  2846 	/* This is to ensure all pointers are within the limits of _stations_size */
  2847 	if (_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0;
  2847 	if (_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0;
  2848 }
  2848 }
  2849 
  2849 
  2850 static void Save_ROADSTOP(void)
  2850 static void Save_ROADSTOP()
  2851 {
  2851 {
  2852 	RoadStop *rs;
  2852 	RoadStop *rs;
  2853 
  2853 
  2854 	FOR_ALL_ROADSTOPS(rs) {
  2854 	FOR_ALL_ROADSTOPS(rs) {
  2855 		SlSetArrayIndex(rs->index);
  2855 		SlSetArrayIndex(rs->index);
  2856 		SlObject(rs, _roadstop_desc);
  2856 		SlObject(rs, _roadstop_desc);
  2857 	}
  2857 	}
  2858 }
  2858 }
  2859 
  2859 
  2860 static void Load_ROADSTOP(void)
  2860 static void Load_ROADSTOP()
  2861 {
  2861 {
  2862 	int index;
  2862 	int index;
  2863 
  2863 
  2864 	while ((index = SlIterateArray()) != -1) {
  2864 	while ((index = SlIterateArray()) != -1) {
  2865 		RoadStop *rs = new (index) RoadStop(INVALID_TILE);
  2865 		RoadStop *rs = new (index) RoadStop(INVALID_TILE);