From 431c3d2cd17cd6fcae78edb95990cc9dd0db403d Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 17 Feb 2016 09:48:04 +1100 Subject: [PATCH] Remove /scinema and /pcinema as they were slow, lag inducing, and would eat up lots of memory over time. --- Commands/Command.All.cs | 3 - Commands/CommandKeywords.cs | 3 - Commands/other/CmdScinema.cs | 183 --------------------- Commands/other/CmdpCinema.cs | 303 ----------------------------------- MCGalaxy_.csproj | 2 - 5 files changed, 494 deletions(-) delete mode 100644 Commands/other/CmdScinema.cs delete mode 100644 Commands/other/CmdpCinema.cs diff --git a/Commands/Command.All.cs b/Commands/Command.All.cs index 725b11fec..4fb420e0d 100644 --- a/Commands/Command.All.cs +++ b/Commands/Command.All.cs @@ -186,8 +186,6 @@ namespace MCGalaxy all.Add(new CmdPatrol()); all.Add(new CmdPause()); all.Add(new CmdPay()); - all.Add(new CmdpCinema()); - all.Add(new CmdpCinema2()); all.Add(new CmdPClients()); all.Add(new CmdPCount()); all.Add(new CmdPCreate()); @@ -234,7 +232,6 @@ namespace MCGalaxy all.Add(new CmdRules()); all.Add(new CmdSave()); all.Add(new CmdSay()); - all.Add(new CmdSCinema()); all.Add(new CmdSearch()); all.Add(new CmdSeen()); all.Add(new CmdSend()); diff --git a/Commands/CommandKeywords.cs b/Commands/CommandKeywords.cs index bbe2bd6ef..9bf085005 100644 --- a/Commands/CommandKeywords.cs +++ b/Commands/CommandKeywords.cs @@ -167,8 +167,6 @@ namespace MCGalaxy.Commands new CommandKeywords((new CmdPause()), "physics reset"); new CommandKeywords((new CmdPay()), "money give " + Server.moneys); new CommandKeywords((new CmdPlayerEditDB()), "player block limit mod edit"); - new CommandKeywords((new CmdpCinema()), "cinema gif"); - new CommandKeywords((new CmdpCinema2()), "cinema gif"); new CommandKeywords((new CmdPCount()), "player online total number count"); new CommandKeywords((new CmdPCreate()), "create add new plugin"); new CommandKeywords((new CmdPerbuildMax()), "perm build max rank"); @@ -208,7 +206,6 @@ namespace MCGalaxy.Commands new CommandKeywords((new CmdRules()), "read prot"); new CommandKeywords((new CmdSave()), "store load"); new CommandKeywords((new CmdSay()), "speak broad cast"); - new CommandKeywords((new CmdSCinema()), "cinema show"); new CommandKeywords((new CmdSearch()), "find block command player rank"); new CommandKeywords((new CmdSeen()), "saw last user"); new CommandKeywords((new CmdServerReport()), "report server"); diff --git a/Commands/other/CmdScinema.cs b/Commands/other/CmdScinema.cs deleted file mode 100644 index 5f12ff776..000000000 --- a/Commands/other/CmdScinema.cs +++ /dev/null @@ -1,183 +0,0 @@ -/* - Copyright 2011 MCGalaxy - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. -*/ -using System; -using System.Collections.Generic; -using System.IO; -namespace MCGalaxy.Commands -{ - public sealed class CmdSCinema : Command - { - StreamWriter cin; - String Filepath = ""; - - public override string name { get { return "scinema"; } } - public override string shortcut { get { return "sc"; } } - public override string type { get { return CommandTypes.Other; } } - public override bool museumUsable { get { return true; } } - public override LevelPermission defaultRank { get { return LevelPermission.Admin; } } - public override void Use(Player p, string message) - { - - if (message.Length == 0) - { - //no message - Help(p); return; - } - else - { - //message found. propably filename - Filepath = "extra/cin/" + message + ".cin"; - if (!File.Exists(Filepath)) - { - if (!Directory.Exists("extra/cin/")) - { - Directory.CreateDirectory("extra/cin/"); - } - //File has to be created then append - FileStream damn = File.Create(Filepath); - damn.Close(); - damn.Dispose(); - StreamWriter temp = File.AppendText(Filepath); - temp.WriteLine(String.Format("{0:00000}", 0)); //number of last frame Frame. in this case 0 - temp.Flush(); - temp.Close(); - temp.Dispose(); - } - //just append - //have to add this otherwise will crash - CatchPos cpos; - cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos; - Player.SendMessage(p, "Place two blocks to determine the edges."); - p.ClearBlockchange(); - //happens when block is changed. then call blockchange1 - p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); - } - } - - public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) - { - RevertAndClearState(p, x, y, z); - CatchPos bp = (CatchPos)p.blockchangeObject; - p.copystart[0] = x; - p.copystart[1] = y; - p.copystart[2] = z; - //com(p, "saving the coordinates"); - com(p, x + "," + y + "," + z); - bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp; - //com(p, "wait for next blockchange"); - p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2); - } - - void com(Player p, String lol) - { - Player.SendMessage(p, lol); - } - - public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) - { - RevertAndClearState(p, x, y, z); - CatchPos cpos = (CatchPos)p.blockchangeObject; - List CBuffer = new List(); - - CBuffer.Clear(); - //com(p, "copy stuff"); - for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx) - { - for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy) - { - for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz) - { - byte b = p.level.GetTile(xx, yy, zz); - BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), b, CBuffer); - } - } - } - //com(p, "stuff is copied. now append to file"); - //com(p, "get the number of next frame"); - int FrameNumber = 0; - Byte[] ba = new Byte[5]; - using (FileStream ReadStream = File.OpenRead(Filepath)) - { - String temp = ""; - for (int j = 0; j < 5; j++) - { - temp += (Char)ReadStream.ReadByte(); - } - FrameNumber = int.Parse(temp); - //framecount aquired(hopefully) - //now we have to add 1 to that and write it back in the file - FrameNumber++; - int Fnum = FrameNumber; - for (int i = 4; i >= 0; i--) - { - ba[i] = Byte.Parse((Fnum % 10).ToString()); - ba[i] += 48; - //ba[i] = (Byte)49; - Fnum /= 10; - } - } - - using (FileStream WriteStream = File.OpenWrite(Filepath)) - { - WriteStream.Write(ba, 0, 5); - //written new number in file - } - - cin = File.AppendText(Filepath); - cin.Write("[Frame" + String.Format("{0:00000}", FrameNumber) + "]{"); - //written frameheader - foreach (CopyPos CP in CBuffer) - { - String tBlock = ""; - tBlock += CP.x + ";"; - tBlock += CP.y + ";"; - tBlock += CP.z + ";"; - //written coordinates in string - tBlock += CP.type + "|"; - cin.Write(tBlock); - } - cin.Write("}" + Environment.NewLine); - //work done. saved frame in file - cin.Flush(); - cin.Close(); - cin.Dispose(); - com(p, "Saved Blocks to File"); - } - - // This one controls what happens when you use /help [commandname]. - public override void Help(Player p) - { - Player.SendMessage(p, "/sCinema [name] - Saves a given Frame to the File. Can be Played by pCinema"); - } - - void BufferAdd(Player p, ushort x, ushort y, ushort z, byte type, List Buf) - { - CopyPos pos; - pos.x = x; - pos.y = y; - pos.z = z; - pos.type = type; - Buf.Add(pos); - } - - struct CatchPos { public ushort x, y, z; } - struct CopyPos { public ushort x, y, z; public byte type; } - - } -} - diff --git a/Commands/other/CmdpCinema.cs b/Commands/other/CmdpCinema.cs deleted file mode 100644 index d6bfc98e3..000000000 --- a/Commands/other/CmdpCinema.cs +++ /dev/null @@ -1,303 +0,0 @@ -/* - Copyright 2011 MCGalaxy - - Written by Frederik Gelder - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. -*/ -using System; -using System.Collections.Generic; -using System.IO; -namespace MCGalaxy.Commands -{ - public sealed class CmdpCinema : Command - { - CmdpCinema2[] cmdPC = new CmdpCinema2[100]; //reserving space for 100 movies. - bool[] used = new bool[100]; - - public override string name { get { return "pcinema"; } } - public override string shortcut { get { return ""; } } - public override string type { get { return CommandTypes.Other; } } - public override bool museumUsable { get { return false; } } - public override LevelPermission defaultRank { get { return LevelPermission.Admin; } } - public override void Use(Player p, string message) - { - String[] tempmsg = message.Split(' '); - String send = ""; - int movnum = 0; - if (tempmsg.Length < 2 || tempmsg.Length > 3) - { - Help(p); - return; - } - - if (tempmsg.Length == 2) - { - if (tempmsg[0].ToLower() == "abort") - { - try - { - cmdPC[int.Parse(tempmsg[1])].abort(); - - used[int.Parse(tempmsg[1])] = false; - } - catch - { - Help(p); - return; - } - Player.SendMessage(p, "movie " + tempmsg[1] + " was aborted."); - return; - } - else if (tempmsg[0].ToLower() == "delete") - { - if(System.IO.File.Exists("extra/cin/" + tempmsg[1] + ".cin")){ - System.IO.File.Delete("extra/cin/" + tempmsg[1] + ".cin"); - } - return; - } - //no frametime. use default 1000. but that does pcinema2 for us - send = tempmsg[1]; - } - else if (tempmsg.Length == 3) - { - //frametime given - send = tempmsg[1] + " " + tempmsg[2]; - } - - try - { - movnum = int.Parse(tempmsg[0]); - } - catch - { - Help(p); - return; - } - - if (used[movnum]) - { - Player.SendMessage(p, "Movie is already used. stop it by using /pcinema abort [movienumber]"); - return; - } - else - { - //cmdPC[movnum] = new CmdpCinema2(); - try - { - cmdPC[movnum].Use(p, send);//better not use a new instance. it worked but they were not stopable. - } - catch - { - cmdPC[movnum] = new CmdpCinema2(); - cmdPC[movnum].Use(p, send); - } - used[movnum] = true; - } - - } - public override void Help(Player p) - { - Player.SendMessage(p, "/pCinema [movienumber] [filename] - movienumber can be 0-99. filename explains itself. frametime is the time in ms each rame is displayed.no values under 200 accepted.else set to 200. You can delete unwanted movies with /pcinema delete "); - } - } - - public sealed class CmdpCinema2 : Command - { - String FilePath; - int frameLonging; - String temp = ""; - CFrame[] Frames; - int FrameCount = 0; - int Framenow = 0; - System.Timers.Timer lool; - Player MEEE; - public bool running; - Level plLevel; - - - public override string name { get { return "pcinema2"; } } - public override string shortcut { get { return ""; } } - public override string type { get { return CommandTypes.Other; } } - public override bool museumUsable { get { return false; } } - public override LevelPermission defaultRank { get { return LevelPermission.Nobody; } } - - public void abort() - { - FilePath = ""; - Frames = null; - Framenow = 0; - lool.Enabled = false;//even i dispose it,i disable it because i dont know if it really stops - lool.Dispose(); - running = false; - } - - public override void Use(Player p, string message) - { - if (message.Length == 0) - { - Help(p); return; - } - String[] tempa = message.Split(' '); - if (tempa.Length > 2) - { - Help(p); return; - } - else if (tempa.Length == 1) - { - if (tempa[0].ToLower() == "abort") - { - //player wants to abort the running action - if (!running) - { - Player.SendMessage(p, "There is no movie running"); - return; - } - //abortion - abort(); - return; - } - else if (running) - { - Player.SendMessage(p, "Movie is already running.Abort first"); - return; - } - //frametime not given << default - frameLonging = 1000; - } - else - { - frameLonging = int.Parse(tempa[1]); - if (frameLonging < 200) frameLonging = 200; - } - FilePath = "extra/cin/" + tempa[0] + ".cin"; - if (!File.Exists(FilePath)) - { - Player.SendMessage(p, "File does not exist"); - return; - } - MEEE = p; - //temp[0] is the name of the file and temp[1] in ms is the time each frame is displayed - Player.SendMessage(p, "Place a Block to determine the position"); - p.ClearBlockchange(); - //happens when block is changed. then call blockchange1 - p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); - - } - - public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) - { - p.ClearBlockchange(); - //com(p, "get the type of the changed block"); - byte b = p.level.GetTile(x, y, z); - //com(p, "undo the change2"); - p.SendBlockchange(x, y, z, b); - //now we have to load the stuff from the temp string - Player.SendMessage(p, "Reading file, please wait..."); - temp = readFile(FilePath); - Player.SendMessage(p, "File read"); - String[] textFrames = temp.Split('['); - //[0] is the framecount. rest is in this format: FrameXXXXX]{0,0,0,0|0,0,0,0|} - FrameCount = int.Parse(textFrames[0]); - Frames = new CFrame[FrameCount]; - plLevel = p.level; - for (int i = 0; i < FrameCount; i++) - { - Player.SendMessage(p, String.Format("Frame {0:00000}...", i + 1)); - textFrames[i + 1] = textFrames[i + 1].Replace(String.Format("Frame{0:00000}]", i + 1), ""); - textFrames[i + 1] = textFrames[i + 1].Replace("{", ""); - textFrames[i + 1] = textFrames[i + 1].Replace("}", ""); - String[] Coords = textFrames[i + 1].Split('|'); - Frames[i].BlockCollection = new List(); - //coords now in array with format: 0,0,0,0 - //now split by , and write in XYZ,type - for (int j = 0; j < Coords.Length - 1; j++) - { - String[] tempXYZ = Coords[j].Split(';'); - Frames[i].BlockCollection.Add(new Blok((ushort)(x + int.Parse(tempXYZ[0])), - (ushort)(y + int.Parse(tempXYZ[1])), - (ushort)(z + int.Parse(tempXYZ[2])), - (Byte)int.Parse(tempXYZ[3]))); - //frame has now its blocks. - } - Player.SendMessage(p, "Done!"); - } - //frames are all aquired - Player.SendMessage(p, "Frames ready! start Playing"); - - //better using timers.timer. forms timer doesnt work sometimes for fcking reasons o.O - lool = new System.Timers.Timer(frameLonging); - lool.Elapsed += new System.Timers.ElapsedEventHandler(nextFrameUpdate); - lool.Enabled = true; - running = true; - } - - void nextFrameUpdate(object sender, EventArgs e) - { - //update the frames - foreach (Blok Bl in Frames[Framenow].BlockCollection) - { - Bl.applyBlockToMap(MEEE, plLevel); - } - //blaahhh write blocks to map - Framenow++; - if (Framenow >= FrameCount) - { - Framenow = 0;//begin from start again - } - - } - - String readFile(String Path) - { - if (File.Exists(Path)) - { - return File.ReadAllText(Path); - } - else - { - return null; - } - } - - struct CFrame - { - public List BlockCollection; - } - - struct Blok - { - public ushort X, Y, Z; - public byte Type; - public Blok(ushort x, ushort y, ushort z, byte typ) - { - X = x; - Y = y; - Z = z; - Type = typ; - } - public void applyBlockToMap(Player p, Level l) - { - l.Blockchange(p, X, Y, Z, Type); - //p.SendBlockchange(X, Y, Z, Type); - } - } - - public override void Help(Player p) - { - Player.SendMessage(p, "/pcinema2 should not be used directly. better use pcinema."); - } - } -} diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index ec2a77efc..e440bb46e 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -332,7 +332,6 @@ - @@ -343,7 +342,6 @@ -