Skip to content
Permalink
Browse files

Now big /reach persists across world joins, unless a map has specific…

…ally set a small /mrd
  • Loading branch information...
UnknownShadow200 committed Feb 9, 2018
1 parent d88d70f commit e6f2505801754ea160064e665cb1a756132a2cb6
@@ -2273,7 +2273,7 @@ static class CpeCommands {
if (!short.TryParse(disString, out distance)) {
if (disString.CaselessEquals("normal") || disString.CaselessEquals("reset") ||
disString.CaselessEquals("default")) {
distance = 160;
distance = -1;
} else {
player.Message("Invalid distance!");
return;
@@ -2286,7 +2286,7 @@ static class CpeCommands {
}
}
player.Message("Set max reach distance for world &f{0}&S to &f{1} &S(&f{2}&S blocks)", world.ClassyName, distance, distance / 32);
world.maxReach = distance;
world.MaxReach = distance;

}

@@ -1206,8 +1206,7 @@ bool LoginSequence()
}

if (Supports(CpeExt.ClickDistance)) {
short reach = (World.maxReach < Info.ReachDistance && !IsStaff) ? World.maxReach : Info.ReachDistance;
SendNow(Packet.MakeSetClickDistance(reach));
SendNow(Packet.MakeSetClickDistance(ReachDistance));
}

if (Supports(CpeExt.MessageType) && !IsPlayingCTF) {
@@ -182,6 +182,10 @@ public sealed partial class Player : IClassy {
}
Message("&WYou can use /" + cmd.Name + " again in " + timeLeft + " seconds");
}

internal short ReachDistance {
get { return (Info.ReachDistance < World.MaxReach || World.MaxReach == -1 || IsStaff) ? Info.ReachDistance : World.MaxReach; }
}

/// <summary> The world that the player is currently on. May be null.
/// Use .JoinWorld() to make players teleport to another world. </summary>
@@ -790,8 +790,7 @@ public sealed partial class PlayerInfo {
target.MaxCopySlots = target.Info.Rank.CopySlots;

if (target.Supports(CpeExt.ClickDistance) && target.World != null) {
target.Send(Packet.MakeSetClickDistance((target.World.maxReach < ReachDistance
&& !target.IsStaff) ? target.World.maxReach : ReachDistance));
target.Send(Packet.MakeSetClickDistance(target.ReachDistance));
}
if (target.Supports(CpeExt.BlockPermissions) && target.World != null) {
target.SendBlockPermissions();
@@ -307,20 +307,6 @@ static unsafe class FormatUtil {
}


// Quicker Int32.Parse(string) by Karl Seguin
public static int Parse( [NotNull] string stringToConvert ) {
if( stringToConvert == null ) throw new ArgumentNullException( "stringToConvert" );
int value = 0;
int length = stringToConvert.Length;
fixed( char* characters = stringToConvert ) {
for( int i = 0; i < length; ++i ) {
value = 10 * value + ( characters[i] - 48 );
}
}
return value;
}


// UppercaseFirst by Sam Allen of http://www.dotnetperls.com
[NotNull]
public static string UppercaseFirst( this string s ) {
@@ -1007,7 +1007,7 @@ public sealed class World : IClassy {
#endregion

/// <summary> The max reachdistance of the map. </summary>
public short maxReach = 160;
public short MaxReach = -1;


/// <summary> Ensures that player name has the correct length (2-16 characters)
@@ -255,6 +255,10 @@ static void LoadWorldListEntry([NotNull] XElement el)
tempEl = el.Element("MOTD");
if (tempEl != null) world.MOTD = tempEl.Value;

tempEl = el.Element("MaxReach");
short reach;
if (tempEl != null && Int16.TryParse(tempEl.Value, out reach)) world.MaxReach = reach;

//XElement bhEl = el.Element("BlockHunt");
//if (bhEl != null) LoadBlockHuntSettings(world, worldName, bhEl);

@@ -356,9 +360,6 @@ static void LoadWorldListEntry([NotNull] XElement el)
if ((attr = el.Attribute("terrain")) != null) {
world.Texture = ParseString(attr, worldName);
}
if ((attr = el.Attribute("maxreach")) != null) {
world.maxReach = ParseShort(attr, worldName, 160, "normal");
}
if ((attr = el.Attribute("weather")) != null) {
world.Weather = ParseByte(attr, worldName, 0, "sunny");
}
@@ -555,6 +556,9 @@ static void LoadWorldListEntry([NotNull] XElement el)
if (!world.Deletable) {
temp.Add(new XAttribute("deletable", false));
}
if (world.MaxReach != -1) {
temp.Add(new XElement("MaxReach", world.MaxReach));
}

/*save BlockHunt settings
XElement BHunt = new XElement("BlockHunt");
@@ -613,8 +617,7 @@ static void LoadWorldListEntry([NotNull] XElement el)
elEnv.Add(new XAttribute("water", world.HorizonBlock.GetHashCode()));
elEnv.Add(new XAttribute("bedrock", world.EdgeBlock.GetHashCode()));
if (world.Texture != null)
elEnv.Add(new XAttribute("terrain", world.Texture));
elEnv.Add(new XAttribute("maxreach", world.maxReach));
elEnv.Add(new XAttribute("terrain", world.Texture));
elEnv.Add(new XAttribute("weather", world.Weather));

if (world.CloudsHeight != short.MinValue)

0 comments on commit e6f2505

Please sign in to comment.
You can’t perform that action at this time.