src/ship_cmd.cpp
changeset 7928 63e18de69e50
parent 7815 b821a6aafd09
child 7929 6c9b25842b0f
equal deleted inserted replaced
7927:3a3289a049f9 7928:63e18de69e50
   670 			gp.x = v->x_pos;
   670 			gp.x = v->x_pos;
   671 			gp.y = v->y_pos;
   671 			gp.y = v->y_pos;
   672 		} else {
   672 		} else {
   673 			/* Not inside depot */
   673 			/* Not inside depot */
   674 			r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
   674 			r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
   675 			if (HASBIT(r, VETS_CANNOT_ENTER)) goto reverse_direction;
   675 			if (HasBit(r, VETS_CANNOT_ENTER)) goto reverse_direction;
   676 
   676 
   677 			/* A leave station order only needs one tick to get processed, so we can
   677 			/* A leave station order only needs one tick to get processed, so we can
   678 			 * always skip ahead. */
   678 			 * always skip ahead. */
   679 			if (v->current_order.type == OT_LEAVESTATION) {
   679 			if (v->current_order.type == OT_LEAVESTATION) {
   680 				v->current_order.Free();
   680 				v->current_order.Free();
   740 		gp.x = (gp.x & ~0xF) | b[0];
   740 		gp.x = (gp.x & ~0xF) | b[0];
   741 		gp.y = (gp.y & ~0xF) | b[1];
   741 		gp.y = (gp.y & ~0xF) | b[1];
   742 
   742 
   743 		/* Call the landscape function and tell it that the vehicle entered the tile */
   743 		/* Call the landscape function and tell it that the vehicle entered the tile */
   744 		r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
   744 		r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
   745 		if (HASBIT(r, VETS_CANNOT_ENTER)) goto reverse_direction;
   745 		if (HasBit(r, VETS_CANNOT_ENTER)) goto reverse_direction;
   746 
   746 
   747 		if (!HASBIT(r, VETS_ENTERED_WORMHOLE)) {
   747 		if (!HasBit(r, VETS_ENTERED_WORMHOLE)) {
   748 			v->tile = gp.new_tile;
   748 			v->tile = gp.new_tile;
   749 			v->u.ship.state = TrackToTrackBits(track);
   749 			v->u.ship.state = TrackToTrackBits(track);
   750 		}
   750 		}
   751 
   751 
   752 		v->direction = (Direction)b[2];
   752 		v->direction = (Direction)b[2];
   821 	 * so we must check against cheaters no sooner than now. --pasky */
   821 	 * so we must check against cheaters no sooner than now. --pasky */
   822 	if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR;
   822 	if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR;
   823 	if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
   823 	if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
   824 
   824 
   825 	v = new Ship();
   825 	v = new Ship();
   826 	unit_num = HASBIT(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP);
   826 	unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP);
   827 	AutoPtrT<Vehicle> v_auto_delete = v;
   827 	AutoPtrT<Vehicle> v_auto_delete = v;
   828 
   828 
   829 	if (v == NULL || unit_num > _patches.max_ships)
   829 	if (v == NULL || unit_num > _patches.max_ships)
   830 		return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
   830 		return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
   831 
   831 
  1002 
  1002 
  1003 	if (v->IsInDepot()) return CMD_ERROR;
  1003 	if (v->IsInDepot()) return CMD_ERROR;
  1004 
  1004 
  1005 	/* If the current orders are already goto-depot */
  1005 	/* If the current orders are already goto-depot */
  1006 	if (v->current_order.type == OT_GOTO_DEPOT) {
  1006 	if (v->current_order.type == OT_GOTO_DEPOT) {
  1007 		if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
  1007 		if (!!(p2 & DEPOT_SERVICE) == HasBit(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
  1008 			/* We called with a different DEPOT_SERVICE setting.
  1008 			/* We called with a different DEPOT_SERVICE setting.
  1009 			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
  1009 			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
  1010 			 * Note: the if is (true for requesting service == true for ordered to stop in depot)          */
  1010 			 * Note: the if is (true for requesting service == true for ordered to stop in depot)          */
  1011 			if (flags & DC_EXEC) {
  1011 			if (flags & DC_EXEC) {
  1012 				CLRBIT(v->current_order.flags, OFB_PART_OF_ORDERS);
  1012 				CLRBIT(v->current_order.flags, OFB_PART_OF_ORDERS);
  1018 
  1018 
  1019 		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
  1019 		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
  1020 		if (flags & DC_EXEC) {
  1020 		if (flags & DC_EXEC) {
  1021 			/* If the orders to 'goto depot' are in the orders list (forced servicing),
  1021 			/* If the orders to 'goto depot' are in the orders list (forced servicing),
  1022 			 * then skip to the next order; effectively cancelling this forced service */
  1022 			 * then skip to the next order; effectively cancelling this forced service */
  1023 			if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS))
  1023 			if (HasBit(v->current_order.flags, OFB_PART_OF_ORDERS))
  1024 				v->cur_order_index++;
  1024 				v->cur_order_index++;
  1025 
  1025 
  1026 			v->current_order.type = OT_DUMMY;
  1026 			v->current_order.type = OT_DUMMY;
  1027 			v->current_order.flags = 0;
  1027 			v->current_order.flags = 0;
  1028 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1028 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1082 	if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
  1082 	if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
  1083 
  1083 
  1084 	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
  1084 	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
  1085 
  1085 
  1086 	/* Check the refit capacity callback */
  1086 	/* Check the refit capacity callback */
  1087 	if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
  1087 	if (HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
  1088 		/* Back up the existing cargo type */
  1088 		/* Back up the existing cargo type */
  1089 		CargoID temp_cid = v->cargo_type;
  1089 		CargoID temp_cid = v->cargo_type;
  1090 		byte temp_subtype = v->cargo_subtype;
  1090 		byte temp_subtype = v->cargo_subtype;
  1091 		v->cargo_type = new_cid;
  1091 		v->cargo_type = new_cid;
  1092 		v->cargo_subtype = new_subtype;
  1092 		v->cargo_subtype = new_subtype;