@@ -35,24 +35,28 @@ export function applyAbPlayerObjectAssignments(
35
35
poolName : string
36
36
) : ABSessionAssignments {
37
37
const newAssignments : ABSessionAssignments = { }
38
- const persistAssignment = ( sessionId : string , playerId : AbPlayerId , lookahead : boolean ) : void => {
38
+ const persistAssignment = ( session : ABSessionAssignment ) : void => {
39
39
// Track the assignment, so that the next onTimelineGenerate can try to reuse the same session
40
- if ( newAssignments [ sessionId ] ) {
40
+ if ( newAssignments [ session . sessionId ] ) {
41
41
// TODO - warn?
42
42
}
43
- newAssignments [ sessionId ] = { sessionId , playerId , lookahead }
43
+ newAssignments [ session . sessionId ] = session
44
44
}
45
45
46
46
// collect objects by their sessionId
47
- const groupedObjectsMap = new Map < string , Array < OnGenerateTimelineObjExt > > ( )
47
+ const groupedObjectsMap = new Map < string , { name : string ; objs : Array < OnGenerateTimelineObjExt > } > ( )
48
48
for ( const obj of timelineObjs ) {
49
49
if ( obj . abSessions && obj . pieceInstanceId ) {
50
50
for ( const session of obj . abSessions ) {
51
51
if ( session . poolName === poolName ) {
52
52
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 ] } )
56
60
}
57
61
}
58
62
}
@@ -63,7 +67,7 @@ export function applyAbPlayerObjectAssignments(
63
67
const unexpectedSessions : string [ ] = [ ]
64
68
65
69
// Apply the known assignments
66
- for ( const [ sessionId , objs ] of groupedObjectsMap . entries ( ) ) {
70
+ for ( const [ sessionId , info ] of groupedObjectsMap . entries ( ) ) {
67
71
if ( sessionId === 'undefined' ) continue
68
72
69
73
const matchingAssignment = resolvedAssignments . find ( ( req ) => req . id === sessionId )
@@ -76,24 +80,34 @@ export function applyAbPlayerObjectAssignments(
76
80
abConfiguration ,
77
81
poolName ,
78
82
matchingAssignment . playerId ,
79
- objs
83
+ info . objs
80
84
)
81
85
)
82
- persistAssignment ( sessionId , matchingAssignment . playerId , ! ! matchingAssignment . lookaheadRank )
86
+ persistAssignment ( {
87
+ sessionId,
88
+ sessionName : matchingAssignment . name ,
89
+ playerId : matchingAssignment . playerId ,
90
+ lookahead : ! ! matchingAssignment . lookaheadRank ,
91
+ } )
83
92
} else {
84
93
// A warning will already have been raised about this having no player
85
94
}
86
95
} else {
87
96
// 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 ( ',' ) } )` )
89
98
90
99
// If there was a previous assignment, hopefully that is better than nothing
91
100
const prev = previousAssignmentMap ?. [ sessionId ]
92
101
if ( prev ) {
93
102
failedObjects . push (
94
- ...updateObjectsToAbPlayer ( blueprintContext , abConfiguration , poolName , prev . playerId , objs )
103
+ ...updateObjectsToAbPlayer ( blueprintContext , abConfiguration , poolName , prev . playerId , info . objs )
95
104
)
96
- persistAssignment ( sessionId , prev . playerId , false )
105
+ persistAssignment ( {
106
+ sessionId,
107
+ sessionName : '?' ,
108
+ playerId : prev . playerId ,
109
+ lookahead : false ,
110
+ } )
97
111
}
98
112
}
99
113
}
@@ -110,7 +124,7 @@ export function applyAbPlayerObjectAssignments(
110
124
for ( const assignment of Object . values < ABSessionAssignment | undefined > ( newAssignments ) ) {
111
125
if ( ! assignment ) continue
112
126
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 } )`
114
128
)
115
129
}
116
130
0 commit comments