Skip to content

Commit 29cda66

Browse files
committed
Add nofences command
1 parent b0548fe commit 29cda66

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

src/BF2WebAdmin.Server/Commands/BF2/Heli2v2Commands.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,9 @@ public class SetTvMissileTypeCommand : BaseCommand
9797
public class ToggleTvLogCommand : BaseCommand
9898
{
9999
public string Name { get; set; }
100+
}
101+
102+
[Command("nofences", Auth.Admin)]
103+
public class NoFencesCommand : BaseCommand
104+
{
100105
}

src/BF2WebAdmin.Server/Modules/BF2/Heli2v2Module.cs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public class Heli2v2Module : BaseModule,
5252
IHandleCommandAsync<NasaCommand>,
5353
IHandleCommandAsync<GetTvMissileValuesCommand>,
5454
IHandleCommandAsync<SetTvMissileValueCommand>,
55-
IHandleCommandAsync<SetTvMissileTypeCommand>
55+
IHandleCommandAsync<SetTvMissileTypeCommand>,
56+
IHandleCommandAsync<NoFencesCommand>
5657
{
5758
private readonly IGameServer _gameServer;
5859
private readonly IMatchRepository _matchRepository;
@@ -1633,6 +1634,50 @@ await _matchRepository.InsertRoundAsync(ToRoundEntity(e.Round))
16331634
SwitchAll();
16341635
}
16351636
}
1637+
1638+
public async ValueTask HandleAsync(NoFencesCommand command)
1639+
{
1640+
var fenceTemplates = new[]
1641+
{
1642+
"fence_corrugated_3x12m",
1643+
"fence_corrugated_3x12m_broken",
1644+
"fence_corrugated_3x12m_broken_parts",
1645+
"wirefence_72m",
1646+
"wirefence_end",
1647+
"wirefence_48m",
1648+
"wirefence_24m",
1649+
"fence_corrugated_pole_3m",
1650+
"fence_corrugated_3x48m",
1651+
"fence_corrugated_3x24m",
1652+
"fence_corrugated_3x12m_corner_02",
1653+
"fence_corrugated_3x12m_corner_01",
1654+
"lamppost_highway_01"
1655+
};
1656+
1657+
var removedObjects = 0;
1658+
1659+
foreach (var fenceTemplate in fenceTemplates)
1660+
{
1661+
var response = await GameServer.GameWriter.GetRconResponseAsync("object.listObjectsOfTemplate " + fenceTemplate);
1662+
foreach (var line in response.Split('\b'))
1663+
{
1664+
var match = Regex.Match(line, "ID ([0-9]+)");
1665+
if (!match.Success)
1666+
continue;
1667+
1668+
var objectId = match.Groups[1].Value;
1669+
// GameServer.GameWriter.SendText(objectId + " | " + line);
1670+
GameServer.GameWriter.SendRcon(
1671+
$"object.active id{objectId}",
1672+
"object.delete"
1673+
);
1674+
1675+
removedObjects++;
1676+
}
1677+
}
1678+
1679+
GameServer.GameWriter.SendText($"Removed {removedObjects} fences and lamp posts");
1680+
}
16361681
}
16371682

16381683
public class ProjectilePath

0 commit comments

Comments
 (0)