Skip to content

Commit

Permalink
Merge pull request #54 from Goobwabber/dev-1.37.5
Browse files Browse the repository at this point in the history
Update to 1.37.5
  • Loading branch information
michael-r-elp authored Oct 9, 2024
2 parents d24e279 + 206ebf3 commit f93430c
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 284 deletions.
86 changes: 58 additions & 28 deletions MultiplayerCore/Models/MpStatusData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,96 @@ public class MpStatusData : MultiplayerStatusData
/// Handled by MultiplayerCore. If defined, and if a mod with a bad version is found, the multiplayer status
/// check fails and MUR-5 is returned.
/// </summary>
[JsonProperty("required_mods")]
public RequiredMod[]? requiredMods { get; set; }
public RequiredMod[]? requiredMods
{
get => required_mods;
set => required_mods = value;
}
public RequiredMod[]? required_mods;

/// <summary>
/// Handled by MultiplayerCore. If defined, and if the current game version exceeds this version, the
/// multiplayer status check fails and MUR-6 is returned.
/// </summary>
[JsonProperty("maximum_app_version")]
public string? maximumAppVersion { get; set; }
public string? maximumAppVersion
{
get => maximum_app_version;
set => maximum_app_version = value;
}
public string? maximum_app_version;

/// <summary>
/// Information only. Indicates whether dedicated server connections should use SSL/TLS. Currently, most modded
/// multiplayer servers do not use encryption.
/// </summary>
[JsonProperty("use_ssl")]
public bool useSsl { get; set; }
public bool useSsl
{
get => use_ssl;
set => use_ssl = value;
}
public bool use_ssl;

/// <summary>
/// Information only. Master server display name.
/// </summary>
[JsonProperty("name")]
public string? name { get; set; }

/// <summary>
/// Information only. Master server display description.
/// </summary>
[JsonProperty("description")]
public string? description { get; set; }

/// <summary>
/// Information only. Master server display image URL.
/// </summary>
[JsonProperty("image_url")]
public string? imageUrl { get; set; }
public string? imageUrl
{
get => image_url;
set => image_url = value;
}
public string? image_url;

/// <summary>
/// Information only. Maximum player count when creating new lobbies.
/// </summary>
[JsonProperty("max_players")]
public int maxPlayers { get; set; }
public int maxPlayers
{
get => max_players;
set => max_players = value;
}
public int max_players;

/// <summary>
/// Information only. Server capability: per-player modifiers.
/// </summary>
[JsonProperty("supports_pp_modifiers")]
public bool supportsPPModifiers { get; set; }
/// <summary>
/// Information only. Server capability: per-player modifiers.
/// </summary>
public bool supportsPPModifiers
{
get => supports_pp_modifiers;
set => supports_pp_modifiers = value;
}
public bool supports_pp_modifiers;

/// <summary>
/// Information only. Server capability: per-player difficulties.
/// </summary>
[JsonProperty("supports_pp_difficulties")]
public bool supportsPPDifficulties { get; set; }
/// <summary>
/// Information only. Server capability: per-player difficulties.
/// </summary>
public bool supportsPPDifficulties
{
get => supports_pp_difficulties;
set => supports_pp_difficulties = value;
}
public bool supports_pp_difficulties;

/// <summary>
/// Information only. Server capability: per-player level selection.
/// </summary>
[JsonProperty("supports_pp_maps")]
public bool supportsPPMaps { get; set; }
/// <summary>
/// Information only. Server capability: per-player level selection.
/// </summary>
public bool supportsPPMaps
{
get => supports_pp_maps;
set => supports_pp_maps = value;
}
public bool supports_pp_maps;

[Serializable]
[Serializable]
public class RequiredMod
{
/// <summary>
Expand Down
29 changes: 27 additions & 2 deletions MultiplayerCore/MultiplayerCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AssemblyName>MultiplayerCore</AssemblyName>
<AssemblyVersion>1.5.1</AssemblyVersion>
<AssemblyVersion>1.5.2</AssemblyVersion>
<TargetFramework>net472</TargetFramework>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
Expand Down Expand Up @@ -60,6 +60,11 @@
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BeatSaber.ViewSystem">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.ViewSystem.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BGLib.Polyglot">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.Polyglot.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -92,6 +97,11 @@
<Reference Include="DataModels" Publicize="True">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\DataModels.dll</HintPath>
</Reference>
<Reference Include="GameInit">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\GameInit.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="GameplayCore">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\GameplayCore.dll</HintPath>
<Private>False</Private>
Expand All @@ -105,15 +115,30 @@
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMRendering.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Interactable">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Interactable.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="LiteNetLib">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\LiteNetLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MenuSystem">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\MenuSystem.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="netstandard">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\netstandard.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="SegmentedControl">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\SegmentedControl.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="SemVer">
<HintPath>$(BeatSaberDir)\Libs\SemVer.dll</HintPath>
<Private>False</Private>
Expand Down Expand Up @@ -263,7 +288,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BeatSaberModdingTools.Tasks">
<Version>1.3.2</Version>
<Version>1.4.3</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
128 changes: 22 additions & 106 deletions MultiplayerCore/Patchers/BeatmapSelectionViewPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,11 @@ internal class BeatmapSelectionViewPatcher : IAffinity
private MpBeatmapLevelProvider _mpBeatmapLevelProvider;
private BeatmapLevelsModel _beatmapLevelsModel;

private static MethodInfo? _lbarInfo;
private static bool _newlbarInfo;


BeatmapSelectionViewPatcher(ILobbyPlayersDataModel playersDataModel, MpBeatmapLevelProvider mpBeatmapLevelProvider, BeatmapLevelsModel beatmapLevelsModel)
{
_mpPlayersDataModel = playersDataModel as MpPlayersDataModel;
_mpBeatmapLevelProvider = mpBeatmapLevelProvider;
_beatmapLevelsModel = beatmapLevelsModel;

_lbarInfo = AccessTools.Method(typeof(LevelBar), "Setup",
new Type[] { typeof(BeatmapLevel), typeof(BeatmapDifficulty), typeof(BeatmapCharacteristicSO) });
if (_lbarInfo != null) _newlbarInfo = true;
else _lbarInfo = AccessTools.Method(typeof(LevelBar), "Setup", new Type[] { typeof(BeatmapLevel), typeof(BeatmapCharacteristicSO), typeof(BeatmapDifficulty) });
if (_lbarInfo == null)
{
Plugin.Logger.Critical("Can't find a fitting LevelBar Method, is your game version supported?");
}
}

[AffinityPrefix]
Expand Down Expand Up @@ -96,14 +83,8 @@ IEnumerator SetBeatmapCoroutine(BeatmapSelectionView instance, BeatmapKey key, s


Plugin.Logger.Debug($"Calling Setup with level type: {level.GetType().Name}, beatmapCharacteristic type: {key.beatmapCharacteristic.GetType().Name}, difficulty type: {key.difficulty.GetType().Name} ");
if (_newlbarInfo)
{
_lbarInfo.Invoke(instance._levelBar, new object[] { level, key.difficulty, key.beatmapCharacteristic });
}
else
{
_lbarInfo.Invoke(instance._levelBar, new object[] { level, key.beatmapCharacteristic, key.difficulty });
}

instance._levelBar.Setup(level, key.difficulty, key.beatmapCharacteristic);
}
else
{
Expand All @@ -129,96 +110,31 @@ public static BeatmapLevel MakeBeatmapLevel(this MpBeatmap mpBeatmap, in Beatmap
0,
0,
0,
0,
new[] { mpBeatmap.LevelAuthorName },
Array.Empty<string>()
)
};

// For 1.35
var conInfo = AccessTools.Constructor(typeof(BeatmapLevel), new Type[]
{
typeof(bool),
typeof(string),
typeof(string),
typeof(string),
typeof(string),
typeof(string[]),
typeof(string[]),
typeof(float),
typeof(float),
typeof(float),
typeof(float),
typeof(float),
typeof(float),
typeof(PlayerSensitivityFlag),
typeof(IPreviewMediaData),
typeof(IReadOnlyDictionary<(BeatmapCharacteristicSO, BeatmapDifficulty), BeatmapBasicData>)
});
if (conInfo != null)
{
return (BeatmapLevel)conInfo.Invoke(new object[]
{
false,
mpBeatmap.LevelID,
mpBeatmap.SongName,
mpBeatmap.SongAuthorName,
mpBeatmap.SongSubName,
new[] { mpBeatmap.LevelAuthorName },
Array.Empty<string>(),
mpBeatmap.BeatsPerMinute,
-6.0f,
0,
0,
0,
mpBeatmap.SongDuration,
PlayerSensitivityFlag.Safe,
previewMediaData,
dict
});
}
// For 1.37
conInfo = AccessTools.Constructor(typeof(BeatmapLevel), new Type[]
{
typeof(int),
typeof(bool),
typeof(string),
typeof(string),
typeof(string),
typeof(string),
typeof(string[]),
typeof(string[]),
typeof(float),
typeof(float),
typeof(float),
typeof(float),
typeof(float),
typeof(float),
typeof(PlayerSensitivityFlag),
typeof(IPreviewMediaData),
typeof(IReadOnlyDictionary<(BeatmapCharacteristicSO, BeatmapDifficulty), BeatmapBasicData>)
});
if (conInfo != null)
return (BeatmapLevel)conInfo.Invoke(new object[]
{
0,
false,
mpBeatmap.LevelID,
mpBeatmap.SongName,
mpBeatmap.SongAuthorName,
mpBeatmap.SongSubName,
new[] { mpBeatmap.LevelAuthorName },
Array.Empty<string>(),
mpBeatmap.BeatsPerMinute,
-6.0f,
0,
0,
0,
mpBeatmap.SongDuration,
PlayerSensitivityFlag.Safe,
previewMediaData,
dict
});
throw new NotSupportedException("Game Version not supported");
return new BeatmapLevel(
0,
false,
mpBeatmap.LevelID,
mpBeatmap.SongName,
mpBeatmap.SongAuthorName,
mpBeatmap.SongSubName,
new[] { mpBeatmap.LevelAuthorName },
Array.Empty<string>(),
mpBeatmap.BeatsPerMinute,
-6.0f,
0,
0,
0,
mpBeatmap.SongDuration,
PlayerSensitivityFlag.Safe,
previewMediaData,
dict
);
}
}
}
Loading

0 comments on commit f93430c

Please sign in to comment.