Reliablesender exception handling, buttons crashing multiplayer, using screwdrivers/wrenches with left click, RestoreCollision exception handling, nerfed c4, UpdateLimbCollisionCategories fix

This commit is contained in:
Regalis
2015-10-23 00:10:27 +03:00
parent 51e68f0949
commit b3462b24b4
34 changed files with 256 additions and 113 deletions

View File

@@ -9,7 +9,7 @@
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
<ProjectView>ShowAllFiles</ProjectView>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
<PropertyGroup>
<ReferencePath>

View File

@@ -30,7 +30,7 @@
<!-- front fins -->
<limb id = "4" width="50" height="200">
<sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="133,5,91,202" depth="0.01" origin="0.7,0.5"/>
<sprite texture="Content/Characters/TigerThresher/tigerthresher.png" sourcerect="133,5,91,202" depth="0.008" origin="0.7,0.5"/>
</limb>
<!-- back fins -->

View File

@@ -15,12 +15,12 @@
<sound file="beep.ogg" type="OnUse" range="500.0"/>
</Controller>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<RequiredItem name="Screwdriver" type="Equipped"/>
<output name="signal_out"/>
</ConnectionPanel>
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" attachedbydefault="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>

View File

@@ -19,7 +19,7 @@
<item name="Welding Tool"/>
</fixrequirement>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="toggle"/>
<input name="set_state"/>
@@ -48,7 +48,7 @@
<item name="Welding Tool"/>
</fixrequirement>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="toggle"/>
<input name="set_state"/>

View File

@@ -11,7 +11,7 @@
<LightComponent color="1.0,1.0,1.0,1.0" range ="800.0" powerconsumption="50"/>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="power"/>
<input name="toggle"/>

View File

@@ -17,7 +17,7 @@
<GuiFrame rect="0,0,350,160" alignment="Center" color="0.0,0.0,0.0,0.6"/>
</PowerTransfer>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<RequiredSkill name="Electrical Engineering" level="30"/>
<StatusEffect type="OnFailure" target="Character">
<Explosion range="100.0" damage="5" stun="10" force="2.0" flames="false" shockwave="false" sparks="true"/>
@@ -45,7 +45,7 @@
<StatusEffect type="OnActive" target="Contained" targetnames="loadable" Condition="2.0"/>
</PowerContainer>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<StatusEffect type="OnFailure" target="Character">
<Explosion range="100.0" damage="15" stun="10" force="3.0" flames="false" shockwave="false" sparks="true"/>
</StatusEffect>
@@ -69,7 +69,7 @@
<GuiFrame rect="0,0,0.3,0.3" alignment="Center" color="0.0,0.0,0.0,0.8"/>
</PowerContainer>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<StatusEffect type="OnFailure" target="Character">
<Explosion range="100.0" damage="30" stun="20" force="5.0" shockwave="false" sparks="true"/>
</StatusEffect>

View File

@@ -80,13 +80,13 @@
<Body width="16" height="16"/>
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in1"/>
<input name="signal_in2"/>
@@ -108,12 +108,12 @@
<Body width="16" height="16"/>
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in1"/>
<input name="signal_in2"/>
@@ -135,12 +135,12 @@
<Body width="16" height="16"/>
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in"/>
<output name="signal_out"/>
@@ -163,11 +163,11 @@
<Body width="16" height="16"/>
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="toggle"/>
<input name="set_state"/>
@@ -188,12 +188,12 @@
<Body width="16" height="16"/>
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<output name="signal_out"/>
</ConnectionPanel>
@@ -212,12 +212,12 @@
<Body width="16" height="16"/>
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in"/>
<input name="set_output"/>
@@ -239,12 +239,12 @@
<Body width="16" height="16"/>
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"
<Holdable selectkey="ActionHit" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"
slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in"/>
<output name="signal_out"/>
@@ -264,12 +264,12 @@
<Body width="16" height="16"/>
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"
<Holdable selectkey="ActionHit" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"
slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in"/>
<output name="signal_out"/>

View File

@@ -13,7 +13,7 @@
<sound file="engine.ogg" type="OnActive" range="3000.0" volume="CurrentVolume" loop="true"/>
</Engine>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
<input name="set_force"/>
@@ -38,7 +38,7 @@
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>
</Radar>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
<input name="velocity_in"/>
@@ -46,4 +46,23 @@
<output name="velocity_y_out"/>
</ConnectionPanel>
</Item>
<Item
name="Sonar Monitor"
linkable="true"
pickdistance="150">
<Sprite texture ="fabricator.png" depth="0.8"/>
<Radar canbeselected = "true" powerconsumption="100">
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" color="0.0,0.0,0.0,0.6"/>
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>
</Radar>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
</ConnectionPanel>
</Item>
</Items>

View File

@@ -10,7 +10,7 @@
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" color="0.0,0.0,0.0,0.8"/>
</MiniMap>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
</ConnectionPanel>

View File

@@ -17,7 +17,7 @@
<Containable name="Oxygen Tank"/>
</ItemContainer>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
</ConnectionPanel>

View File

@@ -10,7 +10,7 @@
<sound file="pump.ogg" type="OnActive" range="800.0" volume="CurrFlow" volumemultiplier="0.01" loop="true"/>
</Pump>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
<input name="toggle"/>

View File

@@ -31,7 +31,7 @@
</StatusEffect>
</Reactor>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<output name="power_out"/>
<output name="temperature_out"/>

View File

@@ -12,7 +12,7 @@
<Pickable slots="Any">
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg">
<Explosion range="500.0" structuredamage="300" damage="200" stun="5" force="20.0"/>
<Explosion range="500.0" structuredamage="250" damage="200" stun="5" force="20.0"/>
</StatusEffect>
</Pickable>
</Item>
@@ -27,7 +27,7 @@
<Body width="16" height="9"/>
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -35,7 +35,7 @@
<Containable name="explosive"/>
</ItemContainer>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="activate">
<StatusEffect type="OnUse" target="Contained" Condition="-100.0"/>

View File

@@ -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.0.0.1")]
[assembly: AssemblyFileVersion("0.0.0.1")]
[assembly: AssemblyVersion("0.2.3.0")]
[assembly: AssemblyFileVersion("0.2.3.0")]

View File

@@ -165,8 +165,8 @@ namespace Barotrauma
try
{
targetDir = message.ReadBoolean();
targetMovement.X = message.ReadRangedSingle(-10.0f, 10.0f, 8);
targetMovement.Y = message.ReadRangedSingle(-10.0f, 10.0f, 8);
targetMovement.X = message.ReadRangedSingle(-10.0f, 10.0f, 16);
targetMovement.Y = message.ReadRangedSingle(-10.0f, 10.0f, 16);
}
catch
@@ -236,7 +236,7 @@ namespace Barotrauma
catch { return; }
//error
AnimController.RefLimb.body.TargetPosition = pos;
AnimController.RefLimb.body.TargetVelocity = vel;

View File

@@ -626,8 +626,7 @@ namespace Barotrauma
selectedCharacter = null;
if (createNetworkEvent)
new NetworkEvent(NetworkEventType.SelectCharacter, ID, true, 0);
if (createNetworkEvent) new NetworkEvent(NetworkEventType.SelectCharacter, ID, true, (ushort)0);
}
/// <summary>
@@ -723,9 +722,10 @@ namespace Barotrauma
if (closestItem != null)
{
closestItem.IsHighlighted = true;
if (GetInputState(InputType.Select) && closestItem.Pick(this, false))
if (closestItem.Pick(this))
{
new NetworkEvent(NetworkEventType.PickItem, ID, true, closestItem.ID);
new NetworkEvent(NetworkEventType.PickItem, ID, true,
new int[] { closestItem.ID, GetInputState(InputType.Select) ? 1 : 0, GetInputState(InputType.ActionHit) ? 1 : 0 });
}
}
}
@@ -801,7 +801,7 @@ namespace Barotrauma
if (!(this is AICharacter)) Control(deltaTime, cam);
UpdateSightRange();
aiTarget.SoundRange = 0.0f;
if (aiTarget != null) aiTarget.SoundRange = 0.0f;
lowPassMultiplier = MathHelper.Lerp(lowPassMultiplier, 1.0f, 0.1f);
@@ -830,6 +830,8 @@ namespace Barotrauma
private void UpdateSightRange()
{
if (aiTarget == null) return;
aiTarget.SightRange = 0.0f;
//distance is approximated based on the mass of the character
@@ -1088,10 +1090,17 @@ namespace Barotrauma
{
if (type == NetworkEventType.PickItem)
{
message.Write((ushort)data);
int[] pickData = (int[])data;
if (pickData.Length != 3) return false;
message.Write((ushort)pickData[0]);
message.Write((int)pickData[1] == 1);
message.Write((int)pickData[2] == 1);
message.WritePadBits();
return true;
}
else if (type== NetworkEventType.SelectCharacter)
else if (type == NetworkEventType.SelectCharacter)
{
message.Write((ushort)data);
return true;
@@ -1193,12 +1202,15 @@ namespace Barotrauma
itemId = message.ReadUInt16();
bool pickHit = message.ReadBoolean();
bool actionHit = message.ReadBoolean();
System.Diagnostics.Debug.WriteLine("item id: "+itemId);
Item item = FindEntityByID(itemId) as Item;
if (item != null)
{
item.Pick(this);
item.Pick(this, false, pickHit, actionHit);
}
return;
@@ -1249,9 +1261,9 @@ namespace Barotrauma
bool hasInputs = message.ReadBoolean();
sendingTime = message.ReadFloat();
if (!hasInputs && sendingTime > LastNetworkUpdate)
if (!hasInputs)
{
ClearInputs();
if (sendingTime > LastNetworkUpdate) ClearInputs();
return;
}
@@ -1266,7 +1278,7 @@ namespace Barotrauma
runState = message.ReadBoolean();
}
catch
catch (Exception e)
{
return;
}
@@ -1310,7 +1322,7 @@ namespace Barotrauma
}
if (secondaryKeyState)
{
cursorPosition = cursorPos;
cursorPosition = MathUtils.IsValid(cursorPos) ? cursorPos : Vector2.Zero;
}
else
{

View File

@@ -531,7 +531,15 @@ namespace Barotrauma
{
if (limb.ignoreCollisions) continue;
limb.body.CollidesWith = collisionCategory;
try
{
limb.body.CollidesWith = collisionCategory;
}
catch (Exception e)
{
DebugConsole.ThrowError("Failed to update ragdoll limb collisioncategories", e);
}
}
}

View File

@@ -159,15 +159,15 @@ namespace Barotrauma
public void GiveReward()
{
if (!string.IsNullOrWhiteSpace(successMessage))
{
new GUIMessageBox("Quest completed successfully", successMessage);
}
var mode = GameMain.GameSession.gameMode as SinglePlayerMode;
if (mode == null) return;
mode.Money += reward;
if (!string.IsNullOrWhiteSpace(successMessage))
{
new GUIMessageBox("Quest completed", successMessage);
}
}
}
}

View File

@@ -185,10 +185,10 @@ namespace Barotrauma
public bool IsParentOf(GUIComponent component)
{
foreach (GUIComponent child in children)
for(int i = children.Count - 1; i >= 0; i--)
{
if (child == component) return true;
if (child.IsParentOf(component)) return true;
if (children[i] == component) return true;
if (children[i].IsParentOf(component)) return true;
}
return false;

View File

@@ -305,7 +305,8 @@ namespace Barotrauma
if (titleScreenOpen)
{
TitleScreen.Draw(spriteBatch, GraphicsDevice, (float)deltaTime);
if (TitleScreen.LoadState>=100.0f && (PlayerInput.GetKeyboardState.GetPressedKeys().Length>0 || PlayerInput.LeftButtonClicked()))
if (TitleScreen.LoadState>=100.0f &&
(!waitForKeyHit || PlayerInput.GetKeyboardState.GetPressedKeys().Length>0 || PlayerInput.LeftButtonClicked()))
{
titleScreenOpen = false;
}
@@ -325,8 +326,10 @@ namespace Barotrauma
Stopwatch sw;
public static void ShowLoading(IEnumerable<object> loader)
static bool waitForKeyHit = true;
public static void ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true)
{
waitForKeyHit = waitKeyHit;
titleScreenOpen = true;
CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader));

View File

@@ -213,7 +213,7 @@ namespace Barotrauma
yield return new WaitForSeconds(5.0f);
infoBox = CreateInfoFrame("You need a screwdriver to check the wiring of the terminal."
+ " Equip a screwdriver by pulling it to either of the slots with a hand symbol, and then select the terminal again by pressing E.");
+ " Equip a screwdriver by pulling it to either of the slots with a hand symbol, and then use it on the terminal by left clicking.");
while (Character.Controlled.SelectedConstruction != steering.Item ||
Character.Controlled.SelectedItems.FirstOrDefault(i => i != null && i.Name == "Screwdriver") == null)

View File

@@ -215,7 +215,7 @@ namespace Barotrauma.Items.Components
attached = true;
item.NewComponentEvent(this, true, true);
if (character != null) item.NewComponentEvent(this, true, true);
return true;
}

View File

@@ -37,7 +37,7 @@ namespace Barotrauma.Items.Components
if (picker == null) return false;
if (picker.Inventory == null) return false;
if (picker.Inventory.TryPutItem(item, allowedSlots))
if (picker.Inventory.TryPutItem(item, allowedSlots, picker==Character.Controlled))
{
if (!picker.HasSelectedItem(item) && item.body!=null) item.body.Enabled = false;
this.picker = picker;

View File

@@ -108,6 +108,18 @@ namespace Barotrauma.Items.Components
set { canBeSelected = value; }
}
public InputType PickKey
{
get;
private set;
}
public InputType SelectKey
{
get;
private set;
}
[HasDefaultValue(false, false)]
public bool DeleteOnUse
{
@@ -166,24 +178,26 @@ namespace Barotrauma.Items.Components
statusEffects = new List<StatusEffect>();
//var initableProperties = ObjectProperty.GetProperties<Initable>(this);
//foreach (ObjectProperty initableProperty in initableProperties)
//{
// object value = ToolBox.GetAttributeObject(element, initableProperty.Name.ToLower());
// if (value==null)
// {
// foreach (var ini in initableProperty.Attributes.OfType<Initable>())
// {
// value = ini.defaultValue;
// break;
// }
// }
SelectKey = InputType.Select;
// initableProperty.TrySetValue(value);
//}
if (item.Name=="Welding Tool")
try
{
int a = 1;
SelectKey = (InputType)Enum.Parse(typeof(InputType), ToolBox.GetAttributeString(element, "selectkey", "Select"), true);
}
catch (Exception e)
{
DebugConsole.ThrowError("Invalid select key in " + element + "!", e);
}
PickKey = InputType.Select;
try
{
PickKey = (InputType)Enum.Parse(typeof(InputType), ToolBox.GetAttributeString(element, "selectkey", "Select"), true);
}
catch (Exception e)
{
DebugConsole.ThrowError("Invalid pick key in " + element + "!", e);
}
properties = ObjectProperty.InitProperties(this, element);

View File

@@ -77,7 +77,7 @@ namespace Barotrauma.Items.Components
if (voltage < minVoltage) return;
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 20, y + 20, 200, 30), "Activate Radar"))
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 20, y + 20, 200, 30), "Activate Sonar"))
{
IsActive = !IsActive;
item.NewComponentEvent(this, true, false);

View File

@@ -119,11 +119,31 @@ namespace Barotrauma.Items.Components
{
if (stickTarget!=null)
{
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
try
{
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
}
catch (Exception e)
{
#if DEBUG
DebugConsole.ThrowError("Failed to restore collision with stickTarget", e);
#endif
}
stickTarget = null;
}
GameMain.World.RemoveJoint(stickJoint);
try
{
GameMain.World.RemoveJoint(stickJoint);
}
catch (Exception e)
{
#if DEBUG
DebugConsole.ThrowError("Failed to remove stickJoint", e);
#endif
}
stickJoint = null;
IsActive = false;

View File

@@ -420,11 +420,17 @@ namespace Barotrauma.Items.Components
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
{
Nodes.Clear();
List<Vector2> newNodes = new List<Vector2>();
int nodeCount = message.ReadByte();
for (int i = 0; i<nodeCount; i++)
{
Nodes.Add(new Vector2(message.ReadFloat(), message.ReadFloat()));
Vector2 newNode = new Vector2(message.ReadFloat(), message.ReadFloat());
if (!MathUtils.IsValid(newNode)) return;
newNodes.Add(newNode);
}
Nodes = newNodes;
}
}
}

View File

@@ -147,11 +147,11 @@ namespace Barotrauma
item.Drop(null, false);
return;
}
public void DropItem(int i)
{
items[i].Drop();
items[i] = null;
}
//public void DropItem(int i)
//{
// items[i].Drop();
// items[i] = null;
//}
public virtual void Draw(SpriteBatch spriteBatch)
{
@@ -194,8 +194,7 @@ namespace Barotrauma
{
if (Owner!=null)
{
ushort[] data = { draggingItem.ID, 0 };
new NetworkEvent(NetworkEventType.InventoryUpdate, Owner.ID, true, data);
new NetworkEvent(NetworkEventType.InventoryUpdate, Owner.ID, true);
}
DropItem(draggingItem);
@@ -281,8 +280,14 @@ namespace Barotrauma
Vector2 pos = new Vector2(rect.X + rect.Width / 2, rect.Y - rect.Height + 20) - GUI.Font.MeasureString(item.Name) * 0.5f;
pos.X = (int)pos.X;
pos.Y = (int)pos.Y;
#if DEBUG
spriteBatch.DrawString(GUI.Font, item.Name+" - "+item.ID, pos - new Vector2(1.0f, 1.0f), Color.Black);
spriteBatch.DrawString(GUI.Font, item.Name+" - "+item.ID, pos, Color.White);
#else
spriteBatch.DrawString(GUI.Font, item.Name, pos - new Vector2(1.0f, 1.0f), Color.Black);
spriteBatch.DrawString(GUI.Font, item.Name, pos, Color.White);
#endif
}
if (item.Condition < 100.0f)

View File

@@ -853,9 +853,9 @@ namespace Barotrauma
return closest;
}
public bool Pick(Character picker, bool forcePick=false)
public bool Pick(Character picker, bool ignoreRequiredItems=false, bool forceSelectKey=false, bool forceActionKey=false)
{
System.Diagnostics.Debug.WriteLine("Item.Pick("+picker+", "+forcePick+")");
bool hasRequiredSkills = true;
bool picked = false, selected = false;
@@ -864,13 +864,42 @@ namespace Barotrauma
foreach (ItemComponent ic in components)
{
bool pickHit = false, selectHit = false;
if (Screen.Selected == GameMain.EditMapScreen)
{
pickHit = picker.GetInputState(InputType.Select);
selectHit = picker.GetInputState(InputType.Select);
}
else
{
if (forceSelectKey)
{
if (ic.PickKey == InputType.Select) pickHit = true;
if (ic.SelectKey == InputType.Select) selectHit = true;
}
else if (forceActionKey)
{
if (ic.PickKey == InputType.ActionHit) pickHit = true;
if (ic.SelectKey == InputType.ActionHit) selectHit = true;
}
else
{
pickHit = picker.GetInputState(ic.PickKey);
selectHit = picker.GetInputState(ic.SelectKey);
}
}
if (!pickHit && !selectHit) continue;
Skill tempRequiredSkill;
if (!ic.HasRequiredSkills(picker, out tempRequiredSkill)) hasRequiredSkills = false;
if (tempRequiredSkill != null) requiredSkill = tempRequiredSkill;
if (!forcePick && !ic.HasRequiredItems(picker, picker == Character.Controlled)) continue;
if ((ic.CanBePicked && ic.Pick(picker)) || (ic.CanBeSelected && ic.Select(picker)))
if (!ignoreRequiredItems && !ic.HasRequiredItems(picker, picker == Character.Controlled)) continue;
if ((ic.CanBePicked && pickHit && ic.Pick(picker)) ||
(ic.CanBeSelected && selectHit && ic.Select(picker)))
{
picked = true;
ic.ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker);
@@ -879,9 +908,16 @@ namespace Barotrauma
}
if (!picked) return false;
if (selected)
System.Diagnostics.Debug.WriteLine("Item.Pick(" + picker + ", " + forceSelectKey + ")");
if (picker.SelectedConstruction == this)
{
picker.SelectedConstruction = (picker.SelectedConstruction == this) ? null : this;
if (picker.GetInputState(InputType.Select)) picker.SelectedConstruction = null;
}
else if (selected)
{
picker.SelectedConstruction = this;
}
if (!hasRequiredSkills && Character.Controlled==picker)
@@ -1177,7 +1213,7 @@ namespace Barotrauma
public override bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
{
message.Write(condition);
message.Write((byte)MathHelper.Clamp(condition*2.55f,0.0f,255.0f));
switch (type)
{
@@ -1244,7 +1280,7 @@ namespace Barotrauma
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
{
Condition = message.ReadFloat();
Condition = (float)message.ReadByte()/2.55f;
switch (type)
{

View File

@@ -173,7 +173,7 @@ namespace Barotrauma.Networking
// When this is set to true, we are approved and ready to go
bool CanStart = false;
DateTime timeOut = DateTime.Now + new TimeSpan(0,0,15);
DateTime timeOut = DateTime.Now + new TimeSpan(0,0,20);
// Loop until we are approved
while (!CanStart && !connectCanceled)
@@ -247,9 +247,9 @@ namespace Barotrauma.Networking
}
break;
case NetIncomingMessageType.StatusChanged:
NetConnectionStatus connectionStatus = (NetConnectionStatus)inc.ReadByte();
Debug.WriteLine(connectionStatus);
DebugConsole.NewMessage("Connection status changed: " + client.ConnectionStatus.ToString(), Color.Orange);
NetConnectionStatus connectionStatus = (NetConnectionStatus)inc.ReadByte();
if (connectionStatus == NetConnectionStatus.Disconnected)
{
string denyMessage = inc.ReadString();
@@ -284,6 +284,9 @@ namespace Barotrauma.Networking
if (client.ConnectionStatus != NetConnectionStatus.Connected)
{
var reconnect = new GUIMessageBox("CONNECTION FAILED", "Failed to connect to server.", new string[] { "Retry", "Cancel" });
DebugConsole.NewMessage("Failed to connect to server - connection status: "+client.ConnectionStatus.ToString(), Color.Orange);
reconnect.Buttons[0].OnClicked += RetryConnection;
reconnect.Buttons[0].OnClicked += reconnect.Close;
reconnect.Buttons[1].OnClicked += SelectMainMenu;
@@ -412,7 +415,7 @@ namespace Barotrauma.Networking
case (byte)PacketTypes.StartGame:
if (gameStarted) continue;
GameMain.ShowLoading(StartGame(inc));
GameMain.ShowLoading(StartGame(inc), false);
break;
case (byte)PacketTypes.EndGame:

View File

@@ -248,6 +248,7 @@ namespace Barotrauma.Networking
{
EndButtonHit(null, null);
AutoRestartTimer = 20.0f;
UpdateNetLobby(null,null);
return;
}
}
@@ -705,7 +706,7 @@ namespace Barotrauma.Networking
return false;
}
GameMain.ShowLoading(StartGame(selectedSub));
GameMain.ShowLoading(StartGame(selectedSub), false);
return true;
}

View File

@@ -19,14 +19,23 @@ namespace Barotrauma.Networking.ReliableMessages
receiver = new ReliableReceiver(host);
}
public ReliableMessage CreateMessage(int lengthBytes = 0)
public ReliableMessage CreateMessage()
{
return sender.CreateMessage();
}
public void SendMessage(ReliableMessage message, NetConnection receiver)
{
sender.SendMessage(message, receiver);
try
{
sender.SendMessage(message, receiver);
}
catch (Exception e)
{
#if DEBUG
DebugConsole.ThrowError("Sending a reliable message failed", e);
#endif
}
}
public void HandleResendRequest(NetIncomingMessage inc)
@@ -348,27 +357,34 @@ namespace Barotrauma.Networking.ReliableMessages
return;
}
Debug.WriteLine("Received ack message: " + messageId + ", need to rerequest messages");
Debug.WriteLine("Received ack message: " + messageId + ", need to rerequest messages (last id: "+lastMessageID+")");
if (lastMessageID > ushort.MaxValue / 2 && messageId < short.MaxValue / 2)
{
for (ushort i = (ushort)Math.Min((int)lastMessageID + 1, ushort.MaxValue); i <= ushort.MaxValue; i++)
{
if (i == ushort.MaxValue && lastMessageID == ushort.MaxValue) break;
if (!missingMessages.ContainsKey(i)) missingMessages.Add(i, new MissingMessage(i));
QueueMissingMessage(i);
if (i == ushort.MaxValue) break;
}
for (ushort i = 1; i < messageId; i++)
{
if (!missingMessages.ContainsKey(i)) missingMessages.Add(i, new MissingMessage(i));
QueueMissingMessage(i);
}
}
else
{
//we already wrapped around but message hasn't, so it's an old message
if (lastMessageID < ushort.MaxValue / 2 && messageId > ushort.MaxValue / 2)
{
Debug.WriteLine("old already received message, ignore");
return;
}
for (ushort i = (ushort)Math.Min((int)lastMessageID+1, ushort.MaxValue); i <= messageId; i++)
{
if (!missingMessages.ContainsKey(i)) missingMessages.Add(i, new MissingMessage(i));
QueueMissingMessage(i);
if (i == ushort.MaxValue) break;
}
}

View File

@@ -391,7 +391,7 @@ namespace Barotrauma
GUI.Draw((float)deltaTime, spriteBatch, null);
spriteBatch.DrawString(GUI.Font, "Barotrauma chat lag test build", new Vector2(10, GameMain.GraphicsHeight-20), Color.White);
spriteBatch.DrawString(GUI.Font, "Barotrauma v"+GameMain.Version, new Vector2(10, GameMain.GraphicsHeight-20), Color.White);
spriteBatch.End();
}

Binary file not shown.