• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

First Machine Age's Mods (Combined repo.)


Commit MetaInfo

Revisãofecb4caf9b5cf821dc400563d331dd30a3161c66 (tree)
Hora2019-11-18 08:28:10
Autormelchior <melchior@user...>
Commitermelchior

Mensagem de Log

W.I.P. #8B - progress on locksmith commands

Mudança Sumário

Diff

--- a/AccessControls/AccessControlMod.cs
+++ b/AccessControls/AccessControlMod.cs
@@ -453,7 +453,7 @@ namespace FirstMachineAge
453453 /// Removes the lock. (set A.C.N. back to LockState.None)
454454 /// </summary>
455455 /// <returns>The lock.</returns>
456- /// <param name="blockSel">Block sel.</param>
456+ /// <param name="blockPos">Block sel.</param>
457457 /// <param name="player">Player.</param>
458458 public void RemoveLock(BlockPos blockPos, IPlayer player)
459459 {
@@ -472,12 +472,21 @@ namespace FirstMachineAge
472472 Mod.Logger.VerboseDebug("De-lockify ACL entry @{0} by {1}", blockPos, player.PlayerName);
473473
474474 if (Server_ACN[chunkPos].Entries.ContainsKey(blockPos)) {
475- AccessControlNode remLockACN = Server_ACN[chunkPos].Entries[blockPos];
476- remLockACN.LockStyle = LockKinds.None;//Remove from other players ACN caches'
477- remLockACN.Tier = 0;
478475
479- //Send message to players that object was unlocked by a player
480- UpdateBroadcast(serverPlayer, blockPos, remLockACN);
476+ var remLockACN = Server_ACN[chunkPos].Entries[blockPos];
477+ if (remLockACN.LockStyle == LockKinds.Key && ACNs_byKeyID.ContainsKey(remLockACN.KeyID.Value))
478+ {
479+ ACNs_byKeyID.Remove(remLockACN.KeyID.Value);
480+ }
481+
482+ Server_ACN[chunkPos].Entries.Remove(blockPos);
483+
484+ remLockACN = new AccessControlNode();//Remove from other players ACN caches'
485+ Server_ACN[chunkPos].Entries.Add(blockPos, remLockACN);
486+ Server_ACN[chunkPos].Altered = true;
487+ //Send message to players that object was de-locked by a player
488+ UpdateBroadcast(serverPlayer, blockPos, remLockACN);
489+
481490 }
482491 else
483492 {
--- a/AccessControls/AccessControls_Internals.cs
+++ b/AccessControls/AccessControls_Internals.cs
@@ -660,7 +660,10 @@ namespace FirstMachineAge
660660 break;
661661 }
662662
663- stati.Add(entry.Key, lcn);
663+ if (stati.ContainsKey(entry.Key) == false)
664+ { stati.Add(entry.Key, lcn); }
665+ else
666+ { Mod.Logger.Error("Duplicate LSL entry @{0}", entry.Key); };
664667 }
665668
666669 return new LockStatusList(stati);
--- a/AccessControls/LocksmithCmd.cs
+++ b/AccessControls/LocksmithCmd.cs
@@ -51,7 +51,14 @@ namespace FirstMachineAge
5151 break;
5252
5353 case "remove":
54+ BlockPos targetPos;
55+ //if (args.Length > 0) {
56+ //targetPos = args.PopVec3i(null).AsBlockPos;
5457
58+ if (player.CurrentBlockSelection == null) return;
59+ targetPos = player.CurrentBlockSelection.Position.Copy( );
60+
61+ RemoveLock(targetPos, player);
5562 break;
5663
5764 case "destroy":
@@ -59,7 +66,7 @@ namespace FirstMachineAge
5966 break;
6067
6168 default:
62- player.SendMessage(GlobalConstants.CurrentChatGroup, "unecognised command", EnumChatType.CommandError);
69+ player.SendMessage(GlobalConstants.CurrentChatGroup, "unrecognised command", EnumChatType.CommandError);
6370 break;
6471
6572 }
@@ -77,13 +84,38 @@ namespace FirstMachineAge
7784
7885 }
7986
87+ private void RemoveLock(BlockPos targetPos, IServerPlayer player)
88+ {
89+ if (ServerAPI.World.BlockAccessor.IsValidPos(targetPos)) {
90+ var actualThing = ServerAPI.World.BlockAccessor.GetBlock(targetPos);
91+ if (actualThing.HasBehavior<BlockBehaviorComplexLockable>( )) {
92+ var acn = AccessControlsMod.RetrieveACN(targetPos);
93+
94+ if (acn != null)
95+ {
96+ if (acn.LockStyle != LockKinds.None) {
97+ AccessControlsMod.RemoveLock(targetPos, player);
98+ player.SendMessage(GlobalConstants.CurrentChatGroup, "OK, Lock Removed !", EnumChatType.CommandSuccess);
99+ }
100+ else { player.SendMessage(GlobalConstants.CurrentChatGroup, "ACN in Default 'None' state. (No lock)", EnumChatType.CommandError); }
101+ }
102+ else {player.SendMessage(GlobalConstants.CurrentChatGroup, "NO ACN (or lock...) there!", EnumChatType.CommandError); }
103+ }
104+ else { player.SendMessage(GlobalConstants.CurrentChatGroup, "Thing selected can't be lockable anyways...", EnumChatType.CommandError); }
105+ }
106+ else {
107+ player.SendMessage(GlobalConstants.CurrentChatGroup, "Invalid location selected", EnumChatType.CommandError);
108+ }
109+
110+ }
111+
80112 private void PrintNodes(IServerPlayer player, int groupId, CmdArgs args )
81113 {
82114 if (args.Length > 0) {
83115 var chunkPos = args.PopVec3i(null);
84116 }
85117 else {
86- BlockPos location = player.Entity.ServerPos.AsBlockPos; ;
118+ BlockPos location = player.Entity.ServerPos.AsBlockPos;
87119 Vec3i chunkPos = ServerAPI.World.BlockAccessor.ToChunkPos(location);
88120
89121 var acn_List = AccessControlsMod.RetrieveACNs_ByChunk(chunkPos);