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

Add visibility to DMAPI #1682

Merged
merged 2 commits into from
Oct 22, 2023
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
2 changes: 1 addition & 1 deletion build/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<TgsCommonLibraryVersion>7.0.0</TgsCommonLibraryVersion>
<TgsApiLibraryVersion>11.1.2</TgsApiLibraryVersion>
<TgsClientVersion>13.0.0</TgsClientVersion>
<TgsDmapiVersion>6.5.4</TgsDmapiVersion>
<TgsDmapiVersion>6.6.0</TgsDmapiVersion>
<TgsInteropVersion>5.6.2</TgsInteropVersion>
<TgsHostWatchdogVersion>1.4.0</TgsHostWatchdogVersion>
<TgsContainerScriptVersion>1.2.1</TgsContainerScriptVersion>
Expand Down
13 changes: 12 additions & 1 deletion src/DMAPI/tgs.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// tgstation-server DMAPI

#define TGS_DMAPI_VERSION "6.5.4"
#define TGS_DMAPI_VERSION "6.6.0"

// All functions and datums outside this document are subject to change with any version and should not be relied on.

Expand Down Expand Up @@ -129,6 +129,13 @@
/// DreamDaemon Ultrasafe security level.
#define TGS_SECURITY_ULTRASAFE 2

/// DreamDaemon public visibility level.
#define TGS_VISIBILITY_PUBLIC 0
/// DreamDaemon private visibility level.
#define TGS_VISIBILITY_PRIVATE 1
/// DreamDaemon invisible visibility level.
#define TGS_VISIBILITY_INVISIBLE 2

//REQUIRED HOOKS

/**
Expand Down Expand Up @@ -458,6 +465,10 @@
/world/proc/TgsSecurityLevel()
return

/// Returns the current BYOND visibility level as a TGS_VISIBILITY_ define if TGS is present, null otherwise. Requires TGS to be using interop API version 5 or higher otherwise the string "___unimplemented" wil be returned. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
/world/proc/TgsVisibility()
return

/// Returns a list of active [/datum/tgs_revision_information/test_merge]s if TGS is present, null otherwise. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
/world/proc/TgsTestMerges()
return
Expand Down
5 changes: 5 additions & 0 deletions src/DMAPI/tgs/core/core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,8 @@
var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs)
if(api)
return api.SecurityLevel()

/world/TgsVisibility()
var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs)
if(api)
return api.Visibility()
3 changes: 3 additions & 0 deletions src/DMAPI/tgs/core/datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ TGS_PROTECT_DATUM(/datum/tgs_api)

/datum/tgs_api/proc/SecurityLevel()
return TGS_UNIMPLEMENTED

/datum/tgs_api/proc/Visibility()
return TGS_UNIMPLEMENTED
1 change: 1 addition & 0 deletions src/DMAPI/tgs/v5/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#define DMAPI5_RUNTIME_INFORMATION_REVISION "revision"
#define DMAPI5_RUNTIME_INFORMATION_TEST_MERGES "testMerges"
#define DMAPI5_RUNTIME_INFORMATION_SECURITY_LEVEL "securityLevel"
#define DMAPI5_RUNTIME_INFORMATION_VISIBILITY "visibility"

#define DMAPI5_CHAT_UPDATE_CHANNELS "channels"

Expand Down
6 changes: 6 additions & 0 deletions src/DMAPI/tgs/v5/api.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

var/instance_name
var/security_level
var/visibility

var/reboot_mode = TGS_REBOOT_MODE_NORMAL

Expand Down Expand Up @@ -54,6 +55,7 @@

version = new /datum/tgs_version(runtime_information[DMAPI5_RUNTIME_INFORMATION_SERVER_VERSION])
security_level = runtime_information[DMAPI5_RUNTIME_INFORMATION_SECURITY_LEVEL]
visibility = runtime_information[DMAPI5_RUNTIME_INFORMATION_VISIBILITY]
instance_name = runtime_information[DMAPI5_RUNTIME_INFORMATION_INSTANCE_NAME]

var/list/revisionData = runtime_information[DMAPI5_RUNTIME_INFORMATION_REVISION]
Expand Down Expand Up @@ -252,3 +254,7 @@
/datum/tgs_api/v5/SecurityLevel()
RequireInitialBridgeResponse()
return security_level

/datum/tgs_api/v5/Visibility()
RequireInitialBridgeResponse()
return visibility
1 change: 1 addition & 0 deletions src/DMAPI/tgs/v5/undefs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#undef DMAPI5_RUNTIME_INFORMATION_REVISION
#undef DMAPI5_RUNTIME_INFORMATION_TEST_MERGES
#undef DMAPI5_RUNTIME_INFORMATION_SECURITY_LEVEL
#undef DMAPI5_RUNTIME_INFORMATION_VISIBILITY

#undef DMAPI5_CHAT_UPDATE_CHANNELS

Expand Down
6 changes: 6 additions & 0 deletions tests/DMAPI/LongRunning/Test.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

log << "Running in security level: [sec]"

var/vis = TgsVisibility()
if(isnull(vis))
FailTest("TGS Visibility was null!")

log << "Running in visibility: [vis]"

if(params["expect_chat_channels"])
var/list/channels = TgsChatChannelInfo()
if(!length(channels))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ await configurationClient.Write(new ConfigurationFileRequest
await configurationClient.CreateDirectory(staticDir, cancellationToken);
}

public Task SetupDMApiTests(bool includingRoot, CancellationToken cancellationToken)
public ValueTask SetupDMApiTests(bool includingRoot, CancellationToken cancellationToken)
{
// just use an I/O manager here
var ioManager = new DefaultIOManager();
Expand All @@ -110,7 +110,7 @@ public Task SetupDMApiTests(bool includingRoot, CancellationToken cancellationTo
"../../../../DMAPI/LongRunning/long_running_test_rooted.dme",
ioManager.ConcatPath(instance.Path, "Repository", "long_running_test_rooted.dme"),
cancellationToken)
: Task.CompletedTask,
: ValueTask.CompletedTask,
ioManager.CopyDirectory(
Enumerable.Empty<string>(),
null,
Expand Down Expand Up @@ -182,9 +182,8 @@ async Task SequencedApiTests(CancellationToken cancellationToken)
}

public Task RunPreWatchdog(CancellationToken cancellationToken) => Task.WhenAll(
SetupDMApiTests(false, cancellationToken),
SetupDMApiTests(false, cancellationToken).AsTask(),
SequencedApiTests(cancellationToken),
SetupDMApiTests(cancellationToken),
TestPregeneratedFilesExist(cancellationToken));
}
}