- Timestamp:
- Oct 29, 2019, 11:20:45 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/ListLandProtection.cs
r326 r359 25 25 26 26 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 27 try { 28 if (_senderInfo.RemoteClientInfo != null) { 29 if (_params.Count >= 1 && _params [0].EqualsCaseInsensitive ("nearby")) { 30 _params.Add (_senderInfo.RemoteClientInfo.playerId); 31 } 27 if (_senderInfo.RemoteClientInfo != null) { 28 if (_params.Count >= 1 && _params [0].EqualsCaseInsensitive ("nearby")) { 29 _params.Add (_senderInfo.RemoteClientInfo.playerId); 32 30 } 31 } 33 32 34 35 33 World w = GameManager.Instance.World; 34 PersistentPlayerList ppl = GameManager.Instance.GetPersistentPlayerList (); 36 35 37 38 39 40 41 42 36 bool summaryOnly = false; 37 string steamIdFilter = string.Empty; 38 Vector3i closeTo = default (Vector3i); 39 bool onlyCloseToPlayer = false; 40 int closeToDistance = 32; 41 bool parseableOutput = false; 43 42 44 45 46 47 43 if (_params.Contains ("parseable")) { 44 parseableOutput = true; 45 _params.Remove ("parseable"); 46 } 48 47 49 50 48 if (_params.Count == 1) { 49 long tempLong; 51 50 52 if (_params [0].EqualsCaseInsensitive ("summary")) { 53 summaryOnly = true; 54 } else if (_params [0].Length == 17 && long.TryParse (_params [0], out tempLong)) { 55 steamIdFilter = _params [0]; 51 if (_params [0].EqualsCaseInsensitive ("summary")) { 52 summaryOnly = true; 53 } else if (_params [0].Length == 17 && long.TryParse (_params [0], out tempLong)) { 54 steamIdFilter = _params [0]; 55 } else { 56 ClientInfo ci = ConsoleHelper.ParseParamIdOrName (_params [0]); 57 if (ci != null) { 58 steamIdFilter = ci.playerId; 56 59 } else { 57 ClientInfo ci = ConsoleHelper.ParseParamIdOrName (_params [0]); 58 if (ci != null) { 59 steamIdFilter = ci.playerId; 60 } else { 61 SdtdConsole.Instance.Output ("Player name or entity id \"" + _params [0] + "\" not found."); 62 return; 63 } 64 } 65 } else if (_params.Count >= 2) { 66 if (_params [0].EqualsCaseInsensitive ("nearby")) { 67 try { 68 if (_params.Count == 3) { 69 if (!int.TryParse (_params [1], out closeToDistance)) { 70 SdtdConsole.Instance.Output ("Given length is not an integer!"); 71 return; 72 } 73 74 closeToDistance /= 2; 75 } 76 77 ClientInfo ci = ConsoleHelper.ParseParamSteamIdOnline (_params [_params.Count - 1]); 78 EntityPlayer ep = w.Players.dict [ci.entityId]; 79 closeTo = new Vector3i (ep.GetPosition ()); 80 onlyCloseToPlayer = true; 81 } catch (Exception e) { 82 SdtdConsole.Instance.Output ("Error getting current player's position"); 83 Log.Out ("Error in ListLandProtection.Run: " + e); 84 return; 85 } 86 } else { 87 SdtdConsole.Instance.Output ("Illegal parameter list"); 60 SdtdConsole.Instance.Output ("Player name or entity id \"" + _params [0] + "\" not found."); 88 61 return; 89 62 } 90 63 } 64 } else if (_params.Count >= 2) { 65 if (_params [0].EqualsCaseInsensitive ("nearby")) { 66 try { 67 if (_params.Count == 3) { 68 if (!int.TryParse (_params [1], out closeToDistance)) { 69 SdtdConsole.Instance.Output ("Given length is not an integer!"); 70 return; 71 } 72 73 closeToDistance /= 2; 74 } 75 76 ClientInfo ci = ConsoleHelper.ParseParamSteamIdOnline (_params [_params.Count - 1]); 77 EntityPlayer ep = w.Players.dict [ci.entityId]; 78 closeTo = new Vector3i (ep.GetPosition ()); 79 onlyCloseToPlayer = true; 80 } catch (Exception e) { 81 SdtdConsole.Instance.Output ("Error getting current player's position"); 82 Log.Out ("Error in ListLandProtection.Run: " + e); 83 return; 84 } 85 } else { 86 SdtdConsole.Instance.Output ("Illegal parameter list"); 87 return; 88 } 89 } 91 90 92 91 93 94 95 96 92 LandClaimList.OwnerFilter[] ownerFilters = null; 93 if (!string.IsNullOrEmpty (steamIdFilter)) { 94 ownerFilters = new[] {LandClaimList.SteamIdFilter (steamIdFilter)}; 95 } 97 96 98 99 100 101 97 LandClaimList.PositionFilter[] posFilters = null; 98 if (onlyCloseToPlayer) { 99 posFilters = new[] {LandClaimList.CloseToFilter2dRect (closeTo, closeToDistance)}; 100 } 102 101 103 102 Dictionary<Player, List<Vector3i>> claims = LandClaimList.GetLandClaims (ownerFilters, posFilters); 104 103 105 foreach (KeyValuePair<Player, List<Vector3i>> kvp in claims) { 106 SdtdConsole.Instance.Output (string.Format ( 107 "Player \"{0} ({1})\" owns {4} keystones (protected: {2}, current hardness multiplier: {3})", 108 kvp.Key.Name, 109 kvp.Key.SteamID, 110 kvp.Key.LandProtectionActive, 111 kvp.Key.LandProtectionMultiplier, 112 kvp.Value.Count)); 113 if (!summaryOnly) { 114 foreach (Vector3i v in kvp.Value) { 115 if (parseableOutput) { 116 SdtdConsole.Instance.Output ("LandProtectionOf: id=" + kvp.Key.SteamID + 117 ", playerName=" + kvp.Key.Name + ", location=" + v); 118 } else { 119 SdtdConsole.Instance.Output (" (" + v + ")"); 120 } 104 foreach (KeyValuePair<Player, List<Vector3i>> kvp in claims) { 105 SdtdConsole.Instance.Output (string.Format ( 106 "Player \"{0} ({1})\" owns {4} keystones (protected: {2}, current hardness multiplier: {3})", 107 kvp.Key.Name, 108 kvp.Key.SteamID, 109 kvp.Key.LandProtectionActive, 110 kvp.Key.LandProtectionMultiplier, 111 kvp.Value.Count)); 112 if (!summaryOnly) { 113 foreach (Vector3i v in kvp.Value) { 114 if (parseableOutput) { 115 SdtdConsole.Instance.Output ("LandProtectionOf: id=" + kvp.Key.SteamID + 116 ", playerName=" + kvp.Key.Name + ", location=" + v); 117 } else { 118 SdtdConsole.Instance.Output (" (" + v + ")"); 121 119 } 122 120 } 123 121 } 122 } 124 123 125 if (string.IsNullOrEmpty (steamIdFilter)) { 126 SdtdConsole.Instance.Output ("Total of " + ppl.m_lpBlockMap.Count + " keystones in the game"); 127 } 128 } catch (Exception e) { 129 Log.Out ("Error in ListLandProtection.Run: " + e); 124 if (string.IsNullOrEmpty (steamIdFilter)) { 125 SdtdConsole.Instance.Output ("Total of " + ppl.m_lpBlockMap.Count + " keystones in the game"); 130 126 } 131 127 }
Note:
See TracChangeset
for help on using the changeset viewer.