Skip to content

Commit 3c503dc

Browse files
committed
HQLessHumansLose Fixes
- Pass result by reference to allow changes - Correctly detect 2-team situation in HvHvA
1 parent 18536c7 commit 3c503dc

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Si_HQlessHumansLose/Si_HQlessHumansLose.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ You should have received a copy of the GNU General Public License
3434
using System;
3535
using SilicaAdminMod;
3636

37-
[assembly: MelonInfo(typeof(HQlessHumansLose), "[Si] HQless Humans Lose", "1.2.8", "databomb", "https://github.com/data-bomb/Silica")]
37+
[assembly: MelonInfo(typeof(HQlessHumansLose), "HQless Humans Lose", "1.2.9", "databomb", "https://github.com/data-bomb/Silica")]
3838
[assembly: MelonGame("Bohemia Interactive", "Silica")]
3939
[assembly: MelonOptionalDependencies("Admin Mod")]
4040

@@ -76,7 +76,7 @@ static void HandleTimerSendLostMessage(object? source, ElapsedEventArgs e)
7676
lostMessageTimerExpired = true;
7777
}
7878

79-
public static bool OneFactionEliminated()
79+
public static bool OneFactionAlreadyEliminated()
8080
{
8181
int TeamsWithMajorStructures = 0;
8282
for (int i = 0; i < Team.Teams.Count; i++)
@@ -89,13 +89,13 @@ public static bool OneFactionEliminated()
8989
}
9090
}
9191

92-
if (TeamsWithMajorStructures < 3)
92+
if (TeamsWithMajorStructures < 2)
9393
{
94-
MelonLogger.Msg("OneFactionEliminated: true");
94+
MelonLogger.Msg("OneFactionAlreadyEliminated: true");
9595
return true;
9696
}
9797

98-
MelonLogger.Msg("OneFactionEliminated: false");
98+
MelonLogger.Msg("OneFactionAlreadyEliminated: false");
9999
return false;
100100
}
101101

@@ -107,7 +107,7 @@ public static void EliminateTeam(Team team)
107107
MelonLogger.Msg("Eliminating team " + team.TeamName + " on versus mode " + versusMode.ToString());
108108

109109
// are there still two remaining factions after this one is eliminated?
110-
if (versusMode == MP_Strategy.ETeamsVersus.HUMANS_VS_HUMANS_VS_ALIENS && !OneFactionEliminated())
110+
if (versusMode == MP_Strategy.ETeamsVersus.HUMANS_VS_HUMANS_VS_ALIENS && !OneFactionAlreadyEliminated())
111111
{
112112
// destroy structures
113113
for (int i = 0; i < team.Structures.Count; i++)
@@ -146,6 +146,8 @@ private static void DestroyAllUnits(Team team)
146146
// introduce a delay so clients can see chat message after round ends
147147
private static void DelayTeamLostMessage(Team team)
148148
{
149+
MelonLogger.Msg("Starting delay lost timer for team " + team.TeamName);
150+
149151
lostMessageTimerExpired = false;
150152
losingTeam = team;
151153

@@ -238,6 +240,8 @@ private static void Postfix(ConstructionSite __instance, bool __0)
238240
return;
239241
}
240242

243+
MelonLogger.Msg("Structure construction destroyed: " + __instance.name);
244+
241245
Team constructionSiteTeam = __instance.Team;
242246
String rootStructureMatchText = GetRootStructurePrefix(constructionSiteTeam);
243247
if (!__instance.ToString().Contains(rootStructureMatchText))
@@ -295,7 +299,7 @@ private static void Postfix(Team __instance)
295299
#endif
296300
private static class ApplyPatch_GetHasLost
297301
{
298-
private static void Postfix(StrategyTeamSetup __instance, bool __result)
302+
private static void Postfix(StrategyTeamSetup __instance, ref bool __result)
299303
{
300304
// only spend the CPU if the team is about to lose
301305
if (__result == true && GameMode.CurrentGameMode.GameOngoing)
@@ -316,7 +320,7 @@ private static void Postfix(StrategyTeamSetup __instance, bool __result)
316320
#endif
317321
private static class ApplyPatch_GetHasAnyMajorStructures
318322
{
319-
private static void Postfix(Team __instance, bool __result)
323+
private static void Postfix(Team __instance, ref bool __result)
320324
{
321325
// only spend the CPU if the team is about to lose
322326
if (__result == false && GameMode.CurrentGameMode.GameOngoing)
@@ -383,6 +387,8 @@ private static void Postfix(MP_Strategy __instance, Structure __0, EDamageType _
383387
return;
384388
}
385389

390+
MelonLogger.Msg("Structure destroyed: " + __0.name);
391+
386392
Team structureTeam = __0.Team;
387393
if (structureTeam == null)
388394
{

0 commit comments

Comments
 (0)