fixed railgun, fixed repairtools radar ping & improved rendering, waypoint bugfixes, inventory bugfixes, syncing wires between clients

This commit is contained in:
Regalis
2015-07-15 23:34:13 +03:00
parent 44b9a63c94
commit 237df18765
39 changed files with 461 additions and 405 deletions

View File

@@ -132,7 +132,8 @@ namespace Subsurface.Networking
{
// All manually sent messages are type of "Data"
case NetIncomingMessageType.Data:
if (inc.ReadByte() == (byte)PacketTypes.LoggedIn)
byte packetType = inc.ReadByte();
if (packetType == (byte)PacketTypes.LoggedIn)
{
myID = inc.ReadInt32();
@@ -152,7 +153,7 @@ namespace Subsurface.Networking
CanStart = true;
}
else if (inc.ReadByte() == (byte)PacketTypes.KickedOut)
else if (packetType == (byte)PacketTypes.KickedOut)
{
string msg = inc.ReadString();
DebugConsole.ThrowError(msg);
@@ -199,6 +200,7 @@ namespace Subsurface.Networking
SendRandomData();
}
if (gameStarted) inGameHUD.Update((float)Physics.step);
if (!connected || updateTimer > DateTime.Now) return;

View File

@@ -21,6 +21,9 @@ namespace Subsurface.Networking
public GameServer()
{
var endRoundButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 170-120, 20, 150, 25), "End round", Alignment.TopLeft, GUI.style, inGameHUD);
endRoundButton.OnClicked = EndButtonHit;
name = "Server";
Config = new NetPeerConfiguration("subsurface");
@@ -49,13 +52,11 @@ namespace Subsurface.Networking
updateInterval = new TimeSpan(0, 0, 0, 0, 30);
DebugConsole.NewMessage("Server started", Color.Green);
}
public override void Update()
{
// Server.ReadMessage() Returns new messages, that have not yet been read.
// If "inc" is null -> ReadMessage returned null -> Its null, so dont do this :)
if (gameStarted) inGameHUD.Update((float)Physics.step);
NetIncomingMessage inc = Server.ReadMessage();
if (inc != null)
@@ -84,6 +85,30 @@ namespace Subsurface.Networking
}
}
private void SparseUpdate()
{
foreach (Character c in Character.CharacterList)
{
bool isClient = false;
foreach (Client client in connectedClients)
{
if (client.character != c) continue;
isClient = true;
break;
}
if (!isClient)
{
c.LargeUpdateTimer = 0;
new NetworkEvent(c.ID, false);
}
}
new NetworkEvent(Submarine.Loaded.ID, false);
sparseUpdateTimer = DateTime.Now + SparseUpdateInterval;
}
private void ReadMessage(NetIncomingMessage inc)
{
NetOutgoingMessage outmsg;
@@ -224,30 +249,6 @@ namespace Subsurface.Networking
}
}
private void SparseUpdate()
{
foreach (Character c in Character.CharacterList)
{
bool isClient = false;
foreach (Client client in connectedClients)
{
if (client.character != c) continue;
isClient = true;
break;
}
if (!isClient)
{
c.LargeUpdateTimer = 0;
new NetworkEvent(c.ID, false);
}
}
new NetworkEvent(Submarine.Loaded.ID, false);
sparseUpdateTimer = DateTime.Now + SparseUpdateInterval;
}
private void SendMessage(NetOutgoingMessage msg, NetDeliveryMethod deliveryMethod, NetConnection excludedConnection)
{
List<NetConnection> recipients = new List<NetConnection>();
@@ -296,7 +297,6 @@ namespace Subsurface.Networking
Submarine selectedMap = Game1.NetLobbyScreen.SelectedMap as Submarine;
//selectedMap.Load();
Game1.GameSession = new GameSession(selectedMap, Game1.NetLobbyScreen.SelectedMode);
@@ -378,6 +378,13 @@ namespace Subsurface.Networking
return true;
}
private bool EndButtonHit(GUIButton button, object obj)
{
Game1.GameSession.gameMode.End("The round has ended");
return true;
}
public void EndGame(string endMessage)
{
Submarine.Unload();

View File

@@ -1,5 +1,6 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Subsurface.Networking
{
@@ -93,12 +94,17 @@ namespace Subsurface.Networking
Alignment.Left, null, null, true);
msg.Padding = new Vector4(20.0f, 0, 0, 0);
chatBox.AddChild(msg);
while (chatBox.CountChildren > 20)
{
chatBox.RemoveChild(chatBox.children[0]);
}
//float prevScroll = chatBox.BarScroll;
//chatBox.AddChild(msg);
//while (chatBox.CountChildren > 20)
//{
// chatBox.RemoveChild(chatBox.children[0]);
//}
//if (prevScroll == 1.0f) chatBox.BarScroll = 1.0f;
GUI.PlayMessageSound();
}
@@ -107,6 +113,13 @@ namespace Subsurface.Networking
public virtual void Update() { }
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
{
if (!gameStarted) return;
inGameHUD.Draw(spriteBatch);
}
public virtual void Disconnect() { }
}