Unstable v0.19.1.0
This commit is contained in:
+16
-15
@@ -15,8 +15,8 @@ namespace Barotrauma
|
||||
public CharacterCampaignData(Client client)
|
||||
{
|
||||
Name = client.Name;
|
||||
ClientEndPoint = client.Connection.EndPointString;
|
||||
SteamID = client.SteamID;
|
||||
ClientAddress = client.Connection.Endpoint.Address;
|
||||
AccountId = client.AccountId;
|
||||
CharacterInfo = client.CharacterInfo;
|
||||
|
||||
healthData = new XElement("health");
|
||||
@@ -55,13 +55,13 @@ namespace Barotrauma
|
||||
public CharacterCampaignData(XElement element)
|
||||
{
|
||||
Name = element.GetAttributeString("name", "Unnamed");
|
||||
ClientEndPoint = element.GetAttributeString("endpoint", null) ?? element.GetAttributeString("ip", "");
|
||||
string steamID = element.GetAttributeString("steamid", "");
|
||||
if (!string.IsNullOrEmpty(steamID))
|
||||
{
|
||||
ulong.TryParse(steamID, out ulong parsedID);
|
||||
SteamID = parsedID;
|
||||
}
|
||||
string clientEndPointStr = element.GetAttributeString("address", null)
|
||||
?? element.GetAttributeString("endpoint", null)
|
||||
?? element.GetAttributeString("ip", "");
|
||||
ClientAddress = Address.Parse(clientEndPointStr).Fallback(new UnknownAddress());
|
||||
string accountIdStr = element.GetAttributeString("accountid", null)
|
||||
?? element.GetAttributeString("steamid", "");
|
||||
AccountId = Networking.AccountId.Parse(accountIdStr);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
@@ -89,19 +89,20 @@ namespace Barotrauma
|
||||
|
||||
public bool MatchesClient(Client client)
|
||||
{
|
||||
if (SteamID > 0)
|
||||
if (AccountId.TryUnwrap(out var accountId)
|
||||
&& client.AccountId.TryUnwrap(out var clientId))
|
||||
{
|
||||
return SteamID == client.SteamID;
|
||||
return accountId == clientId;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ClientEndPoint == client.Connection.EndPointString;
|
||||
return ClientAddress == client.Connection.Endpoint.Address;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDuplicate(CharacterCampaignData other)
|
||||
{
|
||||
return other.SteamID == SteamID && other.ClientEndPoint == ClientEndPoint;
|
||||
return AccountId == other.AccountId && other.ClientAddress == ClientAddress;
|
||||
}
|
||||
|
||||
public void SpawnInventoryItems(Character character, Inventory inventory)
|
||||
@@ -136,8 +137,8 @@ namespace Barotrauma
|
||||
{
|
||||
XElement element = new XElement("CharacterCampaignData",
|
||||
new XAttribute("name", Name),
|
||||
new XAttribute("endpoint", ClientEndPoint),
|
||||
new XAttribute("steamid", SteamID));
|
||||
new XAttribute("address", ClientAddress),
|
||||
new XAttribute("accountid", AccountId.TryUnwrap(out var accountId) ? accountId.StringRepresentation : ""));
|
||||
|
||||
CharacterInfo?.Save(element);
|
||||
if (itemData != null) { element.Add(itemData); }
|
||||
|
||||
+23
-11
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Steam;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -45,21 +46,26 @@ namespace Barotrauma
|
||||
|
||||
class SavedExperiencePoints
|
||||
{
|
||||
public readonly ulong SteamID;
|
||||
public readonly string EndPoint;
|
||||
public readonly Option<AccountId> AccountId;
|
||||
public readonly Address Address;
|
||||
public readonly int ExperiencePoints;
|
||||
|
||||
public SavedExperiencePoints(Client client)
|
||||
{
|
||||
SteamID = client.SteamID;
|
||||
EndPoint = client.Connection.EndPointString;
|
||||
AccountId = client.AccountId;
|
||||
Address = client.Connection.Endpoint.Address;
|
||||
ExperiencePoints = client.Character?.Info?.ExperiencePoints ?? 0;
|
||||
}
|
||||
|
||||
public SavedExperiencePoints(XElement element)
|
||||
{
|
||||
SteamID = element.GetAttributeUInt64("steamid", 0);
|
||||
EndPoint = element.GetAttributeString("endpoint", string.Empty);
|
||||
AccountId = Networking.AccountId.Parse(
|
||||
element.GetAttributeString("accountid", null)
|
||||
?? element.GetAttributeString("steamid", ""));
|
||||
Address = Address.Parse(
|
||||
element.GetAttributeString("address", null)
|
||||
?? element.GetAttributeString("endpoint", ""))
|
||||
.Fallback(new UnknownAddress());
|
||||
ExperiencePoints = element.GetAttributeInt("points", 0);
|
||||
}
|
||||
}
|
||||
@@ -202,11 +208,11 @@ namespace Barotrauma
|
||||
}
|
||||
public int GetSavedExperiencePoints(Client client)
|
||||
{
|
||||
return savedExperiencePoints.Find(s => s.SteamID != 0 && client.SteamID == s.SteamID || client.EndpointMatches(s.EndPoint))?.ExperiencePoints ?? 0;
|
||||
return savedExperiencePoints.Find(s => client.AccountId == s.AccountId || client.Connection.Endpoint.Address == s.Address)?.ExperiencePoints ?? 0;
|
||||
}
|
||||
public void ClearSavedExperiencePoints(Client client)
|
||||
{
|
||||
savedExperiencePoints.RemoveAll(s => s.SteamID != 0 && client.SteamID == s.SteamID || client.EndpointMatches(s.EndPoint));
|
||||
savedExperiencePoints.RemoveAll(s => client.AccountId == s.AccountId || client.Connection.Endpoint.Address == s.Address);
|
||||
}
|
||||
|
||||
public void SavePlayers()
|
||||
@@ -805,6 +811,10 @@ namespace Barotrauma
|
||||
|
||||
Wallet personalWallet = GetWallet(sender);
|
||||
personalWallet?.ForceUpdate();
|
||||
if (AllowedToManageWallets(sender))
|
||||
{
|
||||
Bank.ForceUpdate();
|
||||
}
|
||||
|
||||
if (purchasedHullRepairs != PurchasedHullRepairs)
|
||||
{
|
||||
@@ -886,7 +896,9 @@ namespace Barotrauma
|
||||
foreach (var item in store.Value.ToList())
|
||||
{
|
||||
if (map?.CurrentLocation?.Stores == null || !map.CurrentLocation.Stores.ContainsKey(store.Key)) { continue; }
|
||||
item.Quantity = Math.Min(map.CurrentLocation.Stores[store.Key].Stock.Find(s => s.ItemPrefab == item.ItemPrefab)?.Quantity ?? 0, item.Quantity);
|
||||
int availableQuantity = map.CurrentLocation.Stores[store.Key].Stock.Find(s => s.ItemPrefab == item.ItemPrefab)?.Quantity ?? 0;
|
||||
int alreadyPurchasedQuantity = CargoManager.GetBuyCrateItem(store.Key, item.ItemPrefab)?.Quantity ?? 0;
|
||||
item.Quantity = Math.Min(availableQuantity - alreadyPurchasedQuantity, item.Quantity);
|
||||
if (item.Quantity <= 0) { continue; }
|
||||
CargoManager.ModifyItemQuantityInBuyCrate(store.Key, item.ItemPrefab, item.Quantity, sender);
|
||||
}
|
||||
@@ -1364,8 +1376,8 @@ namespace Barotrauma
|
||||
foreach (var savedExperiencePoint in savedExperiencePoints)
|
||||
{
|
||||
savedExperiencePointsElement.Add(new XElement("Point",
|
||||
new XAttribute("steamid", savedExperiencePoint.SteamID),
|
||||
new XAttribute("endpoint", savedExperiencePoint?.EndPoint ?? string.Empty),
|
||||
new XAttribute("accountid", savedExperiencePoint.AccountId.TryUnwrap(out var accountId) ? accountId.StringRepresentation : ""),
|
||||
new XAttribute("address", savedExperiencePoint.Address.StringRepresentation),
|
||||
new XAttribute("points", savedExperiencePoint.ExperiencePoints)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user