@@ -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 ( / s e l e c t e d _ j o b : [ ^ , \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