src/train_cmd.cpp
changeset 8705 cd752f8e86fd
parent 8704 d0a22c1b20d7
child 8706 95102fcf66b4
equal deleted inserted replaced
8704:d0a22c1b20d7 8705:cd752f8e86fd
   289 	v->u.rail.cached_tilt = train_can_tilt;
   289 	v->u.rail.cached_tilt = train_can_tilt;
   290 
   290 
   291 	/* recalculate cached weights and power too (we do this *after* the rest, so it is known which wagons are powered and need extra weight added) */
   291 	/* recalculate cached weights and power too (we do this *after* the rest, so it is known which wagons are powered and need extra weight added) */
   292 	TrainCargoChanged(v);
   292 	TrainCargoChanged(v);
   293 
   293 
   294 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
   294 	if (IsFrontEngine(v)) InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
   295 }
   295 }
   296 
   296 
   297 enum AccelType {
   297 enum AccelType {
   298 	AM_ACCEL,
   298 	AM_ACCEL,
   299 	AM_BRAKE
   299 	AM_BRAKE
  1246 			NormaliseTrainConsist(src_head);
  1246 			NormaliseTrainConsist(src_head);
  1247 			TrainConsistChanged(src_head);
  1247 			TrainConsistChanged(src_head);
  1248 			UpdateTrainGroupID(src_head);
  1248 			UpdateTrainGroupID(src_head);
  1249 			if (IsFrontEngine(src_head)) {
  1249 			if (IsFrontEngine(src_head)) {
  1250 				UpdateTrainAcceleration(src_head);
  1250 				UpdateTrainAcceleration(src_head);
  1251 				InvalidateWindow(WC_VEHICLE_DETAILS, src_head->index);
       
  1252 				/* Update the refit button and window */
  1251 				/* Update the refit button and window */
  1253 				InvalidateWindow(WC_VEHICLE_REFIT, src_head->index);
  1252 				InvalidateWindow(WC_VEHICLE_REFIT, src_head->index);
  1254 				InvalidateWindowWidget(WC_VEHICLE_VIEW, src_head->index, VVW_WIDGET_REFIT_VEH);
  1253 				InvalidateWindowWidget(WC_VEHICLE_VIEW, src_head->index, VVW_WIDGET_REFIT_VEH);
  1255 			}
  1254 			}
  1256 			/* Update the depot window */
  1255 			/* Update the depot window */
  1261 			NormaliseTrainConsist(dst_head);
  1260 			NormaliseTrainConsist(dst_head);
  1262 			TrainConsistChanged(dst_head);
  1261 			TrainConsistChanged(dst_head);
  1263 			UpdateTrainGroupID(dst_head);
  1262 			UpdateTrainGroupID(dst_head);
  1264 			if (IsFrontEngine(dst_head)) {
  1263 			if (IsFrontEngine(dst_head)) {
  1265 				UpdateTrainAcceleration(dst_head);
  1264 				UpdateTrainAcceleration(dst_head);
  1266 				InvalidateWindow(WC_VEHICLE_DETAILS, dst_head->index);
       
  1267 				/* Update the refit button and window */
  1265 				/* Update the refit button and window */
  1268 				InvalidateWindowWidget(WC_VEHICLE_VIEW, dst_head->index, VVW_WIDGET_REFIT_VEH);
  1266 				InvalidateWindowWidget(WC_VEHICLE_VIEW, dst_head->index, VVW_WIDGET_REFIT_VEH);
  1269 				InvalidateWindow(WC_VEHICLE_REFIT, dst_head->index);
  1267 				InvalidateWindow(WC_VEHICLE_REFIT, dst_head->index);
  1270 			}
  1268 			}
  1271 			/* Update the depot window */
  1269 			/* Update the depot window */
  1435 				if (first != NULL) {
  1433 				if (first != NULL) {
  1436 					NormaliseTrainConsist(first);
  1434 					NormaliseTrainConsist(first);
  1437 					TrainConsistChanged(first);
  1435 					TrainConsistChanged(first);
  1438 					UpdateTrainGroupID(first);
  1436 					UpdateTrainGroupID(first);
  1439 					if (IsFrontEngine(first)) {
  1437 					if (IsFrontEngine(first)) {
  1440 						InvalidateWindow(WC_VEHICLE_DETAILS, first->index);
       
  1441 						InvalidateWindow(WC_VEHICLE_REFIT, first->index);
  1438 						InvalidateWindow(WC_VEHICLE_REFIT, first->index);
  1442 						UpdateTrainAcceleration(first);
  1439 						UpdateTrainAcceleration(first);
  1443 					}
  1440 					}
  1444 				}
  1441 				}
  1445 
  1442 
  1505 			if (flags & DC_EXEC && first != NULL) {
  1502 			if (flags & DC_EXEC && first != NULL) {
  1506 				NormaliseTrainConsist(first);
  1503 				NormaliseTrainConsist(first);
  1507 				TrainConsistChanged(first);
  1504 				TrainConsistChanged(first);
  1508 				UpdateTrainGroupID(first);
  1505 				UpdateTrainGroupID(first);
  1509 				if (IsFrontEngine(first)) UpdateTrainAcceleration(first);
  1506 				if (IsFrontEngine(first)) UpdateTrainAcceleration(first);
  1510 				InvalidateWindow(WC_VEHICLE_DETAILS, first->index);
       
  1511 				InvalidateWindow(WC_VEHICLE_REFIT, first->index);
  1507 				InvalidateWindow(WC_VEHICLE_REFIT, first->index);
  1512 			}
  1508 			}
  1513 		} break;
  1509 		} break;
  1514 	}
  1510 	}
  1515 	return cost;
  1511 	return cost;
  3228 		DeleteWindowById(WC_VEHICLE_VIEW, v->index);
  3224 		DeleteWindowById(WC_VEHICLE_VIEW, v->index);
  3229 		InvalidateWindow(WC_COMPANY, v->owner);
  3225 		InvalidateWindow(WC_COMPANY, v->owner);
  3230 	} else {
  3226 	} else {
  3231 		/* Recalculate cached train properties */
  3227 		/* Recalculate cached train properties */
  3232 		TrainConsistChanged(first);
  3228 		TrainConsistChanged(first);
  3233 		InvalidateWindow(WC_VEHICLE_DETAILS, first->index);
       
  3234 		/* Update the depot window if the first vehicle is in depot -
  3229 		/* Update the depot window if the first vehicle is in depot -
  3235 		 * if v == first, then it is updated in PreDestructor() */
  3230 		 * if v == first, then it is updated in PreDestructor() */
  3236 		if (first->u.rail.track == TRACK_BIT_DEPOT) {
  3231 		if (first->u.rail.track == TRACK_BIT_DEPOT) {
  3237 			InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
  3232 			InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
  3238 		}
  3233 		}