@@ -35,24 +35,28 @@ export function applyAbPlayerObjectAssignments(
3535 poolName : string
3636) : ABSessionAssignments {
3737 const newAssignments : ABSessionAssignments = { }
38- const persistAssignment = ( sessionId : string , playerId : AbPlayerId , lookahead : boolean ) : void => {
38+ const persistAssignment = ( session : ABSessionAssignment ) : void => {
3939 // Track the assignment, so that the next onTimelineGenerate can try to reuse the same session
40- if ( newAssignments [ sessionId ] ) {
40+ if ( newAssignments [ session . sessionId ] ) {
4141 // TODO - warn?
4242 }
43- newAssignments [ sessionId ] = { sessionId , playerId , lookahead }
43+ newAssignments [ session . sessionId ] = session
4444 }
4545
4646 // collect objects by their sessionId
47- const groupedObjectsMap = new Map < string , Array < OnGenerateTimelineObjExt > > ( )
47+ const groupedObjectsMap = new Map < string , { name : string ; objs : Array < OnGenerateTimelineObjExt > } > ( )
4848 for ( const obj of timelineObjs ) {
4949 if ( obj . abSessions && obj . pieceInstanceId ) {
5050 for ( const session of obj . abSessions ) {
5151 if ( session . poolName === poolName ) {
5252 const sessionId = abSessionHelper . getTimelineObjectAbSessionId ( obj , session )
53- if ( sessionId ) {
54- const existing = groupedObjectsMap . get ( sessionId )
55- groupedObjectsMap . set ( sessionId , existing ? [ ...existing , obj ] : [ obj ] )
53+ if ( ! sessionId ) continue
54+
55+ const existing = groupedObjectsMap . get ( sessionId )
56+ if ( existing ) {
57+ existing . objs . push ( obj )
58+ } else {
59+ groupedObjectsMap . set ( sessionId , { name : session . sessionName , objs : [ obj ] } )
5660 }
5761 }
5862 }
@@ -63,7 +67,7 @@ export function applyAbPlayerObjectAssignments(
6367 const unexpectedSessions : string [ ] = [ ]
6468
6569 // Apply the known assignments
66- for ( const [ sessionId , objs ] of groupedObjectsMap . entries ( ) ) {
70+ for ( const [ sessionId , info ] of groupedObjectsMap . entries ( ) ) {
6771 if ( sessionId === 'undefined' ) continue
6872
6973 const matchingAssignment = resolvedAssignments . find ( ( req ) => req . id === sessionId )
@@ -76,24 +80,34 @@ export function applyAbPlayerObjectAssignments(
7680 abConfiguration ,
7781 poolName ,
7882 matchingAssignment . playerId ,
79- objs
83+ info . objs
8084 )
8185 )
82- persistAssignment ( sessionId , matchingAssignment . playerId , ! ! matchingAssignment . lookaheadRank )
86+ persistAssignment ( {
87+ sessionId,
88+ sessionName : matchingAssignment . name ,
89+ playerId : matchingAssignment . playerId ,
90+ lookahead : ! ! matchingAssignment . lookaheadRank ,
91+ } )
8392 } else {
8493 // A warning will already have been raised about this having no player
8594 }
8695 } else {
8796 // This is a group that shouldn't exist, so are likely a bug. There isnt a lot we can do beyond warn about the issue
88- unexpectedSessions . push ( `${ sessionId } (${ objs . map ( ( obj ) => obj . id ) . join ( ',' ) } )` )
97+ unexpectedSessions . push ( `${ sessionId } (${ info . objs . map ( ( obj ) => obj . id ) . join ( ',' ) } )` )
8998
9099 // If there was a previous assignment, hopefully that is better than nothing
91100 const prev = previousAssignmentMap ?. [ sessionId ]
92101 if ( prev ) {
93102 failedObjects . push (
94- ...updateObjectsToAbPlayer ( blueprintContext , abConfiguration , poolName , prev . playerId , objs )
103+ ...updateObjectsToAbPlayer ( blueprintContext , abConfiguration , poolName , prev . playerId , info . objs )
95104 )
96- persistAssignment ( sessionId , prev . playerId , false )
105+ persistAssignment ( {
106+ sessionId,
107+ sessionName : '?' ,
108+ playerId : prev . playerId ,
109+ lookahead : false ,
110+ } )
97111 }
98112 }
99113 }
@@ -110,7 +124,7 @@ export function applyAbPlayerObjectAssignments(
110124 for ( const assignment of Object . values < ABSessionAssignment | undefined > ( newAssignments ) ) {
111125 if ( ! assignment ) continue
112126 logger . silly (
113- `ABPlayback: Assigned session "${ poolName } "-"${ assignment . sessionId } " to player "${ assignment . playerId } " (lookahead: ${ assignment . lookahead } )`
127+ `ABPlayback: Assigned session "${ poolName } "-"${ assignment . sessionId } " ( ${ assignment . sessionName } ) to player "${ assignment . playerId } " (lookahead: ${ assignment . lookahead } )`
114128 )
115129 }
116130
0 commit comments