mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Import zones from .fcm maps
This commit is contained in:
parent
7ffef91aab
commit
89b4115635
@ -163,7 +163,7 @@ namespace MCGalaxy.Blocks {
|
||||
scope[idx].AnimalAI = (AnimalAI)ai;
|
||||
}
|
||||
if (parts.Length > 11) {
|
||||
byte.TryParse(parts[11], out scope[idx].StackId);
|
||||
byte.TryParse(parts[11], out scope[idx].StackId);
|
||||
}
|
||||
if (parts.Length > 12) {
|
||||
bool.TryParse(parts[12], out scope[idx].OPBlock);
|
||||
|
@ -115,24 +115,9 @@ namespace MCGalaxy.Commands.Info {
|
||||
owners.Join(n => PlayerInfo.GetColoredName(p, n)));
|
||||
}
|
||||
|
||||
static void PrintRanks(Player p, LevelAccessController access, string initial) {
|
||||
static void PrintRanks(Player p, AccessController access, string initial) {
|
||||
StringBuilder perms = new StringBuilder(initial);
|
||||
perms.Append(Group.GetColoredName(access.Min) + "%S+");
|
||||
if (access.Max != LevelPermission.Nobody)
|
||||
perms.Append(" up to " + Group.GetColoredName(access.Max));
|
||||
|
||||
List<string> whitelist = access.Whitelisted;
|
||||
foreach (string name in whitelist)
|
||||
perms.Append(", " + PlayerInfo.GetColoredName(p, name));
|
||||
|
||||
List<string> blacklist = access.Blacklisted;
|
||||
if (blacklist.Count == 0) { Player.Message(p, perms.ToString()); return; }
|
||||
|
||||
perms.Append( " %S(except ");
|
||||
foreach (string name in blacklist)
|
||||
perms.Append(PlayerInfo.GetColoredName(p, name) + ", ");
|
||||
perms.Remove(perms.Length - 2, 2);
|
||||
perms.Append("%S)");
|
||||
access.Describe(p, perms);
|
||||
Player.Message(p, perms.ToString());
|
||||
}
|
||||
|
||||
|
@ -108,13 +108,15 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
}
|
||||
|
||||
void SetZoneProp(Player p, string[] args, Zone zone) {
|
||||
if (args[2].CaselessEq("col")) {
|
||||
ColorDesc desc = default(ColorDesc);
|
||||
ColorDesc desc = default(ColorDesc);
|
||||
string opt = args[2];
|
||||
|
||||
if (opt.CaselessEq("col")) {
|
||||
if (!CommandParser.GetHex(p, args[3], ref desc)) return;
|
||||
|
||||
zone.Config.ShowColor = args[3];
|
||||
zone.ShowAll(p.level);
|
||||
} else if (args[2].CaselessEq("alpha")) {
|
||||
} else if (opt.CaselessEq("alpha")) {
|
||||
if (!CommandParser.GetByte(p, args[3], "Alpha", ref zone.Config.ShowAlpha)) return;
|
||||
zone.ShowAll(p.level);
|
||||
} else {
|
||||
|
@ -104,7 +104,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
}
|
||||
|
||||
void DoDrawImageCore(Player p, Vec3S32[] m, DrawArgs dArgs) {
|
||||
void DoDrawImageCore(Player p, Vec3S32[] marks, DrawArgs dArgs) {
|
||||
Bitmap bmp = HeightmapGen.ReadBitmap(dArgs.name, "extra/images/", p);
|
||||
if (bmp == null) return;
|
||||
try {
|
||||
@ -116,21 +116,15 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
ImagePrintDrawOp op = new ImagePrintDrawOp();
|
||||
int dir;
|
||||
if (Math.Abs(m[1].X - m[0].X) > Math.Abs(m[1].Z - m[0].Z)) {
|
||||
dir = m[1].X <= m[0].X ? 1 : 0;
|
||||
} else {
|
||||
dir = m[1].Z <= m[0].Z ? 3 : 2;
|
||||
}
|
||||
op.LayerMode = dArgs.layer; op.DualLayer = dArgs.dualLayered;
|
||||
op.CalcState(dir);
|
||||
op.CalcState(marks);
|
||||
|
||||
ResizeImage(p, m, op, ref bmp);
|
||||
ResizeImage(p, marks, op, ref bmp);
|
||||
op.SetLevel(p.level);
|
||||
op.Player = p; op.Source = bmp;
|
||||
|
||||
op.Palette = dArgs.palette; op.Filename = dArgs.name;
|
||||
DrawOpPerformer.Do(op, null, p, m, false);
|
||||
DrawOpPerformer.Do(op, null, p, marks, false);
|
||||
}
|
||||
|
||||
void ResizeImage(Player p, Vec3S32[] m, ImagePrintDrawOp op, ref Bitmap bmp) {
|
||||
|
@ -72,9 +72,9 @@ namespace MCGalaxy.Commands.Building {
|
||||
block.BlockID = Block.MB_White; block.ExtID = 0;
|
||||
if (name == "white") block.BlockID = Block.MB_White;
|
||||
if (name == "black") block.BlockID = Block.MB_Black;
|
||||
if (name == "air") block.BlockID = Block.MB_Air;
|
||||
if (name == "air") block.BlockID = Block.MB_Air;
|
||||
if (name == "water") block.BlockID = Block.MB_Water;
|
||||
if (name == "lava") block.BlockID = Block.MB_Lava;
|
||||
if (name == "lava") block.BlockID = Block.MB_Lava;
|
||||
|
||||
allMessage = block.BlockID == Block.MB_White && name != "white";
|
||||
if (p.level.Props[block.Index].IsMessageBlock) return block;
|
||||
|
@ -63,11 +63,11 @@ namespace MCGalaxy.Commands.Building {
|
||||
// Hardcoded aliases for backwards compatibility
|
||||
block.BlockID = Block.Invalid; block.ExtID = 0;
|
||||
if (name.Length == 0) block.BlockID = Block.Portal_Blue;
|
||||
if (name == "blue") block.BlockID = Block.Portal_Blue;
|
||||
if (name == "blue") block.BlockID = Block.Portal_Blue;
|
||||
if (name == "orange") block.BlockID = Block.Portal_Orange;
|
||||
if (name == "air") block.BlockID = Block.Portal_Air;
|
||||
if (name == "water") block.BlockID = Block.Portal_Water;
|
||||
if (name == "lava") block.BlockID = Block.Portal_Lava;
|
||||
if (name == "air") block.BlockID = Block.Portal_Air;
|
||||
if (name == "water") block.BlockID = Block.Portal_Water;
|
||||
if (name == "lava") block.BlockID = Block.Portal_Lava;
|
||||
|
||||
if (p.level.Props[block.Index].IsPortal) return block;
|
||||
Help(p); return ExtBlock.Invalid;
|
||||
|
@ -132,10 +132,17 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
}
|
||||
}
|
||||
|
||||
public void CalcState(int dir) {
|
||||
public void CalcState(Vec3S32[] m) {
|
||||
dx = default(Vec3S32); dy = default(Vec3S32); adj = default(Vec3S32);
|
||||
DualLayer = DualLayer && !LayerMode;
|
||||
|
||||
int dir;
|
||||
if (Math.Abs(m[1].X - m[0].X) > Math.Abs(m[1].Z - m[0].Z)) {
|
||||
dir = m[1].X <= m[0].X ? 1 : 0;
|
||||
} else {
|
||||
dir = m[1].Z <= m[0].Z ? 3 : 2;
|
||||
}
|
||||
|
||||
// Calculate back layer offset
|
||||
if (dir == 0) adj.Z = -1;
|
||||
if (dir == 1) adj.Z = +1;
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using MCGalaxy.Commands;
|
||||
|
||||
namespace MCGalaxy {
|
||||
@ -80,6 +81,28 @@ namespace MCGalaxy {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Describe(Player p, StringBuilder perms) {
|
||||
perms.Append(Group.GetColoredName(Min) + "%S+");
|
||||
if (Max != LevelPermission.Nobody) {
|
||||
perms.Append(" up to " + Group.GetColoredName(Max));
|
||||
}
|
||||
|
||||
List<string> whitelist = Whitelisted;
|
||||
foreach (string name in whitelist) {
|
||||
perms.Append(", " + PlayerInfo.GetColoredName(p, name));
|
||||
}
|
||||
|
||||
List<string> blacklist = Blacklisted;
|
||||
if (blacklist.Count == 0) return;
|
||||
|
||||
perms.Append(" %S(except ");
|
||||
foreach (string name in blacklist) {
|
||||
perms.Append(PlayerInfo.GetColoredName(p, name) + ", ");
|
||||
}
|
||||
perms.Remove(perms.Length - 2, 2);
|
||||
perms.Append("%S)");
|
||||
}
|
||||
|
||||
|
||||
public bool SetMin(Player p, Group grp) {
|
||||
string minType = "Min " + Type;
|
||||
|
@ -54,6 +54,14 @@ namespace MCGalaxy.Levels.IO {
|
||||
string group = ReadString(reader);
|
||||
string key = ReadString(reader);
|
||||
string value = ReadString(reader);
|
||||
|
||||
if (group != "zones") continue;
|
||||
try {
|
||||
ParseZone(lvl, value);
|
||||
} catch (Exception ex) {
|
||||
Logger.Log(LogType.Warning, "Error importing zone '" + key + "' from fCraft map");
|
||||
Logger.LogError(ex);
|
||||
}
|
||||
}
|
||||
int read = ds.Read(lvl.blocks, 0, lvl.blocks.Length);
|
||||
}
|
||||
@ -78,5 +86,47 @@ namespace MCGalaxy.Levels.IO {
|
||||
byte[] data = reader.ReadBytes(length);
|
||||
return Encoding.ASCII.GetString(data);
|
||||
}
|
||||
|
||||
static char[] comma = new char[] { ',' };
|
||||
static void ParseZone(Level lvl, string raw) {
|
||||
string[] parts = raw.Split(comma);
|
||||
string[] header = parts[0].SplitSpaces();
|
||||
Zone zone = new Zone(lvl);
|
||||
|
||||
// fCraft uses Z for height
|
||||
zone.Config.Name = header[0];
|
||||
zone.MinX = ushort.Parse(header[1]);
|
||||
zone.MinZ = ushort.Parse(header[2]);
|
||||
zone.MinY = ushort.Parse(header[3]);
|
||||
zone.MaxX = ushort.Parse(header[4]);
|
||||
zone.MaxZ = ushort.Parse(header[5]);
|
||||
zone.MaxY = ushort.Parse(header[6]);
|
||||
|
||||
// fCraft uses name#identifier for ranks
|
||||
string minRaw = header[7];
|
||||
int idStart = minRaw.IndexOf('#');
|
||||
if (idStart >= 0) minRaw = minRaw.Substring(0, idStart);
|
||||
Group minRank = Group.Find(minRaw);
|
||||
if (minRank != null) zone.Config.BuildMin = minRank.Permission;
|
||||
|
||||
// Extended ProCraft zone header adds colour
|
||||
if (header.Length > 8) {
|
||||
// header[8] is bool for 'showzone'
|
||||
zone.Config.ShowColor = header[9];
|
||||
zone.Config.ShowAlpha = byte.Parse(header[10]);
|
||||
}
|
||||
|
||||
if (parts[1].Length > 0) {
|
||||
string[] whitelist = parts[1].SplitSpaces();
|
||||
zone.Config.BuildWhitelist.AddRange(whitelist);
|
||||
}
|
||||
|
||||
if (parts[2].Length > 0) {
|
||||
string[] blacklist = parts[2].SplitSpaces();
|
||||
zone.Config.BuildBlacklist.AddRange(blacklist);
|
||||
}
|
||||
|
||||
zone.AddTo(lvl);
|
||||
}
|
||||
}
|
||||
}
|
@ -26,8 +26,8 @@ namespace MCGalaxy {
|
||||
public sealed class ZoneConfig : AreaConfig {
|
||||
[ConfigString("Name", "General", "", true)]
|
||||
public string Name = "";
|
||||
[ConfigString("ShowColor", "General", "", true)]
|
||||
public string ShowColor = "";
|
||||
[ConfigString("ShowColor", "General", "000000", true)]
|
||||
public string ShowColor = "000000";
|
||||
[ConfigByte("ShowAlpha", "General", 0)]
|
||||
public byte ShowAlpha = 0;
|
||||
|
||||
@ -120,7 +120,7 @@ namespace MCGalaxy {
|
||||
|
||||
ColorDesc col = Colors.ParseHex(Config.ShowColor);
|
||||
p.Send(Packet.MakeSelection(
|
||||
ID, "", new Vec3U16(MinX, MinY, MinZ),
|
||||
ID, Config.Name, new Vec3U16(MinX, MinY, MinZ),
|
||||
new Vec3U16((ushort)(MaxX + 1), (ushort)(MaxY + 1), (ushort)(MaxZ + 1)),
|
||||
col.R, col.G, col.B, Config.ShowAlpha, p.hasCP437));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user