v0.11.0.9
This commit is contained in:
@@ -127,8 +127,7 @@ namespace Barotrauma.Networking
|
||||
if (IPAddress.IsLoopback(IP)) { return false; }
|
||||
var bannedPlayer = bannedPlayers.Find(bp =>
|
||||
bp.CompareTo(IP) ||
|
||||
(steamID > 0 && bp.SteamID == steamID) ||
|
||||
(SteamManager.SteamIDStringToUInt64(bp.EndPoint) == steamID));
|
||||
(steamID > 0 && (bp.SteamID == steamID || SteamManager.SteamIDStringToUInt64(bp.EndPoint) == steamID)));
|
||||
reason = bannedPlayer?.Reason;
|
||||
return bannedPlayer != null;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,15 @@ namespace Barotrauma.Networking
|
||||
Entity orderTargetEntity = null;
|
||||
OrderChatMessage orderMsg = null;
|
||||
OrderTarget orderTargetPosition = null;
|
||||
Order.OrderTargetType orderTargetType = Order.OrderTargetType.Entity;
|
||||
int? wallSectionIndex = null;
|
||||
if (type == ChatMessageType.Order)
|
||||
{
|
||||
int orderIndex = msg.ReadByte();
|
||||
orderTargetCharacter = Entity.FindEntityByID(msg.ReadUInt16()) as Character;
|
||||
orderTargetEntity = Entity.FindEntityByID(msg.ReadUInt16()) as Entity;
|
||||
int orderOptionIndex = msg.ReadByte();
|
||||
orderTargetType = (Order.OrderTargetType)msg.ReadByte();
|
||||
if (msg.ReadBoolean())
|
||||
{
|
||||
var x = msg.ReadSingle();
|
||||
@@ -31,6 +34,10 @@ namespace Barotrauma.Networking
|
||||
var hull = Entity.FindEntityByID(msg.ReadUInt16()) as Hull;
|
||||
orderTargetPosition = new OrderTarget(new Vector2(x, y), hull, true);
|
||||
}
|
||||
else if (orderTargetType == Order.OrderTargetType.WallSection)
|
||||
{
|
||||
wallSectionIndex = msg.ReadByte();
|
||||
}
|
||||
|
||||
if (orderIndex < 0 || orderIndex >= Order.PrefabList.Count)
|
||||
{
|
||||
@@ -39,9 +46,12 @@ namespace Barotrauma.Networking
|
||||
return;
|
||||
}
|
||||
|
||||
Order order = Order.PrefabList[orderIndex];
|
||||
string orderOption = orderOptionIndex < 0 || orderOptionIndex >= order.Options.Length ? "" : order.Options[orderOptionIndex];
|
||||
orderMsg = new OrderChatMessage(order, orderOption, orderTargetPosition ?? orderTargetEntity as ISpatialEntity, orderTargetCharacter, c.Character);
|
||||
Order orderPrefab = Order.PrefabList[orderIndex];
|
||||
string orderOption = orderOptionIndex < 0 || orderOptionIndex >= orderPrefab.Options.Length ? "" : orderPrefab.Options[orderOptionIndex];
|
||||
orderMsg = new OrderChatMessage(orderPrefab, orderOption, orderTargetPosition ?? orderTargetEntity as ISpatialEntity, orderTargetCharacter, c.Character)
|
||||
{
|
||||
WallSectionIndex = wallSectionIndex
|
||||
};
|
||||
txt = orderMsg.Text;
|
||||
}
|
||||
else
|
||||
@@ -119,16 +129,39 @@ namespace Barotrauma.Networking
|
||||
if (type == ChatMessageType.Order)
|
||||
{
|
||||
if (c.Character == null || c.Character.SpeechImpediment >= 100.0f || c.Character.IsDead) { return; }
|
||||
if (orderMsg.Order.TargetAllCharacters)
|
||||
Order order = null;
|
||||
if (orderMsg.Order.IsReport)
|
||||
{
|
||||
HumanAIController.ReportProblem(orderMsg.Sender, orderMsg.Order);
|
||||
}
|
||||
else if (orderTargetCharacter != null)
|
||||
else if (orderTargetCharacter != null && !orderMsg.Order.TargetAllCharacters)
|
||||
{
|
||||
var order = orderTargetPosition == null ?
|
||||
new Order(orderMsg.Order.Prefab, orderTargetEntity, orderMsg.Order.Prefab?.GetTargetItemComponent(orderTargetEntity as Item), orderMsg.Sender) :
|
||||
new Order(orderMsg.Order.Prefab, orderTargetPosition, orderMsg.Sender);
|
||||
orderTargetCharacter.SetOrder(order, orderMsg.OrderOption, orderMsg.Sender);
|
||||
switch (orderTargetType)
|
||||
{
|
||||
case Order.OrderTargetType.Entity:
|
||||
order = new Order(orderMsg.Order.Prefab, orderTargetEntity, orderMsg.Order.Prefab?.GetTargetItemComponent(orderTargetEntity as Item), orderGiver: orderMsg.Sender);
|
||||
break;
|
||||
case Order.OrderTargetType.Position:
|
||||
order = new Order(orderMsg.Order.Prefab, orderTargetPosition, orderGiver: orderMsg.Sender);
|
||||
break;
|
||||
}
|
||||
if (order != null)
|
||||
{
|
||||
orderTargetCharacter.SetOrder(order, orderMsg.OrderOption, orderMsg.Sender);
|
||||
}
|
||||
}
|
||||
else if (orderMsg.Order.IsIgnoreOrder)
|
||||
{
|
||||
switch (orderTargetType)
|
||||
{
|
||||
case Order.OrderTargetType.Entity:
|
||||
(orderTargetEntity as MapEntity)?.SetIgnoreByAI(orderMsg.Order.Identifier == "ignorethis");
|
||||
break;
|
||||
case Order.OrderTargetType.WallSection:
|
||||
if (!wallSectionIndex.HasValue) { break; }
|
||||
(orderTargetEntity as Structure)?.GetSection(wallSectionIndex.Value)?.SetIgnoreByAI(orderMsg.Order.Identifier == "ignorethis");
|
||||
break;
|
||||
}
|
||||
}
|
||||
GameMain.Server.SendOrderChatMessage(orderMsg);
|
||||
}
|
||||
|
||||
@@ -811,6 +811,9 @@ namespace Barotrauma.Networking
|
||||
case ClientPacketHeader.CREW:
|
||||
ReadCrewMessage(inc, connectedClient);
|
||||
break;
|
||||
case ClientPacketHeader.READY_CHECK:
|
||||
ReadyCheck.ServerRead(inc, connectedClient);
|
||||
break;
|
||||
case ClientPacketHeader.FILE_REQUEST:
|
||||
if (serverSettings.AllowFileTransfers)
|
||||
{
|
||||
@@ -1543,10 +1546,12 @@ namespace Barotrauma.Networking
|
||||
if (!character.Enabled) { continue; }
|
||||
if (c.SpectatePos == null)
|
||||
{
|
||||
if (c.Character != null && Vector2.DistanceSquared(character.WorldPosition, c.Character.WorldPosition) >= NetConfig.DisableCharacterDistSqr)
|
||||
float distSqr = Vector2.DistanceSquared(character.WorldPosition, c.Character.WorldPosition);
|
||||
if (c.Character.ViewTarget != null)
|
||||
{
|
||||
continue;
|
||||
distSqr = Math.Min(distSqr, Vector2.DistanceSquared(character.WorldPosition, c.Character.ViewTarget.WorldPosition));
|
||||
}
|
||||
if (distSqr >= NetConfig.DisableCharacterDistSqr) { continue; }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2130,6 +2135,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
Level.Loaded?.SpawnNPCs();
|
||||
Level.Loaded?.SpawnCorpses();
|
||||
Level.Loaded?.PrepareBeaconStation();
|
||||
AutoItemPlacer.PlaceIfNeeded();
|
||||
|
||||
CrewManager crewManager = campaign?.CrewManager;
|
||||
@@ -2253,7 +2259,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
for (int i = 0; i < teamClients.Count; i++)
|
||||
{
|
||||
Character spawnedCharacter = Character.Create(teamClients[i].CharacterInfo, spawnWaypoints[i].WorldPosition, teamClients[i].CharacterInfo.Name, true, false);
|
||||
Character spawnedCharacter = Character.Create(teamClients[i].CharacterInfo, spawnWaypoints[i].WorldPosition, teamClients[i].CharacterInfo.Name, isRemotePlayer: true, hasAi: false);
|
||||
spawnedCharacter.AnimController.Frozen = true;
|
||||
spawnedCharacter.TeamID = teamID;
|
||||
teamClients[i].Character = spawnedCharacter;
|
||||
@@ -2269,7 +2275,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
else
|
||||
{
|
||||
characterData.SpawnInventoryItems(spawnedCharacter.Info, spawnedCharacter.Inventory);
|
||||
characterData.SpawnInventoryItems(spawnedCharacter, spawnedCharacter.Inventory);
|
||||
characterData.ApplyHealthData(spawnedCharacter.Info, spawnedCharacter);
|
||||
spawnedCharacter.GiveIdCardTags(mainSubWaypoints[i]);
|
||||
characterData.HasSpawned = true;
|
||||
@@ -2280,7 +2286,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
for (int i = teamClients.Count; i < teamClients.Count + bots.Count; i++)
|
||||
{
|
||||
Character spawnedCharacter = Character.Create(characterInfos[i], spawnWaypoints[i].WorldPosition, characterInfos[i].Name, false, true);
|
||||
Character spawnedCharacter = Character.Create(characterInfos[i], spawnWaypoints[i].WorldPosition, characterInfos[i].Name, isRemotePlayer: false, hasAi: true);
|
||||
spawnedCharacter.TeamID = teamID;
|
||||
spawnedCharacter.GiveJobItems(mainSubWaypoints[i]);
|
||||
spawnedCharacter.GiveIdCardTags(mainSubWaypoints[i]);
|
||||
@@ -2945,7 +2951,7 @@ namespace Barotrauma.Networking
|
||||
else if (type == ChatMessageType.Radio)
|
||||
{
|
||||
//send to chat-linked wifi components
|
||||
senderRadio.TransmitSignal(0, message, senderRadio.Item, senderCharacter, false);
|
||||
senderRadio.TransmitSignal(0, message, senderRadio.Item, senderCharacter, sentFromChat: true);
|
||||
}
|
||||
|
||||
//check which clients can receive the message and apply distance effects
|
||||
@@ -3662,7 +3668,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
public static void Log(string line, ServerLog.MessageType messageType)
|
||||
{
|
||||
if (GameMain.Server == null || !GameMain.Server.ServerSettings.SaveServerLogs) return;
|
||||
if (GameMain.Server == null || !GameMain.Server.ServerSettings.SaveServerLogs) { return; }
|
||||
|
||||
GameMain.Server.ServerSettings.ServerLog.WriteLine(line, messageType);
|
||||
|
||||
|
||||
@@ -226,6 +226,13 @@ namespace Barotrauma
|
||||
clientMemories.Remove(client);
|
||||
}
|
||||
|
||||
public void OnBallastFloraDamaged(Character character, float damage)
|
||||
{
|
||||
if (character == null) { return; }
|
||||
float karmaChange = damage * BallastFloraKarmaIncrease;
|
||||
AdjustKarma(character, karmaChange, "Damaged ballast flora");
|
||||
}
|
||||
|
||||
// ReSharper disable once UseNegatedPatternMatching, LoopCanBeConvertedToQuery
|
||||
public void OnItemTakenFromPlayer(CharacterInventory inventory, Client yoinker, Item item)
|
||||
{
|
||||
|
||||
+2
-2
@@ -490,7 +490,7 @@ namespace Barotrauma.Networking
|
||||
continue;
|
||||
}
|
||||
|
||||
byte msgLength = msg.ReadByte();
|
||||
int msgLength = (int)msg.ReadVariableUInt32();
|
||||
|
||||
IClientSerializable entity = Entity.FindEntityByID(entityID) as IClientSerializable;
|
||||
|
||||
@@ -499,7 +499,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.NewMessage("Received msg " + thisEventID, Color.Red);
|
||||
DebugConsole.NewMessage("Received msg " + thisEventID + ", expecting " + sender.LastSentEntityEventID, Color.Red);
|
||||
}
|
||||
msg.BitPosition += msgLength * 8;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ namespace Barotrauma.Networking
|
||||
msg.Write(TargetCharacter == null ? (UInt16)0 : TargetCharacter.ID);
|
||||
msg.Write(TargetEntity is Entity ? (TargetEntity as Entity).ID : (UInt16)0);
|
||||
msg.Write((byte)Array.IndexOf(Order.Prefab.Options, OrderOption));
|
||||
if (TargetEntity is OrderTarget orderTarget)
|
||||
msg.Write((byte)Order.TargetType);
|
||||
if (Order.TargetType == Order.OrderTargetType.Position && TargetEntity is OrderTarget orderTarget)
|
||||
{
|
||||
msg.Write(true);
|
||||
msg.Write(orderTarget.Position.X);
|
||||
@@ -31,6 +32,10 @@ namespace Barotrauma.Networking
|
||||
else
|
||||
{
|
||||
msg.Write(false);
|
||||
if (Order.TargetType == Order.OrderTargetType.WallSection)
|
||||
{
|
||||
msg.Write((byte)(WallSectionIndex ?? Order.WallSectionIndex ?? 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-2
@@ -39,7 +39,16 @@ namespace Barotrauma.Networking
|
||||
public double UpdateTime;
|
||||
public double TimeOut;
|
||||
public int Retries;
|
||||
public UInt64? SteamID;
|
||||
private UInt64? steamId;
|
||||
public UInt64? SteamID
|
||||
{
|
||||
get { return steamId; }
|
||||
set
|
||||
{
|
||||
steamId = value;
|
||||
Connection.SetSteamIDIfUnknown(value ?? 0);
|
||||
}
|
||||
}
|
||||
public Int32? PasswordSalt;
|
||||
public bool AuthSessionStarted;
|
||||
|
||||
@@ -224,7 +233,7 @@ namespace Barotrauma.Networking
|
||||
case ConnectionInitialization.ContentPackageOrder:
|
||||
outMsg.Write(GameMain.Server.ServerName);
|
||||
|
||||
var mpContentPackages = GameMain.Config.AllEnabledPackages.Where(cp => cp.HasMultiplayerIncompatibleContent).ToList();
|
||||
var mpContentPackages = GameMain.Config.AllEnabledPackages.Where(cp => cp.HasMultiplayerIncompatibleContent).Reverse().ToList();
|
||||
outMsg.WriteVariableUInt32((UInt32)mpContentPackages.Count);
|
||||
for (int i = 0; i < mpContentPackages.Count; i++)
|
||||
{
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace Barotrauma.Networking
|
||||
characterInfos[i].CurrentOrder = null;
|
||||
characterInfos[i].CurrentOrderOption = null;
|
||||
|
||||
var character = Character.Create(characterInfos[i], shuttleSpawnPoints[i].WorldPosition, characterInfos[i].Name, !bot, bot);
|
||||
var character = Character.Create(characterInfos[i], shuttleSpawnPoints[i].WorldPosition, characterInfos[i].Name, isRemotePlayer: !bot, hasAi: bot);
|
||||
character.TeamID = Character.TeamType.Team1;
|
||||
|
||||
if (bot)
|
||||
@@ -341,7 +341,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
else
|
||||
{
|
||||
characterData.SpawnInventoryItems(character.Info, character.Inventory);
|
||||
characterData.SpawnInventoryItems(character, character.Inventory);
|
||||
characterData.ApplyHealthData(character.Info, character);
|
||||
character.GiveIdCardTags(mainSubSpawnPoints[i]);
|
||||
characterData.HasSpawned = true;
|
||||
|
||||
Reference in New Issue
Block a user