src/ship_cmd.cpp
changeset 7439 0c0e2945c890
parent 7384 cf8880d026f8
child 7446 1c4d469f986e
equal deleted inserted replaced
7438:45e90ff7c97a 7439:0c0e2945c890
   173 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   173 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   174 }
   174 }
   175 
   175 
   176 void OnNewDay_Ship(Vehicle *v)
   176 void OnNewDay_Ship(Vehicle *v)
   177 {
   177 {
   178 	int32 cost;
   178 	CommandCost cost;
   179 
   179 
   180 	if ((++v->day_counter & 7) == 0)
   180 	if ((++v->day_counter & 7) == 0)
   181 		DecreaseVehicleValue(v);
   181 		DecreaseVehicleValue(v);
   182 
   182 
   183 	CheckVehicleBreakdown(v);
   183 	CheckVehicleBreakdown(v);
   401 	v->progress = (t = v->progress) - (byte)spd;
   401 	v->progress = (t = v->progress) - (byte)spd;
   402 
   402 
   403 	return (t < v->progress);
   403 	return (t < v->progress);
   404 }
   404 }
   405 
   405 
   406 static int32 EstimateShipCost(EngineID engine_type)
   406 static CommandCost EstimateShipCost(EngineID engine_type)
   407 {
   407 {
   408 	return GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->base_cost) * (_price.ship_base>>3)>>5;
   408 	return GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->base_cost) * (_price.ship_base >> 3) >> 5;
   409 }
   409 }
   410 
   410 
   411 static void ShipArrivesAt(const Vehicle* v, Station* st)
   411 static void ShipArrivesAt(const Vehicle* v, Station* st)
   412 {
   412 {
   413 	/* Check if station was ever visited before */
   413 	/* Check if station was ever visited before */
   807  * @param tile tile of depot where ship is built
   807  * @param tile tile of depot where ship is built
   808  * @param flags type of operation
   808  * @param flags type of operation
   809  * @param p1 ship type being built (engine)
   809  * @param p1 ship type being built (engine)
   810  * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
   810  * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
   811  */
   811  */
   812 int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   812 CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   813 {
   813 {
   814 	int32 value;
   814 	CommandCost value;
   815 	Vehicle *v;
   815 	Vehicle *v;
   816 	UnitID unit_num;
   816 	UnitID unit_num;
   817 	Engine *e;
   817 	Engine *e;
   818 
   818 
   819 	if (!IsEngineBuildable(p1, VEH_SHIP, _current_player)) return_cmd_error(STR_SHIP_NOT_AVAILABLE);
   819 	if (!IsEngineBuildable(p1, VEH_SHIP, _current_player)) return_cmd_error(STR_SHIP_NOT_AVAILABLE);
   902  * @param tile unused
   902  * @param tile unused
   903  * @param flags type of operation
   903  * @param flags type of operation
   904  * @param p1 vehicle ID to be sold
   904  * @param p1 vehicle ID to be sold
   905  * @param p2 unused
   905  * @param p2 unused
   906  */
   906  */
   907 int32 CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   907 CommandCost CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   908 {
   908 {
   909 	Vehicle *v;
   909 	Vehicle *v;
   910 
   910 
   911 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
   911 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
   912 
   912 
   936  * @param tile unused
   936  * @param tile unused
   937  * @param flags type of operation
   937  * @param flags type of operation
   938  * @param p1 ship ID to start/stop
   938  * @param p1 ship ID to start/stop
   939  * @param p2 unused
   939  * @param p2 unused
   940  */
   940  */
   941 int32 CmdStartStopShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   941 CommandCost CmdStartStopShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   942 {
   942 {
   943 	Vehicle *v;
   943 	Vehicle *v;
   944 	uint16 callback;
   944 	uint16 callback;
   945 
   945 
   946 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
   946 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
   977  * @param p1 vehicle ID to send to the depot
   977  * @param p1 vehicle ID to send to the depot
   978  * @param p2 various bitmasked elements
   978  * @param p2 various bitmasked elements
   979  * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
   979  * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
   980  * - p2 bit 8-10 - VLW flag (for mass goto depot)
   980  * - p2 bit 8-10 - VLW flag (for mass goto depot)
   981  */
   981  */
   982 int32 CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   982 CommandCost CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   983 {
   983 {
   984 	Vehicle *v;
   984 	Vehicle *v;
   985 	const Depot *dep;
   985 	const Depot *dep;
   986 
   986 
   987 	if (p2 & DEPOT_MASS_SEND) {
   987 	if (p2 & DEPOT_MASS_SEND) {
  1054  * - p2 = (bit 0-7) - the new cargo type to refit to (p2 & 0xFF)
  1054  * - p2 = (bit 0-7) - the new cargo type to refit to (p2 & 0xFF)
  1055  * - p2 = (bit 8-15) - the new cargo subtype to refit to
  1055  * - p2 = (bit 8-15) - the new cargo subtype to refit to
  1056  * - p2 = (bit 16) - refit only this vehicle (ignored)
  1056  * - p2 = (bit 16) - refit only this vehicle (ignored)
  1057  * @return cost of refit or error
  1057  * @return cost of refit or error
  1058  */
  1058  */
  1059 int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
  1059 CommandCost CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
  1060 {
  1060 {
  1061 	Vehicle *v;
  1061 	Vehicle *v;
  1062 	int32 cost;
  1062 	CommandCost cost;
  1063 	CargoID new_cid = GB(p2, 0, 8); //gets the cargo number
  1063 	CargoID new_cid = GB(p2, 0, 8); //gets the cargo number
  1064 	byte new_subtype = GB(p2, 8, 8);
  1064 	byte new_subtype = GB(p2, 8, 8);
  1065 	uint16 capacity = CALLBACK_FAILED;
  1065 	uint16 capacity = CALLBACK_FAILED;
  1066 
  1066 
  1067 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
  1067 	if (!IsValidVehicleID(p1)) return CMD_ERROR;