Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cmptextEx() #2200

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Content.Tests/DMProject/Tests/Builtins/cmptext.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

/proc/RunTest()
ASSERT(cmptext("Test", "test", "tEsT"))
ASSERT(!cmptext("foo", "bar"))
ASSERT(cmptextEx("hello world", "hello world"))
ASSERT(!cmptextEx("Hello World", "hello world"))
2 changes: 0 additions & 2 deletions DMCompiler/DMStandard/UnsortedAdditions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
set opendream_unimplemented = TRUE
/proc/bounds_dist(Ref, Target)
set opendream_unimplemented = TRUE
/proc/cmptextEx(T1)
set opendream_unimplemented = TRUE

// An undocumented proc
// Doesn't evaluate DM as you might expect, but instead DMScript
Expand Down
1 change: 1 addition & 0 deletions DMCompiler/DMStandard/_Standard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ proc/ckey(Key) as text|null
proc/ckeyEx(Text) as text|null
proc/clamp(Value, Low, High) as /list|num|null
proc/cmptext(T1) as num
proc/cmptextEx(T1) as num
proc/copytext(T, Start = 1, End = 0) as text|null
proc/copytext_char(T,Start=1,End=0) as text|null
proc/CRASH(msg) as null
Expand Down
1 change: 1 addition & 0 deletions OpenDreamRuntime/Procs/Native/DreamProcNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static void SetupNativeProcs(DreamObjectTree objectTree) {
objectTree.SetGlobalNativeProc(DreamProcNativeRoot.NativeProc_ckeyEx);
objectTree.SetGlobalNativeProc(DreamProcNativeRoot.NativeProc_clamp);
objectTree.SetGlobalNativeProc(DreamProcNativeRoot.NativeProc_cmptext);
objectTree.SetGlobalNativeProc(DreamProcNativeRoot.NativeProc_cmptextEx);
objectTree.SetGlobalNativeProc(DreamProcNativeRoot.NativeProc_copytext);
objectTree.SetGlobalNativeProc(DreamProcNativeRoot.NativeProc_copytext_char);
objectTree.SetGlobalNativeProc(DreamProcNativeRoot.NativeProc_CRASH);
Expand Down
19 changes: 19 additions & 0 deletions OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,25 @@ public static DreamValue NativeProc_cmptext(NativeProc.Bundle bundle, DreamObjec
return DreamValue.True;
}

[DreamProc("cmptextEx")]
[DreamProcParameter("T1", Type = DreamValueTypeFlag.String)]
public static DreamValue NativeProc_cmptextEx(NativeProc.Bundle bundle, DreamObject? src, DreamObject? usr) {
if (!bundle.GetArgument(0, "T1").TryGetValueAsString(out var t1))
return DreamValue.False;

for (int i = 1; i < bundle.Arguments.Length; i++) {
var arg = bundle.Arguments[i];

if (!arg.TryGetValueAsString(out var t2))
return DreamValue.False;

if (!t2.Equals(t1, StringComparison.InvariantCulture))
return DreamValue.False;
}

return DreamValue.True;
}

[DreamProc("copytext")]
[DreamProcParameter("T", Type = DreamValueTypeFlag.String)]
[DreamProcParameter("Start", Type = DreamValueTypeFlag.Float, DefaultValue = 1)]
Expand Down
Loading