Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
dad1a19
Now we're cooking
N1Ran Jan 27, 2019
617f8a4
Voting updated with reset for admins
N1Ran Feb 2, 2019
93e01e5
This is the percentage limiter for voting system...derp
N1Ran Feb 2, 2019
c2cd494
funsies
N1Ran Feb 3, 2019
b21be2d
?
N1Ran Feb 3, 2019
fedea70
voting module updated
N1Ran Feb 6, 2019
1591f95
voting module updated
N1Ran Feb 7, 2019
8347c1f
voting module updated.
N1Ran Feb 7, 2019
77dc054
Merge branch 'Patron' into ToPatron
N1Ran Feb 9, 2019
aeb591a
GPS Marker for grids list command
N1Ran Feb 9, 2019
b9239dc
some faction functions
N1Ran Feb 9, 2019
514ea6e
List players online
N1Ran Feb 9, 2019
1ba4878
Faction functions
N1Ran Feb 10, 2019
a33e369
New method to calculate vote
N1Ran Feb 10, 2019
6592cbe
new method to calculate votes
N1Ran Feb 10, 2019
86af0de
twe
N1Ran Feb 10, 2019
72d72e0
tweak
N1Ran Feb 10, 2019
b44e4df
Booyah
N1Ran Feb 11, 2019
0160488
Added command to list players online with admin command (useful for d…
N1Ran Feb 11, 2019
e8a59a6
Added GPS marker option to Grids list command
N1Ran Feb 11, 2019
5cb7f03
added faction list and faction remove option to faction command
N1Ran Feb 11, 2019
a528dc1
Resolving conflict before uploading
N1Ran Feb 11, 2019
7271434
Rex's faction removal merged
N1Ran Feb 11, 2019
cb3d6c7
updated with patrol Torch
N1Ran Feb 11, 2019
3c4d312
comma makes a major difference
N1Ran Feb 13, 2019
e602ea5
Resolve
N1Ran Feb 14, 2019
57f4262
Merger
N1Ran Feb 14, 2019
cecb2de
New Faction feation
N1Ran Feb 15, 2019
3115e8d
AutoCommands revamp in progress
N1Ran Feb 16, 2019
9722ca0
Yet another fix for the damned voting module
N1Ran Feb 17, 2019
3a71685
AutoCommands major tweaks and another go at fixing the damned voting …
N1Ran Feb 17, 2019
0e8019e
Let's get those new goodies loaded and decrease conflicts
N1Ran Feb 17, 2019
3a6acc4
meh
N1Ran Feb 17, 2019
7c7442b
Remove Old method and added OnStart Trigger to AutoCommands
N1Ran Feb 18, 2019
2958523
Run on Start trigger added
N1Ran Feb 18, 2019
ffc03e6
updated
N1Ran Feb 18, 2019
326820a
Here are the commit addressing the review.
N1Ran Feb 20, 2019
cf60893
Lets clear things up and look professional 🕴
N1Ran Feb 20, 2019
bb6e249
Merge branch 'Patron' into ToPatron
rexxar-tc Feb 21, 2019
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
New Faction feation
  • Loading branch information
N1Ran committed Feb 15, 2019
commit cecb2de0f16185c5c7b8e2266ced4e407544c5a3
83 changes: 50 additions & 33 deletions Essentials/Commands/WorldModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using Sandbox.ModAPI;
using SpaceEngineers.Game.GUI;
using Torch.Commands;
using Torch.Mod;
using Torch.Mod.Messages;
using Torch.Commands.Permissions;
using Torch.Managers;
using Torch.Utils;
Expand Down Expand Up @@ -49,7 +51,7 @@ public void CleanIdentities(int days)
count++;
}
}

RemoveEmptyFactions();
FixBlockOwnership();
Context.Respond($"Removed {count} old identities");
Expand Down Expand Up @@ -82,7 +84,7 @@ public void PurgeIdentities(int days)
}
}
}

RemoveEmptyFactions();
FixBlockOwnership();
Context.Respond($"Removed {count} old identities and {count2} grids owned by them.");
Expand All @@ -96,17 +98,6 @@ public void CleanFactions(int memberCount = 1)
Context.Respond($"Removed {count} factions with fewer than {memberCount} members.");
}

[Command("faction list", "lists all factions in the game")]
[Permission(MyPromoteLevel.Admin)]
public void ListFactions()
{
StringBuilder sb = new StringBuilder();
foreach(var faction in MySession.Static.Factions.ToList())
{
sb.Append($"{faction.Value.Tag}({faction.Value.Members.Count}) ");
}
Context.Respond(sb.ToString());
}

[Command("faction remove", "removes faction by tag name")]
[Permission(MyPromoteLevel.Admin)]
Expand All @@ -119,7 +110,7 @@ public void RemoveFaction(string tag)
}

var fac = MySession.Static.Factions.TryGetFactionByTag(tag);

if (fac != null)
{
RemoveFaction(fac);
Expand All @@ -135,29 +126,54 @@ public void RemoveFaction(string tag)
}
}

[Command("faction members", "lists members of given faction")]
[Command("faction info", "lists members of given faction")]
[Permission(MyPromoteLevel.Admin)]
public void FactionMembers(string tag)
public void FactionInfo()
{
if (tag == null)

StringBuilder sb = new StringBuilder();
double memberCount;

foreach (var factionID in MySession.Static.Factions)
{
Context.Respond("list a faction tag you would like to get members of");
return;
var faction = factionID.Value;
memberCount = faction.Members.Count();
sb.AppendLine();
sb.AppendLine($"{faction.Tag} - {memberCount} players in this faction");
foreach (var player in faction.Members)
{
var playerID = MySession.Static.Players.TryGetIdentity(player.Value.PlayerId);
sb.AppendLine($"{playerID.DisplayName}");
}
}
if (MySession.Static.Factions.FactionTagExists(tag))

//Just don't see the need for this anymore. Leaving for now in case it comes handy in the future
/*
else if (MySession.Static.Factions.FactionTagExists(tag))
{
StringBuilder sb = new StringBuilder();
var faction = MySession.Static.Factions.TryGetFactionByTag(tag);
memberCount = faction.Members.Count();

sb.AppendLine($"{faction.Tag} - {memberCount} players in this faction");
foreach (var player in faction.Members)
{
var playerID = MySession.Static.Players.TryGetIdentity(player.Value.PlayerId);
sb.Append($"{playerID.DisplayName}, ");
sb.AppendLine($"{playerID.DisplayName}");
}
Context.Respond(sb.ToString());

}
else
Context.Respond($"{tag} is not a faction on this server");

*/

if (Context.Player == null)
Context.Respond(sb.ToString());
else if (Context?.Player?.SteamUserId > 0)
{
ModCommunication.SendMessageTo(new DialogMessage("Faction Info", null, sb.ToString()), Context.Player.SteamUserId);
}


}

private static void RemoveEmptyFactions()
Expand Down Expand Up @@ -214,7 +230,7 @@ private static bool RemoveFromFaction_Internal(MyIdentity identity)
[ReflectedMethod(Name = "ApplyFactionStateChange", Type = typeof(MyFactionCollection))]
private static Action<MyFactionCollection, MyFactionStateChange, long, long, long, long> _applyFactionState;

private static MethodInfo _factionChangeSuccessInfo = typeof(MyFactionCollection).GetMethod("FactionStateChangeSuccess", BindingFlags.NonPublic|BindingFlags.Static);
private static MethodInfo _factionChangeSuccessInfo = typeof(MyFactionCollection).GetMethod("FactionStateChangeSuccess", BindingFlags.NonPublic | BindingFlags.Static);
private static readonly MethodInfo _factionStateChangeReq = typeof(MyFactionCollection).GetMethod("FactionStateChangeRequest", BindingFlags.Static | BindingFlags.NonPublic);
//TODO: This should probably be moved into Torch base, but I honestly cannot be bothered
/// <summary>
Expand All @@ -225,9 +241,10 @@ private static void RemoveFaction(MyFaction faction)
{
//bypass the check that says the server doesn't have permission to delete factions
//_applyFactionState(MySession.Static.Factions, MyFactionStateChange.RemoveFaction, faction.FactionId, faction.FactionId, 0L, 0L);
MyMultiplayer.RaiseStaticEvent(s =>
(Action<MyFactionStateChange, long, long, long, long>) Delegate.CreateDelegate(typeof(Action<MyFactionStateChange, long, long, long, long>), _factionStateChangeReq),
MyFactionStateChange.RemoveFaction, faction.FactionId, faction.FactionId, faction.FounderId, faction.FounderId);
//MyMultiplayer.RaiseStaticEvent(s =>
// (Action<MyFactionStateChange, long, long, long, long>) Delegate.CreateDelegate(typeof(Action<MyFactionStateChange, long, long, long, long>), _factionStateChangeReq),
// MyFactionStateChange.RemoveFaction, faction.FactionId, faction.FactionId, faction.FounderId, faction.FounderId);
NetworkManager.RaiseStaticEvent(_factionChangeSuccessInfo, MyFactionStateChange.RemoveFaction, faction.FactionId, faction.FactionId, 0L, 0L);
}

private static int FixBlockOwnership()
Expand All @@ -244,7 +261,7 @@ private static int FixBlockOwnership()
{
if (block.OwnerId == 0 || MySession.Static.Players.HasIdentity(block.OwnerId))
continue;

block.ChangeOwner(owner, share);
count++;
}
Expand All @@ -256,8 +273,8 @@ private static int FixBlockOwnership()
private static readonly FieldInfo GpsDicField = GpssField.FieldType.GetField("m_playerGpss", BindingFlags.NonPublic | BindingFlags.Instance);
private static readonly FieldInfo SeedParamField = typeof(MyProceduralWorldGenerator).GetField("m_existingObjectsSeeds", BindingFlags.NonPublic | BindingFlags.Instance);

private static readonly FieldInfo CamerasField = typeof(MySession).GetField("Cameras", BindingFlags.NonPublic|BindingFlags.Instance);
private static readonly FieldInfo AllCamerasField = CamerasField.FieldType.GetField("m_entityCameraSettings", BindingFlags.NonPublic|BindingFlags.Instance);
private static readonly FieldInfo CamerasField = typeof(MySession).GetField("Cameras", BindingFlags.NonPublic | BindingFlags.Instance);
private static readonly FieldInfo AllCamerasField = CamerasField.FieldType.GetField("m_entityCameraSettings", BindingFlags.NonPublic | BindingFlags.Instance);

[Command("sandbox clean", "Cleans up junk data from the sandbox file")]
[Permission(MyPromoteLevel.SpaceMaster)]
Expand Down Expand Up @@ -342,9 +359,9 @@ public void CleanSandbox()
}
count += idCache.Count;
idCache.Clear();

//delete chat history for deleted factions
for(int i = MySession.Static.FactionChatHistory.Count -1; i >=0; i--)
for (int i = MySession.Static.FactionChatHistory.Count - 1; i >= 0; i--)
{
var history = MySession.Static.FactionChatHistory[i];
if (MySession.Static.Factions.TryGetFactionById(history.FactionId1) == null || MySession.Static.Factions.TryGetFactionById(history.FactionId2) == null)
Expand Down