Skip to content

Commit 5e60925

Browse files
committed
Pre-allocate bools for config.ini checks
+ also disabling the removal of "cps" field, which causing the endless "Broken config.ini" dialog to appear for non-Bilibili games
1 parent 0fbb35b commit 5e60925

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

CollapseLauncher/Classes/GameManagement/GameVersion/BaseClass/GameVersionBase.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,12 @@ protected virtual bool IsGameConfigIdValid()
819819
|| GamePreset.SubChannelID == null)
820820
return true;
821821

822-
if (!GameIniVersion[_defaultIniVersionSection].ContainsKey(ChannelIdKeyName)
823-
|| !GameIniVersion[_defaultIniVersionSection].ContainsKey(SubChannelIdKeyName)
824-
|| !GameIniVersion[_defaultIniVersionSection].ContainsKey(CpsKeyName))
822+
bool isContainsChannelId = GameIniVersion[_defaultIniVersionSection].ContainsKey(ChannelIdKeyName);
823+
bool isContainsSubChannelId = GameIniVersion[_defaultIniVersionSection].ContainsKey(SubChannelIdKeyName);
824+
bool isCps = GameIniVersion[_defaultIniVersionSection].ContainsKey(CpsKeyName);
825+
if (!isContainsChannelId
826+
|| !isContainsSubChannelId
827+
|| !isCps)
825828
return false;
826829

827830
string? channelIdCurrent = GameIniVersion[_defaultIniVersionSection][ChannelIdKeyName].ToString();
@@ -992,20 +995,24 @@ public void UpdateGameVersion(GameVersion? version, bool saveValue = true)
992995

993996
public void UpdateGameChannels(bool saveValue = true)
994997
{
995-
bool isBilibili = GamePreset.ZoneName == "Bilibili";
996998
GameIniVersion[_defaultIniVersionSection]["channel"] = gameChannelID;
997999
GameIniVersion[_defaultIniVersionSection]["sub_channel"] = gameSubChannelID;
9981000
GameIniVersion[_defaultIniVersionSection]["cps"] = gameCps;
999-
1001+
1002+
/* Disable these lines as these will trigger some bugs (like Endless "Broken config.ini" dialog)
1003+
* and causes the cps field to be missing for other non-Bilibili games
1004+
*
10001005
// Remove the contains section if the client is not Bilibili and it does have the value.
10011006
// This to avoid an issue with HSR config.ini detection
1007+
bool isBilibili = GamePreset.ZoneName == "Bilibili";
10021008
if ( !isBilibili
10031009
&& GameIniVersion.ContainsSection(_defaultIniVersionSection)
10041010
&& GameIniVersion[_defaultIniVersionSection].ContainsKey("cps")
10051011
&& GameIniVersion[_defaultIniVersionSection]["cps"].ToString().IndexOf("bilibili", StringComparison.OrdinalIgnoreCase) >= 0)
10061012
{
10071013
GameIniVersion[_defaultIniVersionSection].Remove("cps");
10081014
}
1015+
*/
10091016

10101017
if (saveValue)
10111018
{

0 commit comments

Comments
 (0)