Skip to content

Commit

Permalink
v0.8.64 Silica Admin Mod Patches
Browse files Browse the repository at this point in the history
  • Loading branch information
data-bomb committed Jul 12, 2024
1 parent 1e64385 commit bf574dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions Si_AdminMod/Event_Roles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public static bool Prefix(MP_Strategy __instance, ref GameByteStreamReader __0,
}

// only look at RPC_RequestRole
if (__1 != (byte)MP_Strategy.ERPCs.REQUEST_ROLE)
if (__1 != (byte)GameModeExt.ERPCs.REQUEST_ROLE)
{
return true;
}

Player requestingPlayer = Player.FindPlayer((CSteamID)__0.ReadUInt64(), (int)__0.ReadByte());
MP_Strategy.ETeamRole eRole = (MP_Strategy.ETeamRole)__0.ReadByte();
GameModeExt.ETeamRole eRole = (GameModeExt.ETeamRole)__0.ReadByte();

if (requestingPlayer == null)
{
Expand All @@ -70,15 +70,15 @@ public static bool Prefix(MP_Strategy __instance, ref GameByteStreamReader __0,
}

// would the game code treat it as an infantry/no role request?
if (eRole != MP_Strategy.ETeamRole.COMMANDER || __instance.GetCommanderForTeam(requestingPlayer.Team))
if (eRole != GameModeExt.ETeamRole.COMMANDER || __instance.GetCommanderForTeam(requestingPlayer.Team))
{
__0 = RestoreRPC_RequestRoleReader(requestingPlayer, eRole);
FireOnRoleChangedEvent(requestingPlayer, eRole);
return true;
}

StrategyTeamSetup strategyTeamSetup = __instance.GetStrategyTeamSetup(requestingPlayer.Team);
if (strategyTeamSetup == null)
BaseTeamSetup baseTeamSetup = __instance.GetTeamSetup(requestingPlayer.Team);
if (baseTeamSetup == null)
{
return false;
}
Expand All @@ -92,26 +92,26 @@ public static bool Prefix(MP_Strategy __instance, ref GameByteStreamReader __0,
{
MelonLogger.Msg("Preventing Spawn");
__instance.SpawnUnitForPlayer(requestingPlayer, requestingPlayer.Team);
FireOnRoleChangedEvent(requestingPlayer, MP_Strategy.ETeamRole.INFANTRY);
FireOnRoleChangedEvent(requestingPlayer, GameModeExt.ETeamRole.INFANTRY);
}

return false;
}

MelonLogger.Msg("Allowing to join commander");
#if NET6_0
__instance.SetCommander(strategyTeamSetup.Team, requestingPlayer);
__instance.RPC_SynchCommander(strategyTeamSetup.Team);
__instance.SetCommander(baseTeamSetup.Team, requestingPlayer);
__instance.RPC_SynchCommander(baseTeamSetup.Team);
#else
Type strategyType = typeof(MP_Strategy);
MethodInfo setCommanderMethod = strategyType.GetMethod("SetCommander", BindingFlags.Instance | BindingFlags.NonPublic);
setCommanderMethod.Invoke(__instance, parameters: new object?[] { strategyTeamSetup.Team, requestingPlayer });
setCommanderMethod.Invoke(__instance, parameters: new object?[] { baseTeamSetup.Team, requestingPlayer });

MethodInfo synchCommanderMethod = strategyType.GetMethod("RPC_SynchCommander", BindingFlags.Instance | BindingFlags.NonPublic);
synchCommanderMethod.Invoke(__instance, new object[] { strategyTeamSetup.Team });
synchCommanderMethod.Invoke(__instance, new object[] { baseTeamSetup.Team });
#endif

FireOnRoleChangedEvent(requestingPlayer, MP_Strategy.ETeamRole.COMMANDER);
FireOnRoleChangedEvent(requestingPlayer, GameModeExt.ETeamRole.COMMANDER);

return false;
}
Expand All @@ -124,12 +124,12 @@ public static bool Prefix(MP_Strategy __instance, ref GameByteStreamReader __0,
}
}

public static GameByteStreamReader RestoreRPC_RequestRoleReader(Player requestingPlayer, MP_Strategy.ETeamRole role)
public static GameByteStreamReader RestoreRPC_RequestRoleReader(Player requestingPlayer, GameModeExt.ETeamRole role)
{
GameByteStreamWriter gameByteStreamWriter = GameByteStreamWriter.GetGameByteStreamWriter(0U, "Si_AdminMod::RestoreRPC_RequestRoleReader", true);
gameByteStreamWriter.WriteByte((byte)ENetworkPacketType.GameModeRPC);
gameByteStreamWriter.WriteByte(0);
gameByteStreamWriter.WriteByte((byte)MP_Strategy.ERPCs.REQUEST_ROLE);
gameByteStreamWriter.WriteByte((byte)GameModeExt.ERPCs.REQUEST_ROLE);
gameByteStreamWriter.WriteUInt64((ulong)requestingPlayer.PlayerID);
gameByteStreamWriter.WriteByte((byte)requestingPlayer.PlayerChannel);
gameByteStreamWriter.WriteByte((byte)role);
Expand All @@ -140,7 +140,7 @@ public static GameByteStreamReader RestoreRPC_RequestRoleReader(Player requestin
return gameByteStreamReader;
}

public static void FireOnRoleChangedEvent(Player player, MP_Strategy.ETeamRole role)
public static void FireOnRoleChangedEvent(Player player, GameModeExt.ETeamRole role)
{
MelonLogger.Msg("Firing Role Change Event for " + player.PlayerName + " to role " + role.ToString());

Expand Down
2 changes: 1 addition & 1 deletion Si_AdminMod/ModAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You should have received a copy of the GNU General Public License
using SilicaAdminMod;
using System.Drawing;

[assembly: MelonInfo(typeof(SiAdminMod), "Admin Mod", "2.0.873", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonInfo(typeof(SiAdminMod), "Admin Mod", "2.0.878", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonGame("Bohemia Interactive", "Silica")]

// Color.Cyan
Expand Down

0 comments on commit bf574dd

Please sign in to comment.