src/train_cmd.cpp
changeset 8300 dfd530665621
parent 8283 bbe075d76da6
child 8302 ed068d41cf1e
equal deleted inserted replaced
8299:e8b5a9aef71a 8300:dfd530665621
  2166 			return true;
  2166 			return true;
  2167 		}
  2167 		}
  2168 
  2168 
  2169 		v->load_unload_time_rem = 0;
  2169 		v->load_unload_time_rem = 0;
  2170 
  2170 
  2171 		if (UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR)) {
  2171 		if (UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner)) {
  2172 			InvalidateWindowClasses(WC_TRAINS_LIST);
  2172 			InvalidateWindowClasses(WC_TRAINS_LIST);
  2173 			return true;
  2173 			return true;
  2174 		}
  2174 		}
  2175 	}
  2175 	}
  2176 
  2176 
  2185 	v->cur_speed = 0;
  2185 	v->cur_speed = 0;
  2186 
  2186 
  2187 	v->UpdateDeltaXY(v->direction);
  2187 	v->UpdateDeltaXY(v->direction);
  2188 	v->cur_image = v->GetImage(v->direction);
  2188 	v->cur_image = v->GetImage(v->direction);
  2189 	VehiclePositionChanged(v);
  2189 	VehiclePositionChanged(v);
  2190 	UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR);
  2190 	UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
  2191 	UpdateTrainAcceleration(v);
  2191 	UpdateTrainAcceleration(v);
  2192 	InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
  2192 	InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
  2193 
  2193 
  2194 	return false;
  2194 	return false;
  2195 }
  2195 }
  2766 static void TrainMovedChangeSignals(TileIndex tile, DiagDirection dir)
  2766 static void TrainMovedChangeSignals(TileIndex tile, DiagDirection dir)
  2767 {
  2767 {
  2768 	if (IsTileType(tile, MP_RAILWAY) &&
  2768 	if (IsTileType(tile, MP_RAILWAY) &&
  2769 			GetRailTileType(tile) == RAIL_TILE_SIGNALS) {
  2769 			GetRailTileType(tile) == RAIL_TILE_SIGNALS) {
  2770 		uint i = FindFirstBit2x64(GetTrackBits(tile) * 0x101 & _reachable_tracks[dir]);
  2770 		uint i = FindFirstBit2x64(GetTrackBits(tile) * 0x101 & _reachable_tracks[dir]);
  2771 		UpdateSignalsOnSegment(tile, _otherside_signal_directions[i]);
  2771 		UpdateSignalsOnSegment(tile, _otherside_signal_directions[i], GetTileOwner(tile));
  2772 	}
  2772 	}
  2773 }
  2773 }
  2774 
  2774 
  2775 
  2775 
  2776 static void SetVehicleCrashed(Vehicle *v)
  2776 static void SetVehicleCrashed(Vehicle *v)
  3139 	EndVehicleMove(v);
  3139 	EndVehicleMove(v);
  3140 
  3140 
  3141 	/* 'v' shouldn't be accessed after it has been deleted */
  3141 	/* 'v' shouldn't be accessed after it has been deleted */
  3142 	TrackBits track = v->u.rail.track;
  3142 	TrackBits track = v->u.rail.track;
  3143 	TileIndex tile = v->tile;
  3143 	TileIndex tile = v->tile;
       
  3144 	Owner owner = v->owner;
  3144 
  3145 
  3145 	delete v;
  3146 	delete v;
       
  3147 	v = NULL; // make sure nobody will won't try to read 'v' anymore
  3146 
  3148 
  3147 	/* Check if the wagon was on a road/rail-crossing and disable it if no
  3149 	/* Check if the wagon was on a road/rail-crossing and disable it if no
  3148 	 * others are on it */
  3150 	 * others are on it */
  3149 	DisableTrainCrossing(tile);
  3151 	DisableTrainCrossing(tile);
  3150 
  3152 
  3151 	/* Update signals */
  3153 	/* Update signals */
  3152 	if (IsTileType(tile, MP_TUNNELBRIDGE) || IsTileDepotType(tile, TRANSPORT_RAIL)) {
  3154 	if (IsTileType(tile, MP_TUNNELBRIDGE) || IsTileDepotType(tile, TRANSPORT_RAIL)) {
  3153 		UpdateSignalsOnSegment(tile, INVALID_DIAGDIR);
  3155 		UpdateSignalsOnSegment(tile, INVALID_DIAGDIR, owner);
  3154 	} else {
  3156 	} else {
  3155 		SetSignalsOnBothDir(tile, (Track)(FIND_FIRST_BIT(track)));
  3157 		SetSignalsOnBothDir(tile, (Track)(FIND_FIRST_BIT(track)), owner);
  3156 	}
  3158 	}
  3157 }
  3159 }
  3158 
  3160 
  3159 static void ChangeTrainDirRandomly(Vehicle *v)
  3161 static void ChangeTrainDirRandomly(Vehicle *v)
  3160 {
  3162 {