Skip to content

Commit

Permalink
Merge branch 'master' into organize_ast
Browse files Browse the repository at this point in the history
# Conflicts:
#	DMCompiler/Compiler/DM/DMAST.cs
#	DMCompiler/DM/Visitors/DMASTSimplifier.cs
  • Loading branch information
wixoaGit committed Feb 12, 2024
2 parents 2482807 + ca4f0b8 commit 66a37b4
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 21 deletions.
5 changes: 5 additions & 0 deletions Content.Tests/DMProject/Tests/Statements/EmptyBlock.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// COMPILE ERROR
#pragma EmptyBlock error

/proc/RunTest()
if (TRUE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma EmptyBlock error

/proc/RunTest()
if (TRUE)
;
7 changes: 7 additions & 0 deletions DMCompiler/Compiler/DM/DMParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public DMASTFile File() {

public DMASTStatement? Statement(bool requireDelimiter = true) {
var loc = Current().Location;

DMASTPath? path = Path();
if (path is null)
return null;
Expand Down Expand Up @@ -619,6 +620,12 @@ public DMASTFile File() {

public DMASTProcStatement? ProcStatement() {
var loc = Current().Location;

if (Current().Type == TokenType.DM_Semicolon) { // A lone semicolon creates a "null statement" (like C)
// Note that we do not consume the semicolon here
return new DMASTNullProcStatement(loc);

Check failure on line 626 in DMCompiler/Compiler/DM/DMParser.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'DMASTNullProcStatement' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 626 in DMCompiler/Compiler/DM/DMParser.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'DMASTNullProcStatement' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 626 in DMCompiler/Compiler/DM/DMParser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'DMASTNullProcStatement' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 626 in DMCompiler/Compiler/DM/DMParser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'DMASTNullProcStatement' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 626 in DMCompiler/Compiler/DM/DMParser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'DMASTNullProcStatement' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 626 in DMCompiler/Compiler/DM/DMParser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'DMASTNullProcStatement' could not be found (are you missing a using directive or an assembly reference?)
}

var leadingColon = Check(TokenType.DM_Colon);

DMASTExpression? expression = null;
Expand Down
1 change: 1 addition & 0 deletions DMCompiler/DM/Builders/DMProcBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private void ProcessBlockInner(DMASTProcBlockInner block, bool silenceEmptyBlock

public void ProcessStatement(DMASTProcStatement statement) {
switch (statement) {
case DMASTNullProcStatement: break;

Check failure on line 116 in DMCompiler/DM/Builders/DMProcBuilder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'DMASTNullProcStatement' does not exist in the current context

Check failure on line 116 in DMCompiler/DM/Builders/DMProcBuilder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'DMASTNullProcStatement' does not exist in the current context

Check failure on line 116 in DMCompiler/DM/Builders/DMProcBuilder.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The name 'DMASTNullProcStatement' does not exist in the current context

Check failure on line 116 in DMCompiler/DM/Builders/DMProcBuilder.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The name 'DMASTNullProcStatement' does not exist in the current context

Check failure on line 116 in DMCompiler/DM/Builders/DMProcBuilder.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The name 'DMASTNullProcStatement' does not exist in the current context

Check failure on line 116 in DMCompiler/DM/Builders/DMProcBuilder.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The name 'DMASTNullProcStatement' does not exist in the current context
case DMASTProcStatementExpression statementExpression: ProcessStatementExpression(statementExpression); break;
case DMASTProcStatementContinue statementContinue: ProcessStatementContinue(statementContinue); break;
case DMASTProcStatementGoto statementGoto: ProcessStatementGoto(statementGoto); break;
Expand Down
4 changes: 3 additions & 1 deletion OpenDreamClient/ClientVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ public IEnumerable<VerbInfo> GetAllVerbs() {
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 = _sightQuery.GetComponent(_playerManager.LocalEntity.Value).SeeInvisibility;
seeInvisibility = mobSight?.SeeInvisibility;
}

// First, the verbs attached to our client
Expand Down
7 changes: 7 additions & 0 deletions OpenDreamClient/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public sealed class EntryPoint : GameClient {
[Dependency] private readonly IDreamSoundEngine _soundEngine = default!;
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly ILightManager _lightManager = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;

private const string UserAgent =
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)";
Expand Down Expand Up @@ -76,6 +77,12 @@ public override void PostInit() {

_dreamInterface.Initialize();
IoCManager.Resolve<IDreamSoundEngine>().Initialize();

if (_configurationManager.GetCVar(CVars.DisplayCompat))
_dreamInterface.OpenAlert(
"Compatibility Mode Warning",
"You are using compatibility mode. Clicking in-game objects is not supported in this mode.",
"Ok", null, null, null);
}

protected override void Dispose(bool disposing) {
Expand Down
1 change: 1 addition & 0 deletions OpenDreamClient/Interface/DreamInterfaceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ public interface IDreamInterfaceManager {
void SaveScreenshot(bool openDialog);
void LoadInterfaceFromSource(string source);

public void OpenAlert(string title, string message, string button1, string? button2, string? button3, Action<DreamValueType, object?>? onClose);
void Prompt(DreamValueType types, string title, string message, string defaultValue, Action<DreamValueType, object?>? onClose);
void RunCommand(string fullCommand);
void StartRepeatingCommand(string command);
Expand Down
4 changes: 4 additions & 0 deletions OpenDreamClient/Interface/DummyDreamInterfaceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public void WinSet(string? controlId, string winsetParams) {

}

public void OpenAlert(string title, string message, string button1, string? button2, string? button3, Action<DreamValueType, object?>? onClose) {

}

public void Prompt(DreamValueType types, string title, string message, string defaultValue, Action<DreamValueType, object?>? onClose) {

}
Expand Down
2 changes: 1 addition & 1 deletion Resources/Shaders/alpha.swsl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void fragment() {

// The mask is the average of RGB multiplied by A
// Haven't actually tested this in BYOND, but it does give us behavior seen in SS13
highp float mask = (mask_color.r + mask_color.g + mask_color.b) / 3 * mask_color.a;
highp float mask = (mask_color.r + mask_color.g + mask_color.b) / 3.0 * mask_color.a;

if(mask_invert_flag){
new_color.a *= 1.0-mask;
Expand Down
2 changes: 1 addition & 1 deletion Resources/Shaders/blendoverlay.swsl
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ void fragment() {
oldColor[2] * colorMatrix[3][2] +
oldColor[3] * colorMatrix[3][3];
COLOR = zFromSrgb(COLOR + offsetVector);
COLOR.rgb *= isPlaneMaster ? 1 : COLOR.a;
COLOR.rgb *= isPlaneMaster ? 1.0 : COLOR.a;
}
8 changes: 4 additions & 4 deletions Resources/Shaders/blur.swsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ highp vec4 blur(sampler2D sp, highp vec2 uv, highp vec2 scale) {
highp vec4 col = texture(sp, uv) * weight;
highp float accum = weight;

for (highp int x = 0; x <= size*5; ++x) {
for (highp int y = 1; y <= size*5; ++y) {
for (highp int x = 0; x <= int(size)*5; ++x) {
for (highp int y = 1; y <= int(size)*5; ++y) {
offset = vec2(x, y);
weight = gaussian(offset);
col += texture(sp, uv + scale * offset) * weight;
Expand All @@ -49,8 +49,8 @@ void vertex()
{
VERTEX = apply_mvp(VERTEX);
pos = (VERTEX + vec2(1.0)) / 2.0;
sigma = float(size*5) * 0.25;
sigma2 = 2. * sigma * sigma;
sigma = float(size*5.0) * 0.25;
sigma2 = 2.0 * sigma * sigma;
pisigma2 = pi * sigma2;
}

Expand Down
14 changes: 6 additions & 8 deletions Resources/Shaders/displacement.swsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@ void fragment() {
highp vec2 iResolution = vec2(textureSize(TEXTURE, 0))/2.0; //input texture is doubled in size, but we need the original size
highp vec2 dResolution = vec2(textureSize(displacement_map, 0)); //this one is its original size

vec2 offset = vec2(x,y)/iResolution.xy;
vec2 maxdistortion = size/iResolution.xy;

highp vec2 offset = vec2(x,y)/iResolution.xy;
highp vec2 maxdistortion = size/iResolution.xy;

vec2 subcoord = ((UV * textureSize(TEXTURE, 0)/dResolution) + (0.5 - (textureSize(TEXTURE, 0)/dResolution)/2.0)) + offset;
highp vec2 subcoord = ((UV * vec2(textureSize(TEXTURE, 0))/dResolution) + (0.5 - (vec2(textureSize(TEXTURE, 0))/dResolution)/2.0)) + offset;
//sample the displacement map
vec4 dis = texture(displacement_map, subcoord);
highp vec4 dis = texture(displacement_map, subcoord);
dis.r = (clamp(dis.r, 0.5-maxdistortion.x, 0.5+maxdistortion.x) - 0.5) * dis.a;//center them and apply alpha
dis.g = (clamp(dis.g, 0.5-maxdistortion.y, 0.5+maxdistortion.y) - 0.5) * dis.a;


vec2 dis_coord = vec2(dis.r, -dis.g)/2.0;
highp vec2 dis_coord = vec2(dis.r, -dis.g)/2.0;
// Sample the texture
vec4 col = texture(TEXTURE, UV+dis_coord);
highp vec4 col = texture(TEXTURE, UV+dis_coord);

// Output to screen
COLOR = vec4(col);
Expand Down
12 changes: 6 additions & 6 deletions Resources/Shaders/drop_shadow.swsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ uniform highp float y;
uniform highp vec4 shadow_color;

void fragment() {
highp float shadow_blur_samples = pow(size * 2 + 1, 2);
highp float shadow_blur_samples = pow((size * 2.0 + 1.0), 2.0);
highp vec4 texture_color = zTexture(UV);
highp vec2 ps = TEXTURE_PIXEL_SIZE;
highp vec2 shadow_uv = UV - (ps * vec2(x, -y)); // Y is up

highp float sampled_shadow_alpha = 0;
highp float sampled_shadow_alpha = 0.0;
for (highp float blur_x = -size; blur_x <= size; blur_x++) {
for (highp float blur_y = -size; blur_y <= size; blur_y++) {
vec2 blur_uv = shadow_uv + ps * vec2(blur_x, blur_y);
highp vec2 blur_uv = shadow_uv + ps * vec2(blur_x, blur_y);

sampled_shadow_alpha += zTexture(blur_uv).a / shadow_blur_samples;
}
}

vec4 final_shadow_color = vec4(shadow_color.rgb, shadow_color.a * sampled_shadow_alpha);
highp vec4 final_shadow_color = vec4(shadow_color.rgb, shadow_color.a * sampled_shadow_alpha);

// Mix the shadow with the initial image based on the image's alpha
COLOR.rgb = final_shadow_color.rgb * (1 - texture_color.a) + (texture_color.rgb / texture_color.a); //texture color needs to be divided by alpha to account for alpha premultiplication in the overlay shader
COLOR.a = clamp(final_shadow_color.a + texture_color.a, 0, 1);
COLOR.rgb = final_shadow_color.rgb * (1.0 - texture_color.a) + (texture_color.rgb / texture_color.a); //texture color needs to be divided by alpha to account for alpha premultiplication in the overlay shader
COLOR.a = clamp(final_shadow_color.a + texture_color.a, 0.0, 1.0);
COLOR.rgb *= COLOR.a;
}

0 comments on commit 66a37b4

Please sign in to comment.