Networking bugfixes & optimization
This commit is contained in:
BIN
Farseer Physics Engine 3.5/Farseer Physics Engine.v12.suo
Normal file
BIN
Farseer Physics Engine 3.5/Farseer Physics Engine.v12.suo
Normal file
Binary file not shown.
@@ -96,28 +96,25 @@ namespace Launcher
|
||||
fileButton.Enabled = (selectedPackage != null);
|
||||
}
|
||||
|
||||
if (selectedPackage == null)
|
||||
|
||||
foreach (ListBox fileBox in fileBoxes)
|
||||
{
|
||||
foreach (ListBox fileBox in fileBoxes)
|
||||
fileBox.Items.Clear();
|
||||
}
|
||||
|
||||
|
||||
foreach (ListBox fileBox in fileBoxes)
|
||||
{
|
||||
ContentType type = (fileBox.Tag is ContentType) ? (ContentType)fileBox.Tag : ContentType.None;
|
||||
|
||||
foreach (ContentFile file in selectedPackage.files)
|
||||
{
|
||||
fileBox.Items.Clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
foreach (ListBox fileBox in fileBoxes)
|
||||
{
|
||||
ContentType type = (fileBox.Tag is ContentType) ? (ContentType)fileBox.Tag : ContentType.None;
|
||||
|
||||
foreach (ContentFile file in selectedPackage.files)
|
||||
{
|
||||
if (file.type != type) continue;
|
||||
|
||||
fileBox.Items.Add(file);
|
||||
}
|
||||
if (file.type != type) continue;
|
||||
|
||||
fileBox.Items.Add(file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void newPackage_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.1.2.0")]
|
||||
[assembly: AssemblyFileVersion("0.1.2.0")]
|
||||
[assembly: AssemblyVersion("0.1.3.1")]
|
||||
[assembly: AssemblyFileVersion("0.1.3.1")]
|
||||
|
||||
@@ -470,14 +470,21 @@ namespace Subsurface
|
||||
public override void FillNetworkData(NetOutgoingMessage message)
|
||||
{
|
||||
message.Write((byte)state);
|
||||
|
||||
bool wallAttack = (wallAttackPos!=Vector2.Zero && state == AiState.Attack);
|
||||
|
||||
message.Write(wallAttackPos.X);
|
||||
message.Write(wallAttackPos.Y);
|
||||
message.Write(wallAttack);
|
||||
|
||||
message.Write(steeringManager.WanderAngle);
|
||||
message.Write(updateTargetsTimer);
|
||||
message.Write(raycastTimer);
|
||||
message.Write(coolDownTimer);
|
||||
if (wallAttack)
|
||||
{
|
||||
message.Write(wallAttackPos.X);
|
||||
message.Write(wallAttackPos.Y);
|
||||
}
|
||||
|
||||
message.Write(MathUtils.AngleToByte(steeringManager.WanderAngle));
|
||||
message.WriteRangedSingle(Math.Max(updateTargetsTimer,0.0f), 0.0f, UpdateTargetsInterval, 8);
|
||||
message.WriteRangedSingle(Math.Max(raycastTimer,0.0f), 0.0f, RaycastInterval, 8);
|
||||
message.WriteRangedSingle(Math.Max(coolDownTimer, 0.0f), 0.0f, attackCoolDown*2.0f, 8);
|
||||
|
||||
message.Write(targetEntity==null ? -1 : (targetEntity as Entity).ID);
|
||||
}
|
||||
@@ -485,7 +492,7 @@ namespace Subsurface
|
||||
public override void ReadNetworkData(NetIncomingMessage message)
|
||||
{
|
||||
AiState newState = AiState.None;
|
||||
Vector2 newWallAttackPos;
|
||||
Vector2 newWallAttackPos = Vector2.Zero;
|
||||
float wanderAngle;
|
||||
float updateTargetsTimer, raycastTimer, coolDownTimer;
|
||||
|
||||
@@ -495,12 +502,18 @@ namespace Subsurface
|
||||
{
|
||||
|
||||
newState = (AiState)(message.ReadByte());
|
||||
newWallAttackPos = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
|
||||
wanderAngle = MathUtils.WrapAngleTwoPi(message.ReadFloat());
|
||||
updateTargetsTimer = MathHelper.Clamp(message.ReadFloat(), 0.0f, UpdateTargetsInterval);
|
||||
raycastTimer = MathHelper.Clamp(message.ReadFloat(), 0.0f, RaycastInterval);
|
||||
coolDownTimer = MathHelper.Clamp(message.ReadFloat(), 0.0f, attackCoolDown);
|
||||
bool wallAttack = message.ReadBoolean();
|
||||
|
||||
if (wallAttack)
|
||||
{
|
||||
newWallAttackPos = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
}
|
||||
|
||||
wanderAngle = MathUtils.ByteToAngle(message.ReadByte());
|
||||
updateTargetsTimer = message.ReadRangedSingle(0.0f, UpdateTargetsInterval, 8);
|
||||
raycastTimer = message.ReadRangedSingle(0.0f, RaycastInterval, 8);
|
||||
coolDownTimer = message.ReadRangedSingle(0.0f, attackCoolDown*2.0f, 8);
|
||||
|
||||
targetID = message.ReadInt32();
|
||||
}
|
||||
|
||||
@@ -426,6 +426,11 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (info != null && !string.IsNullOrWhiteSpace(info.Name)) ? info.Name : SpeciesName;
|
||||
}
|
||||
|
||||
public void GiveJobItems(WayPoint spawnPoint)
|
||||
{
|
||||
if (info == null || info.Job == null) return;
|
||||
@@ -1032,14 +1037,17 @@ namespace Subsurface
|
||||
message.Write(NetTime.Now);
|
||||
|
||||
// Write byte = move direction
|
||||
message.Write(AnimController.TargetMovement.X);
|
||||
message.Write(AnimController.TargetMovement.Y);
|
||||
message.WriteRangedSingle(AnimController.TargetMovement.X, -10.0f, 10.0f, 8);
|
||||
message.WriteRangedSingle(AnimController.TargetMovement.Y, -10.0f, 10.0f, 8);
|
||||
|
||||
message.Write(AnimController.TargetDir==Direction.Right);
|
||||
|
||||
message.Write(cursorPosition.X);
|
||||
message.Write(cursorPosition.Y);
|
||||
|
||||
if (aiController!=null)
|
||||
{
|
||||
message.WriteRangedSingle(cursorPosition.X, -1000.0f, 1000.0f, 16);
|
||||
message.WriteRangedSingle(cursorPosition.Y, -1000.0f, 1000.0f, 16);
|
||||
}
|
||||
|
||||
message.Write(LargeUpdateTimer <= 0);
|
||||
|
||||
if (LargeUpdateTimer<=0)
|
||||
@@ -1053,29 +1061,28 @@ namespace Subsurface
|
||||
message.Write(limb.body.LinearVelocity.X);
|
||||
message.Write(limb.body.LinearVelocity.Y);
|
||||
|
||||
message.Write(limb.body.Rotation);
|
||||
message.Write(MathUtils.AngleToByte(limb.body.Rotation));
|
||||
message.Write(limb.body.AngularVelocity);
|
||||
i++;
|
||||
}
|
||||
|
||||
message.Write(AnimController.StunTimer);
|
||||
message.WriteRangedSingle(AnimController.StunTimer, 0.0f, 60.0f, 8);
|
||||
message.Write((byte)health);
|
||||
|
||||
LargeUpdateTimer = 5;
|
||||
if (aiController != null) aiController.FillNetworkData(message);
|
||||
|
||||
LargeUpdateTimer = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
Limb torso = AnimController.GetLimb(LimbType.Torso);
|
||||
if (torso == null) torso = AnimController.GetLimb(LimbType.Head);
|
||||
|
||||
message.Write(torso.body.Position.X);
|
||||
message.Write(torso.body.Position.Y);
|
||||
|
||||
LargeUpdateTimer = Math.Max(0, LargeUpdateTimer-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (aiController != null) aiController.FillNetworkData(message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
|
||||
@@ -1127,10 +1134,19 @@ namespace Subsurface
|
||||
|
||||
sendingTime = message.ReadDouble();
|
||||
|
||||
targetMovement = new Vector2 (message.ReadFloat(), message.ReadFloat());
|
||||
targetMovement = new Vector2(message.ReadRangedSingle(-10.0f, 10.0f, 8), message.ReadRangedSingle(-10.0f, 10.0f, 8));
|
||||
targetMovement.X = MathUtils.Round(targetMovement.X, 0.1f);
|
||||
targetMovement.Y = MathUtils.Round(targetMovement.Y, 0.1f);
|
||||
|
||||
targetDir = message.ReadBoolean();
|
||||
|
||||
cursorPos = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
if (aiController!=null)
|
||||
{
|
||||
cursorPos = new Vector2(
|
||||
message.ReadRangedSingle(-1000.0f, 1000.0f, 16),
|
||||
message.ReadRangedSingle(-1000.0f, 1000.0f, 16));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
catch
|
||||
@@ -1165,7 +1181,7 @@ namespace Subsurface
|
||||
vel.X = message.ReadFloat();
|
||||
vel.Y = message.ReadFloat();
|
||||
|
||||
rotation = message.ReadFloat();
|
||||
rotation = MathUtils.ByteToAngle(message.ReadByte());
|
||||
angularVel = message.ReadFloat();
|
||||
}
|
||||
catch
|
||||
@@ -1187,7 +1203,7 @@ namespace Subsurface
|
||||
|
||||
try
|
||||
{
|
||||
newStunTimer = message.ReadFloat();
|
||||
newStunTimer = message.ReadRangedSingle(0.0f, 60.0f, 8);
|
||||
newHealth = message.ReadByte();
|
||||
}
|
||||
catch { return; }
|
||||
@@ -1196,6 +1212,8 @@ namespace Subsurface
|
||||
Health = newHealth;
|
||||
|
||||
LargeUpdateTimer = 1;
|
||||
|
||||
if (aiController != null) aiController.ReadNetworkData(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1210,13 +1228,12 @@ namespace Subsurface
|
||||
|
||||
|
||||
Limb torso = AnimController.GetLimb(LimbType.Torso);
|
||||
if (torso == null) torso = AnimController.GetLimb(LimbType.Head);
|
||||
torso.body.TargetPosition = pos;
|
||||
|
||||
LargeUpdateTimer = 0;
|
||||
}
|
||||
|
||||
if (aiController != null) aiController.ReadNetworkData(message);
|
||||
|
||||
LastNetworkUpdate = sendingTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace Subsurface
|
||||
{
|
||||
UpdateCharacterItems();
|
||||
}
|
||||
|
||||
|
||||
if (pickedItems.Count > 0)
|
||||
{
|
||||
charElement.Add(new XAttribute("items", string.Join(",", pickedItems)));
|
||||
|
||||
@@ -63,8 +63,10 @@ namespace Subsurface
|
||||
{
|
||||
string endMessage = traitor.character.Info.Name + " was a traitor! ";
|
||||
endMessage += (traitor.character.Info.Gender == Gender.Male) ? "His" : "Her";
|
||||
endMessage += " task was to assassinate " + target.character.Info.Name + ". ";
|
||||
endMessage += "The task was unsuccessful - the has submarine reached its destination.";
|
||||
endMessage += " task was to assassinate " + target.character.Info.Name + ", but ";
|
||||
endMessage += (traitor.character.Info.Gender == Gender.Male) ? "he" : "she";
|
||||
endMessage += " got " + ((traitor.character.Info.Gender == Gender.Male) ? "himself" : "herself");
|
||||
endMessage += " killed before completing it.";
|
||||
End(endMessage);
|
||||
return;
|
||||
}
|
||||
@@ -72,10 +74,8 @@ namespace Subsurface
|
||||
{
|
||||
string endMessage = traitor.character.Info.Name + " was a traitor! ";
|
||||
endMessage += (traitor.character.Info.Gender == Gender.Male) ? "His" : "Her";
|
||||
endMessage += " task was to assassinate " + target.character.Info.Name + ", but ";
|
||||
endMessage += (traitor.character.Info.Gender == Gender.Male) ? "he" : "she";
|
||||
endMessage += " got " + ((traitor.character.Info.Gender == Gender.Male) ? "himself" : "herself");
|
||||
endMessage += " killed before completing it.";
|
||||
endMessage += " task was to assassinate " + target.character.Info.Name + ". ";
|
||||
endMessage += "The task was unsuccessful - the has submarine reached its destination.";
|
||||
End(endMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,21 @@ namespace Subsurface
|
||||
GraphicsHeight = int.Parse(graphicsMode.Attribute("height").Value);
|
||||
|
||||
FullScreenEnabled = graphicsMode.Attribute("fullscreen").Value == "true";
|
||||
|
||||
MasterServerUrl = ToolBox.GetAttributeString(doc.Root, "masterserverurl", "");
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLower())
|
||||
{
|
||||
case "contentpackage":
|
||||
string path = ToolBox.GetAttributeString(subElement, "path", "");
|
||||
SelectedContentPackage = ContentPackage.list.Find(cp => cp.Path == path);
|
||||
|
||||
if (SelectedContentPackage == null) SelectedContentPackage = new ContentPackage(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -60,20 +75,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
MasterServerUrl = ToolBox.GetAttributeString(doc.Root, "masterserverurl", "");
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLower())
|
||||
{
|
||||
case "contentpackage":
|
||||
string path = ToolBox.GetAttributeString(subElement, "path", "");
|
||||
SelectedContentPackage = ContentPackage.list.Find(cp => cp.Path == path);
|
||||
|
||||
if (SelectedContentPackage == null) SelectedContentPackage = new ContentPackage(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,6 +88,8 @@ namespace Subsurface
|
||||
doc.Add(new XElement("config"));
|
||||
}
|
||||
|
||||
doc.Root.Add(new XAttribute("masterserverurl", MasterServerUrl));
|
||||
|
||||
XElement gMode = doc.Root.Element("graphicsmode");
|
||||
if (gMode == null)
|
||||
{
|
||||
|
||||
@@ -139,16 +139,17 @@ namespace Subsurface
|
||||
if (items[i] != null)
|
||||
{
|
||||
bool combined = false;
|
||||
if (item.Combine(items[i]))
|
||||
{
|
||||
//PutItem(item, i, false, false);
|
||||
combined = true;
|
||||
}
|
||||
//else if (items[i].Combine(item))
|
||||
//if (item.Combine(items[i]))
|
||||
//{
|
||||
// //PutItem(items[i], i, false, false);
|
||||
// //PutItem(item, i, false, false);
|
||||
// combined = true;
|
||||
//}
|
||||
//else
|
||||
if (items[i].Combine(item))
|
||||
{
|
||||
//PutItem(items[i], i, false, false);
|
||||
combined = true;
|
||||
}
|
||||
|
||||
if (!combined) return false;
|
||||
|
||||
|
||||
@@ -66,7 +66,9 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
this.cam = cam;
|
||||
|
||||
if (character == null || character.SelectedConstruction != item)
|
||||
if (character == null
|
||||
|| character.SelectedConstruction != item
|
||||
|| Vector2.Distance(character.SimPosition, item.SimPosition) > item.PickDistance * 1.5f)
|
||||
{
|
||||
if (character != null)
|
||||
{
|
||||
|
||||
@@ -239,24 +239,15 @@ namespace Subsurface.Items.Components
|
||||
|
||||
new RepairTask(item, 60.0f, "Reactor meltdown!");
|
||||
item.Condition = 0.0f;
|
||||
//fissionRate = 0.0f;
|
||||
//coolingRate = 0.0f;
|
||||
|
||||
//PlaySound(ActionType.OnFailure, item.Position);
|
||||
//item.ApplyStatusEffects(ActionType.OnFailure, 1.0f, null);
|
||||
|
||||
//new Explosion(item.SimPosition, 6.0f, 500.0f, 600.0f, 10.0f, 2.0f).Explode();
|
||||
var containedItems = item.ContainedItems;
|
||||
if (containedItems == null) return;
|
||||
|
||||
if (item.ContainedItems!=null)
|
||||
foreach (Item containedItem in item.ContainedItems)
|
||||
{
|
||||
foreach (Item containedItem in item.ContainedItems)
|
||||
{
|
||||
if (containedItem == null) continue;
|
||||
containedItem.Condition = 0.0f;
|
||||
}
|
||||
if (containedItem == null) continue;
|
||||
containedItem.Condition = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override bool Pick(Character picker)
|
||||
|
||||
@@ -173,16 +173,19 @@ namespace Subsurface.Items.Components
|
||||
(float)Math.Cos(item.body.Rotation),
|
||||
(float)Math.Sin(item.body.Rotation));
|
||||
|
||||
if (Vector2.Dot(f1.Body.LinearVelocity, normal)<0 ) return StickToTarget(f2.Body, dir);
|
||||
if (Vector2.Dot(f1.Body.LinearVelocity, normal) < 0.0f) return StickToTarget(f2.Body, dir);
|
||||
}
|
||||
|
||||
foreach (Item contained in item.ContainedItems)
|
||||
|
||||
var containedItems = item.ContainedItems;
|
||||
if (containedItems == null) return true;
|
||||
foreach (Item contained in containedItems)
|
||||
{
|
||||
contained.Condition = 0.0f;
|
||||
if (contained.body != null)
|
||||
{
|
||||
contained.body.SetTransform(item.SimPosition, contained.body.Rotation);
|
||||
contained.SetTransform(item.SimPosition, contained.body.Rotation);
|
||||
}
|
||||
contained.Condition = 0.0f;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -61,6 +61,11 @@ namespace Subsurface
|
||||
get { return prefab.sprite; }
|
||||
}
|
||||
|
||||
public float PickDistance
|
||||
{
|
||||
get { return prefab.PickDistance; }
|
||||
}
|
||||
|
||||
public float Condition
|
||||
{
|
||||
get { return condition; }
|
||||
|
||||
@@ -505,7 +505,7 @@ namespace Subsurface
|
||||
|
||||
private void Translate(Vector2 amount)
|
||||
{
|
||||
if (amount == Vector2.Zero) return;
|
||||
if (amount == Vector2.Zero || ! amount.IsValid()) return;
|
||||
|
||||
Level.Loaded.Move(-amount);
|
||||
}
|
||||
@@ -516,11 +516,6 @@ namespace Subsurface
|
||||
speed += force/mass;
|
||||
}
|
||||
|
||||
//public void Move(Vector2 amount)
|
||||
//{
|
||||
// speed = Vector2.Lerp(speed, amount, 0.05f);
|
||||
//}
|
||||
|
||||
VoronoiCell collidingCell;
|
||||
public bool OnCollision(Fixture f1, Fixture f2, Contact contact)
|
||||
{
|
||||
@@ -597,6 +592,8 @@ namespace Subsurface
|
||||
return;
|
||||
}
|
||||
|
||||
if (!speed.IsValid() || targetPosition.IsValid()) return;
|
||||
|
||||
//newTargetPosition = newTargetPosition + newSpeed * (float)(NetTime.Now - sendingTime);
|
||||
|
||||
targetPosition = newTargetPosition;
|
||||
|
||||
@@ -74,8 +74,8 @@ namespace Subsurface.Networking
|
||||
// Create new instance of configs. Parameter is "application Id". It has to be same on client and server.
|
||||
NetPeerConfiguration Config = new NetPeerConfiguration("subsurface");
|
||||
|
||||
//Config.SimulatedLoss = 0.2f;
|
||||
//Config.SimulatedMinimumLatency = 0.25f;
|
||||
Config.SimulatedLoss = 0.2f;
|
||||
Config.SimulatedMinimumLatency = 0.5f;
|
||||
|
||||
// Create new client, with previously created configs
|
||||
client = new NetClient(Config);
|
||||
@@ -141,7 +141,7 @@ namespace Subsurface.Networking
|
||||
// When this is set to true, we are approved and ready to go
|
||||
bool CanStart = false;
|
||||
|
||||
DateTime timeOut = DateTime.Now + new TimeSpan(0,0,5);
|
||||
DateTime timeOut = DateTime.Now + new TimeSpan(0,0,15);
|
||||
|
||||
// Loop untill we are approved
|
||||
while (!CanStart)
|
||||
@@ -421,6 +421,26 @@ namespace Subsurface.Networking
|
||||
gameStarted = false;
|
||||
}
|
||||
|
||||
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
if (!Game1.DebugDraw) return;
|
||||
|
||||
int width = 200, height = 300;
|
||||
int x = Game1.GraphicsWidth - width, y = (int)(Game1.GraphicsHeight * 0.3f);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black * 0.7f, true);
|
||||
spriteBatch.DrawString(GUI.Font, "Network statistics:", new Vector2(x + 10, y + 10), Color.White);
|
||||
|
||||
spriteBatch.DrawString(GUI.SmallFont, "Received bytes: " + client.Statistics.ReceivedBytes, new Vector2(x + 10, y + 45), Color.White);
|
||||
spriteBatch.DrawString(GUI.SmallFont, "Received packets: " + client.Statistics.ReceivedPackets, new Vector2(x + 10, y + 60), Color.White);
|
||||
|
||||
spriteBatch.DrawString(GUI.SmallFont, "Sent bytes: " + client.Statistics.SentBytes, new Vector2(x + 10, y + 75), Color.White);
|
||||
spriteBatch.DrawString(GUI.SmallFont, "Sent packets: " + client.Statistics.SentPackets, new Vector2(x + 10, y + 90), Color.White);
|
||||
|
||||
}
|
||||
|
||||
public override void Disconnect()
|
||||
{
|
||||
NetOutgoingMessage msg = client.CreateMessage();
|
||||
@@ -514,7 +534,7 @@ namespace Subsurface.Networking
|
||||
msg.Write((byte)type);
|
||||
msg.Write(message);
|
||||
|
||||
client.SendMessage(msg, NetDeliveryMethod.Unreliable);
|
||||
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -38,12 +38,12 @@ namespace Subsurface.Networking
|
||||
this.name = name;
|
||||
|
||||
this.password = password;
|
||||
|
||||
|
||||
config = new NetPeerConfiguration("subsurface");
|
||||
|
||||
//config.SimulatedLoss = 0.2f;
|
||||
//config.SimulatedMinimumLatency = 0.25f;
|
||||
|
||||
config.SimulatedLoss = 0.2f;
|
||||
config.SimulatedMinimumLatency = 0.5f;
|
||||
|
||||
config.Port = port;
|
||||
Port = port;
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace Subsurface.Networking
|
||||
|
||||
if (!isClient)
|
||||
{
|
||||
c.LargeUpdateTimer = 0;
|
||||
//c.LargeUpdateTimer = 0;
|
||||
new NetworkEvent(c.ID, false);
|
||||
}
|
||||
}
|
||||
@@ -259,32 +259,38 @@ namespace Subsurface.Networking
|
||||
catch
|
||||
{
|
||||
inc.SenderConnection.Deny("Connection error - server failed to read your ConnectionApproval message");
|
||||
DebugConsole.NewMessage("Connection error - server failed to read the ConnectionApproval message", Color.Red);
|
||||
break;
|
||||
}
|
||||
|
||||
if (userPassword != password)
|
||||
{
|
||||
inc.SenderConnection.Deny("Wrong password!");
|
||||
|
||||
break;
|
||||
}
|
||||
else if (version != Game1.Version.ToString())
|
||||
{
|
||||
inc.SenderConnection.Deny("Subsurface version " + Game1.Version + " required to connect to the server (Your version: " + version + ")");
|
||||
DebugConsole.NewMessage("Connection error - wrong game version", Color.Red);
|
||||
break;
|
||||
}
|
||||
else if (packageName != Game1.SelectedPackage.Name)
|
||||
{
|
||||
inc.SenderConnection.Deny("Your content package ("+packageName+") doesn't match the server's version (" + Game1.SelectedPackage.Name + ")");
|
||||
DebugConsole.NewMessage("Connection error - wrong content package name", Color.Red);
|
||||
break;
|
||||
}
|
||||
else if (packageHash != Game1.SelectedPackage.MD5hash.Hash)
|
||||
{
|
||||
inc.SenderConnection.Deny("Your content package (MD5: " + packageHash + ") doesn't match the server's version (MD5: " + Game1.SelectedPackage.MD5hash.Hash + ")");
|
||||
DebugConsole.NewMessage("Connection error - wrong content package hash", Color.Red);
|
||||
break;
|
||||
}
|
||||
else if (connectedClients.Find(c => c.name.ToLower() == name.ToLower())!=null)
|
||||
{
|
||||
inc.SenderConnection.Deny("The name ''" + name + "'' is already in use. Please choose another name.");
|
||||
DebugConsole.NewMessage("Connection error - name already in use", Color.Red);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -397,7 +403,9 @@ namespace Subsurface.Networking
|
||||
}
|
||||
|
||||
if (recipients.Count == 0) break;
|
||||
server.SendMessage(outmsg, recipients, inc.DeliveryMethod, 0);
|
||||
server.SendMessage(outmsg, recipients, inc.DeliveryMethod, 0);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("Sending networkevent (" + outmsg.LengthBytes+" bytes)");
|
||||
|
||||
break;
|
||||
case (byte)PacketTypes.Chatmessage:
|
||||
@@ -451,6 +459,8 @@ namespace Subsurface.Networking
|
||||
|
||||
networkEvent.FillData(message);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("Sending networkevent " + Entity.FindEntityByID(networkEvent.ID).ToString() + " (" + message.LengthBytes + " bytes)");
|
||||
|
||||
if (server.ConnectionsCount>0)
|
||||
{
|
||||
server.SendMessage(message, server.Connections,
|
||||
@@ -464,13 +474,19 @@ namespace Subsurface.Networking
|
||||
|
||||
public bool StartGame(GUIButton button, object obj)
|
||||
{
|
||||
Submarine selectedMap = Game1.NetLobbyScreen.SelectedMap as Submarine;
|
||||
|
||||
if (selectedMap == null)
|
||||
{
|
||||
Game1.NetLobbyScreen.SubList.Flash();
|
||||
return false;
|
||||
}
|
||||
|
||||
int seed = DateTime.Now.Millisecond;
|
||||
Rand.SetSyncedSeed(seed);
|
||||
|
||||
AssignJobs();
|
||||
|
||||
Submarine selectedMap = Game1.NetLobbyScreen.SelectedMap as Submarine;
|
||||
|
||||
AssignJobs();
|
||||
|
||||
//selectedMap.Load();
|
||||
|
||||
Game1.GameSession = new GameSession(selectedMap, "", Game1.NetLobbyScreen.SelectedMode);
|
||||
@@ -654,7 +670,7 @@ namespace Subsurface.Networking
|
||||
|
||||
public void NewTraitor(Client traitor, Client target)
|
||||
{
|
||||
new GUIMessageBox("New traitor", traitor.name + " is the traitor and the target is " + target+".");
|
||||
new GUIMessageBox("New traitor", traitor.name + " is the traitor and the target is " + target.name+".");
|
||||
|
||||
NetOutgoingMessage msg = server.CreateMessage();
|
||||
msg.Write((byte)PacketTypes.Traitor);
|
||||
@@ -665,6 +681,38 @@ namespace Subsurface.Networking
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
if (!Game1.DebugDraw) return;
|
||||
|
||||
int width = 200, height = 300;
|
||||
int x = Game1.GraphicsWidth - width, y = (int)(Game1.GraphicsHeight*0.3f);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(x,y,width,height), Color.Black*0.7f, true);
|
||||
spriteBatch.DrawString(GUI.Font, "Network statistics:", new Vector2(x+10, y+10), Color.White);
|
||||
|
||||
spriteBatch.DrawString(GUI.SmallFont, "Connections: "+server.ConnectionsCount, new Vector2(x + 10, y + 30), Color.White);
|
||||
spriteBatch.DrawString(GUI.SmallFont, "Received bytes: " + server.Statistics.ReceivedBytes, new Vector2(x + 10, y + 45), Color.White);
|
||||
spriteBatch.DrawString(GUI.SmallFont, "Received packets: " + server.Statistics.ReceivedPackets, new Vector2(x + 10, y + 60), Color.White);
|
||||
|
||||
spriteBatch.DrawString(GUI.SmallFont, "Sent bytes: " + server.Statistics.SentBytes, new Vector2(x + 10, y + 75), Color.White);
|
||||
spriteBatch.DrawString(GUI.SmallFont, "Sent packets: " + server.Statistics.SentPackets, new Vector2(x + 10, y + 90), Color.White);
|
||||
|
||||
|
||||
y += 110;
|
||||
foreach (Client c in connectedClients)
|
||||
{
|
||||
spriteBatch.DrawString(GUI.SmallFont, c.name + ":", new Vector2(x + 10, y), Color.White);
|
||||
spriteBatch.DrawString(GUI.SmallFont, "- avg roundtrip " + c.Connection.AverageRoundtripTime+" s", new Vector2(x + 20, y + 15), Color.White);
|
||||
spriteBatch.DrawString(GUI.SmallFont, "- current MTU " + c.Connection.CurrentMTU, new Vector2(x + 20, y + 30), Color.White);
|
||||
y += 50;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool UpdateNetLobby(object obj)
|
||||
{
|
||||
NetOutgoingMessage msg = server.CreateMessage();
|
||||
@@ -699,12 +747,12 @@ namespace Subsurface.Networking
|
||||
}
|
||||
if (recipients.Count>0)
|
||||
{
|
||||
server.SendMessage(msg, recipients, NetDeliveryMethod.Unreliable, 0);
|
||||
server.SendMessage(msg, recipients, NetDeliveryMethod.ReliableUnordered, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
server.SendMessage(msg, server.Connections, NetDeliveryMethod.Unreliable, 0);
|
||||
server.SendMessage(msg, server.Connections, NetDeliveryMethod.ReliableUnordered, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -113,6 +113,8 @@ namespace Subsurface.Networking
|
||||
return false;
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("Networkevent entity: "+e.ToString());
|
||||
|
||||
//System.Diagnostics.Debug.WriteLine("new message: " + eventType +" - "+e);
|
||||
|
||||
e.ReadNetworkData(eventType, message);
|
||||
|
||||
@@ -428,7 +428,7 @@ namespace Subsurface
|
||||
|
||||
private bool StartShift(GUIButton button, object selection)
|
||||
{
|
||||
Game1.GameSession.StartShift(TimeSpan.Zero, selectedLevel);
|
||||
Game1.GameSession.StartShift(TimeSpan.Zero, selectedLevel, false);
|
||||
Game1.GameScreen.Select();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -23,8 +23,6 @@ namespace Subsurface
|
||||
|
||||
private GUITextBox textBox, seedBox;
|
||||
|
||||
//GUIFrame previewPlayer;
|
||||
|
||||
private GUIScrollBar durationBar;
|
||||
|
||||
private GUIFrame playerFrame;
|
||||
@@ -36,6 +34,11 @@ namespace Subsurface
|
||||
|
||||
private GUITextBox serverMessage;
|
||||
|
||||
public GUIListBox SubList
|
||||
{
|
||||
get { return subList; }
|
||||
}
|
||||
|
||||
public Submarine SelectedMap
|
||||
{
|
||||
get { return subList.SelectedData as Submarine; }
|
||||
@@ -275,7 +278,7 @@ namespace Subsurface
|
||||
modeList.OnSelected += Game1.Server.UpdateNetLobby;
|
||||
durationBar.OnMoved = Game1.Server.UpdateNetLobby;
|
||||
|
||||
if (subList.CountChildren > 0) subList.Select(0);
|
||||
if (subList.CountChildren > 0) subList.Select(-1);
|
||||
if (GameModePreset.list.Count > 0) modeList.Select(0);
|
||||
}
|
||||
else if (playerFrame.children.Count==0)
|
||||
@@ -443,6 +446,7 @@ namespace Subsurface
|
||||
((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black*0.1f, color,
|
||||
Alignment.Left, GUI.style, null, true);
|
||||
msg.Font = GUI.SmallFont;
|
||||
msg.CanBeFocused = false;
|
||||
|
||||
msg.Padding = new Vector4(20, 0, 0, 0);
|
||||
chatBox.AddChild(msg);
|
||||
@@ -658,57 +662,13 @@ namespace Subsurface
|
||||
return;
|
||||
}
|
||||
|
||||
TrySelectMap(mapName, md5Hash);
|
||||
if (!string.IsNullOrWhiteSpace(mapName)) TrySelectMap(mapName, md5Hash);
|
||||
|
||||
modeList.Select(modeIndex);
|
||||
|
||||
durationBar.BarScroll = durationScroll;
|
||||
|
||||
LevelSeed = levelSeed;
|
||||
|
||||
//try
|
||||
//{
|
||||
// int playerCount = msg.ReadInt32();
|
||||
|
||||
// for (int i = 0; i < playerCount; i++)
|
||||
// {
|
||||
// int clientID = msg.ReadInt32();
|
||||
// string jobName = msg.ReadString();
|
||||
|
||||
// Client client = null;
|
||||
// GUITextBlock textBlock = null;
|
||||
// foreach (GUIComponent child in playerList.children)
|
||||
// {
|
||||
// Client tempClient = child.UserData as Client;
|
||||
// if (tempClient == null || tempClient.ID != clientID) continue;
|
||||
|
||||
// client = tempClient;
|
||||
// textBlock = child as GUITextBlock;
|
||||
// break;
|
||||
// }
|
||||
// if (client == null) continue;
|
||||
|
||||
// client.assignedJob = JobPrefab.List.Find(jp => jp.Name == jobName);
|
||||
|
||||
// textBlock.Text = client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")");
|
||||
|
||||
// if (client.assignedJob==null || jobName != client.assignedJob.Name)
|
||||
// {
|
||||
// if (clientID == Game1.Client.ID)
|
||||
// {
|
||||
// Game1.Client.CharacterInfo.Job = new Job(client.assignedJob);
|
||||
// Game1.Client.CharacterInfo.Name = client.name;
|
||||
// UpdatePreviewPlayer(Game1.Client.CharacterInfo);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//catch
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,11 +51,6 @@ namespace Subsurface
|
||||
new GUITextBlock(new Rectangle(0, 100, 0, 30), "Server IP:", GUI.style, menu);
|
||||
ipBox = new GUITextBox(new Rectangle(0, 130, 200, 30), GUI.style, menu);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int middleX = (int)(width * 0.4f);
|
||||
|
||||
serverList = new GUIListBox(new Rectangle(middleX,60,0,(int)(height*0.7f)), GUI.style, menu);
|
||||
@@ -80,6 +75,10 @@ namespace Subsurface
|
||||
|
||||
joinButton = new GUIButton(new Rectangle(0,0,150,30), "Join", Alignment.BottomRight, GUI.style, menu);
|
||||
joinButton.OnClicked = JoinServer;
|
||||
|
||||
GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.style, menu);
|
||||
button.UserData = 0;
|
||||
button.OnClicked = Game1.MainMenuScreen.SelectTab;
|
||||
|
||||
|
||||
refreshDisableTimer = DateTime.Now;
|
||||
@@ -286,7 +285,7 @@ namespace Subsurface
|
||||
{
|
||||
string selectedPassword = "";
|
||||
|
||||
if ((serverList.Selected.GetChild("password") as GUITickBox).Selected)
|
||||
if (serverList.Selected!=null && (serverList.Selected.GetChild("password") as GUITickBox).Selected)
|
||||
{
|
||||
var msgBox = new GUIMessageBox("Password required", "");
|
||||
var passwordBox = new GUITextBox(new Rectangle(0,0,150,20), Alignment.BottomCenter, GUI.style, msgBox);
|
||||
|
||||
@@ -17,7 +17,9 @@ namespace Subsurface
|
||||
|
||||
public static float Round(float value, float div)
|
||||
{
|
||||
return (float)Math.Floor(value / div) * div;
|
||||
return (value < 0.0f) ?
|
||||
(float)Math.Ceiling(value / div) * div :
|
||||
(float)Math.Floor(value / div) * div;
|
||||
}
|
||||
|
||||
public static float VectorToAngle(Vector2 vector)
|
||||
|
||||
@@ -55,11 +55,16 @@ namespace Subsurface
|
||||
{
|
||||
DebugConsole.ThrowError("Error saving gamesession", e);
|
||||
}
|
||||
//Game1.GameSession.crewManager.Save(directory+"\\crew.xml");
|
||||
|
||||
try
|
||||
{
|
||||
CompressDirectory(tempPath, fileName+".save", null);
|
||||
}
|
||||
|
||||
CompressDirectory(tempPath, fileName+".save", null);
|
||||
|
||||
//Directory.Delete(tempPath, true);
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error compressing save file", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadGame(string fileName)
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
v0.1.3.1
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
|
||||
Multiplayer:
|
||||
- chat messages are sent reliably
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
v0.1.3
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
|
||||
Multiplayer:
|
||||
- fixed master server connection errors in server list screen
|
||||
- fixed a bug that caused other characters to get "stuck" to the railgun controller, causing them
|
||||
to fly back to it as they try to move away
|
||||
|
||||
Items:
|
||||
- putting items inside other items works properly now (i.e. by pulling a spear to the same slot as
|
||||
a harpoon, not the other way around)
|
||||
- C4 blocks loaded inside a railgun shell won't explode inside the submarine when firing the railgun
|
||||
- fixed another game-crashing railgun bug
|
||||
- fixed a bug that caused characters to spawn with an incorrect number of items
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
v0.1.2
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,6 @@
|
||||
Content\SpriteFont1.xnb
|
||||
Content\SmallFont.xnb
|
||||
Content\LargeFont.xnb
|
||||
Content\SpriteFont1.spritefont
|
||||
Content\SmallFont.spritefont
|
||||
Content\LargeFont.spritefont
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
Content\SpriteFont1.xnb
|
||||
Content\SmallFont.xnb
|
||||
Content\LargeFont.xnb
|
||||
Content\SpriteFont1.spritefont
|
||||
Content\SmallFont.spritefont
|
||||
Content\LargeFont.spritefont
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,6 @@
|
||||
Content\SpriteFont1.xnb
|
||||
Content\SmallFont.xnb
|
||||
Content\LargeFont.xnb
|
||||
Content\SpriteFont1.spritefont
|
||||
Content\SmallFont.spritefont
|
||||
Content\LargeFont.spritefont
|
||||
|
||||
@@ -7,8 +7,26 @@
|
||||
<Importer>FontDescriptionImporter</Importer>
|
||||
<Processor>FontDescriptionProcessor</Processor>
|
||||
<Options>None</Options>
|
||||
<Output>C:\Users\Joonas\Desktop\SBMR_3011\Sbmr_content\Sbmr_content\bin\Windows\Content\SpriteFont1.xnb</Output>
|
||||
<Time>2014-08-09T18:03:17.8614245+03:00</Time>
|
||||
<Output>E:\Subsurface\Subsurface_content\Subsurface_content\bin\Windows\Content\SpriteFont1.xnb</Output>
|
||||
<Time>2015-07-19T00:51:29.3427566+03:00</Time>
|
||||
</Item>
|
||||
<Item>
|
||||
<Source>SmallFont.spritefont</Source>
|
||||
<Name>SmallFont</Name>
|
||||
<Importer>FontDescriptionImporter</Importer>
|
||||
<Processor>FontDescriptionProcessor</Processor>
|
||||
<Options>None</Options>
|
||||
<Output>E:\Subsurface\Subsurface_content\Subsurface_content\bin\Windows\Content\SmallFont.xnb</Output>
|
||||
<Time>2015-07-19T00:51:26.3565858+03:00</Time>
|
||||
</Item>
|
||||
<Item>
|
||||
<Source>LargeFont.spritefont</Source>
|
||||
<Name>LargeFont</Name>
|
||||
<Importer>FontDescriptionImporter</Importer>
|
||||
<Processor>FontDescriptionProcessor</Processor>
|
||||
<Options>None</Options>
|
||||
<Output>E:\Subsurface\Subsurface_content\Subsurface_content\bin\Windows\Content\LargeFont.xnb</Output>
|
||||
<Time>2015-08-13T19:53:28.5907374+03:00</Time>
|
||||
</Item>
|
||||
<BuildSuccessful>true</BuildSuccessful>
|
||||
<Settings>
|
||||
@@ -17,15 +35,15 @@
|
||||
<TargetProfile>HiDef</TargetProfile>
|
||||
<BuildConfiguration>Windows</BuildConfiguration>
|
||||
<CompressContent>false</CompressContent>
|
||||
<RootDirectory>C:\Users\Joonas\Desktop\SBMR_3011\Sbmr_content\Sbmr_contentContent\</RootDirectory>
|
||||
<LoggerRootDirectory>C:\Users\Joonas\Desktop\SBMR_3011\Sbmr_content\Sbmr_content\</LoggerRootDirectory>
|
||||
<IntermediateDirectory>C:\Users\Joonas\Desktop\SBMR_3011\Sbmr_content\Sbmr_content\obj\Windows\</IntermediateDirectory>
|
||||
<OutputDirectory>C:\Users\Joonas\Desktop\SBMR_3011\Sbmr_content\Sbmr_content\bin\Windows\Content\</OutputDirectory>
|
||||
<RootDirectory>E:\Subsurface\Subsurface_content\Subsurface_contentContent\</RootDirectory>
|
||||
<LoggerRootDirectory>E:\Subsurface\Subsurface_content\Subsurface_content\</LoggerRootDirectory>
|
||||
<IntermediateDirectory>E:\Subsurface\Subsurface_content\Subsurface_content\obj\Windows\</IntermediateDirectory>
|
||||
<OutputDirectory>E:\Subsurface\Subsurface_content\Subsurface_content\bin\Windows\Content\</OutputDirectory>
|
||||
</Settings>
|
||||
<Assemblies>
|
||||
<Assembly>
|
||||
<Key>C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGameContentProcessors.dll</Key>
|
||||
<Value>2014-04-06T00:56:18+03:00</Value>
|
||||
<Value>2015-02-12T06:10:24+02:00</Value>
|
||||
</Assembly>
|
||||
<Assembly>
|
||||
<Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll</Key>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +1,6 @@
|
||||
Content\SpriteFont1.xnb
|
||||
Content\SmallFont.xnb
|
||||
Content\LargeFont.xnb
|
||||
Content\SpriteFont1.spritefont
|
||||
Content\SmallFont.spritefont
|
||||
Content\LargeFont.spritefont
|
||||
|
||||
@@ -65,6 +65,15 @@
|
||||
<Processor>FontDescriptionProcessor</Processor>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LargeFont.spritefont">
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<Name>LargeFont</Name>
|
||||
<Importer>FontDescriptionImporter</Importer>
|
||||
<Processor>FontDescriptionProcessor</Processor>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
|
||||
<!--
|
||||
To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user