Traitormode won't choose the first client as the target, admin can be traitor/target, banlist & removing IPs, environment dust particles, clients are responsible for the KillCharacter message of their own character, moar backgroundfish, syncing item FixRequirement states, longer gameserver tickrate
This commit is contained in:
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Launcher")]
|
||||
[assembly: AssemblyTitle("OldLauncher")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Launcher2</RootNamespace>
|
||||
<AssemblyName>Launcher2</AssemblyName>
|
||||
<AssemblyName>Barotrauma Launcher</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MonoGamePlatform>Windows</MonoGamePlatform>
|
||||
<MonoGameContentBuilderExe>
|
||||
@@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Barotrauma Launcher")]
|
||||
[assembly: AssemblyProduct("Launcher2")]
|
||||
[assembly: AssemblyProduct("Barotrauma Launcher")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
|
||||
@@ -512,6 +512,9 @@
|
||||
<Content Include="Content\Map\citySymbol.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Map\dustparticles.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Map\iceCrack.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<backgroundsprites>
|
||||
<Fish1 speed ="100.0" wanderamount="5.0" wanderzamount="0.1" swarmmin="2" swarmmax="10" swarmradius="500">
|
||||
<Sprite texture="Content/BackgroundSprites/bgFish1.png" sourcerect="0,0,128,64"/>
|
||||
<Sprite texture="Content/BackgroundSprites/bgFish1.png" sourcerect="0,0,119,61"/>
|
||||
</Fish1>
|
||||
|
||||
<Fish2 speed="20.0" wanderamount="0.2" wanderzamount="0.1" swarmmin="1" swarmmax="3" swarmradius="300">
|
||||
<Sprite texture="Content/BackgroundSprites/bgFish1.png" sourcerect="0,64,128,64"/>
|
||||
<Fish2 speed="40.0" wanderamount="0.2" wanderzamount="0.1" swarmmin="1" swarmmax="3" swarmradius="300">
|
||||
<Sprite texture="Content/BackgroundSprites/bgFish1.png" sourcerect="1,65,113,64"/>
|
||||
</Fish2>
|
||||
|
||||
<Fish3 speed="20.0" wanderamount="5.0" wanderzamount="0.1" swarmmin="3" swarmmax="6" swarmradius="300" disablerotation="true">
|
||||
<Sprite texture="Content/BackgroundSprites/bgFish1.png" sourcerect="135,0,117,70"/>
|
||||
</Fish3>
|
||||
|
||||
<Fish4 speed="200.0" wanderamount="5.0" wanderzamount="0.1" swarmmin="1" swarmmax="3" swarmradius="300">
|
||||
<Sprite texture="Content/BackgroundSprites/bgFish1.png" sourcerect="117,70,139,64"/>
|
||||
</Fish4>
|
||||
|
||||
<Fish5 speed="40.0" wanderamount="0.1" wanderzamount="0.1" swarmmin="1" swarmmax="3" swarmradius="300">
|
||||
<Sprite texture="Content/BackgroundSprites/bgFish1.png" sourcerect="0,130,159,50"/>
|
||||
</Fish5>
|
||||
|
||||
|
||||
</backgroundsprites>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 70 KiB |
BIN
Subsurface/Content/Map/dustparticles.png
Normal file
BIN
Subsurface/Content/Map/dustparticles.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
Binary file not shown.
Binary file not shown.
@@ -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.2.3.1")]
|
||||
[assembly: AssemblyFileVersion("0.2.3.1")]
|
||||
[assembly: AssemblyVersion("0.2.3.2")]
|
||||
[assembly: AssemblyFileVersion("0.2.3.2")]
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace Barotrauma
|
||||
|
||||
static Character()
|
||||
{
|
||||
DeathMsg[(int)CauseOfDeath.Damage] = "died";
|
||||
DeathMsg[(int)CauseOfDeath.Damage] = "succumbed to your injuries";
|
||||
DeathMsg[(int)CauseOfDeath.Bloodloss] = "bled out";
|
||||
DeathMsg[(int)CauseOfDeath.Drowning] = "drowned";
|
||||
DeathMsg[(int)CauseOfDeath.Suffocation] = "suffocated";
|
||||
@@ -841,7 +841,7 @@ namespace Barotrauma
|
||||
PressureProtection -= deltaTime*100.0f;
|
||||
}
|
||||
|
||||
Health = health - bleeding * deltaTime;
|
||||
health = MathHelper.Clamp(health - bleeding * deltaTime, 0.0f, maxHealth);
|
||||
if (health <= 0.0f) Kill(CauseOfDeath.Bloodloss, false);
|
||||
}
|
||||
|
||||
@@ -983,8 +983,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!isNetworkMessage)
|
||||
{
|
||||
//if the game is run by a client, characters are only killed when the server says so
|
||||
if (GameMain.Client != null && GameMain.Server == null) return;
|
||||
if (GameMain.NetworkMember != null && controlled != this) return;
|
||||
}
|
||||
|
||||
Vector2 centerOfMass = AnimController.GetCenterOfMass();
|
||||
@@ -1065,12 +1064,29 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
public void Kill(CauseOfDeath causeOfDeath, bool networkMessage = false)
|
||||
public void Kill(CauseOfDeath causeOfDeath, bool isNetworkMessage = false)
|
||||
{
|
||||
if (isDead) return;
|
||||
|
||||
//if the game is run by a client, characters are only killed when the server says so
|
||||
if (GameMain.Client != null && GameMain.Server==null && !networkMessage) return;
|
||||
if (GameMain.NetworkMember != null)
|
||||
{
|
||||
//if the character is controlled by this client/server, let others know that the character has died
|
||||
if (Character.controlled == this)
|
||||
{
|
||||
string chatMessage = "You have " + DeathMsg[(int)causeOfDeath] + ".";
|
||||
if (GameMain.Client!=null) chatMessage += " Your chat messages will only be visible to other dead players.";
|
||||
|
||||
GameMain.NetworkMember.AddChatMessage(chatMessage, ChatMessageType.Dead);
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
|
||||
new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath);
|
||||
}
|
||||
//otherwise don't kill the character unless received a message about the character dying
|
||||
else if (!isNetworkMessage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CoroutineManager.StartCoroutine(DeathAnim(GameMain.GameScreen.Cam));
|
||||
|
||||
@@ -1100,11 +1116,6 @@ namespace Barotrauma
|
||||
joint.MaxMotorTorque = 0.0f;
|
||||
}
|
||||
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
new NetworkEvent(NetworkEventType.KillCharacter, ID, false, causeOfDeath);
|
||||
}
|
||||
|
||||
if (GameMain.GameSession != null)
|
||||
{
|
||||
GameMain.GameSession.KillCharacter(this);
|
||||
@@ -1248,6 +1259,13 @@ namespace Barotrauma
|
||||
}
|
||||
return;
|
||||
case NetworkEventType.KillCharacter:
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
Client sender =GameMain.Server.connectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
if (sender ==null || sender.character != this)
|
||||
throw new Exception("Received a KillCharacter message from someone else than the client controlling the character!");
|
||||
}
|
||||
|
||||
CauseOfDeath causeOfDeath = CauseOfDeath.Damage;
|
||||
try
|
||||
{
|
||||
@@ -1267,12 +1285,6 @@ namespace Barotrauma
|
||||
{
|
||||
Kill(causeOfDeath, true);
|
||||
}
|
||||
|
||||
if (GameMain.NetworkMember != null && controlled == this)
|
||||
{
|
||||
GameMain.NetworkMember.AddChatMessage("You have "+DeathMsg[(int)causeOfDeath]+". Your chat messages will only be visible to other dead players.", ChatMessageType.Dead);
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
}
|
||||
return;
|
||||
case NetworkEventType.InventoryUpdate:
|
||||
if (inventory == null) return;
|
||||
|
||||
@@ -359,6 +359,7 @@ namespace Barotrauma
|
||||
|
||||
public virtual void RemoveChild(GUIComponent child)
|
||||
{
|
||||
if (child == null) return;
|
||||
if (children.Contains(child)) children.Remove(child);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@ namespace Barotrauma
|
||||
{
|
||||
class TraitorMode : GameMode
|
||||
{
|
||||
Client traitor;
|
||||
Client target;
|
||||
|
||||
private Character traitorCharacter, targetCharacter;
|
||||
|
||||
public TraitorMode(GameModePreset preset)
|
||||
@@ -21,8 +18,8 @@ namespace Barotrauma
|
||||
{
|
||||
base.Start();
|
||||
|
||||
traitor = null;
|
||||
target = null;
|
||||
traitorCharacter = null;
|
||||
targetCharacter = null;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
@@ -32,42 +29,24 @@ namespace Barotrauma
|
||||
base.Update(deltaTime);
|
||||
|
||||
if (!isRunning) return;
|
||||
|
||||
|
||||
if (traitor==null || target ==null)
|
||||
|
||||
if (traitorCharacter == null || targetCharacter == null)
|
||||
{
|
||||
int clientCount = GameMain.Server.connectedClients.Count();
|
||||
if (clientCount < 2) return;
|
||||
|
||||
int traitorIndex = Rand.Int(clientCount, false);
|
||||
traitor = GameMain.Server.connectedClients[traitorIndex];
|
||||
|
||||
int targetIndex = 0;
|
||||
while (targetIndex == traitorIndex)
|
||||
{
|
||||
targetIndex = Rand.Int(clientCount, false);
|
||||
}
|
||||
target = GameMain.Server.connectedClients[targetIndex];
|
||||
|
||||
traitorCharacter = traitor.character;
|
||||
targetCharacter = target.character;
|
||||
|
||||
|
||||
GameMain.Server.NewTraitor(traitor, target);
|
||||
GameMain.Server.NewTraitor(out traitorCharacter, out targetCharacter);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target.character == null || target.character.IsDead)
|
||||
if (targetCharacter == null || targetCharacter.IsDead)
|
||||
{
|
||||
string endMessage = traitorCharacter.Name + " was a traitor! ";
|
||||
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her";
|
||||
endMessage += " task was to assassinate " + targetCharacter.Name + ". The task was successful.";
|
||||
End(endMessage);
|
||||
}
|
||||
else if (traitor.character == null || traitor.character.IsDead)
|
||||
else if (traitorCharacter == null || traitorCharacter.IsDead)
|
||||
{
|
||||
string endMessage = traitorCharacter.Name + " was a traitor! ";
|
||||
//TODO: remove references to traitor.character
|
||||
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her";
|
||||
endMessage += " task was to assassinate " + targetCharacter.Name + ", but ";
|
||||
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "he" : "she";
|
||||
@@ -88,5 +67,21 @@ namespace Barotrauma
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void CharacterLeft(Character character)
|
||||
{
|
||||
if (character != traitorCharacter && character != targetCharacter) return;
|
||||
|
||||
if (character == traitorCharacter)
|
||||
{
|
||||
string endMessage = "The traitor has disconnected from the server.";
|
||||
End(endMessage);
|
||||
}
|
||||
else if (character == targetCharacter)
|
||||
{
|
||||
string endMessage = "The traitor's target has disconnected from the server.";
|
||||
End(endMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -138,11 +139,18 @@ namespace Barotrauma
|
||||
|
||||
requirement.Fixed = true;
|
||||
|
||||
Item item = frame.UserData as Item;
|
||||
if (item == null) return true;
|
||||
|
||||
new NetworkEvent(NetworkEventType.ItemFixed, item.ID, true, (byte)item.FixRequirements.IndexOf(requirement) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void UpdateGUIFrame(Item item, Character character)
|
||||
{
|
||||
if (frame == null) return;
|
||||
|
||||
bool unfixedFound = false;
|
||||
foreach (GUIComponent child in frame.children)
|
||||
{
|
||||
|
||||
@@ -1224,6 +1224,11 @@ namespace Barotrauma
|
||||
message.Write(body.SimPosition.Y);
|
||||
}
|
||||
break;
|
||||
case NetworkEventType.ItemFixed:
|
||||
byte requirementIndex = (byte)data;
|
||||
|
||||
message.Write(requirementIndex);
|
||||
break;
|
||||
case NetworkEventType.InventoryUpdate:
|
||||
var itemContainer = GetComponent<ItemContainer>();
|
||||
if (itemContainer == null || itemContainer.inventory == null) return false;
|
||||
@@ -1290,6 +1295,13 @@ namespace Barotrauma
|
||||
SetTransform(newSimPos, body.Rotation);
|
||||
Drop(null, false);
|
||||
break;
|
||||
case NetworkEventType.ItemFixed:
|
||||
|
||||
byte requirementIndex = message.ReadByte();
|
||||
if (requirementIndex>=FixRequirements.Count) return;
|
||||
|
||||
FixRequirements[requirementIndex].Fixed = true;
|
||||
break;
|
||||
case NetworkEventType.InventoryUpdate:
|
||||
var itemContainer = GetComponent<ItemContainer>();
|
||||
if (itemContainer == null || itemContainer.inventory == null) return;
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderBack (SpriteBatch spriteBatch, RenderTarget2D texture, float blurAmount = 0.0007f)
|
||||
public void RenderBack (SpriteBatch spriteBatch, RenderTarget2D texture, float blurAmount = 0.0f)
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap);
|
||||
|
||||
|
||||
@@ -59,14 +59,21 @@ namespace Barotrauma.Networking
|
||||
return bannedPlayers.FirstOrDefault(bp => bp.IP == IP)!=null;
|
||||
}
|
||||
|
||||
public bool ToggleBanFrame(GUIButton button, object obj)
|
||||
{
|
||||
banFrame = CreateBanFrame();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private GUIFrame CreateBanFrame()
|
||||
{
|
||||
banFrame = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), Color.Black*0.3f);
|
||||
banFrame = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), Color.Black*0.5f);
|
||||
|
||||
GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,300,300), null, Alignment.Center, GUI.Style, banFrame);
|
||||
GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,400,300), null, Alignment.Center, GUI.Style, banFrame);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Banned IPs:", GUI.Style, Alignment.Left, Alignment.Left, innerFrame, false, GUI.LargeFont);
|
||||
var banList = new GUIListBox(new Rectangle(0, 30, 200, 0), GUI.Style, innerFrame);
|
||||
new GUITextBlock(new Rectangle(0, -10, 0, 30), "Banned IPs:", GUI.Style, Alignment.Left, Alignment.Left, innerFrame, false, GUI.LargeFont);
|
||||
var banList = new GUIListBox(new Rectangle(0, 30, 0, 0), GUI.Style, innerFrame);
|
||||
|
||||
foreach (BannedPlayer bannedPlayer in bannedPlayers)
|
||||
{
|
||||
@@ -78,12 +85,12 @@ namespace Barotrauma.Networking
|
||||
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
|
||||
textBlock.UserData = banList;
|
||||
|
||||
var removeButton = new GUIButton(new Rectangle(0,0,100,20), "Remove", Alignment.Right, GUI.Style, textBlock);
|
||||
var removeButton = new GUIButton(new Rectangle(0,00,100,20), "Remove", Alignment.Right | Alignment.CenterY, GUI.Style, textBlock);
|
||||
removeButton.UserData = bannedPlayer;
|
||||
removeButton.OnClicked = RemoveBan;
|
||||
}
|
||||
|
||||
var closeButton = new GUIButton(new Rectangle(0,0,100,20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
|
||||
var closeButton = new GUIButton(new Rectangle(0,30,100,20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
|
||||
closeButton.OnClicked = CloseFrame;
|
||||
|
||||
|
||||
|
||||
@@ -484,8 +484,8 @@ namespace Barotrauma.Networking
|
||||
case (byte)PacketTypes.ResendRequest:
|
||||
reliableChannel.HandleResendRequest(inc);
|
||||
break;
|
||||
case (byte)PacketTypes.Ack:
|
||||
reliableChannel.HandleAckMessage(inc);
|
||||
case (byte)PacketTypes.LatestMessageID:
|
||||
reliableChannel.HandleLatestMessageID(inc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,11 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
public float AutoRestartTimer;
|
||||
|
||||
public BanList BanList
|
||||
{
|
||||
get { return banList; }
|
||||
}
|
||||
|
||||
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
|
||||
{
|
||||
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
|
||||
@@ -86,7 +91,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
config.DisableMessageType(NetIncomingMessageType.DebugMessage |
|
||||
NetIncomingMessageType.WarningMessage | NetIncomingMessageType.Receipt |
|
||||
NetIncomingMessageType.ErrorMessage | NetIncomingMessageType.Error);
|
||||
NetIncomingMessageType.ErrorMessage | NetIncomingMessageType.Error |
|
||||
NetIncomingMessageType.UnconnectedData);
|
||||
|
||||
config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
|
||||
|
||||
@@ -137,7 +143,7 @@ namespace Barotrauma.Networking
|
||||
RegisterToMasterServer();
|
||||
}
|
||||
|
||||
updateInterval = new TimeSpan(0, 0, 0, 0, 60);
|
||||
updateInterval = new TimeSpan(0, 0, 0, 0, 150);
|
||||
|
||||
DebugConsole.NewMessage("Server started", Color.Green);
|
||||
|
||||
@@ -504,8 +510,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
dataSender.ReliableChannel.HandleResendRequest(inc);
|
||||
break;
|
||||
case (byte)PacketTypes.Ack:
|
||||
dataSender.ReliableChannel.HandleAckMessage(inc);
|
||||
case (byte)PacketTypes.LatestMessageID:
|
||||
dataSender.ReliableChannel.HandleLatestMessageID(inc);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -884,7 +890,19 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (client == null) return;
|
||||
|
||||
if (gameStarted && client.character != null) client.character.ClearInputs();
|
||||
if (gameStarted && client.character != null)
|
||||
{
|
||||
if (GameMain.GameSession!=null && GameMain.GameSession.gameMode!=null)
|
||||
{
|
||||
TraitorMode traitorMode = GameMain.GameSession.gameMode as TraitorMode;
|
||||
if (traitorMode!=null)
|
||||
{
|
||||
traitorMode.CharacterLeft(client.character);
|
||||
}
|
||||
}
|
||||
|
||||
client.character.ClearInputs();
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(msg)) msg = client.name + " has left the server";
|
||||
if (string.IsNullOrWhiteSpace(targetmsg)) targetmsg = "You have left the server";
|
||||
@@ -956,23 +974,66 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
public void NewTraitor(Client traitor, Client target)
|
||||
public void NewTraitor(out Character traitor, out Character target)
|
||||
{
|
||||
//new GUIMessageBox("New traitor", traitor.name + " is the traitor and the target is " + target.name+".");
|
||||
List<Character> characters = new List<Character>();
|
||||
foreach (Client client in connectedClients)
|
||||
{
|
||||
if (!client.inGame || client.character==null) continue;
|
||||
characters.Add(client.character);
|
||||
}
|
||||
if (myCharacter!= null) characters.Add(myCharacter);
|
||||
|
||||
if (characters.Count < 2)
|
||||
{
|
||||
traitor = null;
|
||||
target = null;
|
||||
return;
|
||||
}
|
||||
|
||||
int traitorIndex = Rand.Range(0, characters.Count);
|
||||
|
||||
int targetIndex = Rand.Range(0, characters.Count);
|
||||
while (targetIndex==traitorIndex)
|
||||
{
|
||||
targetIndex = Rand.Range(0, characters.Count);
|
||||
}
|
||||
|
||||
|
||||
traitor = characters[traitorIndex];
|
||||
target = characters[targetIndex];
|
||||
|
||||
if (myCharacter==null)
|
||||
{
|
||||
new GUIMessageBox("New traitor", traitor.Info.Name + " is the traitor and the target is " + target.Info.Name+".");
|
||||
}
|
||||
else if (myCharacter == traitor)
|
||||
{
|
||||
new GUIMessageBox("You are the traitor!", "Your task is to assassinate " + target.Info.Name+".");
|
||||
return;
|
||||
}
|
||||
|
||||
Client traitorClient = null;
|
||||
foreach (Client c in connectedClients)
|
||||
{
|
||||
if (c.character != traitor) continue;
|
||||
traitorClient = c;
|
||||
break;
|
||||
}
|
||||
|
||||
NetOutgoingMessage msg = server.CreateMessage();
|
||||
msg.Write((byte)PacketTypes.Traitor);
|
||||
msg.Write(target.name);
|
||||
msg.Write(target.Info.Name);
|
||||
if (server.Connections.Count > 0)
|
||||
{
|
||||
server.SendMessage(msg, traitor.Connection, NetDeliveryMethod.ReliableUnordered, 0);
|
||||
server.SendMessage(msg, traitorClient.Connection, NetDeliveryMethod.ReliableUnordered, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
|
||||
if (!ShowNetStats) return;
|
||||
|
||||
int width = 200, height = 300;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
public const float DeleteDisconnectedTime = 10.0f;
|
||||
|
||||
public const float AckInterval = 0.2f;
|
||||
public const float IdSendInterval = 0.2f;
|
||||
public const float RerequestInterval = 0.2f;
|
||||
|
||||
public const int ResendAttempts = 8;
|
||||
|
||||
@@ -18,9 +18,10 @@ namespace Barotrauma.Networking
|
||||
PickItem = 6,
|
||||
DropItem = 7,
|
||||
InventoryUpdate = 8,
|
||||
ItemFixed = 9,
|
||||
|
||||
UpdateProperty = 9,
|
||||
WallDamage = 10,
|
||||
UpdateProperty = 10,
|
||||
WallDamage = 11,
|
||||
|
||||
|
||||
}
|
||||
@@ -34,7 +35,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
static NetworkEvent()
|
||||
{
|
||||
isImportant = new bool[11];
|
||||
isImportant = new bool[Enum.GetNames(typeof(NetworkEventType)).Length];
|
||||
isImportant[(int)NetworkEventType.ImportantEntityUpdate] = true;
|
||||
isImportant[(int)NetworkEventType.ImportantComponentUpdate] = true;
|
||||
isImportant[(int)NetworkEventType.KillCharacter] = true;
|
||||
@@ -44,12 +45,13 @@ namespace Barotrauma.Networking
|
||||
isImportant[(int)NetworkEventType.PickItem] = true;
|
||||
isImportant[(int)NetworkEventType.DropItem] = true;
|
||||
isImportant[(int)NetworkEventType.InventoryUpdate] = true;
|
||||
isImportant[(int)NetworkEventType.ItemFixed] = true;
|
||||
|
||||
isImportant[(int)NetworkEventType.UpdateProperty] = true;
|
||||
isImportant[(int)NetworkEventType.WallDamage] = true;
|
||||
|
||||
overridePrevious = new bool[11];
|
||||
for (int i = 0; i < 11; i++ )
|
||||
overridePrevious = new bool[isImportant.Length];
|
||||
for (int i = 0; i < overridePrevious.Length; i++ )
|
||||
{
|
||||
overridePrevious[i] = true;
|
||||
}
|
||||
@@ -57,6 +59,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
overridePrevious[(int)NetworkEventType.PickItem] = false;
|
||||
overridePrevious[(int)NetworkEventType.DropItem] = false;
|
||||
overridePrevious[(int)NetworkEventType.ItemFixed] = false;
|
||||
}
|
||||
|
||||
private ushort id;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
ResendRequest,
|
||||
ReliableMessage,
|
||||
Ack
|
||||
LatestMessageID
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,10 @@ namespace Barotrauma.Networking.ReliableMessages
|
||||
sender.HandleResendRequest(inc);
|
||||
}
|
||||
|
||||
public void HandleAckMessage(NetIncomingMessage inc)
|
||||
public void HandleLatestMessageID(NetIncomingMessage inc)
|
||||
{
|
||||
//make sure we've received what's been sent to us, if not, rerequest
|
||||
receiver.HandleAckMessage(inc);
|
||||
receiver.HandleLatestMessageID(inc);
|
||||
}
|
||||
|
||||
public bool CheckMessage(NetIncomingMessage inc)
|
||||
@@ -73,9 +73,9 @@ namespace Barotrauma.Networking.ReliableMessages
|
||||
|
||||
private NetConnection recipient;
|
||||
|
||||
private float ackTimer;
|
||||
private float idSendTimer;
|
||||
|
||||
private float ackInterval;
|
||||
private float idSendInterval;
|
||||
|
||||
public ReliableSender(NetPeer sender)
|
||||
{
|
||||
@@ -134,8 +134,8 @@ namespace Barotrauma.Networking.ReliableMessages
|
||||
|
||||
public void SendMessage(ReliableMessage message, NetConnection connection)
|
||||
{
|
||||
ackInterval = 0.0f;
|
||||
ackTimer = connection.AverageRoundtripTime;
|
||||
idSendInterval = 0.0f;
|
||||
idSendTimer = connection.AverageRoundtripTime;
|
||||
|
||||
messageBuffer.Add(message.ID, message);
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace Barotrauma.Networking.ReliableMessages
|
||||
NetOutgoingMessage resendMessage = sender.CreateMessage();
|
||||
message.RestoreInnerMessage(resendMessage);
|
||||
|
||||
ackTimer = connection.AverageRoundtripTime;
|
||||
idSendTimer = connection.AverageRoundtripTime;
|
||||
|
||||
sender.SendMessage(resendMessage, connection, NetDeliveryMethod.Unreliable);
|
||||
}
|
||||
@@ -177,20 +177,20 @@ namespace Barotrauma.Networking.ReliableMessages
|
||||
{
|
||||
if (recipient == null) return;
|
||||
|
||||
ackTimer -= deltaTime;
|
||||
idSendTimer -= deltaTime;
|
||||
|
||||
if (ackTimer > 0.0f) return;
|
||||
if (idSendTimer > 0.0f) return;
|
||||
|
||||
//Debug.WriteLine("Sending ack message: "+messageCount);
|
||||
|
||||
NetOutgoingMessage message = sender.CreateMessage();
|
||||
message.Write((byte)PacketTypes.Ack);
|
||||
message.Write((byte)PacketTypes.LatestMessageID);
|
||||
message.Write(messageCount);
|
||||
|
||||
sender.SendMessage(message, recipient, NetDeliveryMethod.Unreliable);
|
||||
|
||||
ackTimer = Math.Max(recipient.AverageRoundtripTime, NetConfig.AckInterval+ackInterval);
|
||||
ackInterval += 0.1f;
|
||||
idSendTimer = Math.Max(recipient.AverageRoundtripTime, NetConfig.IdSendInterval+idSendInterval);
|
||||
idSendInterval += 0.1f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace Barotrauma.Networking.ReliableMessages
|
||||
missingMessages.Remove(id);
|
||||
}
|
||||
|
||||
public void HandleAckMessage(NetIncomingMessage inc)
|
||||
public void HandleLatestMessageID(NetIncomingMessage inc)
|
||||
{
|
||||
ushort messageId = inc.ReadUInt16();
|
||||
|
||||
@@ -357,7 +357,7 @@ namespace Barotrauma.Networking.ReliableMessages
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.WriteLine("Received ack message: " + messageId + ", need to rerequest messages (last id: "+lastMessageID+")");
|
||||
Debug.WriteLine("Received id update message: " + messageId + ", need to rerequest messages (last id: "+lastMessageID+")");
|
||||
|
||||
if (lastMessageID > ushort.MaxValue / 2 && messageId < short.MaxValue / 2)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,9 @@ namespace Barotrauma
|
||||
readonly RenderTarget2D renderTargetAir;
|
||||
|
||||
readonly Sprite background, backgroundTop;
|
||||
readonly Texture2D dustParticles;
|
||||
|
||||
Vector2 dustOffset;
|
||||
|
||||
public BackgroundSpriteManager BackgroundSpriteManager;
|
||||
|
||||
@@ -35,7 +38,8 @@ namespace Barotrauma
|
||||
|
||||
background = new Sprite("Content/Map/background.png", Vector2.Zero);
|
||||
backgroundTop = new Sprite("Content/Map/background2.png", Vector2.Zero);
|
||||
|
||||
dustParticles = Sprite.LoadTexture("Content/Map/dustparticles.png");
|
||||
|
||||
BackgroundSpriteManager = new BackgroundSpriteManager("Content/BackgroundSprites/BackgroundSpritePrefabs.xml");
|
||||
}
|
||||
|
||||
@@ -78,6 +82,9 @@ namespace Barotrauma
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//dustOffset -= Vector2.UnitY * 100.0f * (float)deltaTime;
|
||||
|
||||
if (GameMain.GameSession!=null) GameMain.GameSession.Update((float)deltaTime);
|
||||
//EventManager.Update(gameTime);
|
||||
|
||||
@@ -166,7 +173,7 @@ namespace Barotrauma
|
||||
graphics.SetRenderTarget(renderTarget);
|
||||
graphics.Clear(new Color(11, 18, 26, 255));
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullNone);
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap);
|
||||
|
||||
Vector2 backgroundPos = cam.Position;
|
||||
if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position;
|
||||
@@ -196,11 +203,26 @@ namespace Barotrauma
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
||||
BlendState.AlphaBlend,
|
||||
null, null, null, null,
|
||||
SamplerState.LinearWrap, null, null, null,
|
||||
cam.Transform);
|
||||
|
||||
BackgroundSpriteManager.Draw(spriteBatch);
|
||||
|
||||
backgroundPos = new Vector2(cam.WorldView.X, cam.WorldView.Y);
|
||||
if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position;
|
||||
|
||||
Rectangle viewRect = cam.WorldView;
|
||||
viewRect.Y = -viewRect.Y;
|
||||
|
||||
float multiplier = 0.8f;
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
spriteBatch.Draw(dustParticles, viewRect,
|
||||
new Rectangle((int)((backgroundPos.X * multiplier)), (int)((-backgroundPos.Y * multiplier)), cam.WorldView.Width, cam.WorldView.Height),
|
||||
Color.LightGray * multiplier, 0.0f, Vector2.Zero, SpriteEffects.None, 1.0f-multiplier);
|
||||
multiplier -= 0.15f;
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
||||
@@ -211,9 +233,12 @@ namespace Barotrauma
|
||||
Submarine.DrawBack(spriteBatch);
|
||||
|
||||
foreach (Character c in Character.CharacterList) c.Draw(spriteBatch);
|
||||
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
|
||||
GameMain.LightManager.DrawLightMap(spriteBatch, cam);
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater
|
||||
|
||||
@@ -272,7 +297,6 @@ namespace Barotrauma
|
||||
GameMain.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
|
||||
}
|
||||
|
||||
GameMain.LightManager.DrawLightMap(spriteBatch, cam);
|
||||
//----------------------------------------------------------------------------------------
|
||||
//3. draw the sections of the map that are on top of the water
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
@@ -274,11 +274,17 @@ namespace Barotrauma
|
||||
|
||||
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "startButton"));
|
||||
|
||||
playerList.Parent.RemoveChild(playerList.Parent.children.Find(c => c.UserData as string == "banListButton"));
|
||||
|
||||
if (IsServer && GameMain.Server != null)
|
||||
{
|
||||
GUIButton startButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||
startButton.OnClicked = GameMain.Server.StartGameClicked;
|
||||
startButton.UserData = "startButton";
|
||||
|
||||
var banListButton = new GUIButton(new Rectangle(0, 30, 100, 20), "Banned IPs", Alignment.BottomRight, GUI.Style, playerList.Parent);
|
||||
banListButton.OnClicked = GameMain.Server.BanList.ToggleBanFrame;
|
||||
banListButton.UserData = "banListButton";
|
||||
|
||||
//mapList.OnSelected = new GUIListBox.OnSelectedHandler(Game1.server.UpdateNetLobby);
|
||||
modeList.OnSelected += GameMain.Server.UpdateNetLobby;
|
||||
@@ -544,6 +550,11 @@ namespace Barotrauma
|
||||
{
|
||||
autoRestartTimer = Math.Max(autoRestartTimer - (float)deltaTime, 0.0f);
|
||||
}
|
||||
|
||||
if (GameMain.Server != null && GameMain.Server.BanList != null)
|
||||
{
|
||||
if (GameMain.Server.BanList.BanFrame != null) GameMain.Server.BanList.BanFrame.Update((float)deltaTime);
|
||||
}
|
||||
|
||||
//durationBar.BarScroll = Math.Max(durationBar.BarScroll, 1.0f / 60.0f);
|
||||
}
|
||||
@@ -564,6 +575,11 @@ namespace Barotrauma
|
||||
|
||||
if (playerFrame != null) playerFrame.Draw(spriteBatch);
|
||||
|
||||
if (GameMain.Server!=null && GameMain.Server.BanList!=null)
|
||||
{
|
||||
if (GameMain.Server.BanList.BanFrame != null) GameMain.Server.BanList.BanFrame.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
GUI.Draw((float)deltaTime, spriteBatch, null);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
v0.2.3.2
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
|
||||
- more reliable NPC position syncing
|
||||
- more reliable method of handling players dying in multiplayer, there should now be less cases of
|
||||
the server killing players who have equipped a diving suit or switched an oxygen tank just in time for example
|
||||
- the "you have died" message in multiplayer now also tells your cause of death
|
||||
- fixed incorrectly placed waypoints in Aegir
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
v0.2.3.1
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -11,11 +11,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Subsurface_content", "Subsu
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Farseer Physics MonoGame", "Farseer Physics Engine 3.5\Farseer Physics MonoGame.csproj", "{0AAD36E3-51A5-4A07-AB60-5C8A66BD38B7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher\Launcher.csproj", "{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OldLauncher", "Launcher\OldLauncher.csproj", "{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "Lidgren.Network\Lidgren.Network.csproj", "{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher2", "Launcher2\Launcher2.csproj", "{251AAFE1-F24B-4837-9128-9D04FCBFD528}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher2\Launcher.csproj", "{251AAFE1-F24B-4837-9128-9D04FCBFD528}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrashReporter", "CrashReporter\CrashReporter.csproj", "{6BE950CD-9A34-49C9-939A-786AC89C287E}"
|
||||
EndProject
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user