src/station_cmd.cpp
branchnoai
changeset 10645 8cbdb511a674
parent 10513 33cb70ff2f5d
child 10715 6bdf79ffb022
equal deleted inserted replaced
10644:6c4314786d68 10645:8cbdb511a674
   407 	for (uint i = 0; i < num_items; i++) {
   407 	for (uint i = 0; i < num_items; i++) {
   408 		SetDParam(i + 1, GetCargo(cargo[i])->name);
   408 		SetDParam(i + 1, GetCargo(cargo[i])->name);
   409 	}
   409 	}
   410 
   410 
   411 	SetDParam(0, st->index);
   411 	SetDParam(0, st->index);
   412 	AddNewsItem(msg, NM_SMALL, NF_VIEWPORT | NF_TILE, NT_ACCEPTANCE, DNC_NONE, st->xy, 0);
   412 	AddNewsItem(msg, NS_ACCEPTANCE, st->xy, 0);
   413 }
   413 }
   414 
   414 
   415 /**
   415 /**
   416  * Get a list of the cargo types being produced around the tile (in a rectangle).
   416  * Get a list of the cargo types being produced around the tile (in a rectangle).
   417  * @param produced: Destination array of produced cargo
   417  * @param produced: Destination array of produced cargo
   648  */
   648  */
   649 static void DeleteStationIfEmpty(Station *st)
   649 static void DeleteStationIfEmpty(Station *st)
   650 {
   650 {
   651 	if (st->facilities == 0) {
   651 	if (st->facilities == 0) {
   652 		st->delete_ctr = 0;
   652 		st->delete_ctr = 0;
   653 		RebuildStationLists();
   653 		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
   654 		InvalidateWindow(WC_STATION_LIST, st->owner);
       
   655 	}
   654 	}
   656 	/* station remains but it probably lost some parts - station sign should stay in the station boundaries */
   655 	/* station remains but it probably lost some parts - station sign should stay in the station boundaries */
   657 	UpdateStationSignCoord(st);
   656 	UpdateStationSignCoord(st);
   658 }
   657 }
   659 
   658 
  1049 		} while (--numtracks);
  1048 		} while (--numtracks);
  1050 
  1049 
  1051 		st->MarkTilesDirty(false);
  1050 		st->MarkTilesDirty(false);
  1052 		UpdateStationVirtCoordDirty(st);
  1051 		UpdateStationVirtCoordDirty(st);
  1053 		UpdateStationAcceptance(st, false);
  1052 		UpdateStationAcceptance(st, false);
  1054 		RebuildStationLists();
  1053 		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
  1055 		InvalidateWindow(WC_STATION_LIST, st->owner);
       
  1056 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
  1054 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
  1057 	}
  1055 	}
  1058 
  1056 
  1059 	return cost;
  1057 	return cost;
  1060 }
  1058 }
  1408 			MakeRoadStop(tile, st->owner, st->index, rs_type, rts, (DiagDirection)p1);
  1406 			MakeRoadStop(tile, st->owner, st->index, rs_type, rts, (DiagDirection)p1);
  1409 		}
  1407 		}
  1410 
  1408 
  1411 		UpdateStationVirtCoordDirty(st);
  1409 		UpdateStationVirtCoordDirty(st);
  1412 		UpdateStationAcceptance(st, false);
  1410 		UpdateStationAcceptance(st, false);
  1413 		RebuildStationLists();
  1411 		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
  1414 		InvalidateWindow(WC_STATION_LIST, st->owner);
       
  1415 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
  1412 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
  1416 	}
  1413 	}
  1417 	return cost;
  1414 	return cost;
  1418 }
  1415 }
  1419 
  1416 
  1721 			} END_TILE_LOOP(tile_cur, w, h, tile)
  1718 			} END_TILE_LOOP(tile_cur, w, h, tile)
  1722 		}
  1719 		}
  1723 
  1720 
  1724 		UpdateStationVirtCoordDirty(st);
  1721 		UpdateStationVirtCoordDirty(st);
  1725 		UpdateStationAcceptance(st, false);
  1722 		UpdateStationAcceptance(st, false);
  1726 		RebuildStationLists();
  1723 		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
  1727 		InvalidateWindow(WC_STATION_LIST, st->owner);
       
  1728 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
  1724 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
  1729 	}
  1725 	}
  1730 
  1726 
  1731 	return cost;
  1727 	return cost;
  1732 }
  1728 }
  1818 
  1814 
  1819 		MakeBuoy(tile, st->index, GetWaterClass(tile));
  1815 		MakeBuoy(tile, st->index, GetWaterClass(tile));
  1820 
  1816 
  1821 		UpdateStationVirtCoordDirty(st);
  1817 		UpdateStationVirtCoordDirty(st);
  1822 		UpdateStationAcceptance(st, false);
  1818 		UpdateStationAcceptance(st, false);
  1823 		RebuildStationLists();
  1819 		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
  1824 		InvalidateWindow(WC_STATION_LIST, st->owner);
       
  1825 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
  1820 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
  1826 	}
  1821 	}
  1827 
  1822 
  1828 	return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
  1823 	return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
  1829 }
  1824 }
  1977 
  1972 
  1978 		MakeDock(tile, st->owner, st->index, direction, wc);
  1973 		MakeDock(tile, st->owner, st->index, direction, wc);
  1979 
  1974 
  1980 		UpdateStationVirtCoordDirty(st);
  1975 		UpdateStationVirtCoordDirty(st);
  1981 		UpdateStationAcceptance(st, false);
  1976 		UpdateStationAcceptance(st, false);
  1982 		RebuildStationLists();
  1977 		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
  1983 		InvalidateWindow(WC_STATION_LIST, st->owner);
       
  1984 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
  1978 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
  1985 	}
  1979 	}
  1986 
  1980 
  1987 	return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
  1981 	return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
  1988 }
  1982 }
  2635 	if (flags & DC_EXEC) {
  2629 	if (flags & DC_EXEC) {
  2636 		free(st->name);
  2630 		free(st->name);
  2637 		st->name = strdup(_cmd_text);
  2631 		st->name = strdup(_cmd_text);
  2638 
  2632 
  2639 		UpdateStationVirtCoord(st);
  2633 		UpdateStationVirtCoord(st);
  2640 		ResortStationLists();
  2634 		InvalidateWindowData(WC_STATION_LIST, st->owner, 1);
  2641 		MarkWholeScreenDirty();
  2635 		MarkWholeScreenDirty();
  2642 	}
  2636 	}
  2643 
  2637 
  2644 	return CommandCost();
  2638 	return CommandCost();
  2645 }
  2639 }
  2856 	if (new_player != PLAYER_SPECTATOR) {
  2850 	if (new_player != PLAYER_SPECTATOR) {
  2857 		Station *st = GetStationByTile(tile);
  2851 		Station *st = GetStationByTile(tile);
  2858 
  2852 
  2859 		SetTileOwner(tile, new_player);
  2853 		SetTileOwner(tile, new_player);
  2860 		if (!IsBuoy(tile)) st->owner = new_player; // do not set st->owner for buoys
  2854 		if (!IsBuoy(tile)) st->owner = new_player; // do not set st->owner for buoys
  2861 		RebuildStationLists();
  2855 		InvalidateWindowClassesData(WC_STATION_LIST, 0);
  2862 		InvalidateWindowClasses(WC_STATION_LIST);
       
  2863 	} else {
  2856 	} else {
  2864 		if (IsDriveThroughStopTile(tile)) {
  2857 		if (IsDriveThroughStopTile(tile)) {
  2865 			/* Remove the drive-through road stop */
  2858 			/* Remove the drive-through road stop */
  2866 			DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? ROADSTOP_TRUCK : ROADSTOP_BUS, DC_EXEC | DC_BANKRUPT, CMD_REMOVE_ROAD_STOP);
  2859 			DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? ROADSTOP_TRUCK : ROADSTOP_BUS, DC_EXEC | DC_BANKRUPT, CMD_REMOVE_ROAD_STOP);
  2867 			assert(IsTileType(tile, MP_ROAD));
  2860 			assert(IsTileType(tile, MP_ROAD));