train_cmd.c
changeset 3140 5555cc95043a
parent 3139 b17abef09e15
child 3153 e83501906eae
equal deleted inserted replaced
3139:b17abef09e15 3140:5555cc95043a
  3270 }
  3270 }
  3271 
  3271 
  3272 
  3272 
  3273 static const byte _depot_track_ind[4] = {0,1,0,1};
  3273 static const byte _depot_track_ind[4] = {0,1,0,1};
  3274 
  3274 
  3275 // Validation for the news item "Train is waiting in depot"
       
  3276 static bool ValidateTrainInDepot( uint data_a, uint data_b )
       
  3277 {
       
  3278 	Vehicle *v = GetVehicle(data_a);
       
  3279 	return  (v->u.rail.track == 0x80 && (v->vehstatus | VS_STOPPED));
       
  3280 }
       
  3281 
  3275 
  3282 void TrainEnterDepot(Vehicle *v, TileIndex tile)
  3276 void TrainEnterDepot(Vehicle *v, TileIndex tile)
  3283 {
  3277 {
  3284 	SetSignalsOnBothDir(tile, _depot_track_ind[GB(_m[tile].m5, 0, 2)]);
  3278 	SetSignalsOnBothDir(tile, _depot_track_ind[GB(_m[tile].m5, 0, 2)]);
  3285 
  3279 
  3308 			v->cur_order_index++;
  3302 			v->cur_order_index++;
  3309 		} else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) { // User initiated?
  3303 		} else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) { // User initiated?
  3310 			v->vehstatus |= VS_STOPPED;
  3304 			v->vehstatus |= VS_STOPPED;
  3311 			if (v->owner == _local_player) {
  3305 			if (v->owner == _local_player) {
  3312 				SetDParam(0, v->unitnumber);
  3306 				SetDParam(0, v->unitnumber);
  3313 				AddValidatedNewsItem(
  3307 				AddNewsItem(
  3314 					STR_8814_TRAIN_IS_WAITING_IN_DEPOT,
  3308 					STR_8814_TRAIN_IS_WAITING_IN_DEPOT,
  3315 					NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
  3309 					NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
  3316 					v->index,
  3310 					v->index,
  3317 					0,
  3311 					0
  3318 					ValidateTrainInDepot);
  3312 				);
  3319 			}
  3313 			}
  3320 		}
  3314 		}
  3321 	}
  3315 	}
  3322 	InvalidateWindowClasses(WC_TRAINS_LIST);
  3316 	InvalidateWindowClasses(WC_TRAINS_LIST);
  3323 }
  3317 }
  3401 				NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
  3395 				NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
  3402 				v->index,
  3396 				v->index,
  3403 				0);
  3397 				0);
  3404 		}
  3398 		}
  3405 
  3399 
  3406 		CheckOrders(v->index, OC_INIT);
  3400 		CheckOrders(v);
  3407 
  3401 
  3408 		/* update destination */
  3402 		/* update destination */
  3409 		if (v->current_order.type == OT_GOTO_STATION &&
  3403 		if (v->current_order.type == OT_GOTO_STATION &&
  3410 				(tile = GetStation(v->current_order.station)->train_tile) != 0) {
  3404 				(tile = GetStation(v->current_order.station)->train_tile) != 0) {
  3411 			v->dest_tile = tile;
  3405 			v->dest_tile = tile;