Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GameServerConfig: Fix broken migrations #614

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions Refresh.GameServer/Configuration/GameServerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,36 @@ protected override void Migrate(int oldVer, dynamic oldConfig)
{
if (oldVer < 18)
{
int oldSafetyLevel = (int)oldConfig.MaximumAssetSafetyLevel;
this.BlockedAssetFlags = new ConfigAssetFlags
// Asset safety level was added in config version 2, so dont try to migrate if we are coming from an older version than that
if (oldVer >= 2)
{
Dangerous = oldSafetyLevel < 3,
Modded = oldSafetyLevel < 2,
Media = oldSafetyLevel < 1,
};

// There was no version bump for trusted users being added, so we just have to catch this error :/
try
{
int oldTrustedSafetyLevel = (int)oldConfig.MaximumAssetSafetyLevelForTrustedUsers;
this.BlockedAssetFlagsForTrustedUsers = new ConfigAssetFlags
int oldSafetyLevel = (int)oldConfig.MaximumAssetSafetyLevel;
this.BlockedAssetFlags = new ConfigAssetFlags
{
Dangerous = oldTrustedSafetyLevel < 3,
Modded = oldTrustedSafetyLevel < 2,
Media = oldTrustedSafetyLevel < 1,
Dangerous = oldSafetyLevel < 3,
Modded = oldSafetyLevel < 2,
Media = oldSafetyLevel < 1,
};
}
catch (RuntimeBinderException)

// Asset safety level for trusted users was added in config version 12, so dont try to migrate if we are coming from a version older than that
if (oldVer >= 12)
{
this.BlockedAssetFlagsForTrustedUsers = this.BlockedAssetFlags;
// There was no version bump for trusted users being added, so we just have to catch this error :/
try
{
int oldTrustedSafetyLevel = (int)oldConfig.MaximumAssetSafetyLevelForTrustedUsers;
this.BlockedAssetFlagsForTrustedUsers = new ConfigAssetFlags
{
Dangerous = oldTrustedSafetyLevel < 3,
Modded = oldTrustedSafetyLevel < 2,
Media = oldTrustedSafetyLevel < 1,
};
}
catch (RuntimeBinderException)
{
this.BlockedAssetFlagsForTrustedUsers = this.BlockedAssetFlags;
}
}
}
}
Expand Down
Loading