Skip to content

Commit 127abdc

Browse files
Fix not being able to right click when holding air for selections. Fix deleteadmincrete permission not being used when sending block perms to client.
1 parent 5bc27e8 commit 127abdc

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

fCraft/Network/Player.Networking.cs

+26-23
Original file line numberDiff line numberDiff line change
@@ -1249,31 +1249,34 @@ internal void SendNewEntities(World world) {
12491249
}
12501250
}
12511251

1252-
internal void SendBlockPermissions() {
1253-
Block max = supportsCustomBlocks ? Map.MaxCustomBlockType : Map.MaxLegalBlockType;
1254-
bool build = World.Buildable, delete = World.Deletable;
1255-
for (Block block = Block.Stone; block <= max; block++) {
1256-
Send(Packet.MakeSetBlockPermission(block, build, delete));
1252+
bool CheckPlacePerm(Block block) {
1253+
switch (block) {
1254+
case Block.Air: return World.Deletable;
1255+
case Block.Grass: return Can(Permission.PlaceGrass);
1256+
case Block.Admincrete: return Can(Permission.PlaceAdmincrete);
1257+
case Block.Water:
1258+
case Block.StillWater: return Can(Permission.PlaceWater);
1259+
case Block.Lava:
1260+
case Block.StillLava: return Can(Permission.PlaceLava);
12571261
}
1262+
return true;
1263+
}
1264+
1265+
bool CheckDeletePerm(Block block) {
1266+
return block != Block.Admincrete || Can(Permission.DeleteAdmincrete);
1267+
}
1268+
1269+
internal void SendBlockPermissions() {
1270+
int max = supportsCustomBlocks ? (int)Map.MaxCustomBlockType : (int)Map.MaxLegalBlockType;
1271+
if (supportsBlockDefs) max = byte.MaxValue;
12581272

1259-
Send(Packet.MakeSetBlockPermission(Block.Admincrete,
1260-
build && Can(Permission.PlaceAdmincrete), delete && Can(Permission.PlaceAdmincrete)));
1261-
Send(Packet.MakeSetBlockPermission(
1262-
Block.Water, build && Can(Permission.PlaceWater), delete));
1263-
Send(Packet.MakeSetBlockPermission(
1264-
Block.StillWater, build && Can(Permission.PlaceWater), delete));
1265-
Send(Packet.MakeSetBlockPermission(
1266-
Block.Lava, build && Can(Permission.PlaceLava), delete));
1267-
Send(Packet.MakeSetBlockPermission(
1268-
Block.StillLava, build && Can(Permission.PlaceLava), delete));
1269-
Send(Packet.MakeSetBlockPermission(
1270-
Block.Grass, build && Can(Permission.PlaceGrass), delete));
1271-
1272-
if (!supportsBlockDefs) return;
1273-
BlockDefinition[] defs = World.BlockDefs;
1274-
for (int i = (int)Block.Air + 1; i < defs.Length; i++) {
1275-
if (defs[i] == null) continue;
1276-
Send(Packet.MakeSetBlockPermission((Block)i, build, delete));
1273+
for (int i = (int)Block.Air; i <= max; i++) {
1274+
Block block = (Block)i;
1275+
bool build = World.Buildable && CheckPlacePerm(block);
1276+
bool delete = World.Deletable && CheckDeletePerm(block);
1277+
1278+
if (i > (int)Map.MaxCustomBlockType && World.BlockDefs[i] == null) continue;
1279+
Send(Packet.MakeSetBlockPermission(block, build, delete));
12771280
}
12781281
}
12791282

0 commit comments

Comments
 (0)