Ingame syncing kinda works
Reminder to self: Submarines must spawn attached shuttles in Dedicated Server, must've been something I missed when moving over client-specific code
This commit is contained in:
@@ -505,8 +505,6 @@ namespace Barotrauma
|
||||
protected Character(string file, Vector2 position, CharacterInfo characterInfo = null, bool isRemotePlayer = false)
|
||||
: base(null)
|
||||
{
|
||||
keys = new Key[Enum.GetNames(typeof(InputType)).Length];
|
||||
|
||||
ConfigPath = file;
|
||||
|
||||
selectedItems = new Item[2];
|
||||
@@ -899,8 +897,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (IsRemotePlayer)
|
||||
|
||||
if (IsRemotePlayer && keys!=null)
|
||||
{
|
||||
foreach (Key key in keys)
|
||||
{
|
||||
@@ -1726,9 +1724,9 @@ namespace Barotrauma
|
||||
{
|
||||
GameMain.GameSession.CrewManager.characters.Remove(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (GameMain.Client != null && GameMain.Client.Character == this) GameMain.Client.Character = null;
|
||||
#endif
|
||||
|
||||
if (aiTarget != null) aiTarget.Remove();
|
||||
|
||||
|
||||
@@ -401,7 +401,7 @@ namespace Barotrauma
|
||||
|
||||
attack = dequeuedInput.HasFlag(InputNetFlags.Attack);
|
||||
}
|
||||
else
|
||||
else if (keys != null)
|
||||
{
|
||||
aiming = keys[(int)InputType.Aim].GetHeldQueue;
|
||||
use = keys[(int)InputType.Use].GetHeldQueue;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Barotrauma
|
||||
|
||||
static partial class DebugConsole
|
||||
{
|
||||
const int MaxMessages = 200;
|
||||
const int MaxMessages = 20000;
|
||||
|
||||
public static List<ColoredText> Messages = new List<ColoredText>();
|
||||
|
||||
@@ -55,6 +55,17 @@ namespace Barotrauma
|
||||
|
||||
switch (commands[0].ToLowerInvariant())
|
||||
{
|
||||
case "entitylist":
|
||||
System.IO.StreamWriter sw = new System.IO.StreamWriter("ENTLIST "+Rand.Int(20000).ToString()+".TXT");
|
||||
|
||||
List<Entity> entList = Entity.GetEntityList();
|
||||
foreach (Entity ent in entList)
|
||||
{
|
||||
sw.WriteLine(ent.ID.ToString()+" "+ent.ToString());
|
||||
}
|
||||
|
||||
sw.Close();
|
||||
break;
|
||||
case "help":
|
||||
NewMessage("menu: go to main menu", Color.Cyan);
|
||||
NewMessage("game: enter the \"game screen\"", Color.Cyan);
|
||||
@@ -501,6 +512,7 @@ namespace Barotrauma
|
||||
//TODO: REMOVE
|
||||
Console.ForegroundColor = XnaToConsoleColor.Convert(color);
|
||||
Console.WriteLine(msg);
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
#endif
|
||||
|
||||
if (Messages.Count > MaxMessages)
|
||||
|
||||
@@ -293,11 +293,11 @@ namespace Barotrauma
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
#if CLIENT
|
||||
/*#if CLIENT
|
||||
return (GameMain.DebugDraw) ? Name + "(ID: " + ID + ")" : Name;
|
||||
#elif SERVER
|
||||
#elif SERVER*/
|
||||
return Name + "(ID: " + ID + ")";
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
public List<IPropertyObject> AllPropertyObjects
|
||||
@@ -1304,6 +1304,7 @@ namespace Barotrauma
|
||||
|
||||
public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
|
||||
{
|
||||
DebugConsole.NewMessage(ToString(), Color.Magenta);
|
||||
if (extraData == null || extraData.Length == 0 || !(extraData[0] is NetEntityEvent.Type))
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -10,6 +10,10 @@ namespace Barotrauma
|
||||
class Entity
|
||||
{
|
||||
private static Dictionary<ushort, Entity> dictionary = new Dictionary<ushort, Entity>();
|
||||
public static List<Entity> GetEntityList()
|
||||
{
|
||||
return dictionary.Values.ToList();
|
||||
}
|
||||
|
||||
public static EntitySpawner Spawner;
|
||||
|
||||
|
||||
@@ -183,9 +183,10 @@ namespace Barotrauma
|
||||
else if (entities.Entity is Character)
|
||||
{
|
||||
message.Write((byte)SpawnableType.Character);
|
||||
DebugConsole.NewMessage("WRITING CHARACTER DATA: " + (entities.Entity).ToString(),Color.Cyan);
|
||||
((Character)entities.Entity).WriteSpawnData(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1185,6 +1185,7 @@ namespace Barotrauma.Networking
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CLIENT
|
||||
if (characterInfo != null && hostTeam == teamID)
|
||||
{
|
||||
myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false);
|
||||
@@ -1192,10 +1193,10 @@ namespace Barotrauma.Networking
|
||||
myCharacter.TeamID = (byte)teamID;
|
||||
|
||||
Character.Controlled = myCharacter;
|
||||
#if CLIENT
|
||||
|
||||
GameMain.GameSession.CrewManager.characters.Add(myCharacter);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1247,7 +1248,7 @@ namespace Barotrauma.Networking
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
GameMain.GameScreen.Select();
|
||||
|
||||
AddChatMessage("Press TAB to chat. Use ''r;'' to talk through the radio.", ChatMessageType.Server);
|
||||
AddChatMessage("Press TAB to chat. Use \"r;\" to talk through the radio.", ChatMessageType.Server);
|
||||
|
||||
GameMain.NetLobbyScreen.StartButtonEnabled = true;
|
||||
|
||||
@@ -1336,12 +1337,13 @@ namespace Barotrauma.Networking
|
||||
if (SaveServerLogs) log.Save();
|
||||
|
||||
Character.Controlled = null;
|
||||
myCharacter = null;
|
||||
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
#if CLIENT
|
||||
myCharacter = null;
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
#endif
|
||||
|
||||
|
||||
entityEventManager.Clear();
|
||||
foreach (Client c in connectedClients)
|
||||
{
|
||||
|
||||
@@ -64,6 +64,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
public bool Sent;
|
||||
|
||||
public string StackTrace;
|
||||
|
||||
private double createTime;
|
||||
public double CreateTime
|
||||
{
|
||||
@@ -76,6 +78,8 @@ namespace Barotrauma.Networking
|
||||
serializable = entity;
|
||||
|
||||
createTime = Timing.TotalTime;
|
||||
|
||||
StackTrace = Environment.StackTrace.ToString();
|
||||
}
|
||||
|
||||
public void Write(NetBuffer msg, Client recipient)
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to read event for entity \"" + bufferedEvent.TargetEntity.ToString() + "!", e);
|
||||
DebugConsole.ThrowError("Failed to read event for entity \"" + bufferedEvent.TargetEntity.ToString() + "\"!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +232,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
msg.Write(client.UnreceivedEntityEventCount);
|
||||
msg.Write(client.FirstNewEventID);
|
||||
//DebugConsole.NewMessage(eventsToSync[0].ID.ToString(), Microsoft.Xna.Framework.Color.Yellow);
|
||||
Write(msg, eventsToSync, client);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -90,27 +90,12 @@ namespace Barotrauma.Networking
|
||||
|
||||
protected bool gameStarted;
|
||||
|
||||
protected Character myCharacter;
|
||||
protected CharacterInfo characterInfo;
|
||||
|
||||
public Dictionary<string, bool> monsterEnabled;
|
||||
|
||||
protected RespawnManager respawnManager;
|
||||
|
||||
public Voting Voting;
|
||||
|
||||
public Character Character
|
||||
{
|
||||
get { return myCharacter; }
|
||||
set { myCharacter = value; }
|
||||
}
|
||||
|
||||
public CharacterInfo CharacterInfo
|
||||
{
|
||||
get { return characterInfo; }
|
||||
set { characterInfo = value; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
|
||||
@@ -437,20 +437,24 @@ namespace Barotrauma.Networking
|
||||
var character = Character.Create(characterInfos[i], shuttleSpawnPoints[i].WorldPosition, !myCharacter, false);
|
||||
|
||||
character.TeamID = 1;
|
||||
|
||||
|
||||
#if CLIENT
|
||||
if (myCharacter)
|
||||
{
|
||||
server.Character = character;
|
||||
Character.Controlled = character;
|
||||
#if CLIENT
|
||||
|
||||
GameMain.LightManager.LosEnabled = true;
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
clients[i].Character = character;
|
||||
#if CLIENT
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Vector2 pos = cargoSp == null ? character.Position : cargoSp.Position;
|
||||
|
||||
if (divingSuitPrefab != null && oxyPrefab != null)
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Barotrauma
|
||||
private static void Assert(RandSync sync)
|
||||
{
|
||||
//TODO: REMOVE AFTER FINDING ALL WRONG RNG USAGE
|
||||
#if CLIENT
|
||||
#if false
|
||||
string trace = Environment.StackTrace.ToString();
|
||||
if (sync != RandSync.Server) return;
|
||||
if (trace.ToLower().Contains("barotraumaclient\\source")) DebugConsole.NewMessage("WARNING: Client code using RandSync.Server\n"+trace,Color.Yellow);
|
||||
|
||||
Reference in New Issue
Block a user