yonilerner / cs2-retakes-allocator

Advanced weapon allocation for B3none/cs2-retakes
GNU General Public License v3.0
58 stars 16 forks source link

config file partially overwritten on server restart #79

Closed JesseMH closed 9 months ago

JesseMH commented 9 months ago

The config file in /addons/counterstrikesharp/plugins/RetakesAllocator/config/config.json is overwritten when I restart the server. I'm adding RoundTypeSelection and RoundTypeManualOrdering, which apply if I reload the file from the server, but restarting will overwrite it with the default values including any changes to RoundTypePercentages.

That said, my changes to the following don't get reverted:

DatabaseConnectionString DatabaseProvider AllowedWeaponSelectionTypes

yonilerner commented 9 months ago

Can you share the exact config thats getting overwritten?

JesseMH commented 9 months ago

Can you share the exact config thats getting overwritten?

Sure, I'm just adding the following. I'm not seeing any errors in the console on startup, and the json is valid when I check it. Here's a short video showing that it's overwritten on reboot. In the video I reload the config from the server, add the entries below for manual ordering, save it and it uploads to the server, then I reload the file from the server to show the new config has saved, then I reboot and reload the file which has reverted.

"RoundTypeSelection": [ "ManualOrdering" ], "RoundTypeManualOrdering": [ {"Type": "Pistol", "Count": 5}, {"Type": "FullBuy", "Count": 25}, {"Type": "Pistol", "Count": 1} ],

So the full config is:

{ "UsableWeapons": [ "Deagle", "Glock", "USPS", "HKP2000", "Elite", "Tec9", "P250", "CZ", "FiveSeven", "Revolver", "Mac10", "MP9", "MP7", "P90", "MP5SD", "Bizon", "UMP45", "XM1014", "Nova", "MAG7", "SawedOff", "M249", "Negev", "AK47", "M4A1S", "M4A1", "GalilAR", "Famas", "SG556", "AWP", "AUG", "SSG08", "SCAR20", "G3SG1" ], "AllowedWeaponSelectionTypes": [ "PlayerChoice", "Default" ], "RoundTypeSelection": [ "ManualOrdering" ], "RoundTypeManualOrdering": [ {"Type": "Pistol", "Count": 5}, {"Type": "FullBuy", "Count": 25}, {"Type": "Pistol", "Count": 1} ], "RoundTypePercentages": { "Pistol": 15, "HalfBuy": 25, "FullBuy": 60 }, "MigrateOnStartup": true, "AllowAllocationAfterFreezeTime": false, "EnableRoundTypeAnnouncement": true, "EnableNextRoundTypeVoting": false, "DatabaseProvider": "MySql", "DatabaseConnectionString": "REMOVED" }

yonilerner commented 9 months ago

Your issue is that RoundTypeSelection should be a string, not an array. So change this:

- "RoundTypeSelection": [
- "ManualOrdering"
- ],
+ "RoundTypeSelection": "ManualOrdering",
JesseMH commented 9 months ago

I've tried that too, works when I reload the config live but doesn't survive a reboot.

On Sun, Jan 21, 2024, 7:56 PM Yoni Lerner @.***> wrote:

Your issue is that RoundTypeSelection should be a string, not an array. So change this:

  • "RoundTypeSelection": [- "ManualOrdering"- ],+ "RoundTypeSelection": "ManualOrdering",

— Reply to this email directly, view it on GitHub https://github.com/yonilerner/cs2-retakes-allocator/issues/79#issuecomment-1902839429, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGL3MXZ7YF4KGJXLH3CYT2LYPW2KVAVCNFSM6AAAAABCDYPKZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBSHAZTSNBSHE . You are receiving this because you authored the thread.Message ID: @.***>

yonilerner commented 9 months ago

Can you send me the entire config you tried that didn't work?

Generally when there's an issue with the config, you'll see an error like this: image

JesseMH commented 9 months ago

I confirmed this works with PR #80 just fine, didn't otherwise work.

{ "UsableWeapons": [ "Deagle", "Glock", "USPS", "HKP2000", "Elite", "Tec9", "P250", "CZ", "FiveSeven", "Revolver", "Mac10", "MP9", "MP7", "P90", "MP5SD", "Bizon", "UMP45", "XM1014", "Nova", "MAG7", "SawedOff", "M249", "Negev", "AK47", "M4A1S", "M4A1", "GalilAR", "Famas", "SG556", "AWP", "AUG", "SSG08", "SCAR20", "G3SG1" ], "AllowedWeaponSelectionTypes": [ "PlayerChoice", "Default" ], "RoundTypePercentages": { "Pistol": 15, "HalfBuy": 25, "FullBuy": 60 }, "RoundTypeManualOrdering": [ {"Type": "Pistol", "Count": 5}, {"Type": "FullBuy", "Count": 25}, {"Type": "Pistol", "Count": 1} ], "RoundTypeSelection": "ManualOrdering", "MigrateOnStartup": false, "AllowAllocationAfterFreezeTime": false, "EnableRoundTypeAnnouncement": true, "EnableNextRoundTypeVoting": false, "DatabaseProvider": "MySql", "DatabaseConnectionString": "REMOVED" }

yonilerner commented 9 months ago

You accidentally included the DB connection string there. I removed it, but anyone watching this issue might have seen it so you may want to change the password

yonilerner commented 9 months ago

I just tried this config you pasted in and it worked for me. The plugin did re-add some defaults that were missing (you removed RoundTypeRandomFixedCounts so it added it back), and it reformatted it, but the actual contents of the config stayed the same:

{
  "UsableWeapons": [
    "Deagle",
    "Glock",
    "USPS",
    "HKP2000",
    "Elite",
    "Tec9",
    "P250",
    "CZ",
    "FiveSeven",
    "Revolver",
    "Mac10",
    "MP9",
    "MP7",
    "P90",
    "MP5SD",
    "Bizon",
    "UMP45",
    "XM1014",
    "Nova",
    "MAG7",
    "SawedOff",
    "M249",
    "Negev",
    "AK47",
    "M4A1S",
    "M4A1",
    "GalilAR",
    "Famas",
    "SG556",
    "AWP",
    "AUG",
    "SSG08",
    "SCAR20",
    "G3SG1"
  ],
  "AllowedWeaponSelectionTypes": [
    "PlayerChoice",
    "Default"
  ],
  "RoundTypeSelection": "ManualOrdering",
  "RoundTypePercentages": {
    "Pistol": 15,
    "HalfBuy": 25,
    "FullBuy": 60
  },
  "RoundTypeRandomFixedCounts": {
    "Pistol": 5,
    "HalfBuy": 10,
    "FullBuy": 15
  },
  "RoundTypeManualOrdering": [
    {
      "Type": "Pistol",
      "Count": 5
    },
    {
      "Type": "FullBuy",
      "Count": 25
    },
    {
      "Type": "Pistol",
      "Count": 1
    }
  ],
  "MigrateOnStartup": false,
  "AllowAllocationAfterFreezeTime": false,
  "EnableRoundTypeAnnouncement": true,
  "EnableNextRoundTypeVoting": false,
  "NumberOfExtraVipChancesForPreferredWeapon": 1,
  "DatabaseProvider": "MySql",
  "DatabaseConnectionString": "REMOVED"
}

I also notice that NumberOfExtraVipChancesForPreferredWeapon is not in your config so you may be on a slightly old version, but it should still work.

According to https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions.defaultignorecondition?view=net-7.0, the default value for DefaultIgnoreCondition is Never, so that PR isn't changing anything

JesseMH commented 9 months ago

Hm.. It's certainly changing something, by default the config did not have RoundTypeManualOrdering showing after a reboot and this shows that along with a few others. I was using version 1.2.7, but I can confirm that the issue doesn't exist on vanilla 1.2.11. Thanks for the help.