- File transfer improvements (switching the sub selection during transfer works, max transfer duration, waiting for transfers to finish before starting the round)
- Firesource changes (more particles with shorter lifetimes, combining bugfix) - StatusEffects can target hulls and always be active - Cyrillic character support - Saving server settings - Swapping items in inventory by dropping an item to a non-free slot
This commit is contained in:
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
<Body width="36" height="60" density="5"/>
|
<Body width="36" height="60" density="5"/>
|
||||||
|
|
||||||
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10"/>
|
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10">
|
||||||
|
<StatusEffect type="Always" target="Hull" oxygen="-50000.0"/>
|
||||||
|
</Holdable>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
<Item
|
<Item
|
||||||
@@ -35,7 +37,7 @@
|
|||||||
<Body radius="20" height="20" density="5"/>
|
<Body radius="20" height="20" density="5"/>
|
||||||
|
|
||||||
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10">
|
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10">
|
||||||
<StatusEffect type="OnActive">
|
<StatusEffect type="Always">
|
||||||
<Fire/>
|
<Fire/>
|
||||||
</StatusEffect>
|
</StatusEffect>
|
||||||
</Holdable>
|
</Holdable>
|
||||||
|
|||||||
Binary file not shown.
@@ -115,8 +115,8 @@
|
|||||||
sizechangemin="0.1,0.1" sizechangemax="0.2,0.2"
|
sizechangemin="0.1,0.1" sizechangemax="0.2,0.2"
|
||||||
startrotationmin ="-20.0" startrotationmax="20"
|
startrotationmin ="-20.0" startrotationmax="20"
|
||||||
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
|
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
|
||||||
colorchange="-0.6, -1.0, -4.2, -0.8"
|
colorchange="-0.9, -1.5, -6.3, -1.2"
|
||||||
lifetime="5.0"
|
lifetime="2.5"
|
||||||
growtime ="0.05"
|
growtime ="0.05"
|
||||||
drawtarget="air"
|
drawtarget="air"
|
||||||
collideswithwalls="true"
|
collideswithwalls="true"
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -53,6 +53,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public readonly bool IsNetworkPlayer;
|
public readonly bool IsNetworkPlayer;
|
||||||
|
|
||||||
|
private bool networkUpdateSent;
|
||||||
|
|
||||||
private CharacterInventory inventory;
|
private CharacterInventory inventory;
|
||||||
|
|
||||||
public float LastNetworkUpdate;
|
public float LastNetworkUpdate;
|
||||||
@@ -955,6 +957,17 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (isDead) return;
|
if (isDead) return;
|
||||||
|
|
||||||
|
if (networkUpdateSent)
|
||||||
|
{
|
||||||
|
foreach (Key key in keys)
|
||||||
|
{
|
||||||
|
key.DequeueHit();
|
||||||
|
key.DequeueHeld();
|
||||||
|
}
|
||||||
|
|
||||||
|
networkUpdateSent = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (needsAir)
|
if (needsAir)
|
||||||
{
|
{
|
||||||
bool protectedFromPressure = PressureProtection > 0.0f;
|
bool protectedFromPressure = PressureProtection > 0.0f;
|
||||||
@@ -1421,9 +1434,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
case NetworkEventType.EntityUpdate:
|
case NetworkEventType.EntityUpdate:
|
||||||
message.Write(keys[(int)InputType.Use].DequeueHeld);
|
message.Write(keys[(int)InputType.Use].GetHeldQueue);
|
||||||
|
|
||||||
bool secondaryHeld = keys[(int)InputType.Aim].DequeueHeld;
|
bool secondaryHeld = keys[(int)InputType.Aim].GetHeldQueue;
|
||||||
message.Write(secondaryHeld);
|
message.Write(secondaryHeld);
|
||||||
|
|
||||||
message.Write(keys[(int)InputType.Left].Held);
|
message.Write(keys[(int)InputType.Left].Held);
|
||||||
@@ -1469,6 +1482,8 @@ namespace Barotrauma
|
|||||||
message.Write(SimPosition.X);
|
message.Write(SimPosition.X);
|
||||||
message.Write(SimPosition.Y);
|
message.Write(SimPosition.Y);
|
||||||
|
|
||||||
|
networkUpdateSent = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|||||||
@@ -273,20 +273,21 @@ namespace Barotrauma
|
|||||||
if (disableDeltaTime) deltaTime = 1.0f;
|
if (disableDeltaTime) deltaTime = 1.0f;
|
||||||
|
|
||||||
Type type = value.GetType();
|
Type type = value.GetType();
|
||||||
if (type == typeof(float))
|
if (type == typeof(float) ||
|
||||||
|
(type == typeof(int) && property.GetValue().GetType() == typeof(float)))
|
||||||
{
|
{
|
||||||
float floatValue = (float)value * deltaTime;
|
float floatValue = Convert.ToSingle(value) * deltaTime;
|
||||||
|
|
||||||
if (!setValue) floatValue += (float)property.GetValue();
|
if (!setValue) floatValue += (float)property.GetValue();
|
||||||
property.TrySetValue(floatValue);
|
property.TrySetValue(floatValue);
|
||||||
}
|
}
|
||||||
else if (type == typeof(int))
|
else if (type == typeof(int) && value.GetType()==typeof(int))
|
||||||
{
|
{
|
||||||
int intValue = (int)((int)value * deltaTime);
|
int intValue = (int)((int)value * deltaTime);
|
||||||
if (!setValue) intValue += (int)property.GetValue();
|
if (!setValue) intValue += (int)property.GetValue();
|
||||||
property.TrySetValue(intValue);
|
property.TrySetValue(intValue);
|
||||||
}
|
}
|
||||||
else if (type == typeof(bool))
|
else if (type == typeof(bool) && value.GetType() == typeof(bool))
|
||||||
{
|
{
|
||||||
property.TrySetValue((bool)value);
|
property.TrySetValue((bool)value);
|
||||||
}
|
}
|
||||||
@@ -294,6 +295,11 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
property.TrySetValue((string)value);
|
property.TrySetValue((string)value);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Couldn't apply value "+value.ToString()+" ("+type+") to property ''"+property.Name+"'' ("+property.GetValue().GetType()+")! "
|
||||||
|
+"Make sure the type of the value set in the config files matches the type of the property.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateAll(float deltaTime)
|
public static void UpdateAll(float deltaTime)
|
||||||
|
|||||||
@@ -381,7 +381,8 @@ namespace Barotrauma
|
|||||||
DebugConsole.ThrowError("Illegal symbols in filename (../)");
|
DebugConsole.ThrowError("Illegal symbols in filename (../)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Submarine.SaveCurrent(fileName +".sub")) NewMessage("map saved", Color.Green);
|
|
||||||
|
if (Submarine.SaveCurrent(System.IO.Path.Combine(Submarine.SavePath, fileName +".sub"))) NewMessage("map saved", Color.Green);
|
||||||
Submarine.Loaded.CheckForErrors();
|
Submarine.Loaded.CheckForErrors();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -493,6 +494,12 @@ namespace Barotrauma
|
|||||||
DebugConsole.NewMessage("Deleted TutorialSub from the submarine folder", Color.Green);
|
DebugConsole.NewMessage("Deleted TutorialSub from the submarine folder", Color.Green);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (System.IO.File.Exists(GameServer.SettingsFile))
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(GameServer.SettingsFile);
|
||||||
|
DebugConsole.NewMessage("Deleted server settings", Color.Green);
|
||||||
|
}
|
||||||
|
|
||||||
if (System.IO.File.Exists("crashreport.txt"))
|
if (System.IO.File.Exists("crashreport.txt"))
|
||||||
{
|
{
|
||||||
System.IO.File.Delete("crashreport.txt");
|
System.IO.File.Delete("crashreport.txt");
|
||||||
|
|||||||
@@ -157,8 +157,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
|
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
|
||||||
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
|
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
|
||||||
|
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Items.Components.ItemComponent));
|
||||||
//Event.Init("Content/randomevents.xml");
|
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Hull));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -172,6 +172,29 @@ namespace Barotrauma
|
|||||||
|
|
||||||
combined = true;
|
combined = true;
|
||||||
}
|
}
|
||||||
|
//if moving the item between slots in the same inventory
|
||||||
|
else if (item.ParentInventory == this)
|
||||||
|
{
|
||||||
|
int currentIndex = Array.IndexOf(Items, item);
|
||||||
|
|
||||||
|
Item existingItem = Items[index];
|
||||||
|
|
||||||
|
Items[currentIndex] = null;
|
||||||
|
Items[index] = null;
|
||||||
|
//if the item in the slot can be moved to the slot of the moved item
|
||||||
|
if (TryPutItem(existingItem, currentIndex, false) &&
|
||||||
|
TryPutItem(item, index, false))
|
||||||
|
{
|
||||||
|
new Networking.NetworkEvent(Networking.NetworkEventType.InventoryUpdate, Owner.ID, true, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//swapping the items failed -> move them back to where they were
|
||||||
|
TryPutItem(item, currentIndex, false);
|
||||||
|
TryPutItem(existingItem, index, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return combined;
|
return combined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -487,6 +487,7 @@ namespace Barotrauma
|
|||||||
public void ApplyStatusEffect(StatusEffect effect, ActionType type, float deltaTime, Character character = null)
|
public void ApplyStatusEffect(StatusEffect effect, ActionType type, float deltaTime, Character character = null)
|
||||||
{
|
{
|
||||||
if (condition == 0.0f && effect.type != ActionType.OnBroken) return;
|
if (condition == 0.0f && effect.type != ActionType.OnBroken) return;
|
||||||
|
if (effect.type != type) return;
|
||||||
|
|
||||||
bool hasTargets = (effect.TargetNames == null);
|
bool hasTargets = (effect.TargetNames == null);
|
||||||
|
|
||||||
@@ -501,7 +502,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
List<IPropertyObject> targets = new List<IPropertyObject>();
|
List<IPropertyObject> targets = new List<IPropertyObject>();
|
||||||
|
|
||||||
if (containedItems!=null)
|
if (containedItems != null)
|
||||||
{
|
{
|
||||||
if (effect.Targets.HasFlag(StatusEffect.TargetType.Contained))
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.Contained))
|
||||||
{
|
{
|
||||||
@@ -528,9 +529,14 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!hasTargets) return;
|
if (!hasTargets) return;
|
||||||
|
|
||||||
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.Hull) && CurrentHull != null)
|
||||||
|
{
|
||||||
|
targets.Add(CurrentHull);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (effect.Targets.HasFlag(StatusEffect.TargetType.This))
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.This))
|
||||||
{
|
{
|
||||||
foreach (var pobject in AllPropertyObjects)
|
foreach (var pobject in AllPropertyObjects)
|
||||||
@@ -576,6 +582,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void Update(Camera cam, float deltaTime)
|
public override void Update(Camera cam, float deltaTime)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ApplyStatusEffects(ActionType.Always, deltaTime, null);
|
||||||
|
|
||||||
foreach (ItemComponent ic in components)
|
foreach (ItemComponent ic in components)
|
||||||
{
|
{
|
||||||
if (ic.Parent != null) ic.IsActive = ic.Parent.IsActive;
|
if (ic.Parent != null) ic.IsActive = ic.Parent.IsActive;
|
||||||
|
|||||||
@@ -116,11 +116,13 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (!fireSources[i].CheckOverLap(fireSources[j])) continue;
|
if (!fireSources[i].CheckOverLap(fireSources[j])) continue;
|
||||||
|
|
||||||
fireSources[j].position.X = Math.Min(fireSources[i].position.X, fireSources[j].position.X);
|
float leftEdge = Math.Min(fireSources[i].position.X, fireSources[j].position.X);
|
||||||
|
|
||||||
fireSources[j].size.X =
|
fireSources[j].size.X =
|
||||||
Math.Max(fireSources[i].position.X + fireSources[i].size.X, fireSources[j].position.X + fireSources[j].size.X)
|
Math.Max(fireSources[i].position.X + fireSources[i].size.X, fireSources[j].position.X + fireSources[j].size.X)
|
||||||
- fireSources[j].position.X;
|
- leftEdge;
|
||||||
|
|
||||||
|
fireSources[j].position.X = leftEdge;
|
||||||
|
|
||||||
fireSources[i].Remove();
|
fireSources[i].Remove();
|
||||||
}
|
}
|
||||||
@@ -140,7 +142,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void Update(float deltaTime)
|
public void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
float count = Rand.Range(0.0f, (float)Math.Sqrt(size.X)/3.0f);
|
float count = Rand.Range(0.0f, size.X/50.0f);
|
||||||
|
|
||||||
if (fireSoundBasic != null)
|
if (fireSoundBasic != null)
|
||||||
{
|
{
|
||||||
@@ -176,7 +178,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (Rand.Int(20) == 1) particle.OnChangeHull = OnChangeHull;
|
if (Rand.Int(20) == 1) particle.OnChangeHull = OnChangeHull;
|
||||||
|
|
||||||
particle.Size *= MathHelper.Clamp(size.X/100.0f * Math.Max(hull.Oxygen/hull.FullVolume, 0.4f), 0.5f, 4.0f);
|
particle.Size *= MathHelper.Clamp(size.X/60.0f * Math.Max(hull.Oxygen/hull.FullVolume, 0.4f), 0.5f, 3.0f);
|
||||||
|
|
||||||
if (size.X < 100.0f) continue;
|
if (size.X < 100.0f) continue;
|
||||||
|
|
||||||
@@ -218,7 +220,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (particleHull.FireSources.Find(fs => pos.X > fs.position.X-100.0f && pos.X < fs.position.X+fs.size.X+100.0f)!=null) return;
|
if (particleHull.FireSources.Find(fs => pos.X > fs.position.X-100.0f && pos.X < fs.position.X+fs.size.X+100.0f)!=null) return;
|
||||||
|
|
||||||
new FireSource(new Vector2(pos.X, particleHull.Rect.Y-particleHull.Rect.Height + 5.0f));
|
new FireSource(new Vector2(pos.X, particleHull.WorldRect.Y-particleHull.Rect.Height + 5.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DamageCharacters(float deltaTime)
|
private void DamageCharacters(float deltaTime)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using Lidgren.Network;
|
|||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
|
|
||||||
class Hull : MapEntity
|
class Hull : MapEntity, IPropertyObject
|
||||||
{
|
{
|
||||||
public static List<Hull> hullList = new List<Hull>();
|
public static List<Hull> hullList = new List<Hull>();
|
||||||
private static EntityGrid entityGrid;
|
private static EntityGrid entityGrid;
|
||||||
@@ -36,7 +36,11 @@ namespace Barotrauma
|
|||||||
//how much excess water the room can contain (= more than the volume of the room)
|
//how much excess water the room can contain (= more than the volume of the room)
|
||||||
public const float MaxCompress = 10000f;
|
public const float MaxCompress = 10000f;
|
||||||
|
|
||||||
public readonly Dictionary<string, PropertyDescriptor> properties;
|
public readonly Dictionary<string, ObjectProperty> properties;
|
||||||
|
public Dictionary<string, ObjectProperty> ObjectProperties
|
||||||
|
{
|
||||||
|
get { return properties; }
|
||||||
|
}
|
||||||
|
|
||||||
private float lethalPressure;
|
private float lethalPressure;
|
||||||
|
|
||||||
@@ -161,9 +165,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
fireSources = new List<FireSource>();
|
fireSources = new List<FireSource>();
|
||||||
|
|
||||||
properties = TypeDescriptor.GetProperties(GetType())
|
properties = ObjectProperty.GetProperties(this);
|
||||||
.Cast<PropertyDescriptor>()
|
|
||||||
.ToDictionary(pr => pr.Name);
|
|
||||||
|
|
||||||
int arraySize = (rectangle.Width / WaveWidth + 1);
|
int arraySize = (rectangle.Width / WaveWidth + 1);
|
||||||
waveY = new float[arraySize];
|
waveY = new float[arraySize];
|
||||||
|
|||||||
@@ -511,17 +511,17 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool SaveCurrent(string fileName)
|
public static bool SaveCurrent(string filePath)
|
||||||
{
|
{
|
||||||
if (loaded==null)
|
if (loaded==null)
|
||||||
{
|
{
|
||||||
loaded = new Submarine(fileName);
|
loaded = new Submarine(filePath);
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loaded.filePath = SavePath + System.IO.Path.DirectorySeparatorChar + fileName;
|
loaded.filePath = filePath;
|
||||||
|
|
||||||
return loaded.SaveAs(SavePath+System.IO.Path.DirectorySeparatorChar+fileName);
|
return loaded.SaveAs(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckForErrors()
|
public void CheckForErrors()
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private string downloadFolder;
|
private string downloadFolder;
|
||||||
|
|
||||||
private FileTransferType fileType;
|
private FileTransferMessageType fileType;
|
||||||
|
|
||||||
public string FileName
|
public string FileName
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ namespace Barotrauma.Networking
|
|||||||
get { return received; }
|
get { return received; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileTransferType FileType
|
public FileTransferMessageType FileType
|
||||||
{
|
{
|
||||||
get { return fileType; }
|
get { return fileType; }
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ namespace Barotrauma.Networking
|
|||||||
get { return (float)received / (float)length; }
|
get { return (float)received / (float)length; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileStreamReceiver(NetClient client, string filePath, FileTransferType fileType, OnFinished onFinished)
|
public FileStreamReceiver(NetClient client, string filePath, FileTransferMessageType fileType, OnFinished onFinished)
|
||||||
{
|
{
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case (byte)FileTransferType.Submarine:
|
case (byte)FileTransferMessageType.Submarine:
|
||||||
if (Path.GetExtension(fileName) != ".sub")
|
if (Path.GetExtension(fileName) != ".sub")
|
||||||
{
|
{
|
||||||
ErrorMessage = "Wrong file extension ''" + Path.GetExtension(fileName) + "''! (Expected .sub)";
|
ErrorMessage = "Wrong file extension ''" + Path.GetExtension(fileName) + "''! (Expected .sub)";
|
||||||
@@ -163,9 +163,12 @@ namespace Barotrauma.Networking
|
|||||||
Status == FileTransferStatus.Finished ||
|
Status == FileTransferStatus.Finished ||
|
||||||
Status == FileTransferStatus.Canceled) return;
|
Status == FileTransferStatus.Canceled) return;
|
||||||
|
|
||||||
|
byte transferMessageType = inc.ReadByte();
|
||||||
|
|
||||||
//int chunkLen = inc.LengthBytes;
|
//int chunkLen = inc.LengthBytes;
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
{
|
{
|
||||||
|
if (transferMessageType != (byte)FileTransferMessageType.Initiate) return;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(downloadFolder) && !Directory.Exists(downloadFolder))
|
if (!string.IsNullOrWhiteSpace(downloadFolder) && !Directory.Exists(downloadFolder))
|
||||||
{
|
{
|
||||||
@@ -174,6 +177,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
byte fileTypeByte = inc.ReadByte();
|
byte fileTypeByte = inc.ReadByte();
|
||||||
|
|
||||||
|
|
||||||
length = inc.ReadUInt64();
|
length = inc.ReadUInt64();
|
||||||
FileName = inc.ReadString();
|
FileName = inc.ReadString();
|
||||||
|
|
||||||
@@ -233,7 +237,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
switch (fileType)
|
switch (fileType)
|
||||||
{
|
{
|
||||||
case FileTransferType.Submarine:
|
case FileTransferMessageType.Submarine:
|
||||||
string file = Path.Combine(downloadFolder, FileName);
|
string file = Path.Combine(downloadFolder, FileName);
|
||||||
Stream stream = null;
|
Stream stream = null;
|
||||||
|
|
||||||
@@ -256,15 +260,19 @@ namespace Barotrauma.Networking
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
stream.Position = 0;
|
stream.Position = 0;
|
||||||
var doc = XDocument.Load(stream); //ToolBox.TryLoadXml(file);
|
var doc = XDocument.Load(stream);
|
||||||
stream.Close();
|
|
||||||
stream.Dispose();
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
stream.Close();
|
||||||
|
stream.Dispose();
|
||||||
|
|
||||||
ErrorMessage = "Failed to parse submarine file ''"+file+"''!";
|
ErrorMessage = "Failed to parse submarine file ''"+file+"''!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stream.Close();
|
||||||
|
stream.Dispose();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,15 @@ namespace Barotrauma.Networking
|
|||||||
NotStarted, Sending, Receiving, Finished, Error, Canceled
|
NotStarted, Sending, Receiving, Finished, Error, Canceled
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FileTransferType
|
enum FileTransferMessageType
|
||||||
{
|
{
|
||||||
Unknown, Submarine, Cancel
|
Unknown, Initiate, Submarine, Cancel
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileStreamSender : IDisposable
|
class FileStreamSender : IDisposable
|
||||||
{
|
{
|
||||||
|
public static TimeSpan MaxTransferDuration = new TimeSpan(0, 2, 0);
|
||||||
|
|
||||||
private FileStream inputStream;
|
private FileStream inputStream;
|
||||||
private int sentOffset;
|
private int sentOffset;
|
||||||
private int chunkLen;
|
private int chunkLen;
|
||||||
@@ -24,8 +26,9 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
float waitTimer;
|
float waitTimer;
|
||||||
|
|
||||||
|
DateTime startingTime;
|
||||||
|
|
||||||
private FileTransferType fileType;
|
private FileTransferMessageType fileType;
|
||||||
|
|
||||||
public FileTransferStatus Status
|
public FileTransferStatus Status
|
||||||
{
|
{
|
||||||
@@ -39,6 +42,12 @@ namespace Barotrauma.Networking
|
|||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string FilePath
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
public float Progress
|
public float Progress
|
||||||
{
|
{
|
||||||
get { return inputStream == null ? 0.0f : (float)sentOffset / (float)inputStream.Length; }
|
get { return inputStream == null ? 0.0f : (float)sentOffset / (float)inputStream.Length; }
|
||||||
@@ -54,30 +63,45 @@ namespace Barotrauma.Networking
|
|||||||
get { return inputStream == null ? 0 : inputStream.Length; }
|
get { return inputStream == null ? 0 : inputStream.Length; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileStreamSender Create(NetConnection conn, string fileName, FileTransferType fileType)
|
public static FileStreamSender Create(NetConnection conn, string filePath, FileTransferMessageType fileType)
|
||||||
{
|
{
|
||||||
if (!File.Exists(fileName))
|
if (!File.Exists(filePath))
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Sending a file failed. File ''"+fileName+"'' not found.");
|
DebugConsole.ThrowError("Sending a file failed. File ''"+filePath+"'' not found.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FileStreamSender(conn, fileName, fileType);
|
FileStreamSender sender = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sender = new FileStreamSender(conn, filePath, fileType);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Couldn't open file ''"+filePath+"''",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileStreamSender(NetConnection conn, string fileName, FileTransferType fileType)
|
private FileStreamSender(NetConnection conn, string filePath, FileTransferMessageType fileType)
|
||||||
{
|
{
|
||||||
connection = conn;
|
connection = conn;
|
||||||
inputStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
inputStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
chunkLen = connection.Peer.Configuration.MaximumTransmissionUnit - 100;
|
chunkLen = connection.Peer.Configuration.MaximumTransmissionUnit - 100;
|
||||||
tempBuffer = new byte[chunkLen];
|
tempBuffer = new byte[chunkLen];
|
||||||
sentOffset = 0;
|
sentOffset = 0;
|
||||||
|
|
||||||
FileName = fileName;
|
FilePath = filePath;
|
||||||
|
FileName = Path.GetFileName(filePath);
|
||||||
|
|
||||||
this.fileType = fileType;
|
this.fileType = fileType;
|
||||||
|
|
||||||
Status = FileTransferStatus.NotStarted;
|
Status = FileTransferStatus.NotStarted;
|
||||||
|
|
||||||
|
startingTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(float deltaTime)
|
public void Update(float deltaTime)
|
||||||
@@ -87,6 +111,12 @@ namespace Barotrauma.Networking
|
|||||||
Status == FileTransferStatus.Error ||
|
Status == FileTransferStatus.Error ||
|
||||||
Status == FileTransferStatus.Finished) return;
|
Status == FileTransferStatus.Finished) return;
|
||||||
|
|
||||||
|
if (DateTime.Now > startingTime + MaxTransferDuration)
|
||||||
|
{
|
||||||
|
CancelTransfer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
waitTimer -= deltaTime;
|
waitTimer -= deltaTime;
|
||||||
if (waitTimer > 0.0f) return;
|
if (waitTimer > 0.0f) return;
|
||||||
|
|
||||||
@@ -105,6 +135,7 @@ namespace Barotrauma.Networking
|
|||||||
// first message; send length, chunk length and file name
|
// first message; send length, chunk length and file name
|
||||||
message = connection.Peer.CreateMessage(sendBytes + 8 + 1);
|
message = connection.Peer.CreateMessage(sendBytes + 8 + 1);
|
||||||
message.Write((byte)PacketTypes.FileStream);
|
message.Write((byte)PacketTypes.FileStream);
|
||||||
|
message.Write((byte)FileTransferMessageType.Initiate);
|
||||||
message.Write((byte)fileType);
|
message.Write((byte)fileType);
|
||||||
message.Write((ulong)inputStream.Length);
|
message.Write((ulong)inputStream.Length);
|
||||||
message.Write(Path.GetFileName(inputStream.Name));
|
message.Write(Path.GetFileName(inputStream.Name));
|
||||||
@@ -115,12 +146,13 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
message = connection.Peer.CreateMessage(sendBytes + 8 + 1);
|
message = connection.Peer.CreateMessage(sendBytes + 8 + 1);
|
||||||
message.Write((byte)PacketTypes.FileStream);
|
message.Write((byte)PacketTypes.FileStream);
|
||||||
|
message.Write((byte)fileType);
|
||||||
message.Write(tempBuffer, 0, sendBytes);
|
message.Write(tempBuffer, 0, sendBytes);
|
||||||
|
|
||||||
connection.SendMessage(message, NetDeliveryMethod.ReliableOrdered, 1);
|
connection.SendMessage(message, NetDeliveryMethod.ReliableOrdered, 1);
|
||||||
sentOffset += sendBytes;
|
sentOffset += sendBytes;
|
||||||
|
|
||||||
waitTimer = connection.AverageRoundtripTime + 0.05f;
|
waitTimer = connection.AverageRoundtripTime;
|
||||||
|
|
||||||
//Program.Output("Sent " + m_sentOffset + "/" + m_inputStream.Length + " bytes to " + m_connection);
|
//Program.Output("Sent " + m_sentOffset + "/" + m_inputStream.Length + " bytes to " + m_connection);
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ namespace Barotrauma.Networking
|
|||||||
get { return otherClients; }
|
get { return otherClients; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ActiveFileTransferName
|
||||||
|
{
|
||||||
|
get { return (fileStreamReceiver == null || fileStreamReceiver.Status == FileTransferStatus.Finished) ? "" : fileStreamReceiver.FileName; }
|
||||||
|
}
|
||||||
|
|
||||||
public GameClient(string newName)
|
public GameClient(string newName)
|
||||||
{
|
{
|
||||||
endRoundButton = new GUITickBox(new Rectangle(GameMain.GraphicsWidth - 170, 20, 20, 20), "End round", Alignment.TopLeft, inGameHUD);
|
endRoundButton = new GUITickBox(new Rectangle(GameMain.GraphicsWidth - 170, 20, 20, 20), "End round", Alignment.TopLeft, inGameHUD);
|
||||||
@@ -479,7 +484,20 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case (byte)PacketTypes.RequestFile:
|
case (byte)PacketTypes.RequestFile:
|
||||||
new GUIMessageBox("Couldn't the file from the server", "Sharing files has been disabled by the server.");
|
bool accepted = inc.ReadBoolean();
|
||||||
|
|
||||||
|
if (!accepted)
|
||||||
|
{
|
||||||
|
new GUIMessageBox("File transfer canceled", inc.ReadString());
|
||||||
|
|
||||||
|
if (fileStreamReceiver!=null)
|
||||||
|
{
|
||||||
|
fileStreamReceiver.DeleteFile();
|
||||||
|
fileStreamReceiver.Dispose();
|
||||||
|
fileStreamReceiver = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case (byte)PacketTypes.FileStream:
|
case (byte)PacketTypes.FileStream:
|
||||||
if (fileStreamReceiver == null)
|
if (fileStreamReceiver == null)
|
||||||
@@ -710,14 +728,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (GUI.DrawButton(spriteBatch, new Rectangle((int)pos.X + 310, (int)pos.Y + 20, 100, 15), "Cancel", new Color(0.88f, 0.25f, 0.15f, 0.8f)))
|
if (GUI.DrawButton(spriteBatch, new Rectangle((int)pos.X + 310, (int)pos.Y + 20, 100, 15), "Cancel", new Color(0.88f, 0.25f, 0.15f, 0.8f)))
|
||||||
{
|
{
|
||||||
fileStreamReceiver.DeleteFile();
|
CancelFileTransfer();
|
||||||
fileStreamReceiver.Dispose();
|
|
||||||
fileStreamReceiver = null;
|
|
||||||
|
|
||||||
NetOutgoingMessage msg = client.CreateMessage();
|
|
||||||
msg.Write((byte)PacketTypes.RequestFile);
|
|
||||||
msg.Write((byte)FileTransferType.Cancel);
|
|
||||||
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -737,28 +748,6 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFileReceived(FileStreamReceiver receiver)
|
|
||||||
{
|
|
||||||
if (receiver.Status == FileTransferStatus.Error)
|
|
||||||
{
|
|
||||||
new GUIMessageBox("Error while receiving file from server", receiver.ErrorMessage, 400, 350);
|
|
||||||
receiver.DeleteFile();
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (receiver.Status == FileTransferStatus.Finished)
|
|
||||||
{
|
|
||||||
new GUIMessageBox("Download finished", "File ''"+receiver.FileName+"'' was downloaded succesfully.");
|
|
||||||
|
|
||||||
switch (receiver.FileType)
|
|
||||||
{
|
|
||||||
case FileTransferType.Submarine:
|
|
||||||
Submarine.Preload();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fileStreamReceiver = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Disconnect()
|
public override void Disconnect()
|
||||||
{
|
{
|
||||||
@@ -770,8 +759,13 @@ namespace Barotrauma.Networking
|
|||||||
GameMain.NetworkMember = null;
|
GameMain.NetworkMember = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestFile(string file, FileTransferType fileType)
|
public void RequestFile(string file, FileTransferMessageType fileType)
|
||||||
{
|
{
|
||||||
|
if (fileStreamReceiver!=null)
|
||||||
|
{
|
||||||
|
CancelFileTransfer();
|
||||||
|
}
|
||||||
|
|
||||||
NetOutgoingMessage msg = client.CreateMessage();
|
NetOutgoingMessage msg = client.CreateMessage();
|
||||||
msg.Write((byte)PacketTypes.RequestFile);
|
msg.Write((byte)PacketTypes.RequestFile);
|
||||||
msg.Write((byte)fileType);
|
msg.Write((byte)fileType);
|
||||||
@@ -783,6 +777,41 @@ namespace Barotrauma.Networking
|
|||||||
fileStreamReceiver = new FileStreamReceiver(client, Path.Combine(Submarine.SavePath, "Downloaded"), fileType, OnFileReceived);
|
fileStreamReceiver = new FileStreamReceiver(client, Path.Combine(Submarine.SavePath, "Downloaded"), fileType, OnFileReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnFileReceived(FileStreamReceiver receiver)
|
||||||
|
{
|
||||||
|
if (receiver.Status == FileTransferStatus.Error)
|
||||||
|
{
|
||||||
|
new GUIMessageBox("Error while receiving file from server", receiver.ErrorMessage, 400, 350);
|
||||||
|
receiver.DeleteFile();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (receiver.Status == FileTransferStatus.Finished)
|
||||||
|
{
|
||||||
|
new GUIMessageBox("Download finished", "File ''" + receiver.FileName + "'' was downloaded succesfully.");
|
||||||
|
|
||||||
|
switch (receiver.FileType)
|
||||||
|
{
|
||||||
|
case FileTransferMessageType.Submarine:
|
||||||
|
Submarine.Preload();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fileStreamReceiver = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelFileTransfer()
|
||||||
|
{
|
||||||
|
fileStreamReceiver.DeleteFile();
|
||||||
|
fileStreamReceiver.Dispose();
|
||||||
|
fileStreamReceiver = null;
|
||||||
|
|
||||||
|
NetOutgoingMessage msg = client.CreateMessage();
|
||||||
|
msg.Write((byte)PacketTypes.RequestFile);
|
||||||
|
msg.Write((byte)FileTransferMessageType.Cancel);
|
||||||
|
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||||
|
}
|
||||||
|
|
||||||
public void Vote(VoteType voteType, object userData)
|
public void Vote(VoteType voteType, object userData)
|
||||||
{
|
{
|
||||||
NetOutgoingMessage msg = client.CreateMessage();
|
NetOutgoingMessage msg = client.CreateMessage();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace Barotrauma.Networking
|
|||||||
private DateTime sparseUpdateTimer;
|
private DateTime sparseUpdateTimer;
|
||||||
private DateTime refreshMasterTimer;
|
private DateTime refreshMasterTimer;
|
||||||
|
|
||||||
|
private RestClient restClient;
|
||||||
private bool masterServerResponded;
|
private bool masterServerResponded;
|
||||||
|
|
||||||
private ServerLog log;
|
private ServerLog log;
|
||||||
@@ -96,6 +97,8 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
banList = new BanList();
|
banList = new BanList();
|
||||||
|
|
||||||
|
LoadSettings();
|
||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@@ -160,7 +163,10 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private void RegisterToMasterServer()
|
private void RegisterToMasterServer()
|
||||||
{
|
{
|
||||||
var client = new RestClient(NetConfig.MasterServerUrl);
|
if (restClient==null)
|
||||||
|
{
|
||||||
|
restClient = new RestClient(NetConfig.MasterServerUrl);
|
||||||
|
}
|
||||||
|
|
||||||
var request = new RestRequest("masterserver2.php", Method.GET);
|
var request = new RestRequest("masterserver2.php", Method.GET);
|
||||||
request.AddParameter("action", "addserver");
|
request.AddParameter("action", "addserver");
|
||||||
@@ -171,7 +177,7 @@ namespace Barotrauma.Networking
|
|||||||
request.AddParameter("password", string.IsNullOrWhiteSpace(password) ? 0 : 1);
|
request.AddParameter("password", string.IsNullOrWhiteSpace(password) ? 0 : 1);
|
||||||
|
|
||||||
// execute the request
|
// execute the request
|
||||||
RestResponse response = (RestResponse)client.Execute(request);
|
RestResponse response = (RestResponse)restClient.Execute(request);
|
||||||
|
|
||||||
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
@@ -191,7 +197,10 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private IEnumerable<object> RefreshMaster()
|
private IEnumerable<object> RefreshMaster()
|
||||||
{
|
{
|
||||||
var client = new RestClient(NetConfig.MasterServerUrl);
|
if (restClient == null)
|
||||||
|
{
|
||||||
|
restClient = new RestClient(NetConfig.MasterServerUrl);
|
||||||
|
}
|
||||||
|
|
||||||
var request = new RestRequest("masterserver2.php", Method.GET);
|
var request = new RestRequest("masterserver2.php", Method.GET);
|
||||||
request.AddParameter("action", "refreshserver");
|
request.AddParameter("action", "refreshserver");
|
||||||
@@ -205,7 +214,7 @@ namespace Barotrauma.Networking
|
|||||||
sw.Start();
|
sw.Start();
|
||||||
|
|
||||||
masterServerResponded = false;
|
masterServerResponded = false;
|
||||||
var restRequestHandle = client.ExecuteAsync(request, response => MasterServerCallBack(response));
|
var restRequestHandle = restClient.ExecuteAsync(request, response => MasterServerCallBack(response));
|
||||||
|
|
||||||
DateTime timeOut = DateTime.Now + new TimeSpan(0, 0, 15);
|
DateTime timeOut = DateTime.Now + new TimeSpan(0, 0, 15);
|
||||||
while (!masterServerResponded)
|
while (!masterServerResponded)
|
||||||
@@ -312,40 +321,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
foreach (Client c in ConnectedClients)
|
foreach (Client c in ConnectedClients)
|
||||||
{
|
{
|
||||||
if (c.FileStreamSender != null)
|
if (c.FileStreamSender != null) UpdateFileTransfer(c, deltaTime);
|
||||||
{
|
|
||||||
var clientNameBox = GameMain.NetLobbyScreen.PlayerList.FindChild(c.name);
|
|
||||||
var clientInfo = clientNameBox.FindChild(c.FileStreamSender);
|
|
||||||
|
|
||||||
if (clientInfo==null)
|
|
||||||
{
|
|
||||||
clientInfo = new GUIFrame(new Rectangle(0,0,180,0), Color.Transparent, Alignment.TopRight, null, clientNameBox);
|
|
||||||
clientInfo.UserData = c.FileStreamSender;
|
|
||||||
new GUIProgressBar(new Rectangle(0, 4, 0, clientInfo.Rect.Height-8), Color.Green, GUI.Style, 0.0f, Alignment.Left, clientInfo).IsHorizontal = true;
|
|
||||||
new GUITextBlock(new Rectangle(0,2,0,0), "", GUI.Style, Alignment.TopLeft, Alignment.Left | Alignment.CenterY, clientInfo, true, GUI.SmallFont);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var progressBar = clientInfo.GetChild<GUIProgressBar>();
|
|
||||||
progressBar.BarSize = c.FileStreamSender.Progress;
|
|
||||||
|
|
||||||
var progressText = clientInfo.GetChild<GUITextBlock>();
|
|
||||||
progressText.Text = c.FileStreamSender.FileName + " " +
|
|
||||||
MathUtils.GetBytesReadable(c.FileStreamSender.Sent) + " / " + MathUtils.GetBytesReadable(c.FileStreamSender.FileSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
c.FileStreamSender.Update(deltaTime);
|
|
||||||
|
|
||||||
if (c.FileStreamSender.Status == FileTransferStatus.Finished ||
|
|
||||||
c.FileStreamSender.Status == FileTransferStatus.Error ||
|
|
||||||
c.FileStreamSender.Status == FileTransferStatus.Canceled)
|
|
||||||
{
|
|
||||||
clientNameBox.RemoveChild(clientInfo);
|
|
||||||
|
|
||||||
c.FileStreamSender.Dispose();
|
|
||||||
c.FileStreamSender = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
c.ReliableChannel.Update(deltaTime);
|
c.ReliableChannel.Update(deltaTime);
|
||||||
}
|
}
|
||||||
@@ -542,20 +518,16 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (!allowFileTransfers)
|
if (!allowFileTransfers)
|
||||||
{
|
{
|
||||||
var outmsg = server.CreateMessage();
|
SendCancelTransferMessage(dataSender, "File transfers have been disabled by the server.");
|
||||||
outmsg.Write((byte)PacketTypes.RequestFile);
|
|
||||||
outmsg.Write(false);
|
|
||||||
outmsg.Write("File downloads disabled by the server");
|
|
||||||
server.SendMessage(outmsg, dataSender.Connection, NetDeliveryMethod.ReliableUnordered);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte fileType = inc.ReadByte();
|
byte fileType = inc.ReadByte();
|
||||||
string fileName = fileType == (byte)FileTransferType.Cancel ? "" : inc.ReadString();
|
string fileName = fileType == (byte)FileTransferMessageType.Cancel ? "" : inc.ReadString();
|
||||||
|
|
||||||
switch (fileType)
|
switch (fileType)
|
||||||
{
|
{
|
||||||
case (byte)FileTransferType.Submarine:
|
case (byte)FileTransferMessageType.Submarine:
|
||||||
|
|
||||||
var requestedSubmarine = Submarine.SavedSubmarines.Find(s => s.Name == fileName);
|
var requestedSubmarine = Submarine.SavedSubmarines.Find(s => s.Name == fileName);
|
||||||
|
|
||||||
@@ -565,11 +537,13 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var fileStreamSender = FileStreamSender.Create(dataSender.Connection, requestedSubmarine.FilePath, FileTransferType.Submarine);
|
if (dataSender.FileStreamSender != null) dataSender.FileStreamSender.CancelTransfer();
|
||||||
|
|
||||||
|
var fileStreamSender = FileStreamSender.Create(dataSender.Connection, requestedSubmarine.FilePath, FileTransferMessageType.Submarine);
|
||||||
if (fileStreamSender != null) dataSender.FileStreamSender = fileStreamSender;
|
if (fileStreamSender != null) dataSender.FileStreamSender = fileStreamSender;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case (byte)FileTransferType.Cancel:
|
case (byte)FileTransferMessageType.Cancel:
|
||||||
if (dataSender.FileStreamSender != null)
|
if (dataSender.FileStreamSender != null)
|
||||||
{
|
{
|
||||||
dataSender.FileStreamSender.CancelTransfer();
|
dataSender.FileStreamSender.CancelTransfer();
|
||||||
@@ -881,6 +855,13 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
GUIMessageBox.CloseAll();
|
GUIMessageBox.CloseAll();
|
||||||
|
|
||||||
|
if (ConnectedClients.Any(c => c.FileStreamSender != null && c.FileStreamSender.FilePath == selectedSub.FilePath))
|
||||||
|
{
|
||||||
|
new GUIMessageBox("Couldn't start a round",
|
||||||
|
"Can't start a round while sending the selected submarine to clients. Cancel the transfers or wait for them to finish before starting.", 400, 400);
|
||||||
|
yield return CoroutineStatus.Success;
|
||||||
|
}
|
||||||
|
|
||||||
AssignJobs();
|
AssignJobs();
|
||||||
|
|
||||||
roundStartSeed = DateTime.Now.Millisecond;
|
roundStartSeed = DateTime.Now.Millisecond;
|
||||||
@@ -960,7 +941,6 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
GameMain.GameScreen.Select();
|
GameMain.GameScreen.Select();
|
||||||
|
|
||||||
|
|
||||||
AddChatMessage("Press TAB to chat. Use ''d;'' to talk to dead players and spectators, and ''player name;'' to only send the message to a specific player.", ChatMessageType.Server);
|
AddChatMessage("Press TAB to chat. Use ''d;'' to talk to dead players and spectators, and ''player name;'' to only send the message to a specific player.", ChatMessageType.Server);
|
||||||
|
|
||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
@@ -1166,6 +1146,65 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateFileTransfer(Client client, float deltaTime)
|
||||||
|
{
|
||||||
|
if (client.FileStreamSender == null) return;
|
||||||
|
|
||||||
|
var clientNameBox = GameMain.NetLobbyScreen.PlayerList.FindChild(client.name);
|
||||||
|
var clientInfo = clientNameBox.FindChild(client.FileStreamSender);
|
||||||
|
|
||||||
|
if (clientInfo == null)
|
||||||
|
{
|
||||||
|
clientNameBox.ClearChildren();
|
||||||
|
|
||||||
|
clientInfo = new GUIFrame(new Rectangle(0, 0, 180, 0), Color.Transparent, Alignment.TopRight, null, clientNameBox);
|
||||||
|
clientInfo.UserData = client.FileStreamSender;
|
||||||
|
new GUIProgressBar(new Rectangle(0, 4, 160, clientInfo.Rect.Height - 8), Color.Green, GUI.Style, 0.0f, Alignment.Left, clientInfo).IsHorizontal = true;
|
||||||
|
new GUITextBlock(new Rectangle(0, 2, 160, 0), "", GUI.Style, Alignment.TopLeft, Alignment.Left | Alignment.CenterY, clientInfo, true, GUI.SmallFont);
|
||||||
|
|
||||||
|
var cancelButton = new GUIButton(new Rectangle(20, 0, 14, 0), "X", Alignment.Right, GUI.Style, clientInfo);
|
||||||
|
cancelButton.OnClicked = (GUIButton button, object userdata) =>
|
||||||
|
{
|
||||||
|
(cancelButton.Parent.UserData as FileStreamSender).CancelTransfer();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var progressBar = clientInfo.GetChild<GUIProgressBar>();
|
||||||
|
progressBar.BarSize = client.FileStreamSender.Progress;
|
||||||
|
|
||||||
|
var progressText = clientInfo.GetChild<GUITextBlock>();
|
||||||
|
progressText.Text = client.FileStreamSender.FileName + " " +
|
||||||
|
MathUtils.GetBytesReadable(client.FileStreamSender.Sent) + " / " + MathUtils.GetBytesReadable(client.FileStreamSender.FileSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
client.FileStreamSender.Update(deltaTime);
|
||||||
|
|
||||||
|
if (client.FileStreamSender.Status != FileTransferStatus.Sending &&
|
||||||
|
client.FileStreamSender.Status != FileTransferStatus.NotStarted)
|
||||||
|
{
|
||||||
|
if (client.FileStreamSender.Status == FileTransferStatus.Canceled)
|
||||||
|
{
|
||||||
|
SendCancelTransferMessage(client, "File transfer was canceled by the server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
clientNameBox.RemoveChild(clientInfo);
|
||||||
|
|
||||||
|
client.FileStreamSender.Dispose();
|
||||||
|
client.FileStreamSender = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendCancelTransferMessage(Client client, string message)
|
||||||
|
{
|
||||||
|
var outmsg = server.CreateMessage();
|
||||||
|
outmsg.Write((byte)PacketTypes.RequestFile);
|
||||||
|
outmsg.Write(false);
|
||||||
|
outmsg.Write(message);
|
||||||
|
server.SendMessage(outmsg, client.Connection, NetDeliveryMethod.ReliableUnordered);
|
||||||
|
}
|
||||||
|
|
||||||
public void NewTraitor(Character traitor, Character target)
|
public void NewTraitor(Character traitor, Character target)
|
||||||
{
|
{
|
||||||
Log(traitor.Name + " is the traitor and the target is " + target.Name, Color.Cyan);
|
Log(traitor.Name + " is the traitor and the target is " + target.Name, Color.Cyan);
|
||||||
@@ -1590,6 +1629,16 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
banList.Save();
|
banList.Save();
|
||||||
|
|
||||||
|
|
||||||
|
if (registeredToMaster && restClient != null)
|
||||||
|
{
|
||||||
|
var request = new RestRequest("masterserver2.php", Method.GET);
|
||||||
|
request.AddParameter("action", "removeserver");
|
||||||
|
|
||||||
|
restClient.Execute(request);
|
||||||
|
restClient = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (saveServerLogs)
|
if (saveServerLogs)
|
||||||
{
|
{
|
||||||
Log("Shutting down server...", Color.Cyan);
|
Log("Shutting down server...", Color.Cyan);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Barotrauma.Networking
|
namespace Barotrauma.Networking
|
||||||
{
|
{
|
||||||
@@ -18,6 +19,8 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
partial class GameServer : NetworkMember
|
partial class GameServer : NetworkMember
|
||||||
{
|
{
|
||||||
|
public const string SettingsFile = "serversettings.xml";
|
||||||
|
|
||||||
public bool ShowNetStats;
|
public bool ShowNetStats;
|
||||||
|
|
||||||
private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 30);
|
private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 30);
|
||||||
@@ -91,6 +94,66 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public float EndVoteRequiredRatio = 0.5f;
|
public float EndVoteRequiredRatio = 0.5f;
|
||||||
|
|
||||||
|
private void SaveSettings()
|
||||||
|
{
|
||||||
|
XDocument doc = new XDocument(new XElement("serversettings"));
|
||||||
|
|
||||||
|
doc.Root.Add
|
||||||
|
(
|
||||||
|
new XAttribute("AllowSpectating", allowSpectating),
|
||||||
|
new XAttribute("RandomizeSeed", randomizeSeed),
|
||||||
|
new XAttribute("EndRoundAtLevelEnd", endRoundAtLevelEnd),
|
||||||
|
new XAttribute("AllowFileTransfers", allowFileTransfers),
|
||||||
|
|
||||||
|
new XAttribute("SaveServerLogs", saveServerLogs),
|
||||||
|
new XAttribute("LinesPerLogFile", log.LinesPerFile),
|
||||||
|
|
||||||
|
new XAttribute("SubSelection", subSelectionMode),
|
||||||
|
new XAttribute("ModeSelection", modeSelectionMode)
|
||||||
|
);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
doc.Save(SettingsFile);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Saving server settings failed", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadSettings()
|
||||||
|
{
|
||||||
|
XDocument doc = null;
|
||||||
|
if (System.IO.File.Exists(SettingsFile))
|
||||||
|
{
|
||||||
|
doc = ToolBox.TryLoadXml(SettingsFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc == null)
|
||||||
|
{
|
||||||
|
doc = new XDocument(new XElement("serversettings"));
|
||||||
|
}
|
||||||
|
|
||||||
|
allowSpectating = ToolBox.GetAttributeBool(doc.Root, "AllowSpectating", true);
|
||||||
|
randomizeSeed = ToolBox.GetAttributeBool(doc.Root, "RandomizeSeed", true);
|
||||||
|
endRoundAtLevelEnd = ToolBox.GetAttributeBool(doc.Root, "EndRoundAtLevelEnd", true);
|
||||||
|
allowFileTransfers = ToolBox.GetAttributeBool(doc.Root, "AllowFileTransfers", true);
|
||||||
|
|
||||||
|
saveServerLogs = ToolBox.GetAttributeBool(doc.Root, "SaveServerLogs", true);
|
||||||
|
log.LinesPerFile = ToolBox.GetAttributeInt(doc.Root, "LinesPerLogFile", 800);
|
||||||
|
|
||||||
|
subSelectionMode = SelectionMode.Manual;
|
||||||
|
Enum.TryParse<SelectionMode>(ToolBox.GetAttributeString(doc.Root, "SubSelection", "Manual"), out subSelectionMode);
|
||||||
|
|
||||||
|
modeSelectionMode = SelectionMode.Manual;
|
||||||
|
Enum.TryParse<SelectionMode>(ToolBox.GetAttributeString(doc.Root, "ModeSelection", "Manual"), out modeSelectionMode);
|
||||||
|
}
|
||||||
|
|
||||||
private void CreateSettingsFrame()
|
private void CreateSettingsFrame()
|
||||||
{
|
{
|
||||||
settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
|
settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
|
||||||
@@ -227,6 +290,7 @@ namespace Barotrauma.Networking
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
settingsFrame = null;
|
settingsFrame = null;
|
||||||
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ namespace Barotrauma.Networking
|
|||||||
message.Write((byte)msgBytes.Count);
|
message.Write((byte)msgBytes.Count);
|
||||||
foreach (byte[] msgData in msgBytes)
|
foreach (byte[] msgData in msgBytes)
|
||||||
{
|
{
|
||||||
if (msgData.Length > 255) DebugConsole.ThrowError("too large networkevent (" + msgData.Length + " bytes)");
|
if (msgData.Length > 255) DebugConsole.ThrowError("Too large networkevent (" + msgData.Length + " bytes)");
|
||||||
|
|
||||||
message.Write((byte)msgData.Length);
|
message.Write((byte)msgData.Length);
|
||||||
message.Write(msgData);
|
message.Write(msgData);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
class ServerLog
|
class ServerLog
|
||||||
{
|
{
|
||||||
const int LinesPerFile = 800;
|
private int linesPerFile = 800;
|
||||||
|
|
||||||
public const string SavePath = "ServerLogs";
|
public const string SavePath = "ServerLogs";
|
||||||
|
|
||||||
@@ -21,6 +21,12 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private Queue<ColoredText> lines;
|
private Queue<ColoredText> lines;
|
||||||
|
|
||||||
|
public int LinesPerFile
|
||||||
|
{
|
||||||
|
get { return linesPerFile; }
|
||||||
|
set { linesPerFile = Math.Max(10, linesPerFile); }
|
||||||
|
}
|
||||||
|
|
||||||
public ServerLog(string serverName)
|
public ServerLog(string serverName)
|
||||||
{
|
{
|
||||||
this.serverName = serverName;
|
this.serverName = serverName;
|
||||||
|
|||||||
@@ -155,24 +155,28 @@ namespace Barotrauma
|
|||||||
if (held) heldQueue = true;
|
if (held) heldQueue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Dequeue
|
public bool DequeueHit()
|
||||||
{
|
{
|
||||||
get
|
bool value = hitQueue;
|
||||||
{
|
hitQueue = false;
|
||||||
bool value = hitQueue;
|
return value;
|
||||||
hitQueue = false;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DequeueHeld
|
public bool DequeueHeld()
|
||||||
{
|
{
|
||||||
get
|
bool value = heldQueue;
|
||||||
{
|
heldQueue = false;
|
||||||
bool value = heldQueue;
|
return value;
|
||||||
heldQueue = false;
|
}
|
||||||
return value;
|
|
||||||
}
|
public bool GetHeldQueue
|
||||||
|
{
|
||||||
|
get { return heldQueue; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GetHitQueue
|
||||||
|
{
|
||||||
|
get { return hitQueue; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ namespace Barotrauma
|
|||||||
return editableProperties;
|
return editableProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<string, ObjectProperty> GetProperties(object obj)
|
public static Dictionary<string, ObjectProperty> GetProperties(IPropertyObject obj)
|
||||||
{
|
{
|
||||||
var properties = TypeDescriptor.GetProperties(obj.GetType()).Cast<PropertyDescriptor>();
|
var properties = TypeDescriptor.GetProperties(obj.GetType()).Cast<PropertyDescriptor>();
|
||||||
|
|
||||||
@@ -207,12 +207,12 @@ namespace Barotrauma
|
|||||||
return dictionary;
|
return dictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<string, ObjectProperty> InitProperties(object obj)
|
public static Dictionary<string, ObjectProperty> InitProperties(IPropertyObject obj)
|
||||||
{
|
{
|
||||||
return InitProperties(obj, null);
|
return InitProperties(obj, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<string, ObjectProperty> InitProperties(object obj, XElement element)
|
public static Dictionary<string, ObjectProperty> InitProperties(IPropertyObject obj, XElement element)
|
||||||
{
|
{
|
||||||
var properties = TypeDescriptor.GetProperties(obj.GetType()).Cast<PropertyDescriptor>();
|
var properties = TypeDescriptor.GetProperties(obj.GetType()).Cast<PropertyDescriptor>();
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
@@ -291,7 +292,14 @@ namespace Barotrauma
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Submarine.SaveCurrent(nameBox.Text + ".sub");
|
string savePath = nameBox.Text + ".sub";
|
||||||
|
|
||||||
|
if (Submarine.Loaded != null)
|
||||||
|
{
|
||||||
|
savePath = Path.Combine(Path.GetDirectoryName(Submarine.Loaded.FilePath), savePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
Submarine.SaveCurrent(savePath);
|
||||||
Submarine.Loaded.CheckForErrors();
|
Submarine.Loaded.CheckForErrors();
|
||||||
|
|
||||||
GUI.AddMessage("Submarine saved to " + Submarine.Loaded.FilePath, Color.Green, 3.0f);
|
GUI.AddMessage("Submarine saved to " + Submarine.Loaded.FilePath, Color.Green, 3.0f);
|
||||||
|
|||||||
@@ -514,7 +514,15 @@ namespace Barotrauma
|
|||||||
var hash = (obj as Submarine).MD5Hash;
|
var hash = (obj as Submarine).MD5Hash;
|
||||||
|
|
||||||
//hash will be null if opening the sub file failed -> don't select the sub
|
//hash will be null if opening the sub file failed -> don't select the sub
|
||||||
return hash.Hash != null;
|
if (string.IsNullOrWhiteSpace(hash.Hash))
|
||||||
|
{
|
||||||
|
(component as GUITextBlock).TextColor = Color.DarkRed * 0.8f;
|
||||||
|
component.CanBeFocused = false;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateSubList()
|
public void UpdateSubList()
|
||||||
@@ -590,7 +598,7 @@ namespace Barotrauma
|
|||||||
public void AddPlayer(string name)
|
public void AddPlayer(string name)
|
||||||
{
|
{
|
||||||
GUITextBlock textBlock = new GUITextBlock(
|
GUITextBlock textBlock = new GUITextBlock(
|
||||||
new Rectangle(0, 0, 0, 25), name,
|
new Rectangle(0, 0, playerList.Rect.Width-20, 25), name,
|
||||||
GUI.Style, Alignment.Left, Alignment.Left,
|
GUI.Style, Alignment.Left, Alignment.Left,
|
||||||
playerList);
|
playerList);
|
||||||
|
|
||||||
@@ -629,7 +637,7 @@ namespace Barotrauma
|
|||||||
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, playerFrameInner);
|
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, playerFrameInner);
|
||||||
closeButton.OnClicked = ClosePlayerFrame;
|
closeButton.OnClicked = ClosePlayerFrame;
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ClosePlayerFrame(GUIButton button, object userData)
|
private bool ClosePlayerFrame(GUIButton button, object userData)
|
||||||
@@ -925,50 +933,47 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public bool TrySelectSub(string subName, string md5Hash)
|
public bool TrySelectSub(string subName, string md5Hash)
|
||||||
{
|
{
|
||||||
|
//already downloading the selected sub file
|
||||||
|
if (GameMain.Client.ActiveFileTransferName == subName+".sub") return false;
|
||||||
|
|
||||||
Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name == subName);
|
Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name == subName);
|
||||||
if (sub == null)
|
if (sub == null || sub.MD5Hash.Hash != md5Hash)
|
||||||
{
|
{
|
||||||
var requestFileBox = new GUIMessageBox("Submarine not found!", "The submarine ''" + subName + "'' has been selected by the server. "
|
string errorMsg = "";
|
||||||
+"Matching file not found in your map folder. Do you want to download the file from the server host?", new string[] { "Yes", "No" }, 400, 300);
|
if (sub == null)
|
||||||
|
{
|
||||||
|
errorMsg = "Submarine ''" + subName + "'' was selected by the server. Matching file not found in your submarine folder. ";
|
||||||
|
}
|
||||||
|
else if (sub.MD5Hash.Hash == null)
|
||||||
|
{
|
||||||
|
errorMsg = "Couldn't load submarine ''" + subName + "''. The file may be corrupted. ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorMsg = "Your version of the submarine file ''" + sub.Name + "'' doesn't match the server's version! "
|
||||||
|
+ "Your MD5 hash: " + sub.MD5Hash.Hash + " \n"
|
||||||
|
+ "Server's MD5 hash: " + md5Hash + ". ";
|
||||||
|
}
|
||||||
|
|
||||||
|
string downloadMsg = GameMain.Client.ActiveFileTransferName == "" ?
|
||||||
|
"Do you want to download the file from the server host?" :
|
||||||
|
"Do you want to download the file and cancel downloading ''" + GameMain.Client.ActiveFileTransferName + "''?";
|
||||||
|
|
||||||
|
var requestFileBox = new GUIMessageBox("Submarine not found!", errorMsg+downloadMsg, new string[] { "Yes", "No" }, 400, 300);
|
||||||
requestFileBox.Buttons[0].UserData = subName;
|
requestFileBox.Buttons[0].UserData = subName;
|
||||||
requestFileBox.Buttons[0].OnClicked += requestFileBox.Close;
|
requestFileBox.Buttons[0].OnClicked += requestFileBox.Close;
|
||||||
requestFileBox.Buttons[0].OnClicked += (GUIButton button, object userdata) =>
|
requestFileBox.Buttons[0].OnClicked += (GUIButton button, object userdata) =>
|
||||||
{
|
{
|
||||||
GameMain.Client.RequestFile(userdata.ToString(), FileTransferType.Submarine);
|
GameMain.Client.RequestFile(userdata.ToString(), FileTransferMessageType.Submarine);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
requestFileBox.Buttons[1].OnClicked += requestFileBox.Close;
|
requestFileBox.Buttons[1].OnClicked += requestFileBox.Close;
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (sub.MD5Hash.Hash != md5Hash)
|
|
||||||
{
|
|
||||||
var requestFileBox = new GUIMessageBox("Submarine not found!",
|
|
||||||
"Your version of the map file ''" + sub.Name + "'' doesn't match the server's version! "
|
|
||||||
+"Your file: " + sub.Name + "(MD5 hash: " + sub.MD5Hash.Hash + ") "
|
|
||||||
+"Server's file: " + subName + "(MD5 hash: " + md5Hash + ")\n "
|
|
||||||
+"Do you want to download the file from the server host?", new string[] { "Yes", "No" }, 400, 300);
|
|
||||||
requestFileBox.Buttons[0].UserData = subName;
|
|
||||||
requestFileBox.Buttons[0].OnClicked += requestFileBox.Close;
|
|
||||||
requestFileBox.Buttons[0].OnClicked += (GUIButton button, object userdata) =>
|
|
||||||
{
|
|
||||||
GameMain.Client.RequestFile(userdata.ToString(), FileTransferType.Submarine);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
requestFileBox.Buttons[1].OnClicked += requestFileBox.Close;
|
|
||||||
|
|
||||||
return false;
|
subList.Select(sub, true);
|
||||||
}
|
return true;
|
||||||
else
|
|
||||||
{
|
|
||||||
subList.Select(sub, true);
|
|
||||||
//map.Load();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteData(NetOutgoingMessage msg)
|
public void WriteData(NetOutgoingMessage msg)
|
||||||
@@ -1011,7 +1016,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void ReadData(NetIncomingMessage msg)
|
public void ReadData(NetIncomingMessage msg)
|
||||||
{
|
{
|
||||||
string mapName="", md5Hash="";
|
string mapName = "", md5Hash = "";
|
||||||
|
|
||||||
int modeIndex = 0;
|
int modeIndex = 0;
|
||||||
//float durationScroll = 0.0f;
|
//float durationScroll = 0.0f;
|
||||||
|
|||||||
Binary file not shown.
@@ -53,7 +53,7 @@ with.
|
|||||||
<CharacterRegions>
|
<CharacterRegions>
|
||||||
<CharacterRegion>
|
<CharacterRegion>
|
||||||
<Start> </Start>
|
<Start> </Start>
|
||||||
<End>~</End>
|
<End>Ұ</End>
|
||||||
</CharacterRegion>
|
</CharacterRegion>
|
||||||
|
|
||||||
<CharacterRegion>
|
<CharacterRegion>
|
||||||
|
|||||||
Binary file not shown.
@@ -30,7 +30,7 @@ with.
|
|||||||
<CharacterRegions>
|
<CharacterRegions>
|
||||||
<CharacterRegion>
|
<CharacterRegion>
|
||||||
<Start> </Start>
|
<Start> </Start>
|
||||||
<End>~</End>
|
<End>Ұ</End>
|
||||||
</CharacterRegion>
|
</CharacterRegion>
|
||||||
|
|
||||||
<CharacterRegion>
|
<CharacterRegion>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ with.
|
|||||||
<CharacterRegions>
|
<CharacterRegions>
|
||||||
<CharacterRegion>
|
<CharacterRegion>
|
||||||
<Start> </Start>
|
<Start> </Start>
|
||||||
<End>~</End>
|
<End>Ұ</End>
|
||||||
</CharacterRegion>
|
</CharacterRegion>
|
||||||
|
|
||||||
<CharacterRegion>
|
<CharacterRegion>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ with.
|
|||||||
<CharacterRegions>
|
<CharacterRegions>
|
||||||
<CharacterRegion>
|
<CharacterRegion>
|
||||||
<Start> </Start>
|
<Start> </Start>
|
||||||
<End>~</End>
|
<End>Ұ</End>
|
||||||
</CharacterRegion>
|
</CharacterRegion>
|
||||||
|
|
||||||
<CharacterRegion>
|
<CharacterRegion>
|
||||||
|
|||||||
Reference in New Issue
Block a user