chore(generator): removed additional cargo for intermodals; added new vehicle api types

This commit is contained in:
2026-04-04 21:03:33 +02:00
parent 97ce0febec
commit a37c9916b5
7 changed files with 78 additions and 108 deletions
@@ -110,7 +110,7 @@ import { isTractionUnit } from '../../../utils/vehicleUtils';
import stockMixin from '../../../mixins/stockMixin'; import stockMixin from '../../../mixins/stockMixin';
import { useStockListUtils } from '../../../utils/stockListUtils'; import { useStockListUtils } from '../../../utils/stockListUtils';
import { getCurrentStockFileName, getStockStringOutput } from '../../../composables/file'; import { getCurrentStockFileName } from '../../../composables/file';
import { import {
Bookmark, Bookmark,
@@ -166,7 +166,7 @@ export default defineComponent({
methods: { methods: {
copyToClipboard() { copyToClipboard() {
navigator.clipboard.writeText(getStockStringOutput()); navigator.clipboard.writeText(this.store.stockString);
setTimeout(() => { setTimeout(() => {
alert(this.$t('stocklist.alert-copied')); alert(this.$t('stocklist.alert-copied'));
@@ -224,7 +224,7 @@ export default defineComponent({
if (!fileName) return; if (!fileName) return;
const blob = new Blob([getStockStringOutput()]); const blob = new Blob([this.store.stockString]);
const file = fileName + '.con'; const file = fileName + '.con';
var e = document.createEvent('MouseEvents'), var e = document.createEvent('MouseEvents'),
+1
View File
@@ -25,6 +25,7 @@ export function getCurrentStockFileName() {
return fileName; return fileName;
} }
// UNUSED - PARSES ADDITIONAL CARGO FOR INTERMODALS
export function getStockStringOutput() { export function getStockStringOutput() {
const store = useStore(); const store = useStore();
+8 -5
View File
@@ -4,11 +4,14 @@
"food": ["412Z:tc_20_loaded", "627Z:tc_20_loaded"], "food": ["412Z:tc_20_loaded", "627Z:tc_20_loaded"],
"food-empty": ["412Z:tc_20_empty", "627Z:tc_20_empty"], "food-empty": ["412Z:tc_20_empty", "627Z:tc_20_empty"],
"intermodal": [ "intermodal": [
"627Z:627Z_mix1_sctc_loaded", "627Z:sc_20",
"627Z:627Z_mix2_sctc_loaded", "627Z:sc_40",
"627Z:627Z_mix3_sctc_loaded", "627Z:tc_20_empty",
"412Z:412Z_mix1_sctc_loaded", "627Z:tc_20_loaded",
"412Z:412Z_mix1_sctc_empty" "412Z:sc_20",
"412Z:sc_40",
"412Z:tc_20_empty",
"412Z:tc_20_loaded"
], ],
"biomass": ["412Z:wt_20_biomass", "627Z:wt_20_biomass"], "biomass": ["412Z:wt_20_biomass", "627Z:wt_20_biomass"],
"biomass-empty": [ "biomass-empty": [
+13 -12
View File
@@ -1,7 +1,7 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { useStore } from '../store'; import { useStore } from '../store';
import { ICarWagon, ILocomotive, IStock, ICargo, IVehicle } from '../types/common.types'; import { ICarWagon, ILocomotive, IStock, ICargo, IVehicle } from '../types/common.types';
import { additionalCargoTypes, isTractionUnit } from '../utils/vehicleUtils'; import { isTractionUnit } from '../utils/vehicleUtils';
export default defineComponent({ export default defineComponent({
setup() { setup() {
@@ -75,21 +75,22 @@ export default defineComponent({
this.store.isDoubleManned = spawnProps.includes('d'); this.store.isDoubleManned = spawnProps.includes('d');
} }
} else { } else {
const [carType, ...cargo] = type.split(':'); const [carType, cargo] = type.split(':');
vehicle = this.store.carDataList.find((car) => car.type == carType) || null; vehicle = this.store.carDataList.find((car) => car.type == carType) || null;
if (vehicle && cargo.length > 0) { if (cargo) {
if (/412Z|627Z/.test(vehicle.constructionType)) { vehicleCargo = vehicle?.cargoTypes.find((c) => c.id == cargo) || null;
const additionalCargo = additionalCargoTypes.find(
(c) => c.groupType == vehicle!.constructionType && c.cargoStringVariations.includes(cargo.join(':'))
);
if (additionalCargo) { // UNUSED - ADDITIONAL INTERMODAL CARGO TEST
cargo[0] = additionalCargo.id; // if (/412Z|627Z/.test(vehicle.constructionType)) {
} // const additionalCargo = additionalCargoTypes.find(
} // (c) => c.groupType == vehicle!.constructionType && c.cargoStringVariations.includes(cargo.join(':'))
// );
vehicleCargo = vehicle?.cargoTypes.find((c) => c.id == cargo[0]) || null; // if (additionalCargo) {
// cargo[0] = additionalCargo.id;
// }
// }
} }
} }
+5 -3
View File
@@ -14,7 +14,6 @@ import {
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { import {
acceptableWeight, acceptableWeight,
additionalCargoTypes,
carDataList, carDataList,
getCargoWarnings, getCargoWarnings,
isTractionUnit, isTractionUnit,
@@ -29,6 +28,7 @@ import {
import realCompositionsJSON from './data/realCompositions.json'; import realCompositionsJSON from './data/realCompositions.json';
import { HttpClient } from './http'; import { HttpClient } from './http';
import { API } from './types/api.types';
const baseURL = import.meta.env.VITE_API_DEV === '1' && import.meta.env.DEV ? 'http://localhost:3001' : 'https://stacjownik.spythere.eu'; const baseURL = import.meta.env.VITE_API_DEV === '1' && import.meta.env.DEV ? 'http://localhost:3001' : 'https://stacjownik.spythere.eu';
@@ -129,8 +129,10 @@ export const useStore = defineStore('store', {
actions: { actions: {
async fetchVehiclesAPI() { async fetchVehiclesAPI() {
try { try {
const vehiclesData = await this.httpClient.get<IVehiclesAPIResponse>('api/getVehicles'); const response = await this.httpClient.get<API.VehiclesData.Response>('api/getVehiclesData');
this.vehiclesData = vehiclesData; // this.vehiclesData = response.;
console.log(response);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
+38 -76
View File
@@ -1,87 +1,49 @@
// API namespace // API namespace
export namespace API { export namespace API {
export interface ActiveData { export namespace VehiclesData {
trains: Train[]; export interface VehicleObject {
activeSceneries: ActiveScenery[]; id: number;
} name: string;
type: string;
cabinName: string | null;
restrictions: Record<string, any> | null;
vehicleGroupsId: number;
} }
export interface ActiveScenery { export interface VehicleGroupObject {
dispatcherId: number; id: number;
dispatcherName: string; name: string;
dispatcherIsSupporter: boolean;
stationName: string;
stationHash: string;
region: string;
maxUsers: number;
currentUsers: number;
spawn: number;
lastSeen: number;
dispatcherExp: number;
nameFromHeader: string;
spawnString?: string;
networkConnectionString: string;
isOnline: number;
dispatcherRate: number;
dispatcherStatus: number;
}
export interface Train {
id: string;
trainNo: number;
mass: number;
speed: number; speed: number;
speedLoaded?: number;
speedLoco?: number;
length: number; length: number;
distance: number; weight: number;
stockString: string; cargoTypes: VehicleCargo[] | null;
driverName: string;
driverId: number; locoProps: {
driverIsSupporter: boolean; coldStart: boolean;
driverLevel: number; doubleManned: boolean;
currentStationHash: string; } | null;
currentStationName: string;
signal: string; massSpeeds: VehicleGroupMassSpeeds | null;
connectedTrack: string;
online: number;
lastSeen: number;
region: string;
isTimeout: boolean;
timetable?: Timetable;
} }
export interface Timetable { export interface VehicleGroupMassSpeeds {
SKR: boolean; passenger: Record<string, number> | null;
TWR: boolean; cargo: Record<string, number> | null;
hasDangerousCargo: boolean; none: number | null;
hasExtraDeliveries: boolean;
warningNotes: string;
category: string;
stopList: TimetableStop[];
route: string;
timetableId: number;
sceneries: string[];
path: string;
} }
export interface TimetableStop { export interface VehicleCargo {
stopName: string; id: string;
stopNameRAW: string; weight: number;
stopType: string; }
stopDistance: number;
pointId: string; export interface Data {
comments?: (null | string)[]; vehicles: VehicleObject[];
mainStop: boolean; vehicleGroups: VehicleGroupObject[];
arrivalLine?: string; }
arrivalTimestamp: number;
arrivalRealTimestamp: number; export type Response = Data;
arrivalDelay: number; }
departureLine?: string;
departureTimestamp: number;
departureRealTimestamp: number;
departureDelay: number;
beginsHere: boolean;
terminatesHere: boolean;
confirmed: number;
stopped: number;
stopTime?: number;
} }
+3 -2
View File
@@ -1,6 +1,7 @@
import { ICarWagon, ILocomotive, IStock, IVehicleData, LocoGroupType, WagonGroupType } from '../types/common.types'; import { ICarWagon, ILocomotive, IStock, IVehicleData, LocoGroupType, WagonGroupType } from '../types/common.types';
import { MassLimitLocoType, calculateMassLimit, calculateSpeedLimit } from './vehicleLimitsUtils'; import { MassLimitLocoType, calculateMassLimit, calculateSpeedLimit } from './vehicleLimitsUtils';
// UNUSED - ADDITIONAL CARGO TYPES FOR INTERMODALS
export const additionalCargoTypes = [ export const additionalCargoTypes = [
{ {
groupType: '627Z', groupType: '627Z',
@@ -41,12 +42,12 @@ export const additionalCargoTypes = [
groupType: '412Z', groupType: '412Z',
id: '412Z_mix1_sctc_loaded', id: '412Z_mix1_sctc_loaded',
weight: 43500, weight: 43500,
cargoStringVariations: ['sc_20:tc_20_loaded', 'tc_20_loaded:sc_20'], cargoStringVariations: ['sc_20:tc_20_loaded:tc_20_loaded'],
}, },
{ {
groupType: '412Z', groupType: '412Z',
id: '412Z_mix1_sctc_empty', id: '412Z_mix1_sctc_empty',
weight: 33970, weight: 37735,
cargoStringVariations: ['sc_20:tc_20_empty:sc_20'], cargoStringVariations: ['sc_20:tc_20_empty:sc_20'],
}, },
]; ];