• R/O
  • SSH

zandronum-sandbox-stable: Commit


Commit MetaInfo

Revision36def6dbea37357fbbedcc45efc04aa89c70a2a0 (tree)
Time2022-09-22 21:47:41
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Removed C-style char arrays in GAMEMODE_s.

Change Summary

Incremental Difference

diff -r f95780860a9f -r 36def6dbea37 src/gamemode.cpp
--- a/src/gamemode.cpp Sun Sep 18 22:37:44 2022 -0400
+++ b/src/gamemode.cpp Thu Sep 22 08:47:41 2022 -0400
@@ -178,20 +178,23 @@
178178 else if (0 == stricmp (sc.String, "name"))
179179 {
180180 sc.MustGetString();
181- strncpy( g_GameModes[GameMode].szName, sc.String, 31 );
182- g_GameModes[GameMode].szName[31] = 0;
181+ g_GameModes[GameMode].Name = sc.String;
183182 }
184183 else if (0 == stricmp (sc.String, "shortname"))
185184 {
186185 sc.MustGetString();
187- strncpy( g_GameModes[GameMode].szShortName, sc.String, 8 );
188- g_GameModes[GameMode].szShortName[8] = 0;
186+ g_GameModes[GameMode].ShortName = sc.String;
187+
188+ // [AK] Limit the short name to only 8 characters.
189+ g_GameModes[GameMode].ShortName.Truncate( 8 );
189190 }
190191 else if (0 == stricmp (sc.String, "f1texture"))
191192 {
192193 sc.MustGetString();
193- strncpy( g_GameModes[GameMode].szF1Texture, sc.String, 8 );
194- g_GameModes[GameMode].szF1Texture[8] = 0;
194+ g_GameModes[GameMode].F1Texture = sc.String;
195+
196+ // [AK] The F1 texture cannot exceed more than 8 characters.
197+ g_GameModes[GameMode].F1Texture.Truncate( 8 );
195198 }
196199 else if ((0 == stricmp (sc.String, "gamesettings")) || (0 == stricmp (sc.String, "lockedgamesettings")))
197200 {
@@ -340,9 +343,9 @@
340343 name.ToLower( );
341344
342345 // [AK] Make sure the game mode has a (short) name.
343- if ( strlen( g_GameModes[i].szName ) == 0 )
346+ if ( g_GameModes[i].Name.IsEmpty( ))
344347 I_Error( "\"%s\" has no name.", name.GetChars( ));
345- if ( strlen( g_GameModes[i].szShortName ) == 0 )
348+ if ( g_GameModes[i].ShortName.IsEmpty( ))
346349 I_Error( "\"%s\" has no short name.", name.GetChars( ));
347350
348351 // [AK] Get the game mode type (cooperative, deathmatch, or team game). There shouldn't be more than one enabled or none at all.
@@ -383,39 +386,39 @@
383386
384387 //*****************************************************************************
385388 //
386-char *GAMEMODE_GetShortName( GAMEMODE_e GameMode )
387-{
388- if ( GameMode >= NUM_GAMEMODES )
389- return ( NULL );
390-
391- return ( g_GameModes[GameMode].szShortName );
392-}
393-
394-//*****************************************************************************
395-//
396-char *GAMEMODE_GetName( GAMEMODE_e GameMode )
389+const char *GAMEMODE_GetShortName( GAMEMODE_e GameMode )
397390 {
398391 if ( GameMode >= NUM_GAMEMODES )
399392 return ( NULL );
400393
401- return ( g_GameModes[GameMode].szName );
394+ return ( g_GameModes[GameMode].ShortName.GetChars( ));
402395 }
403396
404397 //*****************************************************************************
405398 //
406-char *GAMEMODE_GetCurrentName( void )
399+const char *GAMEMODE_GetName( GAMEMODE_e GameMode )
407400 {
408- return ( g_GameModes[g_CurrentGameMode].szName );
401+ if ( GameMode >= NUM_GAMEMODES )
402+ return ( NULL );
403+
404+ return ( g_GameModes[GameMode].Name.GetChars( ));
409405 }
410406
411407 //*****************************************************************************
412408 //
413-char *GAMEMODE_GetF1Texture( GAMEMODE_e GameMode )
409+const char *GAMEMODE_GetCurrentName( void )
410+{
411+ return ( g_GameModes[g_CurrentGameMode].Name.GetChars( ));
412+}
413+
414+//*****************************************************************************
415+//
416+const char *GAMEMODE_GetF1Texture( GAMEMODE_e GameMode )
414417 {
415418 if ( GameMode >= NUM_GAMEMODES )
416419 return ( NULL );
417420
418- return ( g_GameModes[GameMode].szF1Texture );
421+ return ( g_GameModes[GameMode].F1Texture.GetChars( ));
419422 }
420423
421424 //*****************************************************************************
diff -r f95780860a9f -r 36def6dbea37 src/gamemode.h
--- a/src/gamemode.h Sun Sep 18 22:37:44 2022 -0400
+++ b/src/gamemode.h Thu Sep 22 08:47:41 2022 -0400
@@ -154,21 +154,21 @@
154154 typedef struct
155155 {
156156 // Flags for this game mode.
157- ULONG ulFlags;
157+ ULONG ulFlags;
158158
159159 // [RC] The name of this game mode.
160- char szName[32];
160+ FString Name;
161161
162162 // This is what's displayed in the internal browser for a server's game mode.
163- char szShortName[9];
163+ FString ShortName;
164164
165165 // This is the name of the texture that displays when we press the F1 key in
166166 // this game mode.
167- char szF1Texture[9];
167+ FString F1Texture;
168168
169169 // [AK] All of the gameplay or compatibility flags we set for this game mode
170170 // (dmflags, compatflags, lmsallowedweapons, lmsspectatorsettings, etc.).
171- LONG lFlagsets[NUM_FLAGSETS][3];
171+ LONG lFlagsets[NUM_FLAGSETS][3];
172172
173173 } GAMEMODE_s;
174174
@@ -181,10 +181,10 @@
181181 void GAMEMODE_ParseGamemodeInfo( void );
182182 ULONG GAMEMODE_GetFlags( GAMEMODE_e GameMode );
183183 ULONG GAMEMODE_GetCurrentFlags( void );
184-char *GAMEMODE_GetShortName( GAMEMODE_e GameMode );
185-char *GAMEMODE_GetName( GAMEMODE_e GameMode );
186-char *GAMEMODE_GetCurrentName( void );
187-char *GAMEMODE_GetF1Texture( GAMEMODE_e GameMode );
184+const char *GAMEMODE_GetShortName( GAMEMODE_e GameMode );
185+const char *GAMEMODE_GetName( GAMEMODE_e GameMode );
186+const char *GAMEMODE_GetCurrentName( void );
187+const char *GAMEMODE_GetF1Texture( GAMEMODE_e GameMode );
188188 int GAMEMODE_GetFlagsetMask( GAMEMODE_e GameMode, FIntCVar *Flagset, bool bLocked = false );
189189 int GAMEMODE_GetCurrentFlagsetMask( FIntCVar *Flagset, bool bLocked = false );
190190 void GAMEMODE_DetermineGameMode( void );
diff -r f95780860a9f -r 36def6dbea37 src/win32/serverconsole/serverconsole.cpp
--- a/src/win32/serverconsole/serverconsole.cpp Sun Sep 18 22:37:44 2022 -0400
+++ b/src/win32/serverconsole/serverconsole.cpp Thu Sep 22 08:47:41 2022 -0400
@@ -1822,8 +1822,10 @@
18221822 SERVERCONSOLE_UpdateTitleString( sv_hostname.GetGenericRep( CVAR_String ).String );
18231823 }
18241824
1825- FString fsMapMode = "";
1826- fsMapMode.Format( "%s | %s", strupr( GAMEMODE_GetName( GAMEMODE_GetCurrentMode( ))), pszString );
1825+ FString fsMapMode = GAMEMODE_GetCurrentName( );
1826+ fsMapMode.ToUpper( );
1827+ fsMapMode.AppendFormat( " | %s", pszString );
1828+
18271829 SetDlgItemText( g_hDlg, IDC_MAPMODE, fsMapMode.GetChars( ));
18281830 }
18291831
Show on old repository browser