train_cmd.c
branch0.4
changeset 10014 9157e384afb6
parent 10013 b6dc91f0cd71
child 10025 c904d781d751
equal deleted inserted replaced
10013:b6dc91f0cd71 10014:9157e384afb6
   668 }
   668 }
   669 
   669 
   670 /** Build a railroad vehicle.
   670 /** Build a railroad vehicle.
   671  * @param x,y tile coordinates (depot) where rail-vehicle is built
   671  * @param x,y tile coordinates (depot) where rail-vehicle is built
   672  * @param p1 engine type id
   672  * @param p1 engine type id
   673  * @param p2 bit 0 prevents any free cars from being added to the train
   673  * @param p2 bit 0 when set, the train will get number 0, otherwise it will get a free number
       
   674  *           bit 1 prevents any free cars from being added to the train
   674  */
   675  */
   675 int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   676 int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   676 {
   677 {
   677 	const RailVehicleInfo *rvi;
   678 	const RailVehicleInfo *rvi;
   678 	int value;
   679 	int value;
   712 		if (!AllocateVehicles(vl, num_vehicles) || IsOrderPoolFull())
   713 		if (!AllocateVehicles(vl, num_vehicles) || IsOrderPoolFull())
   713 			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
   714 			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
   714 
   715 
   715 		v = vl[0];
   716 		v = vl[0];
   716 
   717 
   717 		unit_num = GetFreeUnitNumber(VEH_Train);
   718 		unit_num = (HASBIT(p2, 0) == true) ? 0 : GetFreeUnitNumber(VEH_Train);
   718 		if (unit_num > _patches.max_trains)
   719 		if (unit_num > _patches.max_trains)
   719 			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
   720 			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
   720 
   721 
   721 		if (flags & DC_EXEC) {
   722 		if (flags & DC_EXEC) {
   722 			uint dir;
   723 			uint dir;
   780 			}
   781 			}
   781 
   782 
   782 			TrainConsistChanged(v);
   783 			TrainConsistChanged(v);
   783 			UpdateTrainAcceleration(v);
   784 			UpdateTrainAcceleration(v);
   784 
   785 
   785 			if (!HASBIT(p2, 0)) {	// check if the cars should be added to the new vehicle
   786 			if (!HASBIT(p2, 1)) {	// check if the cars should be added to the new vehicle
   786 				NormalizeTrainVehInDepot(v);
   787 				NormalizeTrainVehInDepot(v);
   787 			}
   788 			}
   788 
   789 
   789 			InvalidateWindow(WC_VEHICLE_DEPOT, tile);
   790 			InvalidateWindow(WC_VEHICLE_DEPOT, tile);
   790 			RebuildVehicleLists();
   791 			RebuildVehicleLists();