static String GenerateSave(String ThumbName, String Type)
        {
            String Save = "EVENT HORIZON ENGINE SAVE FILE\n"
                          + "#VERSION=" + Shell.FrameworkVersion + "\n"
                          + "#TIME=" + System.DateTime.Now.ToBinary() + "\n"
                          + "#THUMB=" + ThumbName + "\n"
                          + "#SAVETYPE=" + Type + "\n"
                          + "#FLAGS=" + RecordApplicableFlags() + "\n";

            if (Type == "ScriptStem")
            {
                ScriptProcessor.ScriptSniffer CurrentSniffer = null;
                Boolean Found = false;
                foreach (WorldEntity E in Shell.UpdateQueue)
                {
                    if (E is ScriptProcessor.ScriptSniffer)
                    {
                        CurrentSniffer = (ScriptProcessor.ScriptSniffer)E;
                        Found          = true;
                        break;
                    }
                }
                if (!Found)
                {
                    throw new SaveLoadException("Error when saving the game - no active script!");
                }
                Save += "#SCRIPTNAME=" + CurrentSniffer.Name.Replace("_SNIFFER", "") + "\n";
                Save += "#SCRIPTSHIFTINDEX=" + CurrentSniffer.Index + "\n";
                Save += "#CONDITIONALS=";
                switch (CurrentSniffer.Name.Replace("_SNIFFER", "").ToUpper())
                {
                default:
                    Save += "DEFAULTUI";
                    break;

                case "VS_MAIN_INTRO":
                    Save += "NULL";
                    break;
                }
            }
            else if (Type == "FullySerializedBinary")
            {
                if (ScriptProcessor.PastStates.Count == 0)
                {
                    Shell.WriteLine("Could not generate save file: No valid RecallableState stored.");
                    return(null);
                }
                RecallableState?State = (RecallableState?)ScriptProcessor.PastStates.Peek();
                if (State is null)
                {
                    Stack StatesClone = (Stack)ScriptProcessor.PastStates.Clone();
                    StatesClone.Pop();
                    while (State is null)
                    {
                        if (StatesClone.Count == 0)
                        {
                            Shell.WriteLine("Could not generate save file: No valid RecallableState stored.");
                            return(null);
                        }
                        State = (RecallableState?)StatesClone.Pop();
                    }
                }
                IFormatter   SerFormatter = new BinaryFormatter();
                ArrayList    Streams      = new ArrayList();
                MemoryStream EntityStream = new MemoryStream();
                SerFormatter.Serialize(EntityStream, State);
                EntityStream.Close();
                byte[] Bin       = EntityStream.ToArray();
                String BinString = Convert.ToBase64String(Bin);
                Save += "#DATASTREAM=" + BinString + "&ENDDATASTREAM";
            }
            Save += "\n";
            Save += "END";
            return(Save);
        }