@@ -75,6 +75,8 @@ public static class CoreParam
7575 OfficialMatchDurationMilliseconds + GameTimeGuardSlackMilliseconds ;
7676 private const int MaximumSingleLiveTimeJumpMilliseconds = MaximumDisplayGameMilliseconds ;
7777 private static bool hasStableLiveGameTime ;
78+ private const int MaxTeamDisplayNameLength = 18 ;
79+ private static readonly Dictionary < long , string > teamDisplayNames = new Dictionary < long , string > ( ) ;
7880
7981 public static Dictionary < long , MessageOfCharacter > characters = new Dictionary < long , MessageOfCharacter > ( ) ;
8082 public static Dictionary < long , MessageOfTeam > teams = new Dictionary < long , MessageOfTeam > ( ) ;
@@ -181,6 +183,61 @@ public static int ClampDisplayGameMilliseconds(int totalMilliseconds)
181183 return Math . Max ( 0 , Math . Min ( totalMilliseconds , MaximumDisplayGameMilliseconds ) ) ;
182184 }
183185
186+ public static void ClearTeamDisplayNames ( )
187+ {
188+ teamDisplayNames . Clear ( ) ;
189+ }
190+
191+ public static void SetTeamDisplayName ( long teamId , string displayName )
192+ {
193+ if ( teamId <= 0 )
194+ {
195+ return ;
196+ }
197+
198+ string normalized = NormalizeTeamDisplayName ( displayName ) ;
199+ if ( string . IsNullOrEmpty ( normalized ) )
200+ {
201+ teamDisplayNames . Remove ( teamId ) ;
202+ return ;
203+ }
204+
205+ teamDisplayNames [ teamId ] = normalized ;
206+ }
207+
208+ public static string GetTeamDisplayLabel ( long teamId )
209+ {
210+ string fallback = $ "队伍 { teamId } ";
211+ return teamDisplayNames . TryGetValue ( teamId , out string displayName ) && ! string . IsNullOrWhiteSpace ( displayName )
212+ ? $ "{ fallback } :{ displayName } "
213+ : fallback ;
214+ }
215+
216+ private static string NormalizeTeamDisplayName ( string displayName )
217+ {
218+ if ( string . IsNullOrWhiteSpace ( displayName ) )
219+ {
220+ return string . Empty ;
221+ }
222+
223+ string normalized = displayName
224+ . Replace ( '\r ' , ' ' )
225+ . Replace ( '\n ' , ' ' )
226+ . Replace ( '\t ' , ' ' )
227+ . Replace ( '<' , '<' )
228+ . Replace ( '>' , '>' )
229+ . Trim ( ) ;
230+
231+ while ( normalized . IndexOf ( " " , StringComparison . Ordinal ) >= 0 )
232+ {
233+ normalized = normalized . Replace ( " " , " " ) ;
234+ }
235+
236+ return normalized . Length > MaxTeamDisplayNameLength
237+ ? normalized . Substring ( 0 , MaxTeamDisplayNameLength ) + "…"
238+ : normalized ;
239+ }
240+
184241 private static void DestroyAll < TKey > ( Dictionary < TKey , GameObject > objects )
185242 {
186243 foreach ( var kvp in objects )
0 commit comments