Characters with no CharacterInfo can't be selected, fixed broken tickboxes in server settings, inventory log tweaking, one gap sound per hull, chat message "commands" changed from /d to d;

This commit is contained in:
Regalis
2016-02-17 20:43:42 +02:00
parent 8129aa2ae5
commit 4ad8105cd6
16 changed files with 216 additions and 70 deletions
+2 -2
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 // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.2.3")] [assembly: AssemblyVersion("0.3.2.4")]
[assembly: AssemblyFileVersion("0.3.2.3")] [assembly: AssemblyFileVersion("0.3.2.4")]
+12 -11
View File
@@ -654,6 +654,16 @@ namespace Barotrauma
if (selectedConstruction != null && IsKeyDown(InputType.Aim)) selectedConstruction.SecondaryUse(deltaTime, this); if (selectedConstruction != null && IsKeyDown(InputType.Aim)) selectedConstruction.SecondaryUse(deltaTime, this);
} }
if (selectedCharacter!=null)
{
if (Vector2.Distance(selectedCharacter.SimPosition, SimPosition) > 3.0f ||
(!selectedCharacter.isDead && selectedCharacter.Stun <= 0.0f))
{
DeselectCharacter();
}
}
if (IsNetworkPlayer) if (IsNetworkPlayer)
{ {
foreach (Key key in keys) foreach (Key key in keys)
@@ -828,10 +838,9 @@ namespace Barotrauma
if (findClosestTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen) if (findClosestTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen)
{ {
closestCharacter = FindClosestCharacter(mouseSimPos); closestCharacter = FindClosestCharacter(mouseSimPos);
if (closestCharacter != null) if (closestCharacter != null && closestCharacter.info==null)
{ {
// if (closestCharacter != selectedCharacter) selectedCharacter = null; closestCharacter = null;
if (!closestCharacter.IsHumanoid) closestCharacter = null;
} }
closestItem = FindClosestItem(mouseSimPos); closestItem = FindClosestItem(mouseSimPos);
@@ -872,14 +881,6 @@ namespace Barotrauma
} }
} }
} }
else
{
if (Vector2.Distance(selectedCharacter.SimPosition, SimPosition) > 2.0f ||
(!selectedCharacter.isDead && selectedCharacter.Stun <= 0.0f))
{
DeselectCharacter();
}
}
if (IsKeyHit(InputType.Select)) if (IsKeyHit(InputType.Select))
{ {
+1 -1
View File
@@ -50,7 +50,7 @@ namespace Barotrauma
box.HoverColor = Color.Gray; box.HoverColor = Color.Gray;
box.SelectedColor = Color.DarkGray; box.SelectedColor = Color.DarkGray;
text = new GUITextBlock(new Rectangle(rect.X + 30, rect.Y+2, 200, rect.Height), label, Color.Transparent, Color.White, Alignment.TopLeft, null, this); text = new GUITextBlock(new Rectangle(rect.X + 30, rect.Y+2, 20, rect.Height), label, Color.Transparent, Color.White, Alignment.TopLeft, null, this);
this.rect = new Rectangle(box.Rect.X, box.Rect.Y, 240, rect.Height); this.rect = new Rectangle(box.Rect.X, box.Rect.Y, 240, rect.Height);
+40 -7
View File
@@ -100,8 +100,6 @@ namespace Barotrauma
/// </summary> /// </summary>
public override bool TryPutItem(Item item, List<LimbSlot> allowedSlots, bool createNetworkEvent = true) public override bool TryPutItem(Item item, List<LimbSlot> allowedSlots, bool createNetworkEvent = true)
{ {
bool alreadyInInventory = Array.Find(Items, i => i == item)!=null;
//try to place the item in LimBlot.Any slot if that's allowed //try to place the item in LimBlot.Any slot if that's allowed
if (allowedSlots.Contains(LimbSlot.Any)) if (allowedSlots.Contains(LimbSlot.Any))
{ {
@@ -109,7 +107,6 @@ namespace Barotrauma
{ {
if (Items[i] != null || limbSlots[i] != LimbSlot.Any) continue; if (Items[i] != null || limbSlots[i] != LimbSlot.Any) continue;
GameServer.Log(character.Name + " picked up " + item.Name, Color.Orange);
PutItem(item, i, createNetworkEvent); PutItem(item, i, createNetworkEvent);
item.Unequip(character); item.Unequip(character);
return true; return true;
@@ -144,7 +141,6 @@ namespace Barotrauma
if (placed) if (placed)
{ {
if (!alreadyInInventory) GameServer.Log(character.Name + " picked up " + item.Name, Color.Orange);
return true; return true;
} }
} }
@@ -367,29 +363,66 @@ namespace Barotrauma
return true; return true;
} }
public override void ReadNetworkData(NetworkEventType type, NetBuffer message, float sendingTime) public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime)
{ {
if (sendingTime < lastUpdate) return; if (sendingTime < lastUpdate) return;
character.ClearInput(InputType.Use); character.ClearInput(InputType.Use);
List<Item> droppedItems = new List<Item>();
List<Item> prevItems = new List<Item>(Items);
for (int i = 0; i<capacity; i++) for (int i = 0; i<capacity; i++)
{ {
ushort itemId = message.ReadUInt16(); ushort itemId = message.ReadUInt16();
if (itemId == 0) if (itemId == 0)
{ {
if (Items[i] != null) Items[i].Drop(character, false); if (Items[i] != null)
{
droppedItems.Add(Items[i]);
Items[i].Drop(character, false);
}
} }
else else
{ {
Item item = Entity.FindEntityByID(itemId) as Item; Item item = Entity.FindEntityByID(itemId) as Item;
if (item == null) continue; if (item == null) continue;
Inventory existingInventory = item.ParentInventory;
if (Items[i] != item && Items[i] != null) Items[i].Drop(character, false); if (Items[i] != item && Items[i] != null) Items[i].Drop(character, false);
TryPutItem(item, i, false);
if (TryPutItem(item, i, false))
{
if (droppedItems.Contains(item))
{
droppedItems.Remove(item);
}
}
} }
} }
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null && sender.Character != null)
{
foreach (Item item in droppedItems)
{
GameServer.Log(sender.Character == character ?
character.Name + " dropped " + item.Name :
sender.Character + " removed " + item.Name+" from "+character+"'s inventory", Color.Orange);
}
foreach (Item item in Items)
{
if (item == null || prevItems.Contains(item)) continue;
GameServer.Log(sender.Character == character ?
character.Name + " picked up " + item.Name :
sender.Character + " placed " + item.Name + " in " + character + "'s inventory", Color.Orange);
}
}
lastUpdate = sendingTime; lastUpdate = sendingTime;
} }
@@ -316,7 +316,16 @@ namespace Barotrauma.Items.Components
} }
item.SetTransform(newPos, 0.0f); item.SetTransform(newPos, 0.0f);
if (!attached) Use(1.0f); if (!attached)
{
Use(1.0f);
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null && sender.Character != null)
{
Networking.GameServer.Log(sender.characterInfo.Name+" attached a "+item.Name+" on a wall", Color.Orange);
}
}
} }
} }
} }
@@ -172,7 +172,9 @@ namespace Barotrauma.Items.Components
wireComponent.Connect(c, false); wireComponent.Connect(c, false);
var otherConnection = c.Wires[i].OtherConnection(c); var otherConnection = c.Wires[i].OtherConnection(c);
Networking.GameServer.Log(c.Name + " -> " + (otherConnection == null ? "none" : otherConnection.Name), Color.Orange); Networking.GameServer.Log(
item.Name+" ("+ c.Name + ") -> " +
otherConnection.Item.Name+" ("+(otherConnection == null ? "none" : otherConnection.Name)+")", Color.Orange);
} }
c.UpdateRecipients(); c.UpdateRecipients();
} }
+23 -1
View File
@@ -361,11 +361,13 @@ namespace Barotrauma
return true; return true;
} }
public virtual void ReadNetworkData(NetworkEventType type, NetBuffer message, float sendingTime) public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime)
{ {
if (sendingTime < lastUpdate) return; if (sendingTime < lastUpdate) return;
List<ushort> newItemIDs = new List<ushort>(); List<ushort> newItemIDs = new List<ushort>();
List<Item> droppedItems = new List<Item>();
List<Item> prevItems = new List<Item>(Items);
byte count = message.ReadByte(); byte count = message.ReadByte();
for (int i = 0; i<count; i++) for (int i = 0; i<count; i++)
@@ -378,7 +380,9 @@ namespace Barotrauma
if (Items[i] == null) continue; if (Items[i] == null) continue;
if (!newItemIDs.Contains(Items[i].ID)) if (!newItemIDs.Contains(Items[i].ID))
{ {
droppedItems.Add(Items[i]);
Items[i].Drop(null, false); Items[i].Drop(null, false);
continue; continue;
} }
} }
@@ -388,8 +392,26 @@ namespace Barotrauma
if (item == null) continue; if (item == null) continue;
TryPutItem(item, item.AllowedSlots, false); TryPutItem(item, item.AllowedSlots, false);
if (droppedItems.Contains(item)) droppedItems.Remove(item);
} }
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null && sender.Character != null)
{
foreach (Item item in droppedItems)
{
GameServer.Log(sender.Character + " removed " + item.Name + " from " + Owner.ToString(), Color.Orange);
}
foreach (Item item in Items)
{
if (item == null || prevItems.Contains(item)) continue;
GameServer.Log(sender.Character + " placed " + item.Name + " in " + Owner.ToString(), Color.Orange);
}
}
lastUpdate = sendingTime; lastUpdate = sendingTime;
} }
} }
+1 -1
View File
@@ -1125,7 +1125,7 @@ namespace Barotrauma
// new NetworkEvent(NetworkEventType.DropItem, ID, true); // new NetworkEvent(NetworkEventType.DropItem, ID, true);
if (dropper != null) GameServer.Log(dropper.Name + " dropped " + Name, Color.Orange); //if (dropper != null) GameServer.Log(dropper.Name + " dropped " + Name, Color.Orange);
foreach (ItemComponent ic in components) ic.Drop(dropper); foreach (ItemComponent ic in components) ic.Drop(dropper);
+2 -2
View File
@@ -145,13 +145,13 @@ namespace Barotrauma
if (fireSoundBasic != null) if (fireSoundBasic != null)
{ {
basicSoundIndex = fireSoundBasic.Loop(basicSoundIndex, basicSoundIndex = fireSoundBasic.Loop(basicSoundIndex,
Math.Min(size.X / 100.0f, 1.0f), position + size / 2.0f, 2000.0f); Math.Min(size.X / 100.0f, 1.0f), position + size / 2.0f, 1000.0f);
} }
if (fireSoundLarge != null) if (fireSoundLarge != null)
{ {
largeSoundIndex = fireSoundLarge.Loop(largeSoundIndex, largeSoundIndex = fireSoundLarge.Loop(largeSoundIndex,
MathHelper.Clamp((size.X - 200.0f) / 100.0f, 0.0f, 1.0f), position + size / 2.0f, 2000.0f); MathHelper.Clamp((size.X - 200.0f) / 100.0f, 0.0f, 1.0f), position + size / 2.0f, 1000.0f);
} }
if (size.X>50.0f) if (size.X>50.0f)
+16 -18
View File
@@ -30,9 +30,6 @@ namespace Barotrauma
float higherSurface; float higherSurface;
float lowerSurface; float lowerSurface;
private int soundIndex;
float soundVolume;
public float Open public float Open
{ {
@@ -42,10 +39,10 @@ namespace Barotrauma
public Door ConnectedDoor; public Door ConnectedDoor;
public Vector2 FlowForce //public Vector2 FlowForce
{ //{
get { return flowForce*soundVolume; } // get { return flowForce*soundVolume; }
} //}
public Vector2 LerpedFlowForce public Vector2 LerpedFlowForce
{ {
@@ -144,8 +141,12 @@ namespace Barotrauma
hulls[1] = temp; hulls[1] = temp;
} }
linkedTo.Add(hulls[0]); for (int i = 0 ; i <2; i++)
if (hulls[1] != null) linkedTo.Add(hulls[1]); {
if (hulls[i]==null) continue;
linkedTo.Add(hulls[i]);
if (!hulls[i].ConnectedGaps.Contains(this)) hulls[i].ConnectedGaps.Add(this);
}
} }
public override void Draw(SpriteBatch sb, bool editing, bool back = true) public override void Draw(SpriteBatch sb, bool editing, bool back = true)
@@ -205,14 +206,6 @@ namespace Barotrauma
public override void Update(Camera cam, float deltaTime) public override void Update(Camera cam, float deltaTime)
{ {
soundVolume = soundVolume + ((flowForce.Length() < 100.0f) ? -deltaTime * 0.5f : deltaTime * 0.5f);
soundVolume = MathHelper.Clamp(soundVolume, 0.0f, 1.0f);
int index = (int)Math.Floor(flowForce.Length() / 100.0f);
index = Math.Min(index,2);
soundIndex = SoundPlayer.flowSounds[index].Loop(soundIndex, soundVolume, WorldPosition, 2000.0f);
flowForce = Vector2.Zero; flowForce = Vector2.Zero;
if (open == 0.0f) return; if (open == 0.0f) return;
@@ -548,7 +541,12 @@ namespace Barotrauma
GapList.Remove(this); GapList.Remove(this);
if (soundIndex > -1) Sounds.SoundManager.Stop(soundIndex); foreach (MapEntity entity in linkedTo)
{
var hull = entity as Hull;
if (hull.ConnectedGaps.Contains(this)) hull.ConnectedGaps.Remove(this);
}
} }
+46 -11
View File
@@ -48,6 +48,9 @@ namespace Barotrauma
private bool update; private bool update;
private int soundIndex;
private float soundVolume;
float[] waveY; //displacement from the surface of the water float[] waveY; //displacement from the surface of the water
float[] waveVel; //velocity of the point float[] waveVel; //velocity of the point
@@ -56,6 +59,8 @@ namespace Barotrauma
float lastSentVolume; float lastSentVolume;
public List<Gap> ConnectedGaps;
public override string Name public override string Name
{ {
get get
@@ -173,12 +178,15 @@ namespace Barotrauma
hullList.Add(this); hullList.Add(this);
ConnectedGaps = new List<Gap>();
Item.UpdateHulls(); Item.UpdateHulls();
Gap.UpdateHulls(); Gap.UpdateHulls();
Volume = 0.0f; Volume = 0.0f;
InsertToList(); InsertToList();
} }
@@ -262,9 +270,11 @@ namespace Barotrauma
fireSource.Remove(); fireSource.Remove();
} }
if (soundIndex > -1) Sounds.SoundManager.Stop(soundIndex);
//renderer.Dispose(); //renderer.Dispose();
if (entityGrid!=null) entityGrid.RemoveEntity(this); if (entityGrid != null) entityGrid.RemoveEntity(this);
hullList.Remove(this); hullList.Remove(this);
} }
@@ -312,6 +322,31 @@ namespace Barotrauma
FireSource.UpdateAll(fireSources, deltaTime); FireSource.UpdateAll(fireSources, deltaTime);
float strongestFlow = 0.0f;
foreach (Gap gap in ConnectedGaps)
{
float gapFlow = gap.LerpedFlowForce.Length();
if (gapFlow > strongestFlow)
{
strongestFlow = gapFlow;
}
}
if (strongestFlow>0.1f)
{
soundVolume = soundVolume + ((strongestFlow < 100.0f) ? -deltaTime * 0.5f : deltaTime * 0.5f);
soundVolume = MathHelper.Clamp(soundVolume, 0.0f, 1.0f);
int index = (int)Math.Floor(strongestFlow / 100.0f);
index = Math.Min(index, 2);
soundIndex = SoundPlayer.flowSounds[index].Loop(soundIndex, soundVolume, WorldPosition, 2000.0f);
}
else
{
if (soundIndex > -1) Sounds.SoundManager.Stop(soundIndex);
}
//update client hulls if the amount of water has changed by >10% //update client hulls if the amount of water has changed by >10%
if (Math.Abs(lastSentVolume - volume) > FullVolume * 0.1f) if (Math.Abs(lastSentVolume - volume) > FullVolume * 0.1f)
{ {
@@ -588,19 +623,19 @@ namespace Barotrauma
return null; return null;
} }
public List<Gap> FindGaps() //public List<Gap> FindGaps()
{ //{
List<Gap> gaps = new List<Gap>(); // List<Gap> gaps = new List<Gap>();
foreach (Gap gap in Gap.GapList) // foreach (Gap gap in Gap.GapList)
{ // {
if (gap.Open < 0.01f) continue; // if (gap.Open < 0.01f) continue;
if (gap.linkedTo.Contains(this)) gaps.Add(gap); // if (gap.linkedTo.Contains(this)) gaps.Add(gap);
} // }
return gaps; // return gaps;
} //}
public override XElement Save(XDocument doc) public override XElement Save(XDocument doc)
{ {
+1 -1
View File
@@ -425,7 +425,7 @@ namespace Barotrauma
if (newHull == null) return true; if (newHull == null) return true;
} }
var gaps = newHull.FindGaps(); var gaps = newHull.ConnectedGaps;
targetPos = limb.character.WorldPosition; targetPos = limb.character.WorldPosition;
+39 -11
View File
@@ -883,7 +883,7 @@ namespace Barotrauma.Networking
GameMain.GameScreen.Select(); GameMain.GameScreen.Select();
AddChatMessage("Press TAB to chat. Use ''/d'' to talk to dead players and spectators, and ''/playername'' to only send the message to a specific player.", ChatMessageType.Server); AddChatMessage("Press TAB to chat. Use ''d;'' to talk to dead players and spectators, and ''player name;'' to only send the message to a specific player.", ChatMessageType.Server);
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
} }
@@ -1272,33 +1272,61 @@ namespace Barotrauma.Networking
public override void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server) public override void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server)
{ {
string[] words = message.Split(' ');
List<Client> recipients = new List<Client>(); List<Client> recipients = new List<Client>();
Client targetClient = null; Client targetClient = null;
if (words.Length > 2 && words[1].FirstOrDefault()=='/' && type==ChatMessageType.Server) if (type==ChatMessageType.Server)
{ {
if (words[1] == "/dead" || words[1] == "/d") string command = GetChatMessageCommand(message).ToLower();
if (command=="dead" || command=="d")
{ {
type = ChatMessageType.Dead; type = ChatMessageType.Dead;
} }
else else if (command != "")
{ {
targetClient = ConnectedClients.Find(c => targetClient = ConnectedClients.Find(c =>
words[1] == "/" + c.name.ToLower() || command == c.name.ToLower() ||
c.Character != null && words[1] == "/" + c.Character.Name.ToLower()); c.Character != null && command == c.Character.Name.ToLower());
if (targetClient==null) if (targetClient == null)
{ {
AddChatMessage("Player ''"+words[1].Replace("/", "")+"'' not found!", ChatMessageType.Admin); AddChatMessage("Player ''" + command + "'' not found!", ChatMessageType.Admin);
return; return;
} }
} }
message = words[0] + " " + string.Join(" ", words, 2, words.Length - 2);
} }
//remove the ''name: '' part
//string[] words = message.Split(':');
//string[] newMessage = ((string[])words.Skip(1));
//if (words.Length > 2 && words[1].FirstOrDefault()=='/' && type==ChatMessageType.Server)
//{
// if (words[1] == "/dead" || words[1] == "/d")
// {
// type = ChatMessageType.Dead;
// }
// else
// {
// targetClient = ConnectedClients.Find(c =>
// words[1] == "/" + c.name.ToLower() ||
// c.Character != null && words[1] == "/" + c.Character.Name.ToLower());
// if (targetClient==null)
// {
// AddChatMessage("Player ''"+words[1].Replace("/", "")+"'' not found!", ChatMessageType.Admin);
// return;
// }
// }
// message = words[0] + " " + string.Join(" ", words, 2, words.Length - 2);
//}
if (targetClient != null) if (targetClient != null)
{ {
recipients.Add(targetClient); recipients.Add(targetClient);
@@ -214,6 +214,24 @@ namespace Barotrauma.Networking
public virtual void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server) { } public virtual void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server) { }
protected string GetChatMessageCommand(string message)
{
int separatorIndex = message.IndexOf(";");
if (separatorIndex == -1) return "";
int colonIndex = message.IndexOf(":");
string command = "";
try
{
command = message.Substring(colonIndex + 2, separatorIndex - colonIndex - 2);
}
catch { }
return command;
}
public virtual void Update(float deltaTime) public virtual void Update(float deltaTime)
{ {
if (gameStarted && Screen.Selected == GameMain.GameScreen) if (gameStarted && Screen.Selected == GameMain.GameScreen)
+2 -2
View File
@@ -115,7 +115,7 @@ namespace Barotrauma.Particles
if (prefab.DeleteOnCollision || prefab.CollidesWithWalls) if (prefab.DeleteOnCollision || prefab.CollidesWithWalls)
{ {
hullGaps = currentHull==null ? new List<Gap>() : currentHull.FindGaps(); hullGaps = currentHull == null ? new List<Gap>() : currentHull.ConnectedGaps;
//hullLimits = new List<Hull>(); //hullLimits = new List<Hull>();
//hullLimits = FindLimits(position); //hullLimits = FindLimits(position);
} }
@@ -209,7 +209,7 @@ namespace Barotrauma.Particles
else else
{ {
currentHull = Hull.FindHull(position); currentHull = Hull.FindHull(position);
hullGaps = currentHull == null ? new List<Gap>() : currentHull.FindGaps(); hullGaps = currentHull == null ? new List<Gap>() : currentHull.ConnectedGaps;
if (OnChangeHull != null) OnChangeHull(edgePos, currentHull); if (OnChangeHull != null) OnChangeHull(edgePos, currentHull);
Binary file not shown.