Skip to content

Commit

Permalink
v0.3.4.2: fixed section bodies not being restored after repairing a w…
Browse files Browse the repository at this point in the history
…all/window, fixed servers letting all clients in despite a wrong password, game version or content package
  • Loading branch information
Regalis committed Mar 5, 2016
2 parents c2a2f83 + 1bc5cb2 commit 436bdb1
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Subsurface/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// 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.3.4.1")]
[assembly: AssemblyFileVersion("0.3.4.1")]
[assembly: AssemblyVersion("0.3.4.2")]
[assembly: AssemblyFileVersion("0.3.4.2")]
2 changes: 1 addition & 1 deletion Subsurface/Source/Characters/AI/EnemyAIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ private void GetTargetEntity()
float sectionDamage = wall.SectionDamage(sectionIndex);
for (int i = sectionIndex - 2; i <= sectionIndex + 2; i++)
{
if (wall.SectionHasHole(i))
if (wall.SectionBodyDisabled(i))
{
sectionIndex = i;
break;
Expand Down
4 changes: 3 additions & 1 deletion Subsurface/Source/Map/Hull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,10 @@ public void HandleItems(float deltaTime, Item body)
foreach (var gap in ConnectedGaps.Where(gap => gap.Open > 0))
{
var pos = gap.Position - body.Position;
var distance = MathHelper.Max(Vector2.DistanceSquared(body.Position, gap.Position)/1000,1f);

pos.Normalize();
body.body.ApplyForce((pos * gap.LerpedFlowForce) * deltaTime);
body.body.ApplyForce((pos * (gap.LerpedFlowForce/distance)) * deltaTime);
}

}
Expand Down
34 changes: 22 additions & 12 deletions Subsurface/Source/Map/Structure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ public Structure(Rectangle rectangle, StructurePrefab sp, Submarine submarine)

if (prefab.CastShadow)
{
GeneateConvexHull();
GenerateConvexHull();
}

InsertToList();
}

private void GeneateConvexHull()
private void GenerateConvexHull()
{
// If not null and not empty , remove the hulls from the system
if(_convexHulls != null && _convexHulls.Any())
Expand Down Expand Up @@ -452,13 +452,16 @@ public void HighLightSection(int sectionIndex)
sections[sectionIndex].isHighLighted = true;
}

public bool SectionHasHole(int sectionIndex)
public bool SectionBodyDisabled(int sectionIndex)
{
if (sectionIndex < 0 || sectionIndex >= sections.Length) return false;

return (sections[sectionIndex].damage>=prefab.MaxHealth);
}

/// <summary>
/// Sections that are leaking have a gap placed on them
/// </summary>
public bool SectionIsLeaking(int sectionIndex)
{
if (sectionIndex < 0 || sectionIndex >= sections.Length) return false;
Expand Down Expand Up @@ -528,7 +531,7 @@ public AttackResult AddDamage(IDamageable attacker, Vector2 position, Attack att

float damageAmount = attack.GetStructureDamage(deltaTime);

if (playSound && !SectionHasHole(i))
if (playSound && !SectionBodyDisabled(i))
{
DamageSoundType damageSoundType = (attack.DamageType == DamageType.Blunt) ? DamageSoundType.StructureBlunt : DamageSoundType.StructureSlash;
SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, position);
Expand Down Expand Up @@ -561,7 +564,7 @@ private void SetDamage(int sectionIndex, float damage)
sections[sectionIndex].gap.Remove();
sections[sectionIndex].gap = null;
if(CastShadow)
GeneateConvexHull();
GenerateConvexHull();
}
}
else
Expand All @@ -575,20 +578,20 @@ private void SetDamage(int sectionIndex, float damage)
gapRect.Height += 20;
sections[sectionIndex].gap = new Gap(gapRect, !isHorizontal, Submarine);
if(CastShadow)
GeneateConvexHull();
GenerateConvexHull();
}
}

if (sections[sectionIndex].gap != null)
sections[sectionIndex].gap.Open = (float)Math.Pow(((damage / prefab.MaxHealth)-0.5)*2.0, 2.0);

bool hadHole = SectionHasHole(sectionIndex);
bool hadHole = SectionBodyDisabled(sectionIndex);
sections[sectionIndex].damage = MathHelper.Clamp(damage, 0.0f, prefab.MaxHealth);

bool hasHole = SectionHasHole(sectionIndex);
bool hasHole = SectionBodyDisabled(sectionIndex);

if (hadHole == hasHole) return;
if (hasHole) Explosion.ApplyExplosionForces(sections[sectionIndex].gap.WorldPosition, 500.0f, 5.0f, 0.0f, 0.0f);
//if (hasHole) Explosion.ApplyExplosionForces(sections[sectionIndex].gap.WorldPosition, 500.0f, 5.0f, 0.0f, 0.0f);
UpdateSections();
}

Expand All @@ -600,11 +603,18 @@ private void UpdateSections()
}
bodies.Clear();
var mergedSections = new List<WallSection>();
foreach (var section in sections)
for (int i = 0; i < sections.Count(); i++ )
{
if(section.gap == null)
var section = sections[i];

if (!SectionBodyDisabled(i))
{
mergedSections.Add(section);
if (section.gap == null || mergedSections.Count <= 0) continue;
continue;
}

if (mergedSections.Count <= 0) continue;

Rectangle mergedRect;
if (isHorizontal)
mergedRect = new Rectangle(mergedSections.Min(x => x.rect.Left), mergedSections.Max(x => x.rect.Top),
Expand Down
2 changes: 1 addition & 1 deletion Subsurface/Source/Map/Submarine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public static Body CheckVisibility(Vector2 rayStart, Vector2 rayEnd, bool ignore
{
if (structure.IsPlatform || structure.StairDirection != Direction.None) return -1;
int sectionIndex = structure.FindSectionIndex(ConvertUnits.ToDisplayUnits(point));
if (sectionIndex > -1 && structure.SectionHasHole(sectionIndex)) return -1;
if (sectionIndex > -1 && structure.SectionBodyDisabled(sectionIndex)) return -1;
}
if (fraction < closestFraction)
Expand Down
2 changes: 1 addition & 1 deletion Subsurface/Source/Networking/GameClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private IEnumerable<object> WaitForStartingInfo()

if (denyMessage == "Password required!" || denyMessage == "Wrong password!")
{
GameMain.ServerListScreen.JoinServer(serverIP, true);
GameMain.ServerListScreen.JoinServer(serverIP, true, denyMessage);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Subsurface/Source/Networking/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ private void HandleConnectionApproval(NetIncomingMessage inc)
return;
}

#if DEBUG
#if !DEBUG
if (!string.IsNullOrWhiteSpace(password) && string.IsNullOrWhiteSpace(userPassword))
{
inc.SenderConnection.Deny("Password required!");
Expand Down
8 changes: 4 additions & 4 deletions Subsurface/Source/Screens/ServerListScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,18 @@ private bool JoinServer(GUIButton button, object obj)
return true;
}

public void JoinServer(string ip, bool hasPassword)
public void JoinServer(string ip, bool hasPassword, string msg = "Password required")
{
CoroutineManager.StartCoroutine(ConnectToServer(ip, hasPassword));
CoroutineManager.StartCoroutine(ConnectToServer(ip, hasPassword, msg));
}

private IEnumerable<object> ConnectToServer(string ip, bool hasPassword)
private IEnumerable<object> ConnectToServer(string ip, bool hasPassword, string msg = "Password required")
{
string selectedPassword = "";

if (hasPassword)
{
var msgBox = new GUIMessageBox("Password required:", "", new string[] { "OK", "Cancel" });
var msgBox = new GUIMessageBox(msg, "", new string[] { "OK", "Cancel" });
var passwordBox = new GUITextBox(new Rectangle(0,40,150,25), Alignment.TopLeft, GUI.Style, msgBox.children[0]);
passwordBox.UserData = "password";

Expand Down
9 changes: 8 additions & 1 deletion Subsurface/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---------------------------------------------------------------------------------------------------------
v0.3.4.2
---------------------------------------------------------------------------------------------------------

- fixed characters passing through walls/windows that have already been repaired
- fixed the spawn command in Linux version
- fixed clients being able to join servers with the wrong password

---------------------------------------------------------------------------------------------------------
v0.3.4.1
---------------------------------------------------------------------------------------------------------
Expand All @@ -12,7 +20,6 @@ of messages received from different clients and discard valid messages
- mantises don't bleed
- fixed crashing when swapping some specific equipped items with another item in the inventory
- fixed deconstructor, fabricator and railgun connection panels closing immediately after opening
- fixed newly created subs being saved to the root folder instead of the Submarines folder

---------------------------------------------------------------------------------------------------------
v0.3.4.0
Expand Down
4 changes: 2 additions & 2 deletions Subsurface/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ Credits:
------------------------------------------------------------------------

Programming, graphics, sounds, game design - Joonas Rikkonen ("Regalis")
Graphics - James Bear ("Moonsaber99")
Programming - Sebastian Broberg
Graphics - James Bear ("Moonsaber99")
Programming - Sebastian Broberg

------------------------------------------------------------------------

Expand Down

0 comments on commit 436bdb1

Please sign in to comment.