station_cmd.c
changeset 1786 7cfd46c3fcc4
parent 1784 d0698aac0c2e
child 1820 d03c56850dc2
equal deleted inserted replaced
1785:d3f3496b5943 1786:7cfd46c3fcc4
  1696 
  1696 
  1697 	w = _airport_size_x[p1];
  1697 	w = _airport_size_x[p1];
  1698 	h = _airport_size_y[p1];
  1698 	h = _airport_size_y[p1];
  1699 
  1699 
  1700 	cost = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
  1700 	cost = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
  1701 	if (cost == CMD_ERROR) return CMD_ERROR;
  1701 	if (CmdFailed(cost)) return CMD_ERROR;
  1702 
  1702 
  1703 	st = GetStationAround(tile, w, h, -1);
  1703 	st = GetStationAround(tile, w, h, -1);
  1704 	if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
  1704 	if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
  1705 
  1705 
  1706 	/* Find a station close to us */
  1706 	/* Find a station close to us */
  2641 	st->goods[type].enroute_time = 0;
  2641 	st->goods[type].enroute_time = 0;
  2642 	st->goods[type].enroute_from = st->index;
  2642 	st->goods[type].enroute_from = st->index;
  2643 	InvalidateWindow(WC_STATION_VIEW, st->index);
  2643 	InvalidateWindow(WC_STATION_VIEW, st->index);
  2644 }
  2644 }
  2645 
  2645 
       
  2646 /** Rename a station
       
  2647  * @param x,y unused
       
  2648  * @param p1 station ID that is to be renamed
       
  2649  * @param p2 unused
       
  2650  */
  2646 int32 CmdRenameStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
  2651 int32 CmdRenameStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
  2647 {
  2652 {
  2648 	StringID str,old_str;
  2653 	StringID str,old_str;
  2649 	Station *st;
  2654 	Station *st;
  2650 
  2655 
  2652 	st = GetStation(p1);
  2657 	st = GetStation(p1);
  2653 
  2658 
  2654 	if (!IsValidStation(st) || !CheckOwnership(st->owner)) return CMD_ERROR;
  2659 	if (!IsValidStation(st) || !CheckOwnership(st->owner)) return CMD_ERROR;
  2655 
  2660 
  2656 	str = AllocateNameUnique((const char*)_decode_parameters, 6);
  2661 	str = AllocateNameUnique((const char*)_decode_parameters, 6);
  2657 	if (str == 0)
  2662 	if (str == 0) return CMD_ERROR;
  2658 		return CMD_ERROR;
       
  2659 
  2663 
  2660 	if (flags & DC_EXEC) {
  2664 	if (flags & DC_EXEC) {
  2661 		old_str = st->string_id;
  2665 		old_str = st->string_id;
  2662 		st->string_id = str;
  2666 		st->string_id = str;
  2663 		UpdateStationVirtCoord(st);
  2667 		UpdateStationVirtCoord(st);