station_cmd.c
changeset 2427 b7a0ad02af26
parent 2425 99e1e8430a28
child 2436 177cb6a8339f
equal deleted inserted replaced
2426:3362e577adb1 2427:b7a0ad02af26
  2884 	return moved;
  2884 	return moved;
  2885 }
  2885 }
  2886 
  2886 
  2887 void BuildOilRig(TileIndex tile)
  2887 void BuildOilRig(TileIndex tile)
  2888 {
  2888 {
  2889 	Station *st;
       
  2890 	int j;
  2889 	int j;
  2891 
  2890 	Station *st = AllocateStation();
  2892 	FOR_ALL_STATIONS(st) {
  2891 
  2893 		if (st->xy == 0) {
  2892 	if (st == NULL) {
  2894 			st->town = ClosestTownFromTile(tile, (uint)-1);
  2893 		DEBUG(misc, 0) ("Couldn't allocate station for oilrig at %#X, reverting to oilrig only...", tile);
  2895 			st->sign.width_1 = 0;
  2894 		return;
  2896 			if (!GenerateStationName(st, tile, 2))
  2895 	}
  2897 				return;
  2896 	if (!GenerateStationName(st, tile, 2)) {
  2898 
  2897 		DEBUG(misc, 0) ("Couldn't allocate station-name for oilrig at %#X, reverting to oilrig only...", tile);
  2899 			SetTileType(tile, MP_STATION);
  2898 		return;
  2900 			_m[tile].m5 = 0x4B;
  2899 	}
  2901 			SetTileOwner(tile, OWNER_NONE);
  2900 
  2902 			_m[tile].m3 = 0;
  2901 	st->town = ClosestTownFromTile(tile, (uint)-1);
  2903 			_m[tile].m4 = 0;
  2902 	st->sign.width_1 = 0;
  2904 			_m[tile].m2 = st->index;
  2903 
  2905 
  2904 	SetTileType(tile, MP_STATION);
  2906 			st->owner = OWNER_NONE;
  2905 	_m[tile].m5 = 0x4B;
  2907       st->airport_flags = 0;
  2906 	SetTileOwner(tile, OWNER_NONE);
  2908 			st->airport_type = AT_OILRIG;
  2907 	_m[tile].m3 = 0;
  2909 			st->xy = tile;
  2908 	_m[tile].m4 = 0;
  2910 			st->bus_stops = NULL;
  2909 	_m[tile].m2 = st->index;
  2911 			st->truck_stops = NULL;
  2910 
  2912 			st->airport_tile = tile;
  2911 	st->owner = OWNER_NONE;
  2913 			st->dock_tile = tile;
  2912 	st->airport_flags = 0;
  2914 			st->train_tile = 0;
  2913 	st->airport_type = AT_OILRIG;
  2915 			st->had_vehicle_of_type = 0;
  2914 	st->xy = tile;
  2916 			st->time_since_load = 255;
  2915 	st->bus_stops = NULL;
  2917 			st->time_since_unload = 255;
  2916 	st->truck_stops = NULL;
  2918 			st->delete_ctr = 0;
  2917 	st->airport_tile = tile;
  2919 			st->last_vehicle = INVALID_VEHICLE;
  2918 	st->dock_tile = tile;
  2920 			st->facilities = FACIL_AIRPORT | FACIL_DOCK;
  2919 	st->train_tile = 0;
  2921 			st->build_date = _date;
  2920 	st->had_vehicle_of_type = 0;
  2922 			for(j=0; j!=NUM_CARGO; j++) {
  2921 	st->time_since_load = 255;
  2923 				st->goods[j].waiting_acceptance = 0;
  2922 	st->time_since_unload = 255;
  2924 				st->goods[j].days_since_pickup = 0;
  2923 	st->delete_ctr = 0;
  2925 				st->goods[j].enroute_from = INVALID_STATION;
  2924 	st->last_vehicle = INVALID_VEHICLE;
  2926 				st->goods[j].rating = 175;
  2925 	st->facilities = FACIL_AIRPORT | FACIL_DOCK;
  2927 				st->goods[j].last_speed = 0;
  2926 	st->build_date = _date;
  2928 				st->goods[j].last_age = 255;
  2927 
  2929 			}
  2928 	for (j = 0; j != NUM_CARGO; j++) {
  2930 
  2929 		st->goods[j].waiting_acceptance = 0;
  2931 			UpdateStationVirtCoordDirty(st);
  2930 		st->goods[j].days_since_pickup = 0;
  2932 			UpdateStationAcceptance(st, false);
  2931 		st->goods[j].enroute_from = INVALID_STATION;
  2933 			return;
  2932 		st->goods[j].rating = 175;
  2934 		}
  2933 		st->goods[j].last_speed = 0;
  2935 	}
  2934 		st->goods[j].last_age = 255;
       
  2935 	}
       
  2936 
       
  2937 	UpdateStationVirtCoordDirty(st);
       
  2938 	UpdateStationAcceptance(st, false);
  2936 }
  2939 }
  2937 
  2940 
  2938 void DeleteOilRig(TileIndex tile)
  2941 void DeleteOilRig(TileIndex tile)
  2939 {
  2942 {
  2940 	Station *st = GetStation(_m[tile].m2);
  2943 	Station *st = GetStation(_m[tile].m2);