• R/O
  • SSH

zandronum-sandbox-stable: Commit


Commit MetaInfo

Revisioncf76db80aab6376cb855ed88fc14f443c88e7bfc (tree)
Time2023-03-23 05:31:25
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Added code that initializes the scoreboard and parses all loaded SCORINFO lumps.

Change Summary

Incremental Difference

diff -r 53cb82a6576b -r cf76db80aab6 src/d_main.cpp
--- a/src/d_main.cpp Fri Mar 24 23:24:47 2023 -0400
+++ b/src/d_main.cpp Wed Mar 22 16:31:25 2023 -0400
@@ -3075,6 +3075,9 @@
30753075 SBarInfo::Load();
30763076 HUD_InitHud();
30773077
3078+ // [AK] Parse any SCORINFO lumps.
3079+ SCOREBOARD_Construct( );
3080+
30783081 // [RH] User-configurable startup strings. Because BOOM does.
30793082 static const char *startupString[5] = {
30803083 "STARTUP1", "STARTUP2", "STARTUP3", "STARTUP4", "STARTUP5"
diff -r 53cb82a6576b -r cf76db80aab6 src/scoreboard.cpp
--- a/src/scoreboard.cpp Fri Mar 24 23:24:47 2023 -0400
+++ b/src/scoreboard.cpp Wed Mar 22 16:31:25 2023 -0400
@@ -3187,6 +3187,125 @@
31873187
31883188 //*****************************************************************************
31893189 //
3190+// [AK] SCOREBOARD_Construct
3191+//
3192+// Initializes the scoreboard and parses all loaded SCORINFO lumps.
3193+//
3194+//*****************************************************************************
3195+
3196+void SCOREBOARD_Construct( void )
3197+{
3198+ if ( Wads.CheckNumForName( "SCORINFO" ) != -1 )
3199+ {
3200+ int currentLump, lastLump = 0;
3201+
3202+ Printf( "ParseScorInfo: Loading scoreboard definition.\n" );
3203+
3204+ while (( currentLump = Wads.FindLump( "SCORINFO", &lastLump )) != -1 )
3205+ {
3206+ FScanner sc( currentLump );
3207+
3208+ while ( sc.GetString( ))
3209+ {
3210+ if ( stricmp( sc.String, "scoreboard" ) == 0 )
3211+ {
3212+ g_Scoreboard.Parse( sc );
3213+ }
3214+ else if (( stricmp( sc.String, "column" ) == 0 ) || ( stricmp( sc.String, "compositecolumn" ) == 0 ))
3215+ {
3216+ const bool bIsCompositeBlock = ( stricmp( sc.String, "compositecolumn" ) == 0 );
3217+ FString ColumnTypeString = "COLUMNTYPE_";
3218+
3219+ sc.MustGetToken( TK_StringConst );
3220+
3221+ if ( sc.StringLen == 0 )
3222+ sc.ScriptError( "Got an empty string for a column name." );
3223+
3224+ FName ColumnName = sc.String;
3225+ ColumnTypeString += ColumnName.GetChars( );
3226+ ColumnTypeString.ToUpper( );
3227+
3228+ // [AK] If the column doesn't exist yet, then we must create a new one.
3229+ ScoreColumn *pColumn = SCOREBOARD_GetColumn( ColumnName, false );
3230+ const bool bMustCreateNewColumn = ( pColumn == NULL );
3231+
3232+ COLUMNTYPE_e ColumnType = static_cast<COLUMNTYPE_e>( GetValueCOLUMNTYPE_e( ColumnTypeString.GetChars( )));
3233+
3234+ if ( bIsCompositeBlock )
3235+ {
3236+ if ( bMustCreateNewColumn )
3237+ {
3238+ // [AK] Don't allow native types (e.g. "frags") to be used as names for composite columns.
3239+ if ( ColumnType != -1 )
3240+ sc.ScriptError( "You can't use '%s' as a name for a composite column.", ColumnName.GetChars( ));
3241+
3242+ pColumn = new CompositeScoreColumn( ColumnName );
3243+ }
3244+
3245+ if ( pColumn->GetTemplate( ) != COLUMNTEMPLATE_COMPOSITE )
3246+ sc.ScriptError( "Column '%s' isn't a composite column.", ColumnName.GetChars( ));
3247+ }
3248+ else
3249+ {
3250+ if ( bMustCreateNewColumn )
3251+ {
3252+ // [AK] Don't allow data columns to have an "unknown" name.
3253+ if ( ColumnType == COLUMNTYPE_UNKNOWN )
3254+ sc.ScriptError( "You can't use 'unknown' as a name for a data column." );
3255+
3256+ // [AK] If the column isn't using a native type for a name, then it's a custom column.
3257+ // This also implies that "custom" is a valid name for custom columns.
3258+ if ( ColumnType == -1 )
3259+ ColumnType = COLUMNTYPE_CUSTOM;
3260+
3261+ if ( ColumnType == COLUMNTYPE_COUNTRYFLAG )
3262+ pColumn = new CountryFlagScoreColumn( sc, ColumnName );
3263+ else
3264+ pColumn = new DataScoreColumn( ColumnType, ColumnName );
3265+ }
3266+
3267+ if ( pColumn->GetTemplate( ) != COLUMNTEMPLATE_DATA )
3268+ sc.ScriptError( "Column '%s' isn't a data column.", ColumnName.GetChars( ));
3269+ }
3270+
3271+ // [AK] If a new column was created, insert it to the global list.
3272+ if ( bMustCreateNewColumn )
3273+ g_Columns.Insert( ColumnName, pColumn );
3274+
3275+ pColumn->Parse( sc );
3276+ }
3277+ else
3278+ {
3279+ sc.ScriptError( "Unknown option '%s', on line %d in SCORINFO.", sc.String, sc.Line );
3280+ }
3281+ }
3282+ }
3283+ }
3284+
3285+ // [AK] Make sure that there's no custom columns without data on the scoreboard.
3286+ if ( g_Columns.CountUsed( ) > 0 )
3287+ {
3288+ TMapIterator<FName, ScoreColumn *> it( g_Columns );
3289+ TMap<FName, ScoreColumn *>::Pair *pair;
3290+
3291+ while ( it.NextPair( pair ))
3292+ {
3293+ if (( pair->Value->GetScoreboard( ) == NULL ) || ( pair->Value->GetTemplate( ) != COLUMNTEMPLATE_DATA ))
3294+ continue;
3295+
3296+ DataScoreColumn *pDataColumn = static_cast<DataScoreColumn *>( pair->Value );
3297+
3298+ if ( pDataColumn->GetNativeType( ) != COLUMNTYPE_CUSTOM )
3299+ continue;
3300+
3301+ if (( gameinfo.CustomPlayerData.CountUsed( ) == 0 ) || ( gameinfo.CustomPlayerData.CheckKey( pDataColumn->GetInternalName( )) == NULL ))
3302+ I_Error( "Custom column '%s' has no data and can't be on the scoreboard.", pair->Key.GetChars( ));
3303+ }
3304+ }
3305+}
3306+
3307+//*****************************************************************************
3308+//
31903309 // [AK] SCOREBOARD_GetColumn
31913310 //
31923311 // Returns a pointer to a column by searching for its name.
diff -r 53cb82a6576b -r cf76db80aab6 src/scoreboard.h
--- a/src/scoreboard.h Fri Mar 24 23:24:47 2023 -0400
+++ b/src/scoreboard.h Wed Mar 22 16:31:25 2023 -0400
@@ -495,6 +495,7 @@
495495 //*****************************************************************************
496496 // PROTOTYPES
497497
498+void SCOREBOARD_Construct( void );
498499 ScoreColumn *SCOREBOARD_GetColumn( FName Name, const bool bMustBeUsable );
499500 bool SCOREBOARD_ShouldDrawBoard( void );
500501 void SCOREBOARD_Reset( const bool bChangingLevel );
Show on old repository browser