• R/O
  • SSH

zandronum-sandbox-stable: Commit


Commit MetaInfo

Revisionf192097d753a2857a8e1bb4151665dffc336d625 (tree)
Time2023-03-08 00:03:03
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Added a way to return a ScoreColumn's internal name (i.e. the name that will be used to define columns in SCORINFO).

Change Summary

Incremental Difference

diff -r 1d49b488e927 -r f192097d753a src/scoreboard.cpp
--- a/src/scoreboard.cpp Sun Mar 05 17:05:15 2023 -0500
+++ b/src/scoreboard.cpp Tue Mar 07 10:03:03 2023 -0500
@@ -156,7 +156,7 @@
156156 static ScoreColumn *scoreboard_ScanForColumn( FScanner &sc, const bool bMustBeDataColumn );
157157
158158 template<typename ColumnType>
159-static bool scoreboard_TryPushingColumnToList( FScanner &sc, TArray<ColumnType *> &ColumnList, ColumnType *pColumn, const char *pszColumnName );
159+static bool scoreboard_TryPushingColumnToList( FScanner &sc, TArray<ColumnType *> &ColumnList, ColumnType *pColumn );
160160
161161 //*****************************************************************************
162162 // CONSOLE VARIABLES
@@ -435,6 +435,7 @@
435435 //*****************************************************************************
436436
437437 ScoreColumn::ScoreColumn( const char *pszName ) :
438+ InternalName( pszName ),
438439 DisplayName( pszName ),
439440 Alignment( COLUMNALIGN_LEFT ),
440441 pCVar( NULL ),
@@ -502,7 +503,7 @@
502503 //
503504 //*****************************************************************************
504505
505-void ScoreColumn::Parse( const FName Name, FScanner &sc )
506+void ScoreColumn::Parse( FScanner &sc )
506507 {
507508 sc.MustGetToken( '{' );
508509
@@ -524,17 +525,17 @@
524525 FString CommandName = sc.String;
525526
526527 sc.MustGetToken( '=' );
527- ParseCommand( Name, sc, Command, CommandName );
528+ ParseCommand( sc, Command, CommandName );
528529 }
529530 }
530531
531532 // [AK] Unless the ALWAYSUSESHORTESTWIDTH flag is enabled, columns must have a non-zero width.
532533 if ((( ulFlags & COLUMNFLAG_ALWAYSUSESHORTESTWIDTH ) == false ) && ( ulSizing == 0 ))
533- sc.ScriptError( "Column '%s' needs a size that's greater than zero.", Name.GetChars( ));
534+ sc.ScriptError( "Column '%s' needs a size that's greater than zero.", GetInternalName( ));
534535
535536 // [AK] If the short name is longer than the display name, throw a fatal error.
536537 if ( DisplayName.Len( ) < ShortName.Len( ))
537- sc.ScriptError( "Column '%s' has a short name that's greater than its display name.", Name.GetChars( ));
538+ sc.ScriptError( "Column '%s' has a short name that's greater than its display name.", GetInternalName( ));
538539 }
539540
540541 //*****************************************************************************
@@ -545,7 +546,7 @@
545546 //
546547 //*****************************************************************************
547548
548-void ScoreColumn::ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName )
549+void ScoreColumn::ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName )
549550 {
550551 switch ( Command )
551552 {
@@ -650,7 +651,7 @@
650651 }
651652
652653 default:
653- sc.ScriptError( "Couldn't process column command '%s' for column '%s'.", CommandName.GetChars( ), Name.GetChars( ));
654+ sc.ScriptError( "Couldn't process column command '%s' for column '%s'.", CommandName.GetChars( ), GetInternalName( ));
654655 }
655656 }
656657
@@ -1421,7 +1422,7 @@
14211422 //
14221423 //*****************************************************************************
14231424
1424-void DataScoreColumn::ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName )
1425+void DataScoreColumn::ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName )
14251426 {
14261427 switch ( Command )
14271428 {
@@ -1495,7 +1496,7 @@
14951496
14961497 // [AK] Parse any generic column commands if we reach here.
14971498 default:
1498- ScoreColumn::ParseCommand( Name, sc, Command, CommandName );
1499+ ScoreColumn::ParseCommand( sc, Command, CommandName );
14991500 break;
15001501 }
15011502
@@ -1504,10 +1505,10 @@
15041505 if ( pCompositeColumn != NULL )
15051506 {
15061507 if (( ulFlags & COLUMNFLAG_DONTSHOWHEADER ) == false )
1507- sc.ScriptError( "Tried to remove the 'DONTSHOWHEADER' flag from column '%s' which is inside a composite column.", Name.GetChars( ));
1508+ sc.ScriptError( "Tried to remove the 'DONTSHOWHEADER' flag from column '%s' which is inside a composite column.", GetInternalName( ));
15081509
15091510 if ( Alignment != COLUMNALIGN_LEFT )
1510- sc.ScriptError( "Tried to change the alignment of column '%s' which is inside a composite column.", Name.GetChars( ));
1511+ sc.ScriptError( "Tried to change the alignment of column '%s' which is inside a composite column.", GetInternalName( ));
15111512 }
15121513 }
15131514
@@ -1819,7 +1820,7 @@
18191820 //
18201821 //*****************************************************************************
18211822
1822-void CustomScoreColumn::ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName )
1823+void CustomScoreColumn::ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName )
18231824 {
18241825 switch ( Command )
18251826 {
@@ -1889,7 +1890,7 @@
18891890
18901891 // [AK] Parse any data column commands if we reach here.
18911892 default:
1892- DataScoreColumn::ParseCommand( Name, sc, Command, CommandName );
1893+ DataScoreColumn::ParseCommand( sc, Command, CommandName );
18931894 break;
18941895 }
18951896 }
@@ -1963,7 +1964,7 @@
19631964 //
19641965 //*****************************************************************************
19651966
1966-void CompositeScoreColumn::ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName )
1967+void CompositeScoreColumn::ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName )
19671968 {
19681969 switch ( Command )
19691970 {
@@ -1978,11 +1979,11 @@
19781979
19791980 // [AK] Don't add a data column that's already inside another composite column.
19801981 if (( pDataColumn->GetCompositeColumn( ) != NULL ) && ( pDataColumn->GetCompositeColumn( ) != this ))
1981- sc.ScriptError( "Tried to put data column '%s' into composite column '%s', but it's already inside another composite column.", sc.String, Name.GetChars( ));
1982+ sc.ScriptError( "Tried to put data column '%s' into composite column '%s', but it's already inside another composite column.", sc.String, GetInternalName( ));
19821983
19831984 // [AK] Don't add a data column that's already inside a scoreboard's column order.
19841985 if ( pDataColumn->GetScoreboard( ) != NULL )
1985- sc.ScriptError( "Tried to put data column '%s' into composite column '%s', but it's already inside a scoreboard's column order.", sc.String, Name.GetChars( ));
1986+ sc.ScriptError( "Tried to put data column '%s' into composite column '%s', but it's already inside a scoreboard's column order.", sc.String, GetInternalName( ));
19861987
19871988 // [AK] All data columns require the DONTSHOWHEADER flag to be enabled to be inside a composite column.
19881989 if (( pDataColumn->GetFlags( ) & COLUMNFLAG_DONTSHOWHEADER ) == false )
@@ -1992,7 +1993,7 @@
19921993 if ( pDataColumn->Alignment != COLUMNALIGN_LEFT )
19931994 sc.ScriptError( "Data column '%s' must be aligned to the left before it can be put inside a composite column.", sc.String );
19941995
1995- if ( scoreboard_TryPushingColumnToList( sc, SubColumns, pDataColumn, sc.String ))
1996+ if ( scoreboard_TryPushingColumnToList( sc, SubColumns, pDataColumn ))
19961997 pDataColumn->pCompositeColumn = this;
19971998 } while ( sc.CheckToken( ',' ));
19981999
@@ -2004,7 +2005,7 @@
20042005
20052006 // [AK] Parse any generic column commands if we reach here.
20062007 default:
2007- ScoreColumn::ParseCommand( Name, sc, Command, CommandName );
2008+ ScoreColumn::ParseCommand( sc, Command, CommandName );
20082009 break;
20092010 }
20102011 }
@@ -2564,10 +2565,7 @@
25642565 {
25652566 // [AK] Note that if we're adding a column to the rank order, then it must be a data column.
25662567 ScoreColumn *pColumn = scoreboard_ScanForColumn( sc, bAddToRankOrder );
2567-
2568- // [AK] The column's name should still be saved in sc.String, even after calling
2569- // the helper function above.
2570- const char *pszColumnName = sc.String;
2568+ const char *pszColumnName = pColumn->GetInternalName( );
25712569
25722570 if ( bAddToRankOrder )
25732571 {
@@ -2588,7 +2586,7 @@
25882586 sc.ScriptError( "Column '%s' is part of a composite column that must be added to the column order before it can be added to the rank order.", pszColumnName );
25892587 }
25902588
2591- scoreboard_TryPushingColumnToList( sc, RankOrder, pDataColumn, pszColumnName );
2589+ scoreboard_TryPushingColumnToList( sc, RankOrder, pDataColumn );
25922590 }
25932591 else
25942592 {
@@ -2597,7 +2595,7 @@
25972595 if (( pColumn->GetTemplate( ) == COLUMNTEMPLATE_DATA ) && ( static_cast<DataScoreColumn *>( pColumn )->GetCompositeColumn( ) != NULL ))
25982596 sc.ScriptError( "Column '%s' is part of a composite column and can't be added to the order list.", pszColumnName );
25992597
2600- if ( scoreboard_TryPushingColumnToList( sc, ColumnOrder, pColumn, pszColumnName ))
2598+ if ( scoreboard_TryPushingColumnToList( sc, ColumnOrder, pColumn ))
26012599 {
26022600 pColumn->pScoreboard = this;
26032601
@@ -4384,7 +4382,7 @@
43844382 //*****************************************************************************
43854383
43864384 template<typename ColumnType>
4387-static bool scoreboard_TryPushingColumnToList( FScanner &sc, TArray<ColumnType *> &ColumnList, ColumnType *pColumn, const char *pszColumnName )
4385+static bool scoreboard_TryPushingColumnToList( FScanner &sc, TArray<ColumnType *> &ColumnList, ColumnType *pColumn )
43884386 {
43894387 // [AK] Make sure the pointer to the column isn't NULL.
43904388 if ( pColumn == NULL )
@@ -4393,12 +4391,10 @@
43934391 // [AK] Make sure that this column isn't already inside this list.
43944392 for ( unsigned int i = 0; i < ColumnList.Size( ); i++ )
43954393 {
4394+ // [AK] Print an error message to let the user know the issue.
43964395 if ( ColumnList[i] == pColumn )
43974396 {
4398- // [AK] Print an error message to let the user know the issue.
4399- if ( pszColumnName != NULL )
4400- sc.ScriptMessage( "Tried to put column '%s' into a list more than once.", pszColumnName );
4401-
4397+ sc.ScriptMessage( "Tried to put column '%s' into a list more than once.", pColumn->GetInternalName( ));
44024398 return false;
44034399 }
44044400 }
diff -r 1d49b488e927 -r f192097d753a src/scoreboard.h
--- a/src/scoreboard.h Sun Mar 05 17:05:15 2023 -0500
+++ b/src/scoreboard.h Tue Mar 07 10:03:03 2023 -0500
@@ -203,6 +203,7 @@
203203 ScoreColumn( const char *pszName );
204204
205205 Scoreboard *GetScoreboard( void ) const { return pScoreboard; }
206+ const char *GetInternalName( void ) const { return InternalName.GetChars( ); }
206207 const char *GetDisplayName( void ) const { return DisplayName.Len( ) > 0 ? DisplayName.GetChars( ) : NULL; }
207208 const char *GetShortName( void ) const { return ShortName.Len( ) > 0 ? ShortName.GetChars( ) : NULL; }
208209 FBaseCVar *GetCVar( void ) const { return pCVar; }
@@ -217,7 +218,7 @@
217218 bool IsHidden( void ) const { return bHidden; }
218219 bool ShouldUseShortName( void ) const { return bUseShortName; }
219220 void SetHidden( bool bEnable );
220- void Parse( const FName Name, FScanner &sc );
221+ void Parse( FScanner &sc );
221222 void DrawHeader( const LONG lYPos, const ULONG ulHeight, const float fAlpha ) const;
222223 void DrawString( const char *pszString, FFont *pFont, const ULONG ulColor, const LONG lYPos, const ULONG ulHeight, const float fAlpha ) const;
223224 void DrawColor( const PalEntry color, const LONG lYPos, const ULONG ulHeight, const float fAlpha, const int clipWidth, const int clipHeight ) const;
@@ -225,7 +226,7 @@
225226
226227 virtual COLUMNTEMPLATE_e GetTemplate( void ) const { return COLUMNTEMPLATE_UNKNOWN; }
227228 virtual bool IsCustomColumn( void ) const { return false; }
228- virtual void ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName );
229+ virtual void ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName );
229230 virtual void CheckIfUsable( void );
230231 virtual void Refresh( void );
231232 virtual void UpdateWidth( void );
@@ -234,6 +235,7 @@
234235 protected:
235236 bool CanDrawForPlayer( const ULONG ulPlayer ) const;
236237
238+ const FName InternalName;
237239 FString DisplayName;
238240 FString ShortName;
239241 COLUMNALIGN_e Alignment;
@@ -291,7 +293,7 @@
291293 virtual COLUMNDATA_e GetDataType( void ) const;
292294 virtual ULONG GetValueWidth( const ColumnValue &Value ) const;
293295 virtual ColumnValue GetValue( const ULONG ulPlayer ) const;
294- virtual void ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName );
296+ virtual void ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName );
295297 virtual void UpdateWidth( void );
296298 virtual void DrawValue( const ULONG ulPlayer, const ULONG ulColor, const LONG lYPos, const ULONG ulHeight, const float fAlpha ) const;
297299
@@ -354,7 +356,7 @@
354356 virtual void SetDataType( COLUMNDATA_e NewDataType );
355357 virtual void SetValue( const ULONG ulPlayer, const ColumnValue &Value );
356358 virtual void SetDefaultValue( const ColumnValue &Value );
357- virtual void ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName );
359+ virtual void ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName );
358360 virtual void ResetToDefault( const ULONG ulPlayer, const bool bChangingLevel );
359361
360362 protected:
@@ -382,7 +384,7 @@
382384 CompositeScoreColumn( const char *pszName ) : ScoreColumn( pszName ) { }
383385
384386 virtual COLUMNTEMPLATE_e GetTemplate( void ) const { return COLUMNTEMPLATE_COMPOSITE; }
385- virtual void ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName );
387+ virtual void ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName );
386388 virtual void CheckIfUsable( void );
387389 virtual void Refresh( void );
388390 virtual void UpdateWidth( void );
Show on old repository browser