Skip to content

Commit

Permalink
Fix ghosting in lobby (SerbiaStrong-220#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
DexlerXD authored Nov 15, 2023
1 parent 7095227 commit 4d3e151
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Content.Server/Administration/Commands/AGhost.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.GameTicking;
using Content.Server.GameTicking;
using Content.Server.Hands.Systems;
using Content.Shared.Administration;
using Content.Shared.GameTicking;
using Content.Shared.Ghost;
using Content.Shared.Hands.Components;
using Content.Shared.Mind;
Expand Down Expand Up @@ -35,6 +36,15 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

//SS220-lobby-ghost-bug begin
var gameTicker = _entities.System<GameTicker>();
if (!gameTicker.PlayerGameStatuses.TryGetValue(player.UserId, out var status) || status is not PlayerGameStatus.JoinedGame)
{
shell.WriteLine("You can't ghost right now. You're not in game!");
return;
}
//SS220-lobby-ghost-bug end

var metaDataSystem = _entities.System<MetaDataSystem>();

if (mind.VisitingEntity != default && _entities.TryGetComponent<GhostComponent>(mind.VisitingEntity, out var oldGhostComponent))
Expand Down
10 changes: 10 additions & 0 deletions Content.Server/GameTicking/GameTicker.GamePreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Database;
using Content.Shared.GameTicking;
using Content.Shared.Ghost;
using Content.Shared.Mind;
using Content.Shared.Mobs.Components;
Expand Down Expand Up @@ -198,6 +199,15 @@ public bool OnGhostAttempt(EntityUid mindId, bool canReturnGlobal, bool viaComma
if (!Resolve(mindId, ref mind))
return false;

//SS220-lobby-ghost-bug begin
var player = mind.Session;
if (player is null)
return false;

if (!PlayerGameStatuses.TryGetValue(player.UserId, out var status) || status is not PlayerGameStatus.JoinedGame)
return false;
//SS220-lobby-ghost-bug end

var playerEntity = mind.CurrentEntity;

if (playerEntity != null && viaCommand)
Expand Down

0 comments on commit 4d3e151

Please sign in to comment.