Skip to content

Commit

Permalink
Merge branch 'master' into fix-ascii2text
Browse files Browse the repository at this point in the history
  • Loading branch information
amylizzle authored Feb 9, 2024
2 parents 5b228c1 + 5666fa3 commit f2ce028
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ jobs:
dirtyLabel: "Merge Conflict"
repoToken: "${{ secrets.GITHUB_TOKEN }}"
commentOnDirty: "This pull request has conflicts, please resolve those before we can evaluate the pull request."
- name: Apply Size Label
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

2 changes: 1 addition & 1 deletion .github/workflows/test-tgs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
OD_DOTNET_VERSION: 8
TGS_DOTNET_VERSION: 8
TGS_REFERENCE: dev
TGS_TEST_GITHUB_TOKEN: ${{ secrets.TGS_TEST_GITHUB_TOKEN }}
TGS_TEST_GITHUB_TOKEN: ${{ github.token }}

jobs:
build:
Expand Down
6 changes: 6 additions & 0 deletions Content.Tests/DMProject/Tests/Builtins/isnull.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/proc/RunTest()
ASSERT(isnull(null))
var/obj/O = new()
ASSERT(!isnull(O))
del(O)
ASSERT(isnull(O))
10 changes: 10 additions & 0 deletions Content.Tests/DMProject/Tests/Procs/doublebracketlistarg.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/proc/have_fun(ways_to_have_fun[] = list("dancing", "jumping around", "sightseeing"))
return ways_to_have_fun[2]

/proc/emptylistproc(emptylist[] = null)
return emptylist

/proc/RunTest()
ASSERT(have_fun() == "jumping around")
ASSERT(have_fun(list("eating cake", "spinning")) == "spinning")
ASSERT(isnull(emptylistproc()))
3 changes: 2 additions & 1 deletion Content.Tests/DMProject/Tests/Text/num2text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@

// Zero/Negative MinDigits
ASSERT(num2text(1, 0, 10) == "1")
ASSERT(num2text(1, -1, 10) == "1")
ASSERT(num2text(1, -1, 10) == "1")
ASSERT(num2text(0, 0, 16) == "0")
15 changes: 11 additions & 4 deletions DMCompiler/Compiler/DM/DMAST.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,10 +1324,17 @@ public override void Visit(DMASTVisitor visitor) {
}

public bool AllValuesConstant() {
return Values.All(value => value is {
Key: DMASTExpressionConstant,
Value: DMASTExpressionConstant
});
return Values.All(
value => (value is {
Key: DMASTExpressionConstant,
Value: DMASTExpressionConstant
})
||
(value is {
Key: DMASTExpressionConstant,
Value: DMASTList valueList
} && valueList.AllValuesConstant())
);
}
}

Expand Down
5 changes: 5 additions & 0 deletions DMCompiler/Compiler/DM/DMParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,11 @@ public List<DMASTDefinitionParameter> DefinitionParameters(out bool wasIndetermi
DMASTExpression? value = PathArray(ref path.Path);
DMASTExpression? possibleValues = null;

if (Check(TokenType.DM_DoubleSquareBracketEquals)) {
Whitespace();
value = Expression();
}

if (Check(TokenType.DM_Equals)) {
Whitespace();
value = Expression();
Expand Down
7 changes: 5 additions & 2 deletions OpenDreamClient/Interface/DreamInterfaceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ public void FrameUpdate(FrameEventArgs frameEventArgs) {
} else if (Menus.TryGetValue(windowId, out var menu)) {
if (menu.MenuElements.TryGetValue(elementId, out var menuElement))
return menuElement;
} else if(MacroSets.TryGetValue(windowId, out var macroSet)) {
if (macroSet.Macros.TryGetValue(elementId, out var macroElement))
return macroElement;
}

if (window != null) {
Expand Down Expand Up @@ -436,7 +439,7 @@ public void RunCommand(string fullCommand) {
return;

if (args.Length == 1) { // No args given; Let the verb system handle the possible prompting
verbSystem.ExecuteVerb(ClientObjectReference.Client, verbId);
verbSystem.ExecuteVerb(verbSrc, verbId);
} else { // Attempt to parse the given arguments
if (args.Length != verbInfo.Arguments.Length + 1) {
_sawmill.Error(
Expand Down Expand Up @@ -464,7 +467,7 @@ public void RunCommand(string fullCommand) {
}
}

verbSystem.ExecuteVerb(ClientObjectReference.Client, verbId, arguments);
verbSystem.ExecuteVerb(verbSrc, verbId, arguments);
}

break;
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamRuntime/DreamValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public DreamValue(IconAppearance appearance) {

public bool IsNull {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => Type == DreamValueType.DreamObject && _refValue == null;
get => Type == DreamValueType.DreamObject && (_refValue == null || Unsafe.As<DreamObject>(_refValue).Deleted);
}

private DreamValue(DreamValueType type, object refValue) {
Expand Down
3 changes: 3 additions & 0 deletions OpenDreamRuntime/Objects/DreamIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public IconResource GenerateDMI() {
if (_cachedDMI != null)
return _cachedDMI;

if(Width == 0 && Height == 0)
Width = Height = 32; //TODO should be world.icon_size

int frameCount = FrameCount;

int frameWidth = Width, frameHeight = Height;
Expand Down
5 changes: 2 additions & 3 deletions OpenDreamRuntime/Procs/DMOpcodeHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,7 @@ public static ProcStatus GetStep(DMProcState state) {
return ProcStatus.Continue;
}

var dir = d.MustGetValueAsInteger();
var dir = d.IsNull ? 0 : d.MustGetValueAsInteger();

state.Push(new(DreamProcNativeHelpers.GetStep(state.Proc.AtomManager, state.Proc.DreamMapManager, loc, (AtomDirection)dir)));
return ProcStatus.Continue;
Expand Down Expand Up @@ -1930,8 +1930,7 @@ public static ProcStatus PickWeighted(DMProcState state) {
DreamValue value = state.Pop();
if (!state.Pop().TryGetValueAsFloat(out var weight))
{
// Breaking change, no clue what weight BYOND is giving to non-nums
throw new Exception($"pick() weight '{weight}' is not a number");
weight = 100;
}

totalWeight += weight;
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ public static DreamValue NativeProc_num2text(NativeProc.Bundle bundle, DreamObje
}

if(bundle.Arguments.Length == 3) {
var digits = Math.Max(bundle.GetArgument(1, "A").MustGetValueAsInteger(), 0);
var digits = Math.Max(bundle.GetArgument(1, "A").MustGetValueAsInteger(), 1);
var radix = bundle.GetArgument(2, "B").MustGetValueAsInteger();
var intNum = (int)floatNum;

Expand Down
2 changes: 1 addition & 1 deletion OpenDreamShared/Dream/VerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public string GetCategoryOrDefault(string defaultCategory) =>

// TODO: Hidden verbs probably shouldn't be sent to the client in the first place?
public bool IsHidden(bool ignoreHiddenAttr, sbyte seeInvisibility) =>
(!ignoreHiddenAttr && HiddenAttribute) || Name.StartsWith('.') || seeInvisibility < Invisibility;
(!ignoreHiddenAttr && (HiddenAttribute || Name.StartsWith('.'))) || seeInvisibility < Invisibility;

public override string ToString() => GetCommandName();
}
Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,29 @@ All parts of OpenDream should work fine on Windows and Linux, though the latter

For more information or if you'd like to contribute, join our [Discord server](https://discord.gg/qreryhZxxs).

A detailed description of differences with BYOND can be found [here](https://github.com/wixoaGit/OpenDream/wiki/Differences-Between-OpenDream-and-BYOND). **Note that OpenDream cannot connect to BYOND servers, and BYOND's client cannot connect to OpenDream servers.** There is no cross-project compatibility other than being able to migrate from BYOND to OpenDream with minimal effort.
A detailed description of differences with BYOND can be found [here](https://github.com/OpenDreamProject/OpenDream/wiki/Differences-Between-OpenDream-and-BYOND). **Note that OpenDream cannot connect to BYOND servers, and BYOND's client cannot connect to OpenDream servers.** There is no cross-project compatibility other than being able to migrate from BYOND to OpenDream with minimal effort.

## Building
## Running

The first step to building OpenDream is initializing the submodule for the game engine, [Robust Toolbox](https://github.com/space-wizards/RobustToolbox).
Binaries are available for download under our [Releases](https://github.com/OpenDreamProject/OpenDream/releases/tag/latest). If you would rather build from source, see [Building](#building).

To do this, simply run `git submodule update --init --recursive` in git bash and let it finish.
There's 3 main parts: Compiler, Server, and Client:

**OpenDream requires .NET 8.** You can check your version by running `dotnet --version`. It should be at least `8.0.0`.
**Compiler:** Run `DMCompiler.exe`, and pass any number of .dm or .dme files to compile as arguments. Optional arguments can be found [here](https://github.com/OpenDreamProject/OpenDream/wiki/Compiler-Options).

To build, one can use a C# compiler (such as MSBuild) to compile the various projects described in the solution.
**Server:** Run `Robust.Server.exe` (`OpenDreamServer.exe` if built from source) and pass the compiled JSON file you got as a result of running the compiler above as an argument like this: `Robust.Server.exe C:/path/to/compiler/output.json`

There's 3 main parts: Compiler, Server, and Client
**Client:** This is only applicable if you built from source, otherwise connect from the [SS14 launcher](https://spacestation14.io/about/nightlies/). Run `OpenDreamClient.exe`. You will be prompted to choose a server address, port, and username. The defaults should work for a locally hosted server.

## Running
## Building

The first step to building OpenDream is initializing the submodule for the game engine, [Robust Toolbox](https://github.com/space-wizards/RobustToolbox).

**Compiler:** Run `DMCompiler.exe`, and pass any number of .dm or .dme files to compile as arguments. Optional arguments can be found [here](https://github.com/wixoaGit/OpenDream/wiki/Compiler-Options).
To do this, simply run `git submodule update --init --recursive` in git bash and let it finish.

**Server:** Run `OpenDreamServer.exe` and pass the compiled JSON file you got as a result of running the compiler above as an argument like this: `OpenDreamServer.exe C:/path/to/compiler/output.json`
**OpenDream requires .NET 8.** You can check your version by running `dotnet --version`. It should be at least `8.0.0`.

**Client:** Run `OpenDreamClient.exe`. You will be prompted to choose a server address, port, and username. The defaults should work for a locally hosted server.
To build, one can use a C# compiler (such as MSBuild) to compile the various projects described in the solution.

## Screenshots
The following screenshots are taken from a version of Paradise Station with a recompiled 64-bit rustg DLL. This branch of Paradise is available [here](https://github.com/ike709/Paradise/tree/rustg_64).
Expand Down

0 comments on commit f2ce028

Please sign in to comment.