Skip to content

Commit

Permalink
Fix not being able to right click when holding air for selections. Fi…
Browse files Browse the repository at this point in the history
…x deleteadmincrete permission not being used when sending block perms to client.
  • Loading branch information
UnknownShadow200 committed Oct 10, 2018
1 parent 5bc27e8 commit 127abdc
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions fCraft/Network/Player.Networking.cs
Expand Up @@ -1249,31 +1249,34 @@ bool LoginSequence()
} }
} }


internal void SendBlockPermissions() { bool CheckPlacePerm(Block block) {
Block max = supportsCustomBlocks ? Map.MaxCustomBlockType : Map.MaxLegalBlockType; switch (block) {
bool build = World.Buildable, delete = World.Deletable; case Block.Air: return World.Deletable;
for (Block block = Block.Stone; block <= max; block++) { case Block.Grass: return Can(Permission.PlaceGrass);
Send(Packet.MakeSetBlockPermission(block, build, delete)); case Block.Admincrete: return Can(Permission.PlaceAdmincrete);
case Block.Water:
case Block.StillWater: return Can(Permission.PlaceWater);
case Block.Lava:
case Block.StillLava: return Can(Permission.PlaceLava);
} }
return true;
}

bool CheckDeletePerm(Block block) {
return block != Block.Admincrete || Can(Permission.DeleteAdmincrete);
}

internal void SendBlockPermissions() {
int max = supportsCustomBlocks ? (int)Map.MaxCustomBlockType : (int)Map.MaxLegalBlockType;
if (supportsBlockDefs) max = byte.MaxValue;


Send(Packet.MakeSetBlockPermission(Block.Admincrete, for (int i = (int)Block.Air; i <= max; i++) {
build && Can(Permission.PlaceAdmincrete), delete && Can(Permission.PlaceAdmincrete))); Block block = (Block)i;
Send(Packet.MakeSetBlockPermission( bool build = World.Buildable && CheckPlacePerm(block);
Block.Water, build && Can(Permission.PlaceWater), delete)); bool delete = World.Deletable && CheckDeletePerm(block);
Send(Packet.MakeSetBlockPermission(
Block.StillWater, build && Can(Permission.PlaceWater), delete)); if (i > (int)Map.MaxCustomBlockType && World.BlockDefs[i] == null) continue;
Send(Packet.MakeSetBlockPermission( Send(Packet.MakeSetBlockPermission(block, build, delete));
Block.Lava, build && Can(Permission.PlaceLava), delete));
Send(Packet.MakeSetBlockPermission(
Block.StillLava, build && Can(Permission.PlaceLava), delete));
Send(Packet.MakeSetBlockPermission(
Block.Grass, build && Can(Permission.PlaceGrass), delete));

if (!supportsBlockDefs) return;
BlockDefinition[] defs = World.BlockDefs;
for (int i = (int)Block.Air + 1; i < defs.Length; i++) {
if (defs[i] == null) continue;
Send(Packet.MakeSetBlockPermission((Block)i, build, delete));
} }
} }


Expand Down

0 comments on commit 127abdc

Please sign in to comment.