Monster syncing fixes:
- clients freeze and disable AI characters if no updates have been received in a while (due to the monster being far away from player-controlled characters at the servers side for example) - server disables AI characters that are too far for updates to be sent to clients (-> targets of monster missions can't swim away from the spawnpos and cause the clients' sonars to point to an incorrect position)
This commit is contained in:
@@ -51,6 +51,22 @@ namespace Barotrauma
|
||||
|
||||
if (Controlled == this || !aiController.Enabled) return;
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
//freeze AI characters if more than 1 seconds have passed since last update from the server
|
||||
if (lastRecvPositionUpdateTime < NetTime.Now - 1.0f)
|
||||
{
|
||||
AnimController.Frozen = true;
|
||||
memPos.Clear();
|
||||
//hide after 2 seconds
|
||||
if (lastRecvPositionUpdateTime < NetTime.Now - 2.0f)
|
||||
{
|
||||
Enabled = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (soundTimer > 0)
|
||||
{
|
||||
soundTimer -= deltaTime;
|
||||
@@ -149,11 +165,12 @@ namespace Barotrauma
|
||||
public override bool ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime, out object data)
|
||||
{
|
||||
data = null;
|
||||
Enabled = true;
|
||||
|
||||
//server doesn't accept AICharacter updates from the clients
|
||||
if (GameMain.Server != null) return false;
|
||||
|
||||
Enabled = true;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case NetworkEventType.KillCharacter:
|
||||
@@ -198,6 +215,13 @@ namespace Barotrauma
|
||||
case NetworkEventType.EntityUpdate:
|
||||
if (sendingTime <= LastNetworkUpdate) return false;
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
lastRecvPositionUpdateTime = (float)NetTime.Now;
|
||||
AnimController.Frozen = false;
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
bool playerControlled = message.ReadBoolean();
|
||||
if (playerControlled)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user