Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into remove_obsolete_e…
Browse files Browse the repository at this point in the history
…rror_uses

# Conflicts:
#	DMCompiler/DM/Builders/DMProcBuilder.cs
  • Loading branch information
wixoaGit committed Feb 14, 2024
2 parents c0b9b51 + 1627499 commit e12116b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
5 changes: 0 additions & 5 deletions DMCompiler/DM/Builders/DMProcBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,13 @@ public void ProcessStatementSet(DMASTProcStatementSet statementSet) {
switch (statementSet.Value) {
case DMASTIdentifier {Identifier: "usr"}:
proc.VerbSrc = statementSet.WasInKeyword ? VerbSrc.InUsr : VerbSrc.Usr;
if (statementSet.WasInKeyword)
DMCompiler.UnimplementedWarning(statementSet.Location,
"'set src = usr.contents' is unimplemented");
break;
case DMASTDereference {Expression: DMASTIdentifier{Identifier: "usr"}, Operations: var operations}:
if (operations is not [DMASTDereference.FieldOperation {Identifier: var deref}])
goto default;

if (deref == "contents") {
proc.VerbSrc = VerbSrc.InUsr;
DMCompiler.UnimplementedWarning(statementSet.Location,
"'set src = usr.contents' is unimplemented");
} else if (deref == "loc") {
proc.VerbSrc = VerbSrc.UsrLoc;
DMCompiler.UnimplementedWarning(statementSet.Location,
Expand Down
11 changes: 8 additions & 3 deletions OpenDreamClient/ClientVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using OpenDreamClient.Rendering;
using OpenDreamShared.Dream;
using OpenDreamShared.Rendering;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Asynchronous;
Expand All @@ -17,6 +18,7 @@ public sealed class ClientVerbSystem : VerbSystem {
[Dependency] private readonly ITaskManager _taskManager = default!;
[Dependency] private readonly ITimerManager _timerManager = default!;
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;

private EntityQuery<DMISpriteComponent> _spriteQuery;
private EntityQuery<DreamMobSightComponent> _sightQuery;
Expand Down Expand Up @@ -72,12 +74,10 @@ public IEnumerable<VerbInfo> GetAllVerbs() {
/// <param name="ignoreHiddenAttr">Whether to ignore "set hidden = TRUE"</param>
/// <returns>The ID, src, and information of every executable verb</returns>
public IEnumerable<(int Id, ClientObjectReference Src, VerbInfo VerbInfo)> GetExecutableVerbs(bool ignoreHiddenAttr = false) {
ClientObjectReference? ourMob = null;
sbyte? seeInvisibility = null;
if (_playerManager.LocalEntity != null) {
_sightQuery.TryGetComponent(_playerManager.LocalEntity.Value, out var mobSight);

ourMob = new ClientObjectReference(_entityManager.GetNetEntity(_playerManager.LocalEntity.Value));
seeInvisibility = mobSight?.SeeInvisibility;
}

Expand Down Expand Up @@ -112,7 +112,12 @@ public IEnumerable<VerbInfo> GetAllVerbs() {
// Check the verb's "set src" allows us to execute this
switch (verb.Accessibility) {
case VerbAccessibility.Usr:
if (!src.Equals(ourMob))
if (entity != _playerManager.LocalEntity)
continue;

break;
case VerbAccessibility.InUsr:
if (_transformSystem.GetParentUid(entity) != _playerManager.LocalEntity)
continue;

break;
Expand Down
1 change: 1 addition & 0 deletions OpenDreamRuntime/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public override void Init() {

_configManager.OverrideDefault(CVars.NetLogLateMsg, false); // Disable since disabling prediction causes timing errors otherwise.
_configManager.OverrideDefault(CVars.GameAutoPauseEmpty, false); // TODO: world.sleep_offline can control this
_configManager.OverrideDefault(CVars.DiscordRichPresenceSecondIconId, "opendream");
_configManager.SetCVar(CVars.GridSplitting, false); // Grid splitting should never be used
if(String.IsNullOrEmpty(_configManager.GetCVar<string>(OpenDreamCVars.JsonPath))) //if you haven't set the jsonpath cvar, set it to the first valid file path passed as an arg
foreach (string arg in Environment.GetCommandLineArgs().Skip(1)) //skip the first element, because it's just the server's exe path
Expand Down
8 changes: 4 additions & 4 deletions OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace OpenDreamRuntime.Objects.Types;
public class DreamObjectMovable : DreamObjectAtom {
public EntityUid Entity;
public readonly DMISpriteComponent SpriteComponent;
public DreamObjectAtom? Loc;

// TODO: Cache this shit. GetWorldPosition is slow.
public Vector2i Position => (Vector2i?)TransformSystem?.GetWorldPosition(_transformComponent) ?? (0, 0);
Expand All @@ -18,7 +19,6 @@ public class DreamObjectMovable : DreamObjectAtom {

private readonly TransformComponent _transformComponent;

private DreamObjectAtom? _loc;

private string? ScreenLoc {
get => _screenLoc;
Expand Down Expand Up @@ -75,7 +75,7 @@ protected override bool TryGetVar(string varName, out DreamValue value) {
value = new(Z);
return true;
case "loc":
value = new(_loc);
value = new(Loc);
return true;
case "screen_loc":
value = (ScreenLoc != null) ? new(ScreenLoc) : DreamValue.Null;
Expand All @@ -97,7 +97,7 @@ protected override bool TryGetVar(string varName, out DreamValue value) {
case "locs":
// Unimplemented; just return a list containing src.loc
DreamList locs = ObjectTree.CreateList();
locs.AddValue(new(_loc));
locs.AddValue(new(Loc));

value = new DreamValue(locs);
return true;
Expand Down Expand Up @@ -152,7 +152,7 @@ protected override void SetVar(string varName, DreamValue value) {
}

private void SetLoc(DreamObjectAtom? loc) {
_loc = loc;
Loc = loc;
if (TransformSystem == null)
return;

Expand Down
5 changes: 5 additions & 0 deletions OpenDreamRuntime/ServerVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ private bool CanExecute(DreamConnection connection, DreamObject src, DreamProc v
switch (verbInfo.Accessibility) {
case VerbAccessibility.Usr:
return src == connection.Mob;
case VerbAccessibility.InUsr:
if (src is not DreamObjectMovable srcMovable)
return false;

return srcMovable.Loc == connection.Mob;
default:
// TODO: All the other kinds
return true;
Expand Down

0 comments on commit e12116b

Please sign in to comment.