src/station_cmd.cpp
changeset 8424 c3477565c975
parent 8413 c7f3384330a3
child 8429 ec2a1005006e
equal deleted inserted replaced
8423:0c0f0370620b 8424:c3477565c975
   796 	} else {
   796 	} else {
   797 		/* do not allow modifying non-uniform stations,
   797 		/* do not allow modifying non-uniform stations,
   798 		 * the uniform-stations code wouldn't handle it well */
   798 		 * the uniform-stations code wouldn't handle it well */
   799 		BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
   799 		BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
   800 			if (!st->TileBelongsToRailStation(t)) { // there may be adjoined station
   800 			if (!st->TileBelongsToRailStation(t)) { // there may be adjoined station
   801 				_error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED;
   801 				_error_message = STR_NONUNIFORM_STATIONS_DISALLOWED;
   802 				return false;
   802 				return false;
   803 			}
   803 			}
   804 		END_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
   804 		END_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
   805 
   805 
   806 		/* check so the orientation is the same */
   806 		/* check so the orientation is the same */
   807 		if (GetRailStationAxis(st->train_tile) != axis) {
   807 		if (GetRailStationAxis(st->train_tile) != axis) {
   808 			_error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED;
   808 			_error_message = STR_NONUNIFORM_STATIONS_DISALLOWED;
   809 			return false;
   809 			return false;
   810 		}
   810 		}
   811 
   811 
   812 		/* check if the new station adjoins the old station in either direction */
   812 		/* check if the new station adjoins the old station in either direction */
   813 		if (curw == w && st->train_tile == tile + TileDiffXY(0, h)) {
   813 		if (curw == w && st->train_tile == tile + TileDiffXY(0, h)) {
   823 		} else if (curh == h && st->train_tile == tile - TileDiffXY(curw, 0)) {
   823 		} else if (curh == h && st->train_tile == tile - TileDiffXY(curw, 0)) {
   824 			/* to the right */
   824 			/* to the right */
   825 			tile -= TileDiffXY(curw, 0);
   825 			tile -= TileDiffXY(curw, 0);
   826 			curw += w;
   826 			curw += w;
   827 		} else {
   827 		} else {
   828 			_error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED;
   828 			_error_message = STR_NONUNIFORM_STATIONS_DISALLOWED;
   829 			return false;
   829 			return false;
   830 		}
   830 		}
   831 	}
   831 	}
   832 	/* make sure the final size is not too big. */
   832 	/* make sure the final size is not too big. */
   833 	if (curw > _patches.station_spread || curh > _patches.station_spread) {
   833 	if (curw > _patches.station_spread || curh > _patches.station_spread) {
  1194 		}
  1194 		}
  1195 
  1195 
  1196 		/* Do not allow removing from stations if non-uniform stations are not enabled
  1196 		/* Do not allow removing from stations if non-uniform stations are not enabled
  1197 		 * The check must be here to give correct error message
  1197 		 * The check must be here to give correct error message
  1198  		 */
  1198  		 */
  1199 		if (!_patches.nonuniform_stations) return_cmd_error(STR_306D_NONUNIFORM_STATIONS_DISALLOWED);
  1199 		if (!_patches.nonuniform_stations) return_cmd_error(STR_NONUNIFORM_STATIONS_DISALLOWED);
  1200 
  1200 
  1201 		/* If we reached here, the tile is valid so increase the quantity of tiles we will remove */
  1201 		/* If we reached here, the tile is valid so increase the quantity of tiles we will remove */
  1202 		quantity++;
  1202 		quantity++;
  1203 
  1203 
  1204 		if (flags & DC_EXEC) {
  1204 		if (flags & DC_EXEC) {
  1391 	if (st == NULL) st = GetClosestStationFromTile(tile);
  1391 	if (st == NULL) st = GetClosestStationFromTile(tile);
  1392 
  1392 
  1393 	/* give us a road stop in the list, and check if something went wrong */
  1393 	/* give us a road stop in the list, and check if something went wrong */
  1394 	RoadStop *road_stop = new RoadStop(tile);
  1394 	RoadStop *road_stop = new RoadStop(tile);
  1395 	if (road_stop == NULL) {
  1395 	if (road_stop == NULL) {
  1396 		return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS);
  1396 		return_cmd_error(type ? STR_TOO_MANY_TRUCK_STOPS : STR_TOO_MANY_BUS_STOPS);
  1397 	}
  1397 	}
  1398 
  1398 
  1399 	/* ensure that in case of error (or no DC_EXEC) the new road stop gets deleted upon return */
  1399 	/* ensure that in case of error (or no DC_EXEC) the new road stop gets deleted upon return */
  1400 	AutoPtrT<RoadStop> rs_auto_delete(road_stop);
  1400 	AutoPtrT<RoadStop> rs_auto_delete(road_stop);
  1401 
  1401 
  1402 	if (st != NULL &&
  1402 	if (st != NULL &&
  1403 			GetNumRoadStopsInStation(st, RoadStop::BUS) + GetNumRoadStopsInStation(st, RoadStop::TRUCK) >= RoadStop::LIMIT) {
  1403 			GetNumRoadStopsInStation(st, RoadStop::BUS) + GetNumRoadStopsInStation(st, RoadStop::TRUCK) >= RoadStop::LIMIT) {
  1404 		return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS);
  1404 		return_cmd_error(type ? STR_TOO_MANY_TRUCK_STOPS : STR_TOO_MANY_BUS_STOPS);
  1405 	}
  1405 	}
  1406 
  1406 
  1407 	/* In case of new station if DC_EXEC is NOT set we still need to create the station
  1407 	/* In case of new station if DC_EXEC is NOT set we still need to create the station
  1408 	 * to test if everything is OK. In this case we need to delete it before return. */
  1408 	 * to test if everything is OK. In this case we need to delete it before return. */
  1409 	AutoPtrT<Station> st_auto_delete;
  1409 	AutoPtrT<Station> st_auto_delete;
  2901 {
  2901 {
  2902 	if (flags & DC_AUTO) {
  2902 	if (flags & DC_AUTO) {
  2903 		switch (GetStationType(tile)) {
  2903 		switch (GetStationType(tile)) {
  2904 			case STATION_RAIL:    return_cmd_error(STR_300B_MUST_DEMOLISH_RAILROAD);
  2904 			case STATION_RAIL:    return_cmd_error(STR_300B_MUST_DEMOLISH_RAILROAD);
  2905 			case STATION_AIRPORT: return_cmd_error(STR_300E_MUST_DEMOLISH_AIRPORT_FIRST);
  2905 			case STATION_AIRPORT: return_cmd_error(STR_300E_MUST_DEMOLISH_AIRPORT_FIRST);
  2906 			case STATION_TRUCK:   return_cmd_error(HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_3047_MUST_DEMOLISH_CARGO_TRAM_STATION : STR_3047_MUST_DEMOLISH_TRUCK_STATION);
  2906 			case STATION_TRUCK:   return_cmd_error(HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_MUST_DEMOLISH_CARGO_TRAM_STATION : STR_3047_MUST_DEMOLISH_TRUCK_STATION);
  2907 			case STATION_BUS:     return_cmd_error(HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_3046_MUST_DEMOLISH_PASSENGER_TRAM_STATION : STR_3046_MUST_DEMOLISH_BUS_STATION);
  2907 			case STATION_BUS:     return_cmd_error(HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_MUST_DEMOLISH_PASSENGER_TRAM_STATION : STR_3046_MUST_DEMOLISH_BUS_STATION);
  2908 			case STATION_BUOY:    return_cmd_error(STR_306A_BUOY_IN_THE_WAY);
  2908 			case STATION_BUOY:    return_cmd_error(STR_306A_BUOY_IN_THE_WAY);
  2909 			case STATION_DOCK:    return_cmd_error(STR_304D_MUST_DEMOLISH_DOCK_FIRST);
  2909 			case STATION_DOCK:    return_cmd_error(STR_304D_MUST_DEMOLISH_DOCK_FIRST);
  2910 			case STATION_OILRIG:
  2910 			case STATION_OILRIG:
  2911 				SetDParam(0, STR_4807_OIL_RIG);
  2911 				SetDParam(0, STR_4807_OIL_RIG);
  2912 				return_cmd_error(STR_4800_IN_THE_WAY);
  2912 				return_cmd_error(STR_4800_IN_THE_WAY);