Moved MapEntity saving methods to the shared project (the server needs to be able to save subs in the campaign mode)
This commit is contained in:
@@ -103,48 +103,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public bool Save()
|
||||
{
|
||||
return SaveAs(filePath);
|
||||
}
|
||||
|
||||
public bool SaveAs(string filePath)
|
||||
{
|
||||
name = System.IO.Path.GetFileNameWithoutExtension(filePath);
|
||||
|
||||
XDocument doc = new XDocument(new XElement("Submarine"));
|
||||
SaveToXElement(doc.Root);
|
||||
|
||||
hash = new Md5Hash(doc);
|
||||
doc.Root.Add(new XAttribute("md5hash", hash.Hash));
|
||||
|
||||
try
|
||||
{
|
||||
SaveUtil.CompressStringToFile(filePath, doc.ToString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Saving submarine \"" + filePath + "\" failed!", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SaveToXElement(XElement element)
|
||||
{
|
||||
element.Add(new XAttribute("name", name));
|
||||
element.Add(new XAttribute("description", Description == null ? "" : Description));
|
||||
|
||||
element.Add(new XAttribute("tags", tags.ToString()));
|
||||
|
||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||
{
|
||||
if (e.MoveWithLevel || e.Submarine != this) continue;
|
||||
e.Save(element);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SaveCurrent(string filePath)
|
||||
{
|
||||
if (Submarine.MainSub == null)
|
||||
|
||||
Reference in New Issue
Block a user