Fix being able to place block when any of your coordinates are negative values, at guest rank.

This commit is contained in:
UnknownShadow200 2016-06-26 11:23:16 +10:00
parent 51fa8002df
commit 5449f32ca7
5 changed files with 24 additions and 11 deletions

View File

@ -37,7 +37,7 @@ namespace MCGalaxy.Commands.Building {
if (!p.HasBlockchange) { if (!p.HasBlockchange) {
Player.Message(p, "Cannot mark, no selection or cuboid in progress."); return; Player.Message(p, "Cannot mark, no selection or cuboid in progress."); return;
} }
p.ManualChange(P.X, P.Y, P.Z, 0, Block.rock); p.ManualChange(P.X, P.Y, P.Z, 0, Block.rock, 0, false);
Player.Message(p, "Mark placed at &b({0}, {1}, {2})", P.X, P.Y, P.Z); Player.Message(p, "Mark placed at &b({0}, {1}, {2})", P.X, P.Y, P.Z);
} }

View File

@ -46,11 +46,11 @@ namespace MCGalaxy.Commands
void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
p.ClearBlockchange(); p.ClearBlockchange();
if (type == Block.red) { if (type == Block.red) {
p.ManualChange(x, y, z, 1, Block.c4det, 0); p.ManualChange(x, y, z, 1, Block.c4det);
Player.Message(p, "Placed detonator block!"); Player.Message(p, "Placed detonator block!");
return; return;
} else if (type != Block.air) { } else if (type != Block.air) {
p.ManualChange(x, y, z, 1, Block.c4, 0); p.ManualChange(x, y, z, 1, Block.c4);
} }
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
} }

View File

@ -114,6 +114,7 @@ namespace MCGalaxy
public static List<Group> GroupList = new List<Group>(); public static List<Group> GroupList = new List<Group>();
public static Group standard; public static Group standard;
static readonly object saveLock = new object();
/// <summary> Load up all server groups </summary> /// <summary> Load up all server groups </summary>
public static void InitAll() { public static void InitAll() {
@ -146,9 +147,10 @@ namespace MCGalaxy
/// <summary> Save givenList group </summary> /// <summary> Save givenList group </summary>
/// <param name="givenList">The list of groups to save</param> /// <param name="givenList">The list of groups to save</param>
public static void saveGroups(List<Group> givenList) { public static void saveGroups(List<Group> givenList) {
GroupProperties.SaveGroups(givenList); lock (saveLock)
if (OnGroupSave != null) GroupProperties.SaveGroups(givenList);
OnGroupSave();
if (OnGroupSave != null) OnGroupSave();
OnGroupSaveEvent.Call(); OnGroupSaveEvent.Call();
} }

View File

@ -129,7 +129,13 @@ namespace MCGalaxy {
} }
} }
static readonly object saveLock = new object();
public static void Save(List<rankAllowance> givenList) { public static void Save(List<rankAllowance> givenList) {
lock (saveLock)
SaveCore(givenList);
}
static void SaveCore(List<rankAllowance> givenList) {
try { try {
using (StreamWriter w = new StreamWriter("properties/command.properties")) { using (StreamWriter w = new StreamWriter("properties/command.properties")) {
w.WriteLine("#Version 2"); w.WriteLine("#Version 2");

View File

@ -45,6 +45,11 @@ namespace MCGalaxy {
} }
public void ManualChange(ushort x, ushort y, ushort z, byte action, byte type, byte extType = 0) { public void ManualChange(ushort x, ushort y, ushort z, byte action, byte type, byte extType = 0) {
ManualChange(x, y, z, action, type, extType, true);
}
public void ManualChange(ushort x, ushort y, ushort z, byte action,
byte type, byte extType, bool checkPlaceDist) {
byte b = level.GetTile(x, y, z); byte b = level.GetTile(x, y, z);
if ( b == Block.Zero ) { return; } if ( b == Block.Zero ) { return; }
if ( jailed || !agreed ) { RevertBlock(x, y, z); return; } if ( jailed || !agreed ) { RevertBlock(x, y, z); return; }
@ -91,12 +96,12 @@ namespace MCGalaxy {
OnBlockChangeEvent.Call(this, x, y, z, type, extType); OnBlockChangeEvent.Call(this, x, y, z, type, extType);
if ( cancelBlock ) { cancelBlock = false; return; } if ( cancelBlock ) { cancelBlock = false; return; }
if ( group.Permission == LevelPermission.Banned ) return; if (group.Permission == LevelPermission.Banned) return;
if ( group.Permission == LevelPermission.Guest ) { if (checkPlaceDist && group.Permission == LevelPermission.Guest) {
int Diff = Math.Abs((pos[0] / 32) - x) + Math.Abs((pos[1] / 32) - y) int Diff = Math.Abs(((short)pos[0] / 32) - x) + Math.Abs(((short)pos[1] / 32) - y)
+ Math.Abs((pos[2] / 32) - z); + Math.Abs(((short)pos[2] / 32) - z);
if ((Diff > ReachDistance + 4) && !(lastCMD == "click" || lastCMD == "mark")) { if (Diff > ReachDistance + 4) {
Server.s.Log(name + " attempted to build with a " + Diff + " distance offset"); Server.s.Log(name + " attempted to build with a " + Diff + " distance offset");
SendMessage("You can't build that far away."); SendMessage("You can't build that far away.");
RevertBlock(x, y, z); return; RevertBlock(x, y, z); return;