equal
deleted
inserted
replaced
824 void ShipsYearlyLoop() |
824 void ShipsYearlyLoop() |
825 { |
825 { |
826 Vehicle *v; |
826 Vehicle *v; |
827 |
827 |
828 FOR_ALL_VEHICLES(v) { |
828 FOR_ALL_VEHICLES(v) { |
829 if (v->type == VEH_Ship) { |
829 if (v->type == VEH_SHIP) { |
830 v->profit_last_year = v->profit_this_year; |
830 v->profit_last_year = v->profit_this_year; |
831 v->profit_this_year = 0; |
831 v->profit_this_year = 0; |
832 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
832 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
833 } |
833 } |
834 } |
834 } |
844 int32 value; |
844 int32 value; |
845 Vehicle *v; |
845 Vehicle *v; |
846 UnitID unit_num; |
846 UnitID unit_num; |
847 Engine *e; |
847 Engine *e; |
848 |
848 |
849 if (!IsEngineBuildable(p1, VEH_Ship, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE); |
849 if (!IsEngineBuildable(p1, VEH_SHIP, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE); |
850 |
850 |
851 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
851 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
852 |
852 |
853 value = EstimateShipCost(p1); |
853 value = EstimateShipCost(p1); |
854 if (flags & DC_QUERY_COST) return value; |
854 if (flags & DC_QUERY_COST) return value; |
857 * so we must check against cheaters no sooner than now. --pasky */ |
857 * so we must check against cheaters no sooner than now. --pasky */ |
858 if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR; |
858 if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR; |
859 if (!IsTileOwner(tile, _current_player)) return CMD_ERROR; |
859 if (!IsTileOwner(tile, _current_player)) return CMD_ERROR; |
860 |
860 |
861 v = AllocateVehicle(); |
861 v = AllocateVehicle(); |
862 unit_num = HASBIT(p2, 0) ? 0 : GetFreeUnitNumber(VEH_Ship); |
862 unit_num = HASBIT(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP); |
863 |
863 |
864 if (v == NULL || unit_num > _patches.max_ships) |
864 if (v == NULL || unit_num > _patches.max_ships) |
865 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
865 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
866 |
866 |
867 if (flags & DC_EXEC) { |
867 if (flags & DC_EXEC) { |
908 |
908 |
909 v->service_interval = _patches.servint_ships; |
909 v->service_interval = _patches.servint_ships; |
910 v->date_of_last_service = _date; |
910 v->date_of_last_service = _date; |
911 v->build_year = _cur_year; |
911 v->build_year = _cur_year; |
912 v->cur_image = 0x0E5E; |
912 v->cur_image = 0x0E5E; |
913 v->type = VEH_Ship; |
913 v->type = VEH_SHIP; |
914 v->random_bits = VehicleRandomBits(); |
914 v->random_bits = VehicleRandomBits(); |
915 |
915 |
916 v->vehicle_flags = 0; |
916 v->vehicle_flags = 0; |
917 if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE); |
917 if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE); |
918 |
918 |
920 |
920 |
921 InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); |
921 InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); |
922 RebuildVehicleLists(); |
922 RebuildVehicleLists(); |
923 InvalidateWindow(WC_COMPANY, v->owner); |
923 InvalidateWindow(WC_COMPANY, v->owner); |
924 if (IsLocalPlayer()) |
924 if (IsLocalPlayer()) |
925 InvalidateAutoreplaceWindow(VEH_Ship); // updates the replace Ship window |
925 InvalidateAutoreplaceWindow(VEH_SHIP); // updates the replace Ship window |
926 |
926 |
927 GetPlayer(_current_player)->num_engines[p1]++; |
927 GetPlayer(_current_player)->num_engines[p1]++; |
928 } |
928 } |
929 |
929 |
930 return value; |
930 return value; |
941 |
941 |
942 if (!IsValidVehicleID(p1)) return CMD_ERROR; |
942 if (!IsValidVehicleID(p1)) return CMD_ERROR; |
943 |
943 |
944 v = GetVehicle(p1); |
944 v = GetVehicle(p1); |
945 |
945 |
946 if (v->type != VEH_Ship || !CheckOwnership(v->owner)) return CMD_ERROR; |
946 if (v->type != VEH_SHIP || !CheckOwnership(v->owner)) return CMD_ERROR; |
947 |
947 |
948 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
948 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
949 |
949 |
950 if (!IsShipInDepotStopped(v)) { |
950 if (!IsShipInDepotStopped(v)) { |
951 return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN); |
951 return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN); |
975 |
975 |
976 if (!IsValidVehicleID(p1)) return CMD_ERROR; |
976 if (!IsValidVehicleID(p1)) return CMD_ERROR; |
977 |
977 |
978 v = GetVehicle(p1); |
978 v = GetVehicle(p1); |
979 |
979 |
980 if (v->type != VEH_Ship || !CheckOwnership(v->owner)) return CMD_ERROR; |
980 if (v->type != VEH_SHIP || !CheckOwnership(v->owner)) return CMD_ERROR; |
981 |
981 |
982 /* Check if this ship can be started/stopped. The callback will fail or |
982 /* Check if this ship can be started/stopped. The callback will fail or |
983 * return 0xFF if it can. */ |
983 * return 0xFF if it can. */ |
984 callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v); |
984 callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v); |
985 if (callback != CALLBACK_FAILED && callback != 0xFF) { |
985 if (callback != CALLBACK_FAILED && callback != 0xFF) { |
1014 const Depot *dep; |
1014 const Depot *dep; |
1015 |
1015 |
1016 if (p2 & DEPOT_MASS_SEND) { |
1016 if (p2 & DEPOT_MASS_SEND) { |
1017 /* Mass goto depot requested */ |
1017 /* Mass goto depot requested */ |
1018 if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR; |
1018 if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR; |
1019 return SendAllVehiclesToDepot(VEH_Ship, flags, p2 & DEPOT_SERVICE, _current_player, (p2 & VLW_MASK), p1); |
1019 return SendAllVehiclesToDepot(VEH_SHIP, flags, p2 & DEPOT_SERVICE, _current_player, (p2 & VLW_MASK), p1); |
1020 } |
1020 } |
1021 |
1021 |
1022 if (!IsValidVehicleID(p1)) return CMD_ERROR; |
1022 if (!IsValidVehicleID(p1)) return CMD_ERROR; |
1023 |
1023 |
1024 v = GetVehicle(p1); |
1024 v = GetVehicle(p1); |
1025 |
1025 |
1026 if (v->type != VEH_Ship || !CheckOwnership(v->owner)) return CMD_ERROR; |
1026 if (v->type != VEH_SHIP || !CheckOwnership(v->owner)) return CMD_ERROR; |
1027 |
1027 |
1028 if (v->vehstatus & VS_CRASHED) return CMD_ERROR; |
1028 if (v->vehstatus & VS_CRASHED) return CMD_ERROR; |
1029 |
1029 |
1030 if (IsShipInDepot(v)) return CMD_ERROR; |
1030 if (IsShipInDepot(v)) return CMD_ERROR; |
1031 |
1031 |
1090 |
1090 |
1091 if (!IsValidVehicleID(p1)) return CMD_ERROR; |
1091 if (!IsValidVehicleID(p1)) return CMD_ERROR; |
1092 |
1092 |
1093 v = GetVehicle(p1); |
1093 v = GetVehicle(p1); |
1094 |
1094 |
1095 if (v->type != VEH_Ship || !CheckOwnership(v->owner)) return CMD_ERROR; |
1095 if (v->type != VEH_SHIP || !CheckOwnership(v->owner)) return CMD_ERROR; |
1096 |
1096 |
1097 if (!IsShipInDepotStopped(v)) { |
1097 if (!IsShipInDepotStopped(v)) { |
1098 return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN); |
1098 return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN); |
1099 } |
1099 } |
1100 |
1100 |