Skip to content

Commit

Permalink
Unit test some world vars against bad const folding, fix `world.sys…
Browse files Browse the repository at this point in the history
…tem_type` (#2096)

Co-authored-by: ike709 <[email protected]>
Co-authored-by: wixoa <[email protected]>
  • Loading branch information
3 people authored Nov 16, 2024
1 parent 970b6a9 commit 9e1a9e6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

/proc/RunTest()
ASSERT(isnum(world.opendream_topic_port))
3 changes: 3 additions & 0 deletions Content.Tests/DMProject/Tests/Builtins/world_system_type.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

/proc/RunTest()
ASSERT(istext(world.system_type) && length(world.system_type))
4 changes: 2 additions & 2 deletions DMCompiler/DMStandard/Defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
#define SYNC_STEPS 3

//world.system_type
#define UNIX 0
#define MS_WINDOWS 1
#define UNIX "UNIX"
#define MS_WINDOWS "MS_WINDOWS"

//Icon blending functions
#define ICON_ADD 0
Expand Down
4 changes: 2 additions & 2 deletions OpenDreamRuntime/Objects/Types/DreamObjectWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ protected override bool TryGetVar(string varName, out DreamValue value) {
case "system_type":
//system_type value should match the defines in Defines.dm
if (Environment.OSVersion.Platform is PlatformID.Unix or PlatformID.MacOSX or PlatformID.Other)
value = new DreamValue(0);
value = new DreamValue("UNIX");
else
value = new DreamValue(1); //Windows
value = new DreamValue("MS_WINDOWS"); //Windows

return true;

Expand Down

0 comments on commit 9e1a9e6

Please sign in to comment.