src/roadveh_cmd.cpp
changeset 9921 4dfac3c48507
parent 9775 22e256c3bf46
child 9923 3056bf623139
equal deleted inserted replaced
9920:21ce1e2f0e43 9921:4dfac3c48507
   287 
   287 
   288 		GetPlayer(_current_player)->num_engines[p1]++;
   288 		GetPlayer(_current_player)->num_engines[p1]++;
   289 	}
   289 	}
   290 
   290 
   291 	return cost;
   291 	return cost;
   292 }
       
   293 
       
   294 /** Start/Stop a road vehicle.
       
   295  * @param tile unused
       
   296  * @param flags operation to perform
       
   297  * @param p1 road vehicle ID to start/stop
       
   298  * @param p2 unused
       
   299  */
       
   300 CommandCost CmdStartStopRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
       
   301 {
       
   302 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
       
   303 
       
   304 	Vehicle *v = GetVehicle(p1);
       
   305 
       
   306 	if (v->type != VEH_ROAD || !CheckOwnership(v->owner)) return CMD_ERROR;
       
   307 
       
   308 	/* Check if this road veh can be started/stopped. The callback will fail or
       
   309 	 * return 0xFF if it can. */
       
   310 	uint16 callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v);
       
   311 	if (callback != CALLBACK_FAILED && GB(callback, 0, 8) != 0xFF) {
       
   312 		StringID error = GetGRFStringID(GetEngineGRFID(v->engine_type), 0xD000 + callback);
       
   313 		return_cmd_error(error);
       
   314 	}
       
   315 
       
   316 	if (flags & DC_EXEC) {
       
   317 		if (v->IsStoppedInDepot()) {
       
   318 			DeleteVehicleNews(p1, STR_9016_ROAD_VEHICLE_IS_WAITING);
       
   319 		}
       
   320 
       
   321 		v->vehstatus ^= VS_STOPPED;
       
   322 		v->cur_speed = 0;
       
   323 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
       
   324 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
       
   325 	}
       
   326 
       
   327 	return CommandCost();
       
   328 }
   292 }
   329 
   293 
   330 void ClearSlot(Vehicle *v)
   294 void ClearSlot(Vehicle *v)
   331 {
   295 {
   332 	RoadStop *rs = v->u.road.slot;
   296 	RoadStop *rs = v->u.road.slot;