mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
Remove structs that always just get boxed to a reference type anyways.
This commit is contained in:
parent
901ad70064
commit
680f200d41
@ -85,11 +85,10 @@ namespace MCGalaxy.Commands.Maintenance {
|
||||
} else {
|
||||
Log("Server shutdown in " + args.Delay + " seconds");
|
||||
args.Delay--;
|
||||
task.State = args;
|
||||
}
|
||||
}
|
||||
|
||||
struct ShutdownArgs {
|
||||
class ShutdownArgs {
|
||||
public int Delay;
|
||||
public string Reason;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
void HandleOther(Player p, string opt, string[] parts, int offsetIndex) {
|
||||
CopyArgs cArgs = default(CopyArgs);
|
||||
CopyArgs cArgs = new CopyArgs();
|
||||
cArgs.offsetIndex = offsetIndex;
|
||||
|
||||
if (opt == "cut") {
|
||||
@ -160,7 +160,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
bool DoCopy(Player p, Vec3S32[] m, object state, ExtBlock block) { return false; }
|
||||
struct CopyArgs { public int type, offsetIndex; }
|
||||
class CopyArgs { public int type, offsetIndex; }
|
||||
|
||||
void SaveCopy(Player p, string file) {
|
||||
if (!Directory.Exists("extra/savecopy"))
|
||||
|
@ -45,7 +45,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
if (message.Length == 0) { Help(p); return; }
|
||||
string[] parts = message.SplitSpaces(3);
|
||||
|
||||
DrawArgs dArgs = default(DrawArgs);
|
||||
DrawArgs dArgs = new DrawArgs();
|
||||
dArgs.palette = ImagePalette.Find("color");
|
||||
if (dArgs.palette == null) dArgs.palette = ImagePalette.Palettes[0];
|
||||
dArgs.dualLayered = true;
|
||||
@ -135,7 +135,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
Player.Message(p, "%HModes: &fVertical, Vertical2Layer, Horizontal");
|
||||
}
|
||||
|
||||
struct DrawArgs { public bool layer, dualLayered; public ImagePalette palette; public string name; }
|
||||
class DrawArgs { public bool layer, dualLayered; public ImagePalette palette; public string name; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
if (message.Length == 0) { Help(p); return; }
|
||||
|
||||
bool allMessage = false;
|
||||
MBData data;
|
||||
MBArgs data = new MBArgs();
|
||||
string[] args = message.SplitSpaces(2);
|
||||
string block = args[0].ToLower();
|
||||
data.Block = GetBlock(p, block, ref allMessage);
|
||||
@ -107,12 +107,12 @@ namespace MCGalaxy.Commands.Building {
|
||||
|
||||
bool PlacedMark(Player p, Vec3S32[] marks, object state, ExtBlock block) {
|
||||
ushort x = (ushort)marks[0].X, y = (ushort)marks[0].Y, z = (ushort)marks[0].Z;
|
||||
MBData data = (MBData)state;
|
||||
MBArgs args = (MBArgs)state;
|
||||
|
||||
ExtBlock old = p.level.GetBlock(x, y, z);
|
||||
if (p.level.CheckAffectPermissions(p, x, y, z, old, data.Block)) {
|
||||
p.level.UpdateBlock(p, x, y, z, data.Block);
|
||||
UpdateDatabase(p, data, x, y, z);
|
||||
if (p.level.CheckAffectPermissions(p, x, y, z, old, args.Block)) {
|
||||
p.level.UpdateBlock(p, x, y, z, args.Block);
|
||||
UpdateDatabase(p, args, x, y, z);
|
||||
Player.Message(p, "Message block created.");
|
||||
} else {
|
||||
Player.Message(p, "Failed to create a message block.");
|
||||
@ -120,10 +120,10 @@ namespace MCGalaxy.Commands.Building {
|
||||
return true;
|
||||
}
|
||||
|
||||
void UpdateDatabase(Player p, MBData data, ushort x, ushort y, ushort z) {
|
||||
data.Message = data.Message.Replace("'", "\\'");
|
||||
data.Message = Colors.Escape(data.Message);
|
||||
data.Message = data.Message.UnicodeToCp437();
|
||||
void UpdateDatabase(Player p, MBArgs args, ushort x, ushort y, ushort z) {
|
||||
args.Message = args.Message.Replace("'", "\\'");
|
||||
args.Message = Colors.Escape(args.Message);
|
||||
args.Message = args.Message.UnicodeToCp437();
|
||||
|
||||
string lvlName = p.level.name;
|
||||
object locker = ThreadSafeCache.DBCache.GetLocker(lvlName);
|
||||
@ -139,15 +139,15 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
Database.Backend.AddRow("Messages" + lvlName, "X, Y, Z, Message", x, y, z, data.Message);
|
||||
Database.Backend.AddRow("Messages" + lvlName, "X, Y, Z, Message", x, y, z, args.Message);
|
||||
} else {
|
||||
Database.Backend.UpdateRows("Messages" + lvlName, "Message=@3",
|
||||
"WHERE X=@0 AND Y=@1 AND Z=@2", x, y, z, data.Message);
|
||||
"WHERE X=@0 AND Y=@1 AND Z=@2", x, y, z, args.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MBData { public string Message; public ExtBlock Block; }
|
||||
class MBArgs { public string Message; public ExtBlock Block; }
|
||||
|
||||
|
||||
void ShowMessageBlocks(Player p) {
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
PortalData data;
|
||||
PortalArgs data = new PortalArgs();
|
||||
data.Multi = false;
|
||||
string[] args = message.SplitSpaces();
|
||||
string block = message.Length == 0 ? "" : args[0].ToLower();
|
||||
@ -74,27 +74,27 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
void EntryChange(Player p, ushort x, ushort y, ushort z, ExtBlock block) {
|
||||
PortalData data = (PortalData)p.blockchangeObject;
|
||||
PortalArgs args = (PortalArgs)p.blockchangeObject;
|
||||
ExtBlock old = p.level.GetBlock(x, y, z);
|
||||
if (!p.level.CheckAffectPermissions(p, x, y, z, old, data.Block)) {
|
||||
if (!p.level.CheckAffectPermissions(p, x, y, z, old, args.Block)) {
|
||||
p.RevertBlock(x, y, z); return;
|
||||
}
|
||||
p.ClearBlockchange();
|
||||
|
||||
if (data.Multi && block.BlockID == Block.Red && data.Entries.Count > 0) {
|
||||
if (args.Multi && block.BlockID == Block.Red && args.Entries.Count > 0) {
|
||||
ExitChange(p, x, y, z, block); return;
|
||||
}
|
||||
|
||||
p.level.UpdateBlock(p, x, y, z, data.Block);
|
||||
p.level.UpdateBlock(p, x, y, z, args.Block);
|
||||
p.SendBlockchange(x, y, z, (ExtBlock)Block.Green);
|
||||
PortalPos Port;
|
||||
|
||||
Port.Map = p.level.name;
|
||||
Port.x = x; Port.y = y; Port.z = z;
|
||||
data.Entries.Add(Port);
|
||||
p.blockchangeObject = data;
|
||||
args.Entries.Add(Port);
|
||||
p.blockchangeObject = args;
|
||||
|
||||
if (!data.Multi) {
|
||||
if (!args.Multi) {
|
||||
p.Blockchange += ExitChange;
|
||||
Player.Message(p, "&aEntry block placed");
|
||||
} else {
|
||||
@ -107,10 +107,10 @@ namespace MCGalaxy.Commands.Building {
|
||||
void ExitChange(Player p, ushort x, ushort y, ushort z, ExtBlock block) {
|
||||
p.ClearBlockchange();
|
||||
p.RevertBlock(x, y, z);
|
||||
PortalData bp = (PortalData)p.blockchangeObject;
|
||||
PortalArgs args = (PortalArgs)p.blockchangeObject;
|
||||
string dstMap = p.level.name.UnicodeToCp437();
|
||||
|
||||
foreach (PortalPos P in bp.Entries) {
|
||||
foreach (PortalPos P in args.Entries) {
|
||||
string lvlName = P.Map;
|
||||
object locker = ThreadSafeCache.DBCache.GetLocker(lvlName);
|
||||
|
||||
@ -134,17 +134,17 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
}
|
||||
if (P.Map == p.level.name)
|
||||
p.SendBlockchange(P.x, P.y, P.z, bp.Block);
|
||||
p.SendBlockchange(P.x, P.y, P.z, args.Block);
|
||||
}
|
||||
|
||||
Player.Message(p, "&3Exit %Sblock placed");
|
||||
if (!p.staticCommands) return;
|
||||
bp.Entries.Clear();
|
||||
p.blockchangeObject = bp;
|
||||
args.Entries.Clear();
|
||||
p.blockchangeObject = args;
|
||||
p.Blockchange += EntryChange;
|
||||
}
|
||||
|
||||
struct PortalData { public List<PortalPos> Entries; public ExtBlock Block; public bool Multi; }
|
||||
class PortalArgs { public List<PortalPos> Entries; public ExtBlock Block; public bool Multi; }
|
||||
struct PortalPos { public ushort x, y, z; public string Map; }
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
Player.Message(p, "The Interval cannot be greater than the distance."); return;
|
||||
}
|
||||
|
||||
DrawArgs dArgs = default(DrawArgs);
|
||||
DrawArgs dArgs = new DrawArgs();
|
||||
dArgs.distance = distance; dArgs.interval = interval;
|
||||
Player.Message(p, "Place or break two blocks to determine direction.");
|
||||
p.MakeSelection(2, dArgs, DoSPlace);
|
||||
@ -90,7 +90,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
return true;
|
||||
}
|
||||
|
||||
struct DrawArgs { public ushort distance, interval; }
|
||||
class DrawArgs { public ushort distance, interval; }
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/SPlace [distance] <interval>");
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override void Use(Player p, string message) {
|
||||
string[] parts = message.SplitSpaces(3);
|
||||
|
||||
DrawArgs dArgs = default(DrawArgs);
|
||||
DrawArgs dArgs = new DrawArgs();
|
||||
dArgs.size = -1;
|
||||
|
||||
Tree tree = Tree.Find(parts[0]);
|
||||
@ -98,7 +98,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
return brush.Construct(args);
|
||||
}
|
||||
|
||||
struct DrawArgs { public Tree tree; public string brushMsg; public int size; }
|
||||
class DrawArgs { public Tree tree; public string brushMsg; public int size; }
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/Tree [type] %H- Draws a tree.");
|
||||
|
@ -42,7 +42,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
if (!byte.TryParse(args[0], out scale)) scale = 1;
|
||||
if (!byte.TryParse(args[1], out spacing)) spacing = 1;
|
||||
|
||||
WriteArgs wArgs = default(WriteArgs);
|
||||
WriteArgs wArgs = new WriteArgs();
|
||||
wArgs.scale = scale; wArgs.spacing = spacing;
|
||||
wArgs.message = args[2].ToUpper();
|
||||
Player.Message(p, "Place or break two blocks to determine direction.");
|
||||
@ -64,7 +64,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
return true;
|
||||
}
|
||||
|
||||
struct WriteArgs { public byte scale, spacing; public string message; }
|
||||
class WriteArgs { public byte scale, spacing; public string message; }
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/WriteText [scale] [spacing] [message]");
|
||||
|
@ -59,7 +59,7 @@ namespace MCGalaxy.Commands.Misc {
|
||||
|
||||
void DoKick(Player p, Group newRank) {
|
||||
if (!ServerConfig.HackrankKicks) return;
|
||||
HackRankArgs args;
|
||||
HackRankArgs args = new HackRankArgs();
|
||||
args.name = p.name; args.newRank = newRank;
|
||||
|
||||
TimeSpan delay = TimeSpan.FromSeconds(ServerConfig.HackrankKickDelay);
|
||||
@ -75,7 +75,7 @@ namespace MCGalaxy.Commands.Misc {
|
||||
who.Leave("kicked (" + msg + "%S)", "Kicked " + msg);
|
||||
}
|
||||
|
||||
struct HackRankArgs { public string name; public Group newRank; }
|
||||
class HackRankArgs { public string name; public Group newRank; }
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/HackRank [rank] %H- Hacks a rank");
|
||||
|
Loading…
x
Reference in New Issue
Block a user