Skip to content

Commit

Permalink
Unstable 0.1300.1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
3e849f2e5c committed Apr 26, 2021
1 parent 841d755 commit 2c75028
Show file tree
Hide file tree
Showing 76 changed files with 670 additions and 395 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public override void ClientReadInitial(IReadMessage msg)
throw new System.Exception("Error in CargoMission.ClientReadInitial: item count does not match the server count (" + itemCount + " != " + items.Count + ", mission: " + Prefab.Identifier + ")");
}
if (requiredDeliveryAmount == 0) { requiredDeliveryAmount = items.Count; }
if (requiredDeliveryAmount > items.Count)
{
DebugConsole.AddWarning($"Error in mission \"{Prefab.Identifier}\". Required delivery amount is {requiredDeliveryAmount} but there's only {items.Count} items to deliver.");
requiredDeliveryAmount = items.Count;
}
}
}
}
3 changes: 2 additions & 1 deletion Barotrauma/BarotraumaClient/ClientSource/GUI/GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ private static void UpdateMessages(float deltaTime)

private static void UpdateSavingIndicator(float deltaTime)
{
if (Style.SavingIndicator == null) { return; }
lock (mutex)
{
if (timeUntilSavingIndicatorDisabled.HasValue)
Expand Down Expand Up @@ -1651,7 +1652,7 @@ public static void DrawSineWithDots(SpriteBatch spriteBatch, Vector2 from, Vecto

private static void DrawSavingIndicator(SpriteBatch spriteBatch)
{
if (!IsSavingIndicatorVisible) { return; }
if (!IsSavingIndicatorVisible || Style.SavingIndicator == null) { return; }
var sheet = Style.SavingIndicator;
Vector2 pos = new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) - new Vector2(HUDLayoutSettings.Padding) - 2 * Scale * sheet.FrameSize.ToVector2();
sheet.Draw(spriteBatch, (int)Math.Floor(savingIndicatorSpriteIndex), pos, savingIndicatorColor, origin: Vector2.Zero, rotate: 0.0f, scale: new Vector2(Scale));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1319,17 +1319,26 @@ void ResetNodeSelection(GUIButton newSelectedNode = null)

// When using Deselect to close the interface, make sure it's not a seconday mouse button click on a node
// That should be reserved for opening manual assignment
var hitDeselect = PlayerInput.KeyHit(InputType.Deselect) && (!PlayerInput.SecondaryMouseButtonClicked() ||
(optionNodes.None(n => GUI.IsMouseOn(n.Item1)) && shortcutNodes.None(n => GUI.IsMouseOn(n))));
bool isMouseOnOptionNode = optionNodes.Any(n => GUI.IsMouseOn(n.Item1));
bool isMouseOnShortcutNode = !isMouseOnOptionNode && shortcutNodes.Any(n => GUI.IsMouseOn(n));
bool hitDeselect = PlayerInput.KeyHit(InputType.Deselect) &&
(!PlayerInput.SecondaryMouseButtonClicked() || (!isMouseOnOptionNode && !isMouseOnShortcutNode));

bool isBoundToPrimaryMouse = GameMain.Config.KeyBind(InputType.Command).MouseButton is MouseButton mouseButton &&
(mouseButton == MouseButton.PrimaryMouse || mouseButton == (PlayerInput.MouseButtonsSwapped() ? MouseButton.RightMouse : MouseButton.LeftMouse));
bool canToggleInterface = !isBoundToPrimaryMouse ||
(!isMouseOnOptionNode && !isMouseOnShortcutNode && extraOptionNodes.None(n => GUI.IsMouseOn(n)) && !GUI.IsMouseOn(returnNode));

// TODO: Consider using HUD.CloseHUD() instead of KeyHit(Escape), the former method is also used for health UI
if (hitDeselect || PlayerInput.KeyHit(Keys.Escape) || !CanIssueOrders ||
(PlayerInput.KeyHit(InputType.Command) && selectedNode == null && !clicklessSelectionActive))
(canToggleInterface && PlayerInput.KeyHit(InputType.Command) && selectedNode == null && !clicklessSelectionActive))
{
DisableCommandUI();
}
else if (PlayerInput.KeyUp(InputType.Command))
{
if (!isOpeningClick && clicklessSelectionActive && timeSelected < 0.15f)
// Clickless selection behavior
if (canToggleInterface && !isOpeningClick && clicklessSelectionActive && timeSelected < 0.15f)
{
DisableCommandUI();
}
Expand All @@ -1344,6 +1353,7 @@ void ResetNodeSelection(GUIButton newSelectedNode = null)
}
else if (PlayerInput.KeyDown(InputType.Command) && (targetFrame == null || !targetFrame.Visible))
{
// Clickless selection behavior
if (!GUI.IsMouseOn(centerNode))
{
clicklessSelectionActive = true;
Expand Down Expand Up @@ -1914,6 +1924,7 @@ public void DisableCommandUI()

private bool NavigateForward(GUIButton node, object userData)
{
if (commandFrame == null) { return false; }
if (!(optionNodes.Find(n => n.Item1 == node) is Tuple<GUIComponent, Keys> optionNode) || !optionNodes.Remove(optionNode))
{
shortcutNodes.Remove(node);
Expand Down Expand Up @@ -1953,6 +1964,7 @@ private bool NavigateForward(GUIButton node, object userData)

private bool NavigateBackward(GUIButton node, object userData)
{
if (commandFrame == null) { return false; }
RemoveOptionNodes();
if (targetFrame != null) { targetFrame.Visible = false; }
// TODO: Center node could move to option node instead of being removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,7 @@ protected override void ControlInput(Camera cam)

public override void Update(float deltaTime, Camera cam, bool isSubInventory = false)
{
// Need to update the infiltrator's inventory because they use id cards to access the sub. TODO: We don't probably need to update everything.
if (!AccessibleWhenAlive && !character.IsDead && (character.Params.AI == null || !character.Params.AI.Infiltrate))
if (!AccessibleWhenAlive && !character.IsDead)
{
syncItemsDelay = Math.Max(syncItemsDelay - deltaTime, 0.0f);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,22 @@ private void DrawSonar(SpriteBatch spriteBatch, Rectangle rect)
signalWarningText.Visible = false;
}

foreach (AITarget aiTarget in AITarget.List)
{
if (!aiTarget.Enabled) { continue; }
if (string.IsNullOrEmpty(aiTarget.SonarLabel) || aiTarget.SoundRange <= 0.0f) { continue; }

if (Vector2.DistanceSquared(aiTarget.WorldPosition, transducerCenter) < aiTarget.SoundRange * aiTarget.SoundRange)
{
DrawMarker(spriteBatch,
aiTarget.SonarLabel,
aiTarget.SonarIconIdentifier,
aiTarget,
aiTarget.WorldPosition, transducerCenter,
displayScale, center, DisplayRadius * 0.975f);
}
}

if (GameMain.GameSession == null || Level.Loaded == null) { return; }

if (Level.Loaded.StartLocation != null)
Expand Down Expand Up @@ -931,23 +947,7 @@ private void DrawSonar(SpriteBatch spriteBatch, Rectangle rect)
cave.StartPos.ToVector2(), transducerCenter,
displayScale, center, DisplayRadius);
}

foreach (AITarget aiTarget in AITarget.List)
{
if (!aiTarget.Enabled) { continue; }
if (string.IsNullOrEmpty(aiTarget.SonarLabel) || aiTarget.SoundRange <= 0.0f) { continue; }

if (Vector2.DistanceSquared(aiTarget.WorldPosition, transducerCenter) < aiTarget.SoundRange * aiTarget.SoundRange)
{
DrawMarker(spriteBatch,
aiTarget.SonarLabel,
aiTarget.SonarIconIdentifier,
aiTarget,
aiTarget.WorldPosition, transducerCenter,
displayScale, center, DisplayRadius * 0.975f);
}
}


foreach (Mission mission in GameMain.GameSession.Missions)
{
if (!string.IsNullOrWhiteSpace(mission.SonarLabel))
Expand Down
4 changes: 4 additions & 0 deletions Barotrauma/BarotraumaClient/ClientSource/Items/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ public class SlotReference

public int tooltipDisplayedCondition;

public bool ForceTooltipRefresh;

public SlotReference(Inventory parentInventory, VisualSlot slot, int slotIndex, bool isSubSlot, Inventory subInventory = null)
{
ParentInventory = parentInventory;
Expand All @@ -234,12 +236,14 @@ public SlotReference(Inventory parentInventory, VisualSlot slot, int slotIndex,

public bool TooltipNeedsRefresh()
{
if (ForceTooltipRefresh) { return true; }
if (Item == null) { return false; }
return (int)Item.ConditionPercentage != tooltipDisplayedCondition;
}

public void RefreshTooltip()
{
ForceTooltipRefresh = false;
if (Item == null) { return; }
IEnumerable<Item> itemsInSlot = null;
if (ParentInventory != null && Item != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,6 @@ partial void InitProjSpecific()

public void Update(float deltaTime)
{
if (ParticleEmitters != null)
{
for (int i = 0; i < ParticleEmitters.Length; i++)
{
if (ParticleEmitterTriggers[i] != null && !ParticleEmitterTriggers[i].IsTriggered) continue;
Vector2 emitterPos = LocalToWorld(Prefab.EmitterPositions[i]);
ParticleEmitters[i].Emit(deltaTime, emitterPos, hullGuess: null,
angle: ParticleEmitters[i].Prefab.CopyEntityAngle ? Rotation : 0.0f);
}
}

CurrentRotation = Rotation;
if (ActivePrefab.SwingFrequency > 0.0f)
{
Expand Down Expand Up @@ -214,6 +203,17 @@ public void Update(float deltaTime)
UpdateDeformations(deltaTime);
}

if (ParticleEmitters != null)
{
for (int i = 0; i < ParticleEmitters.Length; i++)
{
if (ParticleEmitterTriggers[i] != null && !ParticleEmitterTriggers[i].IsTriggered) { continue; }
Vector2 emitterPos = LocalToWorld(Prefab.EmitterPositions[i]);
ParticleEmitters[i].Emit(deltaTime, emitterPos, hullGuess: null,
angle: ParticleEmitters[i].Prefab.CopyEntityAngle ? -CurrentRotation + MathHelper.PiOver2 : 0.0f);
}
}

for (int i = 0; i < Sounds.Length; i++)
{
if (Sounds[i] == null) { continue; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ private void RenderSubmarine(SpriteBatch spriteBatch, Rectangle scissorRectangle
if (!spriteRecorder.ReadyToRender)
{
string waitText = !loadTask.IsCompleted ?
"Generating preview..." :
TextManager.Get("generatingsubmarinepreview", fallBackTag: "loading") :
(loadTask.Exception?.ToString() ?? "Task completed without marking as ready to render");
Vector2 origin = (GUI.Font.MeasureString(waitText) * 0.5f);
origin.X = MathF.Round(origin.X);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ abstract class ClientPeer
{
protected class ServerContentPackage
{
public string Name;
public string Hash;
public UInt64 WorkshopId;
public readonly string Name;
public readonly string Hash;
public readonly UInt64 WorkshopId;
public readonly DateTime InstallTime;

public ContentPackage RegularPackage
{
Expand All @@ -32,11 +33,12 @@ public ContentPackage CorePackage
}
}

public ServerContentPackage(string name, string hash, UInt64 workshopId)
public ServerContentPackage(string name, string hash, UInt64 workshopId, DateTime installTime)
{
Name = name;
Hash = hash;
WorkshopId = workshopId;
InstallTime = installTime;
}
}

Expand Down Expand Up @@ -129,7 +131,10 @@ protected void ReadConnectionInitializationStep(IReadMessage inc)
string name = inc.ReadString();
string hash = inc.ReadString();
UInt64 workshopId = inc.ReadUInt64();
var pkg = new ServerContentPackage(name, hash, workshopId);
UInt32 installTimeDiffSeconds = inc.ReadUInt32();
DateTime installTime = DateTime.UtcNow + TimeSpan.FromSeconds(installTimeDiffSeconds);

var pkg = new ServerContentPackage(name, hash, workshopId, installTime);
if (pkg.CorePackage != null)
{
corePackage = pkg;
Expand All @@ -147,16 +152,24 @@ protected void ReadConnectionInitializationStep(IReadMessage inc)
if (missingPackages.Count > 0)
{
var nonDownloadable = missingPackages.Where(p => p.WorkshopId == 0);
var mismatchedButDownloaded = missingPackages.Where(p =>
var mismatchedButDownloaded = missingPackages.Where(remote =>
{
var localMatching = ContentPackage.RegularPackages.Find(l => l.SteamWorkshopId != 0 && p.WorkshopId == l.SteamWorkshopId);
localMatching ??= ContentPackage.CorePackages.Find(l => l.SteamWorkshopId != 0 && p.WorkshopId == l.SteamWorkshopId);

return localMatching != null;
return ContentPackage.AllPackages.Any(local =>
local.SteamWorkshopId != 0 && /* is a Workshop item */
remote.WorkshopId == local.SteamWorkshopId /* ids match */);
});
if (GameMain.ServerListScreen.LastAutoConnectEndpoint != ServerConnection.EndPointString)
{
mismatchedButDownloaded = mismatchedButDownloaded.Where(remote =>
{
return ContentPackage.AllPackages.Any(local =>
remote.InstallTime < local.InstallTime/* remote is older than local */);
});
}

if (mismatchedButDownloaded.Any())
{
GameMain.ServerListScreen.LastAutoConnectEndpoint = null;
string disconnectMsg;
if (mismatchedButDownloaded.Count() == 1)
{
Expand Down
Loading

0 comments on commit 2c75028

Please sign in to comment.