• R/O
  • SSH

zandronum-sandbox-stable: Commit


Commit MetaInfo

Revisionf7473637d80ca78d38031f8420ff6f0a81aff8ae (tree)
Time2023-03-25 10:13:32
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

- Separated the data that's used by custom columns, and in turn, removed the now superflous CustomScoreColumn class.
- Mods now allocate or deallocate data for custom columns using the "addcustomdata" and "removecustomdata" commands respectively in the GameInfo block of a MAPINFO lump.
- Removed the column flag DONTRESETONLEVELCHANGE.

Change Summary

Incremental Difference

diff -r 55a5ae6be624 -r f7473637d80c src/bots.cpp
--- a/src/bots.cpp Sun Mar 19 21:14:10 2023 -0400
+++ b/src/bots.cpp Fri Mar 24 21:13:32 2023 -0400
@@ -598,7 +598,7 @@
598598 CHAT_ClearChatMessages( ulPlayerIdx );
599599
600600 // [AK] Reset this player's custom columns to their default values.
601- SCOREBOARD_ResetCustomColumnsForPlayer( ulPlayerIdx, false );
601+ SCOREBOARD_ResetCustomColumnsForPlayer( ulPlayerIdx );
602602
603603 // [BB] Morphed bots need to be unmorphed before disconnecting.
604604 if (players[ulPlayerIdx].morphTics)
diff -r 55a5ae6be624 -r f7473637d80c src/cl_main.cpp
--- a/src/cl_main.cpp Sun Mar 19 21:14:10 2023 -0400
+++ b/src/cl_main.cpp Fri Mar 24 21:13:32 2023 -0400
@@ -4545,7 +4545,7 @@
45454545 CHAT_ClearChatMessages( player - players );
45464546
45474547 // [AK] Reset this player's custom columns to their default values.
4548- SCOREBOARD_ResetCustomColumnsForPlayer( player - players, false );
4548+ SCOREBOARD_ResetCustomColumnsForPlayer( player - players );
45494549
45504550 // Zero out all the player information.
45514551 PLAYER_ResetPlayerData( player );
diff -r 55a5ae6be624 -r f7473637d80c src/gi.cpp
--- a/src/gi.cpp Sun Mar 19 21:14:10 2023 -0400
+++ b/src/gi.cpp Fri Mar 24 21:13:32 2023 -0400
@@ -294,6 +294,35 @@
294294 }
295295 else gameinfo.mCheatMapArrow = "";
296296 }
297+ // [AK] Adds or removes a set of custom data that will be used by a custom column.
298+ else if (( nextKey.CompareNoCase( "addcustomdata" ) == 0 ) || ( nextKey.CompareNoCase( "removecustomdata" ) == 0 ))
299+ {
300+ const bool bAddingData = ( nextKey.CompareNoCase( "addcustomdata" ) == 0 );
301+ sc.MustGetToken( TK_StringConst );
302+
303+ if ( sc.StringLen == 0 )
304+ sc.ScriptError( "Got an empty string for a name." );
305+
306+ FName Name = sc.String;
307+
308+ if ( bAddingData )
309+ {
310+ // [AK] Don't allow the same data to be defined more than once.
311+ if ( gameinfo.CustomPlayerData.CheckKey( Name ) != NULL )
312+ sc.ScriptError( "Custom data '%s' is already defined.", Name.GetChars( ));
313+
314+ sc.MustGetToken( ',' );
315+ gameinfo.CustomPlayerData.Insert( Name, CustomPlayerData( sc, gameinfo.CustomPlayerData.CountUsed( )));
316+ }
317+ else
318+ {
319+ // [AK] Make sure that the data is already defined.
320+ if ( gameinfo.CustomPlayerData.CheckKey( Name ) == NULL )
321+ sc.ScriptError( "Custom data '%s' isn't defined.", Name.GetChars( ));
322+
323+ gameinfo.CustomPlayerData.Remove( Name );
324+ }
325+ }
297326 // Insert valid keys here.
298327 GAMEINFOKEY_CSTRING(titlePage, "titlePage", 8)
299328 GAMEINFOKEY_STRINGARRAY(creditPages, "addcreditPage", 8, false)
diff -r 55a5ae6be624 -r f7473637d80c src/gi.h
--- a/src/gi.h Sun Mar 19 21:14:10 2023 -0400
+++ b/src/gi.h Fri Mar 24 21:13:32 2023 -0400
@@ -36,6 +36,8 @@
3636
3737 #include "basictypes.h"
3838 #include "zstring.h"
39+// [AK] New #includes.
40+#include "scoreboard.h"
3941
4042 // Flags are not user configurable and only depend on the standard IWADs
4143 #define GI_MAPxx 0x00000001
@@ -150,6 +152,9 @@
150152 bool bForceSpawnEventScripts;
151153 bool bForceDamageEventScripts;
152154
155+ // [AK] A list of all custom data for players, particularly used by custom columns.
156+ TMap<FName, CustomPlayerData> CustomPlayerData;
157+
153158 const char *GetFinalePage(unsigned int num) const;
154159 };
155160
diff -r 55a5ae6be624 -r f7473637d80c src/p_acs.cpp
--- a/src/p_acs.cpp Sun Mar 19 21:14:10 2023 -0400
+++ b/src/p_acs.cpp Fri Mar 24 21:13:32 2023 -0400
@@ -1861,25 +1861,6 @@
18611861 return 0;
18621862 }
18631863
1864-// ================================================================================================
1865-//
1866-// [AK] GetCustomScoreColumn
1867-//
1868-// Returns a pointer to a usable CustomScoreColumn object, using its name as an argument.
1869-//
1870-// ================================================================================================
1871-
1872-static CustomScoreColumn *GetCustomScoreColumn ( const char *pszColumnName )
1873-{
1874- ScoreColumn *pColumn = SCOREBOARD_GetColumn( pszColumnName, true );
1875-
1876- // [AK] Return NULL if the column doesn't exist, isn't usable right now, or isn't a custom column.
1877- if (( pColumn == NULL ) || ( pColumn->IsCustomColumn( ) == false ))
1878- return NULL;
1879-
1880- return static_cast<CustomScoreColumn *>( pColumn );
1881-}
1882-
18831864 //---- Plane watchers ----//
18841865
18851866 class DPlaneWatcher : public DThinker
@@ -7897,14 +7878,14 @@
78977878
78987879 case ACSF_SetCustomColumnValue:
78997880 {
7900- CustomScoreColumn *pCustomColumn = GetCustomScoreColumn( FBehavior::StaticLookupString( args[0] ));
7881+ CustomPlayerData *pData = gameinfo.CustomPlayerData.CheckKey( FBehavior::StaticLookupString( args[0] ));
79017882
79027883 // [AK] Make sure that the column and player are both valid.
7903- if (( pCustomColumn != NULL ) && ( PLAYER_IsValidPlayer( args[1] )))
7884+ if (( pData != NULL ) && ( PLAYER_IsValidPlayer( args[1] )))
79047885 {
79057886 ColumnValue Val;
79067887
7907- switch ( pCustomColumn->GetDataType( ))
7888+ switch ( pData->GetDataType( ))
79087889 {
79097890 case COLUMNDATA_INT:
79107891 case COLUMNDATA_COLOR:
@@ -7924,14 +7905,14 @@
79247905 {
79257906 const char *pszValue = FBehavior::StaticLookupString( args[2] );
79267907
7927- if ( pCustomColumn->GetDataType( ) == COLUMNDATA_STRING )
7908+ if ( pData->GetDataType( ) == COLUMNDATA_STRING )
79287909 Val = pszValue;
79297910 else
79307911 Val = TexMan.FindTexture( pszValue );
79317912 }
79327913 }
79337914
7934- pCustomColumn->SetValue( args[1], Val );
7915+ pData->SetValue( args[1], Val );
79357916 return 1;
79367917 }
79377918
@@ -7940,12 +7921,12 @@
79407921
79417922 case ACSF_GetCustomColumnValue:
79427923 {
7943- CustomScoreColumn *pCustomColumn = GetCustomScoreColumn( FBehavior::StaticLookupString( args[0] ));
7924+ CustomPlayerData *pData = gameinfo.CustomPlayerData.CheckKey( FBehavior::StaticLookupString( args[0] ));
79447925
79457926 // [AK] Make sure that the column and player are both valid.
7946- if (( pCustomColumn != NULL ) && ( PLAYER_IsValidPlayer( args[1] )))
7947- {
7948- const ColumnValue Val = pCustomColumn->GetValue( args[1] );
7927+ if (( pData != NULL ) && ( PLAYER_IsValidPlayer( args[1] )))
7928+ {
7929+ const ColumnValue Val = pData->GetValue( args[1] );
79497930
79507931 switch ( Val.GetDataType( ))
79517932 {
@@ -7977,13 +7958,13 @@
79777958
79787959 case ACSF_ResetCustomColumnToDefault:
79797960 {
7980- CustomScoreColumn *pCustomColumn = GetCustomScoreColumn( FBehavior::StaticLookupString( args[0] ));
7961+ CustomPlayerData *pData = gameinfo.CustomPlayerData.CheckKey( FBehavior::StaticLookupString( args[0] ));
79817962 const ULONG ulPlayer = args[1] < 0 ? MAXPLAYERS : args[1];
79827963
79837964 // [AK] Make sure that the column and player are both valid (unless we're resetting for all players).
7984- if (( pCustomColumn != NULL ) && (( ulPlayer == MAXPLAYERS ) || ( PLAYER_IsValidPlayer( ulPlayer ))))
7985- {
7986- pCustomColumn->ResetToDefault( ulPlayer, false );
7965+ if (( pData != NULL ) && (( ulPlayer == MAXPLAYERS ) || ( PLAYER_IsValidPlayer( ulPlayer ))))
7966+ {
7967+ pData->ResetToDefault( ulPlayer );
79877968 return 1;
79887969 }
79897970
diff -r 55a5ae6be624 -r f7473637d80c src/scoreboard.cpp
--- a/src/scoreboard.cpp Sun Mar 19 21:14:10 2023 -0400
+++ b/src/scoreboard.cpp Fri Mar 24 21:13:32 2023 -0400
@@ -431,6 +431,150 @@
431431
432432 //*****************************************************************************
433433 //
434+// [AK] CustomPlayerData::CustomPlayerData
435+//
436+// Initializes the data type and default value that will be used.
437+//
438+//*****************************************************************************
439+
440+CustomPlayerData::CustomPlayerData( FScanner &sc, BYTE NewIndex ) : Index( NewIndex )
441+{
442+ // [AK] Grab the data type first.
443+ sc.MustGetToken( TK_StringConst );
444+
445+ if ( sc.StringLen == 0 )
446+ sc.ScriptError( "Got an empty string for a data type." );
447+
448+ DataType = static_cast<COLUMNDATA_e>( sc.MustGetEnumName( "data type", "COLUMNDATA_", GetValueCOLUMNDATA_e, true ));
449+
450+ // [AK] Don't accept an "unknown" data type.
451+ if ( DataType == COLUMNDATA_UNKNOWN )
452+ sc.ScriptError( "You can't specify an 'unknown' data type!" );
453+
454+ sc.MustGetToken( ',' );
455+
456+ // [AK] Next, grab the default value and store it into a string.
457+ switch ( DataType )
458+ {
459+ case COLUMNDATA_INT:
460+ {
461+ sc.MustGetNumber( );
462+ DefaultValString.Format( "%d", sc.Number );
463+ break;
464+ }
465+
466+ case COLUMNDATA_FLOAT:
467+ {
468+ sc.MustGetFloat( );
469+ DefaultValString.Format( "%f", static_cast<float>( sc.Float ));
470+ break;
471+ }
472+
473+ case COLUMNDATA_BOOL:
474+ case COLUMNDATA_STRING:
475+ case COLUMNDATA_COLOR:
476+ case COLUMNDATA_TEXTURE:
477+ {
478+ sc.MustGetString( );
479+
480+ // [AK] Color values must be saved differently.
481+ if ( DataType == COLUMNDATA_COLOR )
482+ {
483+ FString ColorString = V_GetColorStringByName( sc.String );
484+ DefaultValString.Format( "%d", V_GetColorFromString( NULL, ColorString.IsNotEmpty( ) ? ColorString.GetChars( ) : sc.String ));
485+ }
486+ else
487+ {
488+ DefaultValString = sc.String;
489+ }
490+
491+ break;
492+ }
493+ }
494+}
495+
496+//*****************************************************************************
497+//
498+// [AK] CustomPlayerData::GetValue
499+//
500+// Returns a ColumnValue object containing the value associated with a player,
501+// or the default value if the given player index is invalid.
502+//
503+//*****************************************************************************
504+
505+ColumnValue CustomPlayerData::GetValue( const ULONG ulPlayer ) const
506+{
507+ return PLAYER_IsValidPlayer( ulPlayer ) ? Val[ulPlayer] : GetDefaultValue( );
508+}
509+
510+//*****************************************************************************
511+//
512+// [AK] CustomPlayerData::GetDefaultValue
513+//
514+// Returns a ColumnValue object containing the default value.
515+//
516+//*****************************************************************************
517+
518+ColumnValue CustomPlayerData::GetDefaultValue( void ) const
519+{
520+ ColumnValue DefaultVal;
521+ DefaultVal.FromString( DefaultValString.GetChars( ), DataType );
522+
523+ return DefaultVal;
524+}
525+
526+//*****************************************************************************
527+//
528+// [AK] CustomPlayerData::SetValue
529+//
530+// Changes the value for a player in this column.
531+//
532+//*****************************************************************************
533+
534+void CustomPlayerData::SetValue( const ULONG ulPlayer, const ColumnValue &Value )
535+{
536+ // [AK] Stop here if the player's invalid, or the new value is equal to the old one.
537+ if (( PLAYER_IsValidPlayer( ulPlayer ) == false ) || ( GetValue( ulPlayer ) == Value ))
538+ return;
539+
540+ // [AK] Only set the value if the data types match. Otherwise, throw a fatal error.
541+ if ( DataType != Value.GetDataType( ))
542+ I_Error( "CustomPlayerData::SetValue: data type doesn't match." );
543+
544+ Val[ulPlayer] = Value;
545+ SCOREBOARD_ShouldRefreshBeforeRendering( );
546+}
547+
548+//*****************************************************************************
549+//
550+// [AK] CustomPlayerData::ResetToDefault
551+//
552+// Resets the value of a single player or all players in this column to their
553+// default values.
554+//
555+//*****************************************************************************
556+
557+void CustomPlayerData::ResetToDefault( const ULONG ulPlayer )
558+{
559+ const ColumnValue DefaultVal = GetDefaultValue( );
560+
561+ // [AK] Check if we want to restore the default value for all players.
562+ if ( ulPlayer == MAXPLAYERS )
563+ {
564+ for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ )
565+ Val[ulIdx] = DefaultVal;
566+ }
567+ // [AK] Otherwise, restore it only for the one player.
568+ else if ( ulPlayer < MAXPLAYERS )
569+ {
570+ Val[ulPlayer] = DefaultVal;
571+ }
572+
573+ SCOREBOARD_ShouldRefreshBeforeRendering( );
574+}
575+
576+//*****************************************************************************
577+//
434578 // [AK] ScoreColumn::ScoreColumn
435579 //
436580 // Initializes the members of a ScoreColumn object to their default values.
@@ -1073,6 +1217,16 @@
10731217 case COLUMNTYPE_COUNTRYFLAG:
10741218 return COLUMNDATA_TEXTURE;
10751219
1220+ case COLUMNTYPE_CUSTOM:
1221+ {
1222+ CustomPlayerData *pData = gameinfo.CustomPlayerData.CheckKey( InternalName );
1223+
1224+ if ( pData == NULL )
1225+ I_Error( "DataScoreColumn::GetDataType: custom column '%s' has no data.", GetInternalName( ));
1226+
1227+ return pData->GetDataType( );
1228+ }
1229+
10761230 default:
10771231 return COLUMNDATA_UNKNOWN;
10781232 }
@@ -1394,6 +1548,16 @@
13941548 case COLUMNTYPE_COUNTRYCODE:
13951549 Result = NETWORK_GetCountryCodeFromIndex( players[ulPlayer].ulCountryIndex, cl_usealpha3countrycode );
13961550 break;
1551+
1552+ case COLUMNTYPE_CUSTOM:
1553+ {
1554+ CustomPlayerData *pData = gameinfo.CustomPlayerData.CheckKey( InternalName );
1555+
1556+ if ( pData == NULL )
1557+ I_Error( "DataScoreColumn::GetValue: custom column '%s' has no data.", GetInternalName( ));
1558+
1559+ Result = pData->GetValue( ulPlayer );
1560+ }
13971561 }
13981562 }
13991563
@@ -1719,253 +1883,6 @@
17191883
17201884 //*****************************************************************************
17211885 //
1722-// [AK] CustomScoreColumn::CustomScoreColumn
1723-//
1724-// Initializes the custom column's data type and sets its default value to zero
1725-// (e.g. 0 for integers, booleans, floats, or colors, and NULL for strings
1726-// or textures).
1727-//
1728-//*****************************************************************************
1729-
1730-CustomScoreColumn::CustomScoreColumn( COLUMNDATA_e DataType, const char *pszName ) : DataScoreColumn( COLUMNTYPE_CUSTOM, pszName ), CurrentDataType( COLUMNDATA_UNKNOWN )
1731-{
1732- ValidateDataType( DataType, "CustomScoreColumn::CustomScoreColumn" );
1733- SetDataType( DataType );
1734-}
1735-
1736-//*****************************************************************************
1737-//
1738-// [AK] CustomScoreColumn::GetValue
1739-//
1740-// Returns a ColumnValue object containing the value associated with a player,
1741-// or the default value if the given player index is invalid.
1742-//
1743-//*****************************************************************************
1744-
1745-ColumnValue CustomScoreColumn::GetValue( ULONG ulPlayer ) const
1746-{
1747- return PLAYER_IsValidPlayer( ulPlayer ) ? Val[ulPlayer] : DefaultVal;
1748-}
1749-
1750-//*****************************************************************************
1751-//
1752-// [AK] CustomScoreColumn::GetDefaultValue
1753-//
1754-// Returns a ColumnValue object containing the column's default value.
1755-//
1756-//*****************************************************************************
1757-
1758-ColumnValue CustomScoreColumn::GetDefaultValue( void ) const
1759-{
1760- return DefaultVal;
1761-}
1762-
1763-//*****************************************************************************
1764-//
1765-// [AK] CustomScoreColumn::SetDataType
1766-//
1767-// Changes the columm's data type and zeroes every player's value.
1768-//
1769-//*****************************************************************************
1770-
1771-void CustomScoreColumn::SetDataType( COLUMNDATA_e NewDataType )
1772-{
1773- if ( CurrentDataType == NewDataType )
1774- return;
1775-
1776- ValidateDataType( NewDataType, "CustomScoreColumn::SetDataType" );
1777- CurrentDataType = NewDataType;
1778-
1779- // [AK] We changed the custom column's data type. Now we need to do the same with
1780- // the (default) values and zero everything.
1781- for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ )
1782- Val[ulIdx].ChangeDataType( CurrentDataType );
1783-
1784- DefaultVal.ChangeDataType( CurrentDataType );
1785-}
1786-
1787-//*****************************************************************************
1788-//
1789-// [AK] CustomScoreColumn::SetValue
1790-//
1791-// Changes the value for a player in this column.
1792-//
1793-//*****************************************************************************
1794-
1795-void CustomScoreColumn::SetValue( const ULONG ulPlayer, const ColumnValue &Value )
1796-{
1797- if ( PLAYER_IsValidPlayer( ulPlayer ))
1798- {
1799- // [AK] Stop here if the new value is equal to the old one.
1800- if ( GetValue( ulPlayer ) == Value )
1801- return;
1802-
1803- TryChangingValue( Val[ulPlayer], Value, "CustomScoreColumn::SetValue" );
1804- SCOREBOARD_ShouldRefreshBeforeRendering( );
1805- }
1806-}
1807-
1808-//*****************************************************************************
1809-//
1810-// [AK] CustomScoreColumn::SetDefaultValue
1811-//
1812-// Changes the column's default value.
1813-//
1814-//*****************************************************************************
1815-
1816-void CustomScoreColumn::SetDefaultValue( const ColumnValue &Value )
1817-{
1818- TryChangingValue( DefaultVal, Value, "CustomScoreColumn::SetDefaultValue" );
1819-}
1820-
1821-//*****************************************************************************
1822-//
1823-// [AK] CustomScoreColumn::ParseCommand
1824-//
1825-// Parses commands that are only used for custom columns.
1826-//
1827-//*****************************************************************************
1828-
1829-void CustomScoreColumn::ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName )
1830-{
1831- switch ( Command )
1832- {
1833- case COLUMNCMD_DEFAULTVALUE:
1834- {
1835- const COLUMNDATA_e DataType = GetDataType( );
1836- ColumnValue Value;
1837-
1838- switch ( DataType )
1839- {
1840- case COLUMNDATA_INT:
1841- {
1842- sc.MustGetNumber( );
1843- Value = sc.Number;
1844- break;
1845- }
1846-
1847- case COLUMNDATA_FLOAT:
1848- {
1849- sc.MustGetFloat( );
1850- Value = static_cast<float>( sc.Float );
1851- break;
1852- }
1853-
1854- case COLUMNDATA_BOOL:
1855- case COLUMNDATA_STRING:
1856- case COLUMNDATA_COLOR:
1857- case COLUMNDATA_TEXTURE:
1858- {
1859- sc.MustGetString( );
1860-
1861- if ( DataType == COLUMNDATA_BOOL )
1862- {
1863- if ( stricmp( sc.String, "true" ) == 0 )
1864- Value = true;
1865- else if ( stricmp( sc.String, "false" ) == 0 )
1866- Value = false;
1867- else
1868- Value = !!atoi( sc.String );
1869- }
1870- else if ( DataType == COLUMNDATA_STRING )
1871- {
1872- Value = sc.String;
1873- }
1874- else if ( DataType == COLUMNDATA_COLOR )
1875- {
1876- FString ColorString = V_GetColorStringByName( sc.String );
1877- Value = V_GetColorFromString( NULL, ColorString.IsNotEmpty( ) ? ColorString.GetChars( ) : sc.String );
1878- }
1879- else
1880- {
1881- FTexture *pTexture = TexMan.FindTexture( sc.String );
1882-
1883- if ( pTexture == NULL )
1884- sc.ScriptError( "Couldn't find texture '%s'.", sc.String );
1885-
1886- Value = pTexture;
1887- }
1888-
1889- break;
1890- }
1891- }
1892-
1893- SetDefaultValue( Value );
1894- break;
1895- }
1896-
1897- // [AK] Parse any data column commands if we reach here.
1898- default:
1899- DataScoreColumn::ParseCommand( sc, Command, CommandName );
1900- break;
1901- }
1902-}
1903-
1904-//*****************************************************************************
1905-//
1906-// [AK] CustomScoreColumn::ResetToDefault
1907-//
1908-// Resets the value of a single player or all players in this column to their
1909-// default values.
1910-//
1911-//*****************************************************************************
1912-
1913-void CustomScoreColumn::ResetToDefault( const ULONG ulPlayer, const bool bChangingLevel )
1914-{
1915- // [AK] Don't reset to default if this column forbids it during a level change.
1916- if (( bChangingLevel ) && ( ulFlags & COLUMNFLAG_DONTRESETONLEVELCHANGE ))
1917- return;
1918-
1919- // [AK] Check if we want to restore the default value for all players.
1920- if ( ulPlayer == MAXPLAYERS )
1921- {
1922- for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ )
1923- Val[ulIdx] = DefaultVal;
1924- }
1925- // [AK] Otherwise, restore it only for the one player.
1926- else if ( ulPlayer < MAXPLAYERS )
1927- {
1928- Val[ulPlayer] = DefaultVal;
1929- }
1930-
1931- SCOREBOARD_ShouldRefreshBeforeRendering( );
1932-}
1933-
1934-//*****************************************************************************
1935-//
1936-// [AK] CustomScoreColumn::ValidateDataType
1937-//
1938-// Checks if a data type is valid, and throws a fatal error if it isn't.
1939-//
1940-//*****************************************************************************
1941-
1942-void CustomScoreColumn::ValidateDataType( COLUMNDATA_e DataType, const char *pszFunctionName ) const
1943-{
1944- // [AK] Throw a fatal error if an invalid data type was used.
1945- if (( DataType <= COLUMNDATA_UNKNOWN ) || ( DataType >= NUM_COLUMNDATA_TYPES ))
1946- I_Error( "%s: an invalid data type was used, %d.", pszFunctionName ? pszFunctionName : "CustomScoreColumn", static_cast<int>( DataType ));
1947-}
1948-
1949-//*****************************************************************************
1950-//
1951-// [AK] CustomScoreColumn::TryChangingValue
1952-//
1953-// Checks if it's safe to change a value to that of another ColumnValue object
1954-// (i.e. their data types match), and throws a fatal error if they aren't.
1955-//
1956-//*****************************************************************************
1957-
1958-void CustomScoreColumn::TryChangingValue( ColumnValue &To, const ColumnValue &From, const char *pszFunctionName )
1959-{
1960- // [AK] Only set the value if the data types match. Otherwise, throw a fatal error.
1961- if ( GetDataType( ) == From.GetDataType( ))
1962- To = From;
1963- else
1964- I_Error( "%s: the value's data type doesn't match the column's data type.", pszFunctionName ? pszFunctionName : "CustomScoreColumn" );
1965-}
1966-
1967-//*****************************************************************************
1968-//
19691886 // [AK] CompositeScoreColumn::ParseCommand
19701887 //
19711888 // Parses commands that are only used for composite columns.
@@ -3332,7 +3249,7 @@
33323249 }
33333250
33343251 // [AK] Reset custom columns to their default values for all players.
3335- SCOREBOARD_ResetCustomColumnsForPlayer( MAXPLAYERS, bChangingLevel );
3252+ SCOREBOARD_ResetCustomColumnsForPlayer( MAXPLAYERS );
33363253
33373254 // [AK] It would be a good idea to refresh the scoreboard after resetting.
33383255 SCOREBOARD_ShouldRefreshBeforeRendering( );
@@ -3347,20 +3264,17 @@
33473264 //
33483265 //*****************************************************************************
33493266
3350-void SCOREBOARD_ResetCustomColumnsForPlayer( const ULONG ulPlayer, const bool bChangingLevel )
3267+void SCOREBOARD_ResetCustomColumnsForPlayer( const ULONG ulPlayer )
33513268 {
3352- // [AK] Don't do anything if there are no defined columns.
3353- if ( g_Columns.CountUsed( ) == 0 )
3269+ // [AK] Don't do anything if there is no data.
3270+ if ( gameinfo.CustomPlayerData.CountUsed( ) == 0 )
33543271 return;
33553272
3356- TMapIterator<FName, ScoreColumn *> it( g_Columns );
3357- TMap<FName, ScoreColumn *>::Pair *pair;
3273+ TMapIterator<FName, CustomPlayerData> it( gameinfo.CustomPlayerData );
3274+ TMap<FName, CustomPlayerData>::Pair *pair;
33583275
33593276 while ( it.NextPair( pair ))
3360- {
3361- if (( pair->Value->IsUsableInCurrentGame( )) && ( pair->Value->IsCustomColumn( )))
3362- static_cast<CustomScoreColumn *>( pair->Value )->ResetToDefault( ulPlayer, bChangingLevel );
3363- }
3277+ pair->Value.ResetToDefault( ulPlayer );
33643278 }
33653279
33663280 //*****************************************************************************
diff -r 55a5ae6be624 -r f7473637d80c src/scoreboard.h
--- a/src/scoreboard.h Sun Mar 19 21:14:10 2023 -0400
+++ b/src/scoreboard.h Fri Mar 24 21:13:32 2023 -0400
@@ -187,6 +187,37 @@
187187
188188 //*****************************************************************************
189189 //
190+// [AK] CustomPlayerData
191+//
192+// An array of ColumnValues for each player, used by custom columns to store data.
193+//
194+//*****************************************************************************
195+
196+class CustomPlayerData
197+{
198+public:
199+ CustomPlayerData( FScanner &sc, BYTE NewIndex );
200+
201+ COLUMNDATA_e GetDataType( void ) const { return DataType; }
202+ ColumnValue GetValue( const ULONG ulPlayer ) const;
203+ ColumnValue GetDefaultValue( void ) const;
204+ BYTE GetIndex( void ) const { return Index; }
205+ void SetValue( const ULONG ulPlayer, const ColumnValue &Value );
206+ void ResetToDefault( const ULONG ulPlayer );
207+
208+private:
209+ COLUMNDATA_e DataType;
210+ ColumnValue Val[MAXPLAYERS];
211+ BYTE Index;
212+
213+ // [AK] The default value as a string. MAPINFO lumps are parsed before any
214+ // graphics are loaded, so if a custom column uses textures as data, then
215+ // this is why the value must be stored as a string.
216+ FString DefaultValString;
217+};
218+
219+//*****************************************************************************
220+//
190221 // [AK] ScoreColumn
191222 //
192223 // A base class for all column types (e.g. data or composite) that will appear
@@ -222,7 +253,6 @@
222253 void DrawTexture( FTexture *pTexture, const LONG lYPos, const ULONG ulHeight, const float fAlpha, const int clipWidth, const int clipHeight ) const;
223254
224255 virtual COLUMNTEMPLATE_e GetTemplate( void ) const { return COLUMNTEMPLATE_UNKNOWN; }
225- virtual bool IsCustomColumn( void ) const { return false; }
226256 virtual void Parse( FScanner &sc );
227257 virtual void ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName );
228258 virtual void CheckIfUsable( void );
@@ -337,39 +367,6 @@
337367
338368 //*****************************************************************************
339369 //
340-// [AK] CustomScoreColumn
341-//
342-// A separate class for all custom columns and their respective data types.
343-//
344-//*****************************************************************************
345-
346-class CustomScoreColumn : public DataScoreColumn
347-{
348-public:
349- CustomScoreColumn( COLUMNDATA_e DataType, const char *pszName );
350-
351- virtual bool IsCustomColumn( void ) const { return true; }
352- virtual COLUMNDATA_e GetDataType( void ) const { return CurrentDataType; }
353- virtual ColumnValue GetValue( const ULONG ulPlayer ) const;
354- virtual ColumnValue GetDefaultValue( void ) const;
355- virtual void SetDataType( COLUMNDATA_e NewDataType );
356- virtual void SetValue( const ULONG ulPlayer, const ColumnValue &Value );
357- virtual void SetDefaultValue( const ColumnValue &Value );
358- virtual void ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName );
359- virtual void ResetToDefault( const ULONG ulPlayer, const bool bChangingLevel );
360-
361-protected:
362- COLUMNDATA_e CurrentDataType;
363- ColumnValue Val[MAXPLAYERS];
364- ColumnValue DefaultVal;
365-
366-private:
367- void ValidateDataType( COLUMNDATA_e DataType, const char *pszFunctionName ) const;
368- void TryChangingValue( ColumnValue &To, const ColumnValue &From, const char *pszFunctionName );
369-};
370-
371-//*****************************************************************************
372-//
373370 // [AK] CompositeScoreColumn
374371 //
375372 // A column consisting of more than one data column that are tucked underneath
@@ -501,7 +498,7 @@
501498 ScoreColumn *SCOREBOARD_GetColumn( FName Name, const bool bMustBeUsable );
502499 bool SCOREBOARD_ShouldDrawBoard( void );
503500 void SCOREBOARD_Reset( const bool bChangingLevel );
504-void SCOREBOARD_ResetCustomColumnsForPlayer( const ULONG ulPlayer, const bool bChangingLevel );
501+void SCOREBOARD_ResetCustomColumnsForPlayer( const ULONG ulPlayer );
505502 void SCOREBOARD_Render( ULONG ulDisplayPlayer );
506503 void SCOREBOARD_Refresh( void );
507504 void SCOREBOARD_ShouldRefreshBeforeRendering( void );
diff -r 55a5ae6be624 -r f7473637d80c src/scoreboard_enums.h
--- a/src/scoreboard_enums.h Sun Mar 19 21:14:10 2023 -0400
+++ b/src/scoreboard_enums.h Fri Mar 24 21:13:32 2023 -0400
@@ -192,8 +192,6 @@
192192 ENUM_ELEMENT2( COLUMNFLAG_CVARMUSTBEZERO, 0x4000 ),
193193 // If the column's empty (i.e. no contents inside it), then it's disabled.
194194 ENUM_ELEMENT2( COLUMNFLAG_DISABLEIFEMPTY, 0x8000 ),
195- // This column's values aren't reset to default when the level changes (custom columns only).
196- ENUM_ELEMENT2( COLUMNFLAG_DONTRESETONLEVELCHANGE, 0x10000 ),
197195 }
198196 END_ENUM( COLUMNFLAG_e )
199197
@@ -256,8 +254,6 @@
256254 ENUM_ELEMENT( COLUMNCMD_TRUETEXT ),
257255 // What gets drawn when a row's value is 0 (boolean columns only).
258256 ENUM_ELEMENT( COLUMNCMD_FALSETEXT ),
259- // The default value of this column at the start of a new game (custom columns only).
260- ENUM_ELEMENT( COLUMNCMD_DEFAULTVALUE ),
261257 // What sub-columns are inside the composite column and their order (composite columns only).
262258 ENUM_ELEMENT( COLUMNCMD_COLUMNS ),
263259 // Adds column(s) to the end of the composite column's sub-column list (composite columns only).
diff -r 55a5ae6be624 -r f7473637d80c src/sv_main.cpp
--- a/src/sv_main.cpp Sun Mar 19 21:14:10 2023 -0400
+++ b/src/sv_main.cpp Fri Mar 24 21:13:32 2023 -0400
@@ -3011,7 +3011,7 @@
30113011 CHAT_ClearChatMessages( ulClient );
30123012
30133013 // [AK] Reset this player's custom columns to their default values.
3014- SCOREBOARD_ResetCustomColumnsForPlayer( ulClient, false );
3014+ SCOREBOARD_ResetCustomColumnsForPlayer( ulClient );
30153015
30163016 // [BB] Morphed players need to be unmorphed before disconnecting.
30173017 if (players[ulClient].morphTics)
Show on old repository browser