• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-c誰得cocoaqtpythonrubywindowsphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

This is a fork of Zandronum Beta for TSPG.


Commit MetaInfo

Revision4041f8ff6edd006d31b6c32afcf5ee233ede29fb (tree)
Time2021-09-30 06:34:32
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Fixed serverinfo CVars not being changed correctly if they were entered as custom parameters on the command line.

Change Summary

Incremental Difference

diff -r 80f6abcba677 -r 4041f8ff6edd src/c_cvars.cpp
--- a/src/c_cvars.cpp Wed Sep 29 15:57:51 2021 -0400
+++ b/src/c_cvars.cpp Wed Sep 29 17:34:32 2021 -0400
@@ -80,6 +80,8 @@
8080 static TArray<FLatchedValue> LatchedValues;
8181 // [AK] Saved original values of CVars changed by ConsoleCommand.
8282 static TArray<FLatchedValue> SavedValues;
83+// [AK] A list of ServerInfo CVars entered as custom parameters on the command line.
84+static TArray<FLatchedValue> SavedServerInfoValues;
8385
8486 bool FBaseCVar::m_DoNoSet = false;
8587 bool FBaseCVar::m_UseCallback = false;
@@ -1743,6 +1745,19 @@
17431745 return CVars;
17441746 }
17451747
1748+// [AK] Restores values set for ServerInfo CVars on the command line.
1749+void C_RestoreServerInfoCVars( void )
1750+{
1751+ FLatchedValue var;
1752+
1753+ while ( SavedServerInfoValues.Pop( var ))
1754+ {
1755+ var.Variable->SetGenericRep( var.Value, var.Type );
1756+ if ( var.Type == CVAR_String )
1757+ delete[] var.Value.String;
1758+ }
1759+}
1760+
17461761 // [AK] Try to load a single mod CVar if it exists in the config file.
17471762 bool C_FindModCVar( FBaseCVar **cvar, const char *cvarname, bool userinfo = false )
17481763 {
@@ -1801,6 +1816,26 @@
18011816 else if (GetFlags() & CVAR_LATCH)
18021817 Printf ("%s will be changed for next game.\n", GetName());
18031818
1819+ // [AK] If this is a net ServerInfo CVar that was entered as a custom parameter on the
1820+ // command line, keep a copy of the value. We'll need to restore it once the server
1821+ // has read all ServerInfo CVars from its config file upon startup.
1822+ if ((gamestate == GS_STARTUP) && (NETWORK_GetState() == NETSTATE_SERVER))
1823+ {
1824+ if ((Flags & (CVAR_SERVERINFO | CVAR_ARCHIVE)) == (CVAR_SERVERINFO | CVAR_ARCHIVE))
1825+ {
1826+ FLatchedValue saved;
1827+ saved.Variable = this;
1828+ saved.Type = this->GetRealType();
1829+
1830+ if (saved.Type != CVAR_String)
1831+ saved.Value = this->GetGenericRep(saved.Type);
1832+ else
1833+ saved.Value.String = ncopystring(this->GetGenericRep(saved.Type).String);
1834+
1835+ SavedServerInfoValues.Push(saved);
1836+ }
1837+ }
1838+
18041839 // [AK] If this is a dummy mod CVar that was changed using ConsoleCommand, then make it
18051840 // accessible to ACS. This ensures mods that created their own CVars with the "set" and
18061841 // "archivecvar" CCMDs can still read the value of the CVar.
diff -r 80f6abcba677 -r 4041f8ff6edd src/c_cvars.h
--- a/src/c_cvars.h Wed Sep 29 15:57:51 2021 -0400
+++ b/src/c_cvars.h Wed Sep 29 17:34:32 2021 -0400
@@ -473,6 +473,9 @@
473473 // [Dusk] For CVar iteration
474474 FBaseCVar* C_GetRootCVar();
475475
476+// [AK] Restores values set for ServerInfo CVars on the command line.
477+void C_RestoreServerInfoCVars (void);
478+
476479 #define CUSTOM_CVAR(type,name,def,flags) \
477480 static void cvarfunc_##name(F##type##CVar &); \
478481 F##type##CVar name (#name, def, flags, cvarfunc_##name); \
diff -r 80f6abcba677 -r 4041f8ff6edd src/d_net.cpp
--- a/src/d_net.cpp Wed Sep 29 15:57:51 2021 -0400
+++ b/src/d_net.cpp Wed Sep 29 17:34:32 2021 -0400
@@ -1649,6 +1649,10 @@
16491649 {
16501650 GameConfig->ReadNetVars (); // [RH] Read network ServerInfo cvars
16511651 // D_ArbitrateNetStart ();
1652+
1653+ // [AK] Reading these CVars from the config file overwrites any values we had
1654+ // set for them on the command line. We need to restore them afterwards.
1655+ C_RestoreServerInfoCVars ();
16521656 }
16531657
16541658 // read values out of doomcom