Skip to content

Commit 7f928d8

Browse files
Merge branch 'master' of github.com:Hetal728/MCGalaxy
2 parents 8f2fc6c + b9308cd commit 7f928d8

27 files changed

+69
-37
lines changed

MCGalaxy/Commands/Fun/CmdLavaSurvival.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void HandleSetupBlock(Player p, string[] args) {
161161
}
162162

163163
void HandleSetupSafeZone(Player p, string[] args) {
164-
Player.Message(p, "Place two blocks to determine the edges.");
164+
Player.Message(p, "Place or break two blocks to determine the edges.");
165165
SetBlockHandler(p, 2);
166166
}
167167

MCGalaxy/Commands/Information/CmdMeasure.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override void Use(Player p, string message) {
3737
}
3838
}
3939

40-
Player.Message(p, "Place two blocks to determine the edges.");
40+
Player.Message(p, "Place or break two blocks to determine the edges.");
4141
p.MakeSelection(2, toIgnore, DoMeasure);
4242
}
4343

MCGalaxy/Commands/Information/WhoInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static void Output(Player p, WhoInfo who, bool canSeeIP) {
7878
if (Server.Devs.CaselessContains(who.Name.TrimEnd('+')))
7979
Player.Message(p, " Player is an &9{0} Developer", Server.SoftwareName);
8080
if (Server.Mods.CaselessContains(who.Name.TrimEnd('+')))
81-
Player.Message(p, " Player is an &9{1} Moderator", Server.SoftwareName);
81+
Player.Message(p, " Player is an &9{0} Moderator", Server.SoftwareName);
8282

8383
if (canSeeIP) {
8484
string ipMsg = who.IP;

MCGalaxy/Commands/Moderation/CmdUndoArea.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public override void Use(Player p, string message) {
4242
args.delta = CmdUndo.GetDelta(p, parts[0], parts, 1);
4343
if (args.delta == TimeSpan.MinValue) return;
4444

45-
Player.Message(p, "Place two blocks to determine the edges.");
45+
Player.Message(p, "Place or break two blocks to determine the edges.");
4646
p.MakeSelection(2, args, DoUndo);
4747
}
4848

MCGalaxy/Commands/Moderation/CmdZone.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public override void Use(Player p, string message) {
4444
} else if (args[0].CaselessEq("add")) {
4545
if (!CheckAdd(p, args, "zone add")) return;
4646

47-
Player.Message(p, "Place two blocks to determine the edges.");
47+
Player.Message(p, "Place or break two blocks to determine the edges.");
4848
Player.Message(p, "Zone for: &b" + args[1] + ".");
4949
p.MakeSelection(2, args[1], AddZone);
5050
} else if (args[0].CaselessEq("map")) {

MCGalaxy/Commands/World/CmdFixGrass.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public sealed class CmdFixGrass : Command {
2222
public override string shortcut { get { return "fg"; } }
2323
public override string type { get { return CommandTypes.World; } }
2424
public override bool museumUsable { get { return false; } }
25-
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
25+
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
2626

2727
public override void Use(Player p, string message) {
2828
int totalFixed = 0;

MCGalaxy/Commands/World/CmdNewLvl.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ internal bool GenerateMap(Player p, string message) {
4646
if (!CommandParser.GetUShort(p, args[3], "Length", ref z)) return false;
4747

4848
string seed = args.Length == 6 ? args[5] : "";
49-
if (!MapGen.OkayAxis(x)) { Player.Message(p, "width must be divisible by 16, and >= 16"); return false; }
50-
if (!MapGen.OkayAxis(y)) { Player.Message(p, "height must be divisible by 16, and >= 16"); return false; }
51-
if (!MapGen.OkayAxis(z)) { Player.Message(p, "length must be divisible by 16, and >= 16."); return false; }
52-
if (!CheckMapSize(p, x, y, z)) return false;
49+
ushort xFixed = (ushort)MapGen.MakeOkayAxis(x);
50+
ushort yFixed = (ushort)MapGen.MakeOkayAxis(y);
51+
ushort zFixed = (ushort)MapGen.MakeOkayAxis(z);
52+
if (!MapGen.OkayAxis(x)) { Player.Message(p, "&cWidth should be divisible by 16! %STruncating to " + xFixed + "."); }
53+
if (!MapGen.OkayAxis(y)) { Player.Message(p, "&cHeight should be divisible by 16! %STruncating to " + yFixed + "."); }
54+
if (!MapGen.OkayAxis(z)) { Player.Message(p, "&cLength should be divisible by 16! %STruncating to " + zFixed + "."); }
55+
if (!CheckMapSize(p, xFixed, yFixed, zFixed)) return false;
56+
x = xFixed;
57+
y = yFixed;
58+
z = zFixed;
5359

5460
if (!Formatter.ValidName(p, name, "level")) return false;
5561
if (LevelInfo.MapExists(name)) {

MCGalaxy/Commands/World/CmdResizeLvl.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public static bool DoResize(Player p, string[] args) {
4848
if (!CommandParser.GetUShort(p, args[2], "Height", ref y)) return true;
4949
if (!CommandParser.GetUShort(p, args[3], "Length", ref z)) return true;
5050

51-
if (!MapGen.OkayAxis(x)) { Player.Message(p, "width must be divisible by 16, and >= 16"); return true; }
52-
if (!MapGen.OkayAxis(y)) { Player.Message(p, "height must be divisible by 16, and >= 16"); return true; }
53-
if (!MapGen.OkayAxis(z)) { Player.Message(p, "length must be divisible by 16, and >= 16."); return true; }
51+
x = (ushort)MapGen.MakeOkayAxis(x);
52+
y = (ushort)MapGen.MakeOkayAxis(y);
53+
z = (ushort)MapGen.MakeOkayAxis(z);
5454
if (!CmdNewLvl.CheckMapSize(p, x, y, z)) return true;
5555

5656
bool confirmed = args.Length > 4 && args[4].CaselessEq("confirm");

MCGalaxy/Commands/building/CmdCenter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public sealed class CmdCenter : Command {
2828
public CmdCenter() { }
2929

3030
public override void Use(Player p, string message) {
31-
Player.Message(p, "Place two blocks to determine the edges.");
31+
Player.Message(p, "Place or break two blocks to determine the edges.");
3232
p.ClearBlockchange();
3333
p.MakeSelection(2, null, DoCentre);
3434
}

MCGalaxy/Commands/building/CmdCopy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void HandleOther(Player p, string opt, string[] parts, int offsetIndex) {
8787
Help(p); return;
8888
}
8989

90-
Player.Message(p, "Place two blocks to determine the edges.");
90+
Player.Message(p, "Place or break two blocks to determine the edges.");
9191
p.MakeSelection(2, cArgs, DoCopy);
9292
}
9393

MCGalaxy/Commands/building/CmdFill.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public sealed class CmdFill : DrawCmd {
2323
public override string name { get { return "fill"; } }
2424
public override string shortcut { get { return "f"; } }
2525
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
26-
protected override string PlaceMessage { get { return "Destroy the block you wish to fill."; } }
26+
protected override string PlaceMessage { get { return "Place or break a block to mark the area you wish to fill."; } }
2727
public override int MarksCount { get { return 1; } }
2828

2929
protected override DrawMode GetMode(string[] parts) {

MCGalaxy/Commands/building/CmdHollow.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public override void Use(Player p, string message) {
3535
if (skip == Block.Invalid) { Player.Message(p, "Cannot find block entered."); return; }
3636
}
3737

38-
Player.Message(p, "Place two blocks to determine the edges.");
38+
Player.Message(p, "Place or break two blocks to determine the edges.");
3939
p.MakeSelection(2, skip, DoHollow);
4040
}
4141

MCGalaxy/Commands/building/CmdImageprint.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public override void Use(Player p, string message) {
7777
if (!File.Exists("extra/images/" + dArgs.name + ".bmp")) {
7878
Player.Message(p, "The URL entered was invalid!"); return;
7979
}
80-
Player.Message(p, "Place two blocks to determine direction.");
80+
Player.Message(p, "Place or break two blocks to determine direction.");
8181
p.MakeSelection(2, dArgs, DoImage);
8282
}
8383

MCGalaxy/Commands/building/CmdLine.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace MCGalaxy.Commands.Building {
2323
public sealed class CmdLine : DrawCmd {
2424
public override string name { get { return "line"; } }
2525
public override string shortcut { get { return "l"; } }
26-
protected override string PlaceMessage { get { return "Place two blocks to determine the endpoints."; } }
26+
protected override string PlaceMessage { get { return "Place or break two blocks to determine the endpoints."; } }
2727

2828
protected override DrawMode GetMode(string[] parts) {
2929
string mode = parts[parts.Length - 1];

MCGalaxy/Commands/building/CmdMaze.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public override void Use(Player p, string message) {
3232
Help(p); return;
3333
}
3434

35-
Player.Message(p, "Place two blocks to determine the edges.");
35+
Player.Message(p, "Place or break two blocks to determine the edges.");
3636
p.MakeSelection(2, randomizer, DoMaze);
3737
}
3838

MCGalaxy/Commands/building/CmdOutline.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public override void Use(Player p, string message) {
3535
if (!CommandParser.GetBlockIfAllowed(p, args[0], out dArgs.block, out dArgs.extBlock)) return;
3636
if (!CommandParser.GetBlockIfAllowed(p, args[1], out dArgs.newBlock, out dArgs.newExtBlock)) return;
3737

38-
Player.Message(p, "Place two blocks to determine the edges.");
38+
Player.Message(p, "Place or break two blocks to determine the edges.");
3939
p.MakeSelection(2, dArgs, DoOutline);
4040
}
4141

MCGalaxy/Commands/building/CmdRainbow.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public sealed class CmdRainbow : Command {
2828
public CmdRainbow() { }
2929

3030
public override void Use(Player p, string message) {
31-
Player.Message(p, "Place two blocks to determine the edges.");
31+
Player.Message(p, "Place or break two blocks to determine the edges.");
3232
p.MakeSelection(2, null, DoRainbow);
3333
}
3434

MCGalaxy/Commands/building/CmdReplaceBrush.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public override void Use(Player p, string message) {
4141
string[] parts = message.SplitSpaces(3);
4242
if (!ValidateArgs(p, parts)) return;
4343

44-
Player.Message(p, "Place two blocks to determine the edges.");
44+
Player.Message(p, "Place or break two blocks to determine the edges.");
4545
p.MakeSelection(2, message, DoReplace);
4646
}
4747

MCGalaxy/Commands/building/CmdRestartPhysics.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public override void Use(Player p, string message) {
3333
message = message.ToLower();
3434
if (message != "" && !ParseArgs(p, message, ref extraInfo)) return;
3535

36-
Player.Message(p, "Place two blocks to determine the edges.");
36+
Player.Message(p, "Place or break two blocks to determine the edges.");
3737
p.MakeSelection(2, extraInfo, DoRestart);
3838
}
3939

MCGalaxy/Commands/building/CmdSPlace.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public override void Use(Player p, string message) {
4545

4646
DrawArgs dArgs = default(DrawArgs);
4747
dArgs.distance = distance; dArgs.interval = interval;
48-
Player.Message(p, "Place two blocks to determine direction.");
48+
Player.Message(p, "Place or break two blocks to determine direction.");
4949
p.MakeSelection(2, dArgs, DoSPlace);
5050
}
5151

MCGalaxy/Commands/building/CmdWrite.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public override void Use(Player p, string message) {
4444
WriteArgs wArgs = default(WriteArgs);
4545
wArgs.scale = scale; wArgs.spacing = spacing;
4646
wArgs.message = args[2].ToUpper();
47-
Player.Message(p, "Place two blocks to determine direction.");
47+
Player.Message(p, "Place or break two blocks to determine direction.");
4848
p.MakeSelection(2, wArgs, DoWrite);
4949
}
5050

MCGalaxy/Commands/building/DrawCmd.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected virtual bool DoDraw(Player p, Vec3S32[] marks,
6363
}
6464

6565
protected virtual string PlaceMessage {
66-
get { return "Place two blocks to determine the edges."; }
66+
get { return "Place or break two blocks to determine the edges."; }
6767
}
6868

6969

MCGalaxy/Commands/building/ReplaceCmd.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override void Use(Player p, string message) {
3737
string name = ReplaceNot ? "replacenot" : "replace";
3838
if (!BrushFactory.Find(name).Validate(args)) return;
3939

40-
Player.Message(p, "Place two blocks to determine the edges.");
40+
Player.Message(p, "Place or break two blocks to determine the edges.");
4141
p.MakeSelection(2, message.ToLower(), DoReplace);
4242
}
4343

MCGalaxy/Drawing/Transform/RotateTransform.cs

-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ void OutputBlock(DrawOpBlock b, Action<DrawOpBlock> output) {
6464
rotY = sinZ * dx + cosZ * dy;
6565
dx = rotX; dy = rotY;
6666

67-
Server.s.Log("BASE: " + b.X + ", " + b.Y + ", + " + b.Z);
68-
Server.s.Log("ROTATED: " + (dx + P.X) + ", " + (dy + P.Y) + ", " + (dz + P.Z));
69-
7067
b.X = (ushort)(dx + P.X + ((dx % 1) >= 0.5 ? 1 : 0));
7168
b.Y = (ushort)(dy + P.Y + ((dy % 1) >= 0.5 ? 1 : 0));
7269
b.Z = (ushort)(dz + P.Z + ((dz % 1) >= 0.5 ? 1 : 0));

MCGalaxy/Generator/HeightmapGen.cs

+27-2
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,40 @@ public static bool Generate(MapGenArgs args) {
8686
for (int z = 0; z < bmp.Height; z++)
8787
for (int x = 0; x < bmp.Width; x++)
8888
{
89+
const int drop = 2;
8990
int height = bmp.GetPixel(x, z).R * lvl.Height / 255;
91+
92+
byte dirtBlock = Block.dirt;
93+
byte grassBlock = Block.grass;
94+
95+
if (
96+
IsShorterBy(height, drop, bmp, lvl.Height, x-1, z) ||
97+
IsShorterBy(height, drop, bmp, lvl.Height, x+1, z) ||
98+
IsShorterBy(height, drop, bmp, lvl.Height, x, z-1) ||
99+
IsShorterBy(height, drop, bmp, lvl.Height, x, z+1)
100+
) {
101+
dirtBlock = Block.rock;
102+
grassBlock = Block.rock;
103+
}
104+
90105
for (int y = 0; y < height - 1; y++)
91-
lvl.blocks[index + oneY * y] = Block.dirt;
106+
lvl.blocks[index + oneY * y] = dirtBlock;
92107
if (height > 0)
93-
lvl.blocks[index + oneY * (height - 1)] = Block.grass;
108+
lvl.blocks[index + oneY * (height - 1)] = grassBlock;
94109
index++;
95110
}
96111
}
97112
return true;
98113
}
114+
115+
static bool IsShorterBy(int height, int drop, Bitmap bmp, ushort lvlHeight, int x, int z) {
116+
if (x >= bmp.Width || x < 0 || z >= bmp.Height || z < 0 ) {
117+
return false;
118+
}
119+
120+
int heightNeighbor = bmp.GetPixel(x, z).R * lvlHeight / 255;
121+
122+
return height - heightNeighbor >= drop;
123+
}
99124
}
100125
}

MCGalaxy/Generator/MapGen.cs

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public static void PrintThemes(Player p) {
4747
public static bool OkayAxis(int len) {
4848
return len >= 16 && len <= 8192 && (len % 16) == 0;
4949
}
50+
51+
public static int MakeOkayAxis(int len) {
52+
return (len / 16) * 16;
53+
}
5054

5155
public static bool Generate(Level lvl, string theme, string args, Player p) {
5256
MapGenArgs genArgs = new MapGenArgs();

MCGalaxy/Player/Player.Handlers.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -355,18 +355,18 @@ internal void CheckSurvival(ushort x, ushort y, ushort z) {
355355
byte bHead = GetSurvivalBlock(x, y, z);
356356

357357
if (level.PosToInt(x, y, z) != oldIndex || y != oldFallY) {
358-
bBody = Block.Convert(bBody);
358+
bFeet = Block.Convert(bFeet);
359359

360-
if (bBody == Block.air) {
360+
if (bFeet == Block.air) {
361361
if (y < oldFallY)
362362
fallCount++;
363363
else if (y > oldFallY) // flying up, for example
364364
fallCount = 0;
365365
oldFallY = y;
366366
drownCount = 0;
367367
return;
368-
} else if (!(bBody == Block.water || bBody == Block.waterstill ||
369-
bBody == Block.lava || bBody == Block.lavastill)) {
368+
} else if (!(bFeet == Block.water || bFeet == Block.waterstill ||
369+
bFeet == Block.lava || bFeet == Block.lavastill)) {
370370
if (fallCount > level.fall)
371371
HandleDeath(Block.air, 0, null, false, true);
372372
fallCount = 0;

0 commit comments

Comments
 (0)