Skip to content

Commit f36493d

Browse files
committed
fix: little bugs
1 parent a34fa42 commit f36493d

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ets666",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"author": "rsl140 <rsl140@qq.com>",
55
"description": "ETS666 SaveEdit & JobSync Tool",
66
"license": "GPL-3.0-or-later",

src/renderer/lang/en.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default {
3434
fileNotExist: 'File not exist.',
3535
saveNotFound: 'Save file not found.',
3636
decryptFailed: 'Failed to decrypt the file.',
37-
companyNotFound: 'Unable to find the company. Missing DLC(s).',
37+
companyNotFound: 'Unable to find the company. Missing DLC(s) or MOD(s).',
3838
companyNotSupported: 'The company is not allowed to pick up a job.',
3939
writeFileFailed: 'Failed to write the file.',
4040
error: 'Error',

src/renderer/lang/zh-CN.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default {
3434
fileNotExist: '文件不存在',
3535
saveNotFound: '未找到存档',
3636
decryptFailed: '解码失败',
37-
companyNotFound: '无法在存档内找到起点货场!请确认地图DLC或MOD是否齐全。如确认齐全,则请先加载相应的DLC或MOD并存档,再运行本工具。',
37+
companyNotFound: '无法在存档内找到货场!请确认地图DLC或MOD是否齐全。如确认已齐全,则请先加载相应的DLC或MOD并存档,再运行本工具。',
3838
companyNotSupported: '该货场无法接货',
3939
writeFileFailed: '写入失败',
4040
error: '错误',

src/utils/fileEdit.js

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ export function editGameSii (dir, filedirname, info, callback, errorcallback) {
208208
let inGameTime = 0
209209
const economyEventIndex = []
210210
const jobInfoIndex = []
211+
let selectedJobInfoNameless = ''
211212
const gpsNameless = []
212213
const gpsNamelessIndex = []
213214

@@ -255,20 +256,21 @@ export function editGameSii (dir, filedirname, info, callback, errorcallback) {
255256
companyEndIndex = index
256257
} else if (element.startsWith(' game_time: ')) {
257258
inGameTime = Number(element.split(' ')[2])
258-
} else if (element.startsWith('economy_event : ')) {
259+
} else if (element.startsWith(' unit_link: company.volatile.' + jobInfo.departure_company + '.' + jobInfo.departure_city)) {
259260
economyEventIndex.push(index)
260261
} else if (job.moveToCargo && element.startsWith(' truck_placement: ')) {
261262
arrFile[fileIndex] = ' truck_placement: ' + jobInfo.departure_coordinates
262263
} else if (job.moveToCargo && element.startsWith(' trailer_placement: ')) {
263264
arrFile[fileIndex] = ' trailer_placement: (0, 0, 0) (' + jobInfo.departure_coordinates.split('(')[2]
264265
} else if (job.moveToCargo && element.startsWith(' slave_trailer_placements[')) {
265266
arrFile[fileIndex] = ' slave_trailer_placements[' + element.split('[')[1].split(']')[0] + ']: (0, 0, 0) (' + jobInfo.departure_coordinates.split('(')[2]
266-
} else if (job.moveToCargo && element.startsWith(' stored_gps_ahead_waypoints[')) {
267+
} else if (job.moveToCargo && element.startsWith(' stored_gps_behind_waypoints[')) {
267268
gpsNameless.push(element.split(': ')[1])
268269
} else if (job.moveToCargo && element.startsWith('gps_waypoint_storage : ')) {
269270
gpsNamelessIndex.push(index)
270271
} else if (job.syncJob && job.moveToCargo && element.startsWith(' selected_job: ')) {
271-
arrFile[fileIndex] = element.replace(/selected_job: [^,\n]+/, 'selected_job: ets666.nameless.job.info')
272+
selectedJobInfoNameless = element.split(': ')[1]
273+
arrFile[fileIndex] = ' selected_job: ets666.nameless.job.info'
272274
} else if (job.syncJob && job.moveToCargo && element.startsWith('job_info :')) {
273275
jobInfoIndex.push(index)
274276
}
@@ -423,7 +425,7 @@ export function editGameSii (dir, filedirname, info, callback, errorcallback) {
423425
}
424426
}
425427

426-
// change gps position to (0, 0, 0)
428+
// change navigation position to (0, 0, 0)
427429
if (job.moveToCargo && gpsNameless.length > 0) {
428430
gpsNameless.forEach(value => {
429431
gpsNamelessIndex.forEach(index => {
@@ -436,15 +438,11 @@ export function editGameSii (dir, filedirname, info, callback, errorcallback) {
436438

437439
// 做货
438440
if (job.syncJob) {
439-
if (companyIndex === 0) {
441+
if (companyIndex === 0 || companyEndIndex === 0) {
440442
errorcallback && errorcallback(i18n.t('error.companyNotFound'))
441443
return
442444
}
443445

444-
if (companyEndIndex === 0) {
445-
errorcallback && errorcallback(i18n.t('error.companyNotFound'))
446-
return
447-
}
448446
let jobIndex = companyIndex
449447
const companyJobData = addJobOffer(jobInfo, inGameTime)
450448
while (!arrFile[jobIndex].startsWith(' job_offer: ')) {
@@ -465,9 +463,26 @@ export function editGameSii (dir, filedirname, info, callback, errorcallback) {
465463
for (let i = 0; i < companyJobData.length; i++) {
466464
arrFile[jobIndex + 1 + i] = companyJobData[i]
467465
}
468-
if (job.syncJob && job.moveToCargo) {
469-
const jobInfoDate = addJobInfo(jobInfo, inGameTime)
470-
arrFile.splice(arrFile.length - 2, 0, ...jobInfoDate)
466+
467+
economyEventIndex.forEach(index => {
468+
if (arrFile[index + 1].startsWith(' param: 0')) {
469+
arrFile[index - 1] = ' time: ' + (Number(inGameTime) + 6120)
470+
}
471+
})
472+
473+
if (job.moveToCargo) {
474+
const selectedJobInfo = addJobInfo(jobInfo, inGameTime)
475+
if (selectedJobInfoNameless.startsWith('null')) {
476+
arrFile.splice(arrFile.length - 2, 0, ...selectedJobInfo)
477+
} else {
478+
jobInfoIndex.forEach(index => {
479+
if (arrFile[index].startsWith('job_info : ' + selectedJobInfoNameless)) {
480+
for (let i = 1; i < selectedJobInfo.length; i++) {
481+
arrFile[index + i - 1] = selectedJobInfo[i]
482+
}
483+
}
484+
})
485+
}
471486
}
472487
}
473488

@@ -507,8 +522,8 @@ function addJobInfo (jobInfo, inGameTime) {
507522
jobData.push('')
508523
jobData.push('job_info : ets666.nameless.job.info {')
509524
jobData.push(' cargo: cargo.' + jobInfo.cargo)
510-
jobData.push(' source_company: company.volatile.' + jobInfo.departure_company + '.' + jobInfo.departure_city + '"')
511-
jobData.push(' target_company: company.volatile.' + jobInfo.destination_company + '.' + jobInfo.destination_city + '"')
525+
jobData.push(' source_company: company.volatile.' + jobInfo.departure_company + '.' + jobInfo.departure_city)
526+
jobData.push(' target_company: company.volatile.' + jobInfo.destination_company + '.' + jobInfo.destination_city)
512527
const exp = Number(inGameTime) + 6120
513528
jobData.push(' cargo_model_index: ' + exp)
514529
jobData.push(' is_articulated: false')

0 commit comments

Comments
 (0)