equal
deleted
inserted
replaced
104 return _ship_sprites[spritenum] + direction; |
104 return _ship_sprites[spritenum] + direction; |
105 } |
105 } |
106 |
106 |
107 static const Depot* FindClosestShipDepot(const Vehicle* v) |
107 static const Depot* FindClosestShipDepot(const Vehicle* v) |
108 { |
108 { |
109 if (_patches.pathfinder_for_ships == VPF_NPF) { /* NPF is used */ |
109 if (_settings.pf.pathfinder_for_ships == VPF_NPF) { /* NPF is used */ |
110 Trackdir trackdir = GetVehicleTrackdir(v); |
110 Trackdir trackdir = GetVehicleTrackdir(v); |
111 NPFFoundTargetData ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES); |
111 NPFFoundTargetData ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES); |
112 |
112 |
113 if (ftd.best_bird_dist == 0) return GetDepotByTile(ftd.node.tile); /* Found target */ |
113 if (ftd.best_bird_dist == 0) return GetDepotByTile(ftd.node.tile); /* Found target */ |
114 |
114 |
135 return best_depot; |
135 return best_depot; |
136 } |
136 } |
137 |
137 |
138 static void CheckIfShipNeedsService(Vehicle *v) |
138 static void CheckIfShipNeedsService(Vehicle *v) |
139 { |
139 { |
140 if (_patches.servint_ships == 0 || !v->NeedsAutomaticServicing()) return; |
140 if (_settings.vehicle.servint_ships == 0 || !v->NeedsAutomaticServicing()) return; |
141 if (v->IsInDepot()) { |
141 if (v->IsInDepot()) { |
142 VehicleServiceInDepot(v); |
142 VehicleServiceInDepot(v); |
143 return; |
143 return; |
144 } |
144 } |
145 |
145 |
194 |
194 |
195 InvalidateWindow(WC_VEHICLE_VIEW, v->index); |
195 InvalidateWindow(WC_VEHICLE_VIEW, v->index); |
196 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
196 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
197 |
197 |
198 if (!PlayVehicleSound(v, VSE_BREAKDOWN)) { |
198 if (!PlayVehicleSound(v, VSE_BREAKDOWN)) { |
199 SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ? |
199 SndPlayVehicleFx((_settings.game_creation.landscape != LT_TOYLAND) ? |
200 SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v); |
200 SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v); |
201 } |
201 } |
202 |
202 |
203 if (!(v->vehstatus & VS_HIDDEN)) { |
203 if (!(v->vehstatus & VS_HIDDEN)) { |
204 Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE); |
204 Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE); |
318 spd = min(v->cur_speed + 1, GetVehicleProperty(v, 0x0B, v->max_speed)); |
318 spd = min(v->cur_speed + 1, GetVehicleProperty(v, 0x0B, v->max_speed)); |
319 |
319 |
320 /*updates statusbar only if speed have changed to save CPU time */ |
320 /*updates statusbar only if speed have changed to save CPU time */ |
321 if (spd != v->cur_speed) { |
321 if (spd != v->cur_speed) { |
322 v->cur_speed = spd; |
322 v->cur_speed = spd; |
323 if (_patches.vehicle_speed) |
323 if (_settings.gui.vehicle_speed) |
324 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
324 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
325 } |
325 } |
326 |
326 |
327 /* Decrease somewhat when turning */ |
327 /* Decrease somewhat when turning */ |
328 if (!(v->direction & 1)) spd = spd * 3 / 4; |
328 if (!(v->direction & 1)) spd = spd * 3 / 4; |
457 * direction in which we are entering the tile */ |
457 * direction in which we are entering the tile */ |
458 static Track ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) |
458 static Track ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) |
459 { |
459 { |
460 assert(IsValidDiagDirection(enterdir)); |
460 assert(IsValidDiagDirection(enterdir)); |
461 |
461 |
462 switch (_patches.pathfinder_for_ships) { |
462 switch (_settings.pf.pathfinder_for_ships) { |
463 case VPF_YAPF: { /* YAPF */ |
463 case VPF_YAPF: { /* YAPF */ |
464 Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks); |
464 Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks); |
465 if (trackdir != INVALID_TRACKDIR) return TrackdirToTrack(trackdir); |
465 if (trackdir != INVALID_TRACKDIR) return TrackdirToTrack(trackdir); |
466 } break; |
466 } break; |
467 |
467 |
754 if (!IsShipDepotTile(tile)) return CMD_ERROR; |
754 if (!IsShipDepotTile(tile)) return CMD_ERROR; |
755 if (!IsTileOwner(tile, _current_player)) return CMD_ERROR; |
755 if (!IsTileOwner(tile, _current_player)) return CMD_ERROR; |
756 |
756 |
757 unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP); |
757 unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP); |
758 |
758 |
759 if (!Vehicle::AllocateList(NULL, 1) || unit_num > _patches.max_ships) |
759 if (!Vehicle::AllocateList(NULL, 1) || unit_num > _settings.vehicle.max_ships) |
760 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
760 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
761 |
761 |
762 if (flags & DC_EXEC) { |
762 if (flags & DC_EXEC) { |
763 int x; |
763 int x; |
764 int y; |
764 int y; |
798 _new_vehicle_id = v->index; |
798 _new_vehicle_id = v->index; |
799 |
799 |
800 v->name = NULL; |
800 v->name = NULL; |
801 v->u.ship.state = TRACK_BIT_DEPOT; |
801 v->u.ship.state = TRACK_BIT_DEPOT; |
802 |
802 |
803 v->service_interval = _patches.servint_ships; |
803 v->service_interval = _settings.vehicle.servint_ships; |
804 v->date_of_last_service = _date; |
804 v->date_of_last_service = _date; |
805 v->build_year = _cur_year; |
805 v->build_year = _cur_year; |
806 v->cur_image = 0x0E5E; |
806 v->cur_image = 0x0E5E; |
807 v->random_bits = VehicleRandomBits(); |
807 v->random_bits = VehicleRandomBits(); |
808 |
808 |
812 v->cargo_cap = GetVehicleProperty(v, 0x0D, svi->capacity); |
812 v->cargo_cap = GetVehicleProperty(v, 0x0D, svi->capacity); |
813 |
813 |
814 VehiclePositionChanged(v); |
814 VehiclePositionChanged(v); |
815 |
815 |
816 InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); |
816 InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); |
817 RebuildVehicleLists(); |
817 InvalidateWindowClassesData(WC_SHIPS_LIST, 0); |
818 InvalidateWindow(WC_COMPANY, v->owner); |
818 InvalidateWindow(WC_COMPANY, v->owner); |
819 if (IsLocalPlayer()) |
819 if (IsLocalPlayer()) |
820 InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window |
820 InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window |
821 |
821 |
822 GetPlayer(_current_player)->num_engines[p1]++; |
822 GetPlayer(_current_player)->num_engines[p1]++; |
849 |
849 |
850 CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value); |
850 CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value); |
851 |
851 |
852 if (flags & DC_EXEC) { |
852 if (flags & DC_EXEC) { |
853 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
853 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
854 RebuildVehicleLists(); |
854 InvalidateWindowClassesData(WC_SHIPS_LIST, 0); |
855 InvalidateWindow(WC_COMPANY, v->owner); |
855 InvalidateWindow(WC_COMPANY, v->owner); |
856 DeleteWindowById(WC_VEHICLE_VIEW, v->index); |
856 DeleteWindowById(WC_VEHICLE_VIEW, v->index); |
857 DeleteDepotHighlightOfVehicle(v); |
857 DeleteDepotHighlightOfVehicle(v); |
858 delete v; |
858 delete v; |
859 } |
859 } |
995 v->cargo.Truncate((v->cargo_type == new_cid) ? capacity : 0); |
995 v->cargo.Truncate((v->cargo_type == new_cid) ? capacity : 0); |
996 v->cargo_type = new_cid; |
996 v->cargo_type = new_cid; |
997 v->cargo_subtype = new_subtype; |
997 v->cargo_subtype = new_subtype; |
998 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
998 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
999 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
999 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
1000 RebuildVehicleLists(); |
1000 InvalidateWindowClassesData(WC_SHIPS_LIST, 0); |
1001 } |
1001 } |
1002 |
1002 |
1003 return cost; |
1003 return cost; |
1004 |
1004 |
1005 } |
1005 } |