From 2882b3e143e38e196ce5f505d6ed802fbe1c7d23 Mon Sep 17 00:00:00 2001 From: saurtron Date: Fri, 20 Dec 2024 03:05:58 +0100 Subject: [PATCH 01/21] Fix typo hasVBO -> hasFBO. (#4044) --- common/platformFunctions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/platformFunctions.lua b/common/platformFunctions.lua index 58a2e7d5e9..07c3de43d8 100644 --- a/common/platformFunctions.lua +++ b/common/platformFunctions.lua @@ -35,7 +35,7 @@ local function checkRequires(allRequires) return false elseif req == 'shaders' and not hasShaders then return false - elseif req == 'fbo' and not hasVBO then + elseif req == 'fbo' and not hasFBO then return false end end From e4648fb9f721e2dfafd000df4acf23b1c434fa40 Mon Sep 17 00:00:00 2001 From: saurtron Date: Fri, 20 Dec 2024 03:22:56 +0100 Subject: [PATCH 02/21] Add missing Test.expectCallin to test_wait test example. (#4046) --- luaui/Widgets/TestsExamples/test_utilities/test_wait.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/luaui/Widgets/TestsExamples/test_utilities/test_wait.lua b/luaui/Widgets/TestsExamples/test_utilities/test_wait.lua index c01fb82b6b..78140bea0c 100644 --- a/luaui/Widgets/TestsExamples/test_utilities/test_wait.lua +++ b/luaui/Widgets/TestsExamples/test_utilities/test_wait.lua @@ -1,5 +1,6 @@ function setup() Test.clearMap() + Test.expectCallin("UnitCreated") end function cleanup() From 09fca80f495bd9d0227880241ab245707eea090f Mon Sep 17 00:00:00 2001 From: saurtron Date: Fri, 20 Dec 2024 14:25:00 +0100 Subject: [PATCH 03/21] Fix shutdown from cmd_extractor_snap when WG.DrawUnitShapeGL4 not available. (#4047) Fix shutdown from cmd_extractor_snap when WG.DrawUnitShapeGL4 not available. --- luaui/Widgets/cmd_extractor_snap.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/luaui/Widgets/cmd_extractor_snap.lua b/luaui/Widgets/cmd_extractor_snap.lua index 7e982dd9df..852c0064d5 100644 --- a/luaui/Widgets/cmd_extractor_snap.lua +++ b/luaui/Widgets/cmd_extractor_snap.lua @@ -323,5 +323,8 @@ end function widget:Shutdown() + if not WG.DrawUnitShapeGL4 then + return + end clear() end From 8aeb54ed9290f460c3cf4f91935a058e72a2c462 Mon Sep 17 00:00:00 2001 From: WatchTheFort <36827423+WatchTheFort@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:10:38 -0500 Subject: [PATCH 04/21] Revert "Tweaks and improvement to declutter defense-ranges" (#4049) Revert "Tweaks and improvement to declutter defense-ranges (#3732)" This reverts commit 00678b76f9a06f1daf84d8b7483cbd044cbf7756. --- .../Shaders/attack_range_gl4.vert.glsl | 19 +- .../weapon_range_rings_unified_gl4.frag.glsl | 39 -- .../weapon_range_rings_unified_gl4.vert.glsl | 457 ------------------ luaui/Widgets/gui_anti_ranges.lua | 2 +- luaui/Widgets/gui_attackrange_gl4.lua | 227 ++++----- luaui/Widgets/gui_defenserange.lua | 2 +- luaui/Widgets/gui_defenserange_gl4.lua | 417 ++++++++++++---- units/ArmBots/T2/armaak.lua | 3 - units/ArmBuildings/LandUtil/armmine1.lua | 5 +- units/ArmBuildings/LandUtil/armmine2.lua | 1 - units/ArmBuildings/LandUtil/armmine3.lua | 1 - units/ArmBuildings/SeaUtil/armfmine3.lua | 1 - units/ArmGantry/armthor.lua | 3 - units/ArmShips/T2/armbats.lua | 3 - units/ArmShips/T2/armepoch.lua | 12 - units/ArmShips/T2/armlship.lua | 1 - units/ArmShips/T2/armmship.lua | 1 - units/ArmShips/armpship.lua | 4 - units/CorAircraft/T2/corcrwh.lua | 6 - units/CorBots/T2/coraak.lua | 12 - units/CorBuildings/LandUtil/cormine1.lua | 1 - units/CorBuildings/LandUtil/cormine2.lua | 1 - units/CorBuildings/LandUtil/cormine3.lua | 1 - units/CorBuildings/SeaUtil/corfmine3.lua | 1 - units/CorGantry/corjugg.lua | 6 - units/CorGantry/corkorg.lua | 1 - units/CorShips/T2/corbats.lua | 3 - units/CorShips/T2/corblackhy.lua | 7 - units/CorShips/T2/cormship.lua | 1 - units/Legion/Air/T2 Air/legfort.lua | 6 - units/Legion/Air/T2 Air/legheavydrone.lua | 3 - units/Legion/Air/T2 Air/legionnaire.lua | 3 - units/Legion/Air/T2 Air/legvenator.lua | 3 - units/Legion/Air/legdrone.lua | 3 - units/Legion/Defenses/legbombard.lua | 1 - units/Legion/Ships/leghastatus.lua | 3 - units/Legion/Ships/leghastatusalt.lua | 3 - units/Legion/Ships/legportent.lua | 3 - units/Legion/T3/legpede.lua | 3 - 39 files changed, 403 insertions(+), 866 deletions(-) delete mode 100644 luaui/Widgets/Shaders/weapon_range_rings_unified_gl4.frag.glsl delete mode 100644 luaui/Widgets/Shaders/weapon_range_rings_unified_gl4.vert.glsl diff --git a/luaui/Widgets/Shaders/attack_range_gl4.vert.glsl b/luaui/Widgets/Shaders/attack_range_gl4.vert.glsl index 1929ba2976..1b84b8f84a 100644 --- a/luaui/Widgets/Shaders/attack_range_gl4.vert.glsl +++ b/luaui/Widgets/Shaders/attack_range_gl4.vert.glsl @@ -19,8 +19,6 @@ uniform float lineAlphaUniform = 1.0; uniform float cannonmode = 0.0; uniform float fadeDistOffset = 0.0; uniform float drawMode = 0.0; -uniform float inMiniMap = 0.0; - uniform sampler2D heightmapTex; uniform sampler2D losTex; // hmm maybe? @@ -145,7 +143,7 @@ void main() { // rotate the circle into unit space, wierd that it has to be rotated on other direction float maxAngleDif = 1; float mainDirDegrees = 0; - if (MAXANGLEDIF > 0.0) { + if (MAXANGLEDIF != 0) { maxAngleDif = fract(MAXANGLEDIF);// goes from 0.0 to 1.0, where 0.25 would mean a 90 deg cone mainDirDegrees = MAXANGLEDIF - maxAngleDif;// Is the offset in degrees. } @@ -251,22 +249,14 @@ void main() { //--- DISTANCE FADE --- vec4 camPos = cameraViewInv[3]; - - // Note that this is not the same as the distance from the unit to the camera, but the distance from the circle to the camera float distToCam = length(modelWorldPos.xyz - camPos.xyz); //dist from cam // FadeStart, FadeEnd, StartAlpha, EndAlpha float fadeDist = visibility.y - visibility.x; - if (ISDGUN > 0.5) { FADEALPHA = clamp((visibility.y + fadeDistOffset + 1000 - distToCam)/(fadeDist),visibility.w,visibility.z); } else { FADEALPHA = clamp((visibility.y + fadeDistOffset - distToCam)/(fadeDist),visibility.w,visibility.z); } - - if (inMiniMap> 0.5){ - FADEALPHA = 1.0; - } - //FADEALPHA = clamp((visibility.y + fadeDistOffset - distToCam)/(fadeDist),visibility.w,visibility.z); //--- Optimize by anything faded out getting transformed back to origin with 0 range? @@ -307,12 +297,7 @@ void main() { //worldPos = circleWorldPos; //worldPos.a = RANGE; alphaControl.x = circlepointposition.z; // save circle progress here - - if (inMiniMap < 0.5) { - gl_Position = cameraViewProj * vec4(circleWorldPos.xyz, 1.0); - } else { - gl_Position = mmDrawViewProj * vec4(circleWorldPos.xyz, 1.0); - } + gl_Position = cameraViewProj * vec4(circleWorldPos.xyz, 1.0); //lets blend the alpha here, and save work in FS: float outalpha = OUTOFBOUNDSALPHA * (MOUSEALPHA + FADEALPHA * lineAlphaUniform); diff --git a/luaui/Widgets/Shaders/weapon_range_rings_unified_gl4.frag.glsl b/luaui/Widgets/Shaders/weapon_range_rings_unified_gl4.frag.glsl deleted file mode 100644 index 167f29d969..0000000000 --- a/luaui/Widgets/Shaders/weapon_range_rings_unified_gl4.frag.glsl +++ /dev/null @@ -1,39 +0,0 @@ -#version 330 - -#extension GL_ARB_uniform_buffer_object : require -#extension GL_ARB_shading_language_420pack: require -// This shader is (c) Beherith (mysterme@gmail.com), released under the MIT license - -//__DEFINES__ - -#line 20000 - -uniform float selUnitCount = 1.0; -uniform float selBuilderCount = 1.0; -uniform float drawAlpha = 1.0; -uniform float drawMode = 0.0; - -//_ENGINEUNIFORMBUFFERDEFS__ - -in DataVS { - flat vec4 v_blendedcolor; -}; - -out vec4 fragColor; - -void main() { - - fragColor = v_blendedcolor; - // For testing: - #if (DEBUG == 1) - if (fract(gl_FragCoord.x * 0.125) < 0.4) { - #if (STATICUNITS == 0) - fragColor.rgba *= 0.0; - #endif - }else{ - #if(STATICUNITS == 1) - fragColor.rgba *= 0.0; - #endif - } - #endif -} \ No newline at end of file diff --git a/luaui/Widgets/Shaders/weapon_range_rings_unified_gl4.vert.glsl b/luaui/Widgets/Shaders/weapon_range_rings_unified_gl4.vert.glsl deleted file mode 100644 index d526f6f01b..0000000000 --- a/luaui/Widgets/Shaders/weapon_range_rings_unified_gl4.vert.glsl +++ /dev/null @@ -1,457 +0,0 @@ - -#version 420 -#extension GL_ARB_uniform_buffer_object : require -#extension GL_ARB_shader_storage_buffer_object : require -#extension GL_ARB_shading_language_420pack: require -// This shader is (c) Beherith (mysterme@gmail.com), released under the MIT license -#line 10000 - -//__DEFINES__ - -layout (location = 0) in vec4 circlepointposition; // x,y in range [-1,1], progress in range [0,1] -layout (location = 1) in vec4 posscale; // abs pos for static units, offset for dynamic units, scale is actual range, Y is turretheight -layout (location = 2) in vec4 color1; // Base color for the circle -layout (location = 3) in vec4 visibility; // FadeStart, FadeEnd, StartAlpha, EndAlpha -layout (location = 4) in vec4 projectileParams; // projectileSpeed, iscylinder!!!! , heightBoostFactor , heightMod -layout (location = 5) in vec4 additionalParams; // groupselectionfadescale, weaponType, ISDGUN, MAXANGLEDIF -layout (location = 6) in uvec4 instData; - -uniform float lineAlphaUniform = 1.0; -uniform float cannonmode = 0.0; -uniform float fadeDistOffset = 0.0; -uniform float inMiniMap = 0.0; - - -uniform float selUnitCount = 1.0; -uniform float selBuilderCount = 1.0; -uniform float drawAlpha = 1.0; -uniform float drawMode = 0.0; - - -uniform sampler2D heightmapTex; -uniform sampler2D losTex; // hmm maybe? -uniform sampler2D mapNormalTex; // hmm maybe? - -// Ease-of-use defines for the vertex shader outputs -#define V_CIRCLEPROGRESS v_params.x -#define V_GROUPSELECTIONFADESCALE v_params.y -#define V_WEAPONTYPE v_params.z - -out DataVS { - flat vec4 v_blendedcolor; -}; - -//__ENGINEUNIFORMBUFFERDEFS__ - -#if (STATICUNITS == 0) - struct SUniformsBuffer { - uint composite; // u8 drawFlag; u8 unused1; u16 id; - - uint unused2; - uint unused3; - uint unused4; - - float maxHealth; - float health; - float unused5; - float unused6; - - vec4 drawPos; // Note that this is map height at unit.xz - vec4 speed; - vec4[4] userDefined; //can't use float[16] because float in arrays occupies 4 * float space - }; - - layout(std140, binding=1) readonly buffer UniformsBuffer { - SUniformsBuffer uni[]; - }; - - #define UNITID (uni[instData.y].composite >> 16) -#endif - -#line 11000 - -vec2 inverseMapSize = 1.0 / mapSize.xy; - -float heightAtWorldPos(vec2 w){ - // Some texel magic to make the heightmap tex perfectly align: - const vec2 heightmaptexel = vec2(8.0, 8.0); - w += vec2(-8.0, -8.0) * (w * inverseMapSize) + vec2(4.0, 4.0) ; - - vec2 uvhm = clamp(w, heightmaptexel, mapSize.xy - heightmaptexel); - uvhm = uvhm * inverseMapSize; - - return texture(heightmapTex, uvhm, 0.0).x; -} - -vec4 normalsAndHeightAtWorldPos(vec2 w){ - // Some texel magic to make the heightmap tex perfectly align: - // Some texel magic to make the heightmap tex perfectly align: - const vec2 heightmaptexel = vec2(8.0, 8.0); - w += vec2(-8.0, -8.0) * (w * inverseMapSize) + vec2(4.0, 4.0) ; - - vec2 uvhm = clamp(w, heightmaptexel, mapSize.xy - heightmaptexel); - uvhm = uvhm * inverseMapSize; - vec4 heightAndNormal = vec4(0.0); - heightAndNormal.w = texture(mapNormalTex, uvhm, 0.0).x; - heightAndNormal.xz = texture(mapNormalTex, uvhm, 0.1).ra; - heightAndNormal.y = 1.0 - sqrt(1.0 - dot(heightAndNormal.xz, heightAndNormal.xz)); - return heightAndNormal; -} - -float GetRangeFactor(float projectileSpeed) { // returns >0 if weapon can shoot here, <0 if it cannot, 0 if just right - // on first run, with yDiff = 0, what do we get? - float speed2d = projectileSpeed * 0.707106; - float gravity = 120.0 * (0.001111111); - return ((speed2d * speed2d) * 2.0 ) / (gravity); -} - -float GetRange2DCannon(float yDiff,float projectileSpeed,float rangeFactor,float heightBoostFactor) { // returns >0 if weapon can shoot here, <0 if it cannot, 0 if just right - // on first run, with yDiff = 0, what do we get? - - //float factor = 0.707106; - float smoothHeight = 100.0; - float speed2d = projectileSpeed*0.707106; - float speed2dSq = speed2d * speed2d; - float gravity = -1.0* (120.0 /900); - - if (heightBoostFactor < 0){ - heightBoostFactor = (2.0 - rangeFactor) / sqrt(rangeFactor); - } - - if (yDiff < -100.0){ - yDiff = yDiff * heightBoostFactor; - }else { - if (yDiff < 0.0) { - yDiff = yDiff * (1.0 + (heightBoostFactor - 1.0 ) * (-1.0 * yDiff) * 0.01); - } - } - - float root1 = speed2dSq + 2 * gravity *yDiff; - if (root1 < 0.0 ){ - return 0.0; - }else{ - return rangeFactor * ( speed2dSq + speed2d * sqrt( root1 ) ) / (-1.0 * gravity); - } -} - -vec2 rotate2D(vec2 v, float a) { - float s = sin(a); - float c = cos(a); - mat2 m = mat2(c, s, -s, c); - return m * v; -} - -//float heightMod  default: 0.2 (0.8 for #Cannon, 1.0 for #BeamLaser and #LightningCannon) -//Changes the spherical weapon range into an ellipsoid. Values above 1.0 mean the weapon cannot target as high as it can far, values below 1.0 mean it can target higher than it can far. For example 0.5 would allow the weapon to target twice as high as far. - -//float heightBoostFactor default: -1.0 -//Controls the boost given to range by high terrain. Values > 1.0 result in increased range, 0.0 means the cannon has fixed range regardless of height difference to target. Any value < 0.0 (i.e. the default value) result in an automatically calculated value based on range and theoretical maximum range. - -// Ease of use defines for the vertex shader inputs: -#define RANGE posscale.w -#define TURRETHEIGHT posscale.y - -#define PROJECTILESPEED projectileParams.x -#define ISCYLINDER projectileParams.y -#define HEIGHTBOOSTFACTOR projectileParams.z -#define HEIGHTMOD projectileParams.w - -#define GROUPSELECTIONFADESCALE additionalParams.x -#define WEAPONTYPE additionalParams.y -#define ISDGUN additionalParams.z -#define MAXANGLEDIF additionalParams.w - -#define FADESTART visibility.x -#define FADEEND visibility.y -#define STARTALPHA visibility.z -#define ENDALPHA visibility.w - -#define UNUSEDALPHA alphaControl.x -#define OUTOFBOUNDSALPHA alphaControl.y -#define FADEALPHA alphaControl.z -#define MOUSEALPHA alphaControl.w - -#define SELECTEDNESS uni[instData.y].userDefined[1].z - -bool isSphereVisible(vec3 position, float radius) -{ - vec4 planes[6]; - mat4 m = cameraViewProj; - - // Extract the frustum planes from the combined view-projection matrix - planes[0] = m[3] + m[0]; // Left plane - planes[1] = m[3] - m[0]; // Right plane - planes[2] = m[3] + m[1]; // Bottom plane - planes[3] = m[3] - m[1]; // Top plane - planes[4] = m[3] + m[2]; // Near plane - planes[5] = m[3] - m[2]; // Far plane - - // Normalize the plane equations - for(int i = 0; i < 6; i++) - { - float length = length(planes[i].xyz); - planes[i] /= length; - } - - // Check if the sphere is outside any of the frustum planes - for(int i = 0; i < 6; i++) - { - float distance = dot(planes[i].xyz, position) + planes[i].w; - if(distance < -radius) - return false; // Sphere is completely outside this plane - } - - return true; // Sphere is at least partially inside the frustum -} - -void main() { - vec4 circleWorldPos = vec4(1.0); - vec3 modelWorldPos = vec3(0.0); - float maxAngleDif = 1; - float mainDirDegrees = 0; - vec4 circleprogress = vec4(0.0); - #if (STATICUNITS == 1) - modelWorldPos = posscale.xyz; - circleWorldPos.xz = circlepointposition.xy * RANGE + posscale.xz; - #else - // Get the center pos of the unit - modelWorldPos = uni[instData.y].drawPos.xyz; - - // The turret is a bit higher up than drawPos.y (which is the ground pos) - modelWorldPos.y += TURRETHEIGHT; - - // Get its heading - float unitHeading = uni[instData.y].drawPos.w ; - - circleprogress.xy = circlepointposition.xy; - // find angle between unit Heading and circleprogress.xy - //unitHeading is -pi to +pi, with zero on z+, and increasing towards x+ - //circleheading is -pi to +pi, with zero z-, and increasing towards x+ - - // rotate the circle into unit space, wierd that it has to be rotated on other direction - if (MAXANGLEDIF > 0.0) { - maxAngleDif = fract(MAXANGLEDIF);// goes from 0.0 to 1.0, where 0.25 would mean a 90 deg cone - mainDirDegrees = MAXANGLEDIF - maxAngleDif;// Is the offset in degrees. - } - circleprogress.xy = rotate2D(circleprogress.xy, (3.141592 -1.0*unitHeading + mainDirDegrees * 3.141592 / 180.0)); - if (ISDGUN > 0.5) { - circleWorldPos.xz = circleprogress.xy * RANGE * 1.05 + modelWorldPos.xz; - } else { - circleWorldPos.xz = circleprogress.xy * RANGE + modelWorldPos.xz; - } - #endif - - - - circleprogress.w = circlepointposition.z; - v_blendedcolor = color1; - - #if (STATICUNITS == 1) - //gl_Position = cameraViewProj * vec4(circleWorldPos.xyz, 1.0); return; - #endif - - vec4 alphaControl = vec4(1.0); - - // get heightmap - circleWorldPos.y = heightAtWorldPos(circleWorldPos.xz); - - - if (cannonmode > 0.5){ - - // BAR only has 3 distinct ballistic projectiles, heightBoostFactor is only a handful from -1 to 2.8 and 6 and 8 - // gravity we can assume to be linear - - float heightDiff = (circleWorldPos.y - modelWorldPos.y) * 0.5; - - float rangeFactor = RANGE / GetRangeFactor(PROJECTILESPEED); //correct - if (rangeFactor > 1.0 ) rangeFactor = 1.0; - if (rangeFactor <= 0.0 ) rangeFactor = 1.0; - float radius = RANGE;// - heightDiff; - float adjRadius = GetRange2DCannon(heightDiff * HEIGHTMOD, PROJECTILESPEED, rangeFactor, HEIGHTBOOSTFACTOR); - float adjustment = radius * 0.5; - float yDiff = 0; - float adds = 0; - //for (int i = 0; i < mod(timeInfo.x/8,16); i ++){ //i am a debugging god - for (int i = 0; i < 16; i ++){ - if (adjRadius > radius){ - radius = radius + adjustment; - adds = adds + 1; - }else{ - radius = radius - adjustment; - adds = adds - 1; - } - adjustment = adjustment * 0.5; - circleWorldPos.xz = circleprogress.xy * radius + modelWorldPos.xz; - float newY = heightAtWorldPos(circleWorldPos.xz ); - yDiff = abs(circleWorldPos.y - newY); - circleWorldPos.y = max(0, newY); - heightDiff = circleWorldPos.y - modelWorldPos.y; - adjRadius = GetRange2DCannon(heightDiff * HEIGHTMOD, PROJECTILESPEED, rangeFactor, HEIGHTBOOSTFACTOR); - } - }else{ - if (ISCYLINDER < 0.5){ // isCylinder - //simple implementation, 4 samples per point - //for (int i = 0; i -20) { // for submerged units, try to keep the ranges above the water for clarity - modelWorldPos.y = max(1, modelWorldPos.y); - circleWorldPos.y = max(1, circleWorldPos.y); - } - - - - // -- HANDLE MAXANGLEDIFF - // If the unit cant fire in that direction due to maxanglediff constraints, then put the point back to modelWorldPos - // Also, dont - // convert current circleprogress to relative heading: - float relheadingradians = abs(((circleprogress.w - 0.5)) * 2); - if (MAXANGLEDIF != 0.0) { - if(relheadingradians > maxAngleDif){ - circleWorldPos.xyz = modelWorldPos.xyz; - } - OUTOFBOUNDSALPHA = 1.0; - } - - circleWorldPos.y += 4; // lift it from the ground - - - //--- DISTANCE FADE --- - vec4 camPos = cameraViewInv[3]; - - // Note that this is not the same as the distance from the unit to the camera, but the distance from the circle to the camera - float distToCam = length(modelWorldPos.xyz - camPos.xyz) ; //dist from cam - // FadeStart, FadeEnd, StartAlpha, EndAlpha - float fadeDist = FADEEND - FADESTART; - - // TODO VALIDATE - if (ISDGUN > 0.5) { - FADEALPHA = clamp((FADEEND + fadeDistOffset + 1000 - distToCam)/(fadeDist), ENDALPHA, STARTALPHA); - } else { - FADEALPHA = clamp((FADEEND + fadeDistOffset - distToCam)/(fadeDist), ENDALPHA, STARTALPHA); - } - // -- IN-SHADER MOUSE-POS BASED HIGHLIGHTING - float disttomousefromunit = 1.0 - smoothstep(48, 64, length(modelWorldPos.xz - mouseWorldPos.xz)); - // this will be positive if in mouse, negative else - float highlightme = clamp( (disttomousefromunit ) + 0.0, 0.0, 1.0); - // Note that this doesnt really work well with boundary-only stenciling, due to random draw order. - MOUSEALPHA = (0.1 + 0.5 * step(0.5,drawMode)) * highlightme; - - - if (inMiniMap> 0.5){ - // No extra fade control when on the minimap - FADEALPHA = 1.0; - }else{ - // TODO if the sphere were to be completely faded out, dont draw it at all: - if (highlightme < 0.0 ){ - if (FADESTART < FADEEND) { - // Rings that fade out on distance - if ((distToCam + RANGE) > FADEEND) { - FADEALPHA = 0.0; - circleWorldPos.xz = modelWorldPos.xz; - } - }else { - // Rings that fade out when close to the camera - // TODO ANTINUKES! - if ((distToCam - RANGE) < FADEEND) { - FADEALPHA = 0.0; - //circleWorldPos.xz = modelWorldPos.xz; - } - } - - //--- Optimize by anything faded out getting transformed back to origin with 0 range? - //seems pretty ok! - - //if a sphere at modelworldpos.xyz, with range poscale.w is out of the viewport, set visible to false: - if (isSphereVisibleXY(vec4(modelWorldPos.xyz, 1.0), posscale.w * 3.0 )){ - //circleWorldPos.xz = modelWorldPos.xz; - } - } - } - - //FADEALPHA = clamp((FADEEND + fadeDistOffset - distToCam)/(fadeDist), ENDALPHA, STARTALPHA); - - - if (cannonmode > 0.5){ - // cannons should fade distance based on their range - //float cvmin = max(FADESTART + fadeDistOffset, 2* RANGE); - //float cvmax = max(FADEEND + fadeDistOffset, 4* RANGE); - //FADEALPHA = clamp((cvmin - distToCam)/(cvmax - cvmin + 1.0),STARTALPHA , ENDALPHA); - } - - v_blendedcolor = color1; - - // -- DARKEN OUT OF LOS - //vec4 losTexSample = texture(losTex, vec2(circleWorldPos.x / mapSize.z, circleWorldPos.z / mapSize.w)); // lostex is PO2 - //float inlos = dot(losTexSample.rgb,vec3(0.33)); - //inlos = clamp(inlos*5 -1.4 , 0.5,1.0); // fuck if i know why, but change this if LOSCOLORS are changed! - //v_blendedcolor.rgb *= inlos; - - // --- YES FOG - float fogDist = length((cameraView * vec4(circleWorldPos.xyz,1.0)).xyz); - float fogFactor = clamp((fogParams.y - fogDist) * fogParams.w, 0, 1); - v_blendedcolor.rgb = mix(fogColor.rgb, vec3(v_blendedcolor), fogFactor); - - - - - - // ------------ dump the stuff for FS -------------------- - //V_CIRCLEPROGRESS = circlepointposition.z; // save circle progress here - - - if (inMiniMap < 0.5) { - gl_Position = cameraViewProj * vec4(circleWorldPos.xyz, 1.0); - //pull 16 elmos forward in Z: - gl_Position.z = (gl_Position.z) - 128.0 / (gl_Position.w); // send 16 elmos forward in Z - } else { - gl_Position = mmDrawViewProj * vec4(circleWorldPos.xyz, 1.0); - } - - //lets blend the alpha here, and save work in FS: - float outalpha = OUTOFBOUNDSALPHA * (MOUSEALPHA + FADEALPHA * lineAlphaUniform); - v_blendedcolor.a *= outalpha ; - if (ISDGUN > 0.5) { - v_blendedcolor.a = clamp(v_blendedcolor.a * 3, 0.1, 1.0); - } - // Additional unituniform based selectedness metrics: - - float vs_selunitcount = selUnitCount; - // -- nano is 2 - if(WEAPONTYPE == 2.0) { - vs_selunitcount = selBuilderCount; - } - vs_selunitcount = clamp(selUnitCount, 1, 25); - - float innerRingDim = GROUPSELECTIONFADESCALE * 0.1 * vs_selunitcount; - float finalAlpha = drawAlpha; - if(drawMode == 2.0) { - finalAlpha = drawAlpha / pow(innerRingDim, 2); - } - finalAlpha = clamp(finalAlpha, 0.0, 1.0); - v_blendedcolor.a *= finalAlpha; - - //vec4 heightAndNormal = normalsAndHeightAtWorldPos(circleWorldPos.xz); - //v_blendedcolor.rgb = heightAndNormal.xyz * 0.5 + 0.5; - //v_blendedcolor.rgb = vec3(fract(distToCam/100)); -} \ No newline at end of file diff --git a/luaui/Widgets/gui_anti_ranges.lua b/luaui/Widgets/gui_anti_ranges.lua index 6c4db033fe..0d45816475 100644 --- a/luaui/Widgets/gui_anti_ranges.lua +++ b/luaui/Widgets/gui_anti_ranges.lua @@ -8,7 +8,7 @@ function widget:GetInfo() license = "GNU GPL, v2 or later", version = 4, layer = 5, - enabled = false + enabled = true } end diff --git a/luaui/Widgets/gui_attackrange_gl4.lua b/luaui/Widgets/gui_attackrange_gl4.lua index 09af4eb245..16600f2cbd 100644 --- a/luaui/Widgets/gui_attackrange_gl4.lua +++ b/luaui/Widgets/gui_attackrange_gl4.lua @@ -16,9 +16,6 @@ function widget:GetInfo() } end -------------------------------------- -local autoReload = false - --------------------------------------------------------------------------------------------------------------------------- -- Bindable action: cursor_range_toggle -- The widget's individual unit type's display setup is saved in LuaUI/config/AttackRangeConfig2.lua @@ -38,7 +35,7 @@ local buttonConfig = { local colorConfig = { drawStencil = true, -- whether to draw the outer, merged rings (quite expensive!) - cannon_separate_stencil = true, -- set to true to have cannon and ground be on different stencil mask + cannon_separate_stencil = false, -- set to true to have cannon and ground be on different stencil mask drawInnerRings = true, -- whether to draw inner, per attack rings (very cheap) externalalpha = 0.80, -- alpha of outer rings @@ -47,54 +44,37 @@ local colorConfig = { outer_fade_height_difference = 2500, -- this is the height difference at which the outer ring starts to fade out compared to inner rings ground = { color = { 1.0, 0.22, 0.05, 0.60 }, - fadeparams = { 1500, 3200, 1.0, 0.0 }, -- FadeStart, FadeEnd, StartAlpha, EndAlpha + fadeparams = { 1500, 2200, 1.0, 0.0 }, -- FadeStart, FadeEnd, StartAlpha, EndAlpha groupselectionfadescale = 0.75, externallinethickness = 3.0, - internallinethickness = 1.8, - minimapexternallinethickness = 1.0, - minimapinternallinethickness = 0.5, + internallinethickness = 2.0, }, nano = { - color = { 0.24, 1.0, 0.2, 0.60 }, + color = { 0.24, 1.0, 0.2, 0.40 }, fadeparams = { 2000, 4000, 1.0, 0.0 }, -- FadeStart, FadeEnd, StartAlpha, EndAlpha groupselectionfadescale = 0.05, externallinethickness = 3.0, internallinethickness = 2.0, - minimapexternallinethickness = 1.0, - minimapinternallinethickness = 0.5, }, AA = { color = { 0.8, 0.44, 2.0, 0.40 }, - fadeparams = { 1500, 3200, 1.0, 0.0 }, -- FadeStart, FadeEnd, StartAlpha, EndAlpha + fadeparams = { 1500, 2200, 1.0, 0.0 }, -- FadeStart, FadeEnd, StartAlpha, EndAlpha groupselectionfadescale = 0.75, - externallinethickness = 3.0, - internallinethickness = 1.8, - minimapexternallinethickness = 1.5, - minimapinternallinethickness = 0.5, + externallinethickness = 2.5, + internallinethickness = 2.0, }, cannon = { - color = {1.0, 0.22, 0.05, 0.60}, - fadeparams = { 1500, 3600, 1.0, 0.0 }, -- FadeStart, FadeEnd, StartAlpha, EndAlpha + color = { 1.0, 0.22, 0.05, 0.60 }, + fadeparams = { 1500, 2200, 1.0, 0.0 }, -- FadeStart, FadeEnd, StartAlpha, EndAlpha groupselectionfadescale = 0.75, externallinethickness = 3.0, internallinethickness = 2.0, - minimapexternallinethickness = 1.0, - minimapinternallinethickness = 0.5, - }, - lrpc = { - color = {1.0, 0.22, 0.05, 0.60}, - fadeparams = { 5000, 1000, 1.0, 0.5 }, -- FadeStart, FadeEnd, StartAlpha, EndAlpha - groupselectionfadescale = 0.75, - externallinethickness = 3.0, - internallinethickness = 2.0, -- Not used as LRPC is not stencilled - minimapexternallinethickness = 2.0, - minimapinternallinethickness = 0.5, }, } ---------------------------------- local show_selected_weapon_ranges = true -local weaponTypeMap = { 'ground', 'nano', 'AA', 'cannon', 'lrpc' } +local weaponTypeMap = { 'ground', 'nano', 'AA', 'cannon' } local unitDefRings = {} --each entry should be a unitdefIDkey to a table: @@ -200,14 +180,11 @@ local function initializeUnitDefRing(unitDefID) local color = colorConfig[weaponTypeMap[weaponType]].color local fadeparams = colorConfig[weaponTypeMap[weaponType]].fadeparams - local isCylinder = 0 - if (weaponDef.cylinderTargeting) and (weaponDef.cylinderTargeting > 0.0) then - isCylinder = 1 - end + local isCylinder = weaponDef.cylinderTargeting and 1 or 0 local isDgun = (weaponDef.type == "DGun") and 1 or 0 local wName = weaponDef.name - if (weaponDef.type == "AircraftBomb") or (wName:find("bogus")) or weaponDef.customParams.bogus then + if (weaponDef.type == "AircraftBomb") or (wName:find("bogus")) then range = 0 end --Spring.Echo("weaponNum: ".. weaponNum ..", name: " .. tableToString(weaponDef.name)) @@ -230,11 +207,7 @@ local function initializeUnitDefRing(unitDefID) -- maindir "0 1 0" is designed for shooting at feet prevention! local maxangledif = 0 - - -- customParams (note the case), is a table of strings always - if (weapons[weaponNum].maxAngleDif > -1) and - (not (weaponDef.customParams and weaponDef.customParams.noattackrangearc)) then - --Spring.Echo(weaponDef.customParams)--, weapons[weaponNum].customParams.noattackarc) + if weapons[weaponNum].maxAngleDif > -1 then local offsetdegrees = 0 local difffract = 0 @@ -264,7 +237,7 @@ local function initializeUnitDefRing(unitDefID) maxangledif = maxangledif + difffract else - end + end @@ -275,18 +248,18 @@ local function initializeUnitDefRing(unitDefID) --for k,v in pairs(weapons[weaponNum]) do Spring.Echo(k,v)end end - --if weapons[weaponNum].maxAngleDif then Spring.Echo(weapons[weaponNum].maxAngleDif,'for',weaponDef.name, 'saved as',maxangledif ) end - - local ringParams = { range, color[1], color[2], color[3], color[4], --5 - fadeparams[1], fadeparams[2], fadeparams[3], fadeparams[4], --9 - weaponDef.projectilespeed or 1, --10 - isCylinder,-- and 1 or 0, (11) - weaponDef.heightBoostFactor or 0, --12 - weaponDef.heightMod or 0, --13 - groupselectionfadescale, --14 - weaponType, --15 - isDgun, --16 - maxangledif --17 + --if weapons[weaponNum].maxAngleDif then Spring.Echo(weapons[weaponNum].maxAngleDif,'for',weaponDef.name ) end + + local ringParams = { range, color[1], color[2], color[3], color[4], + fadeparams[1], fadeparams[2], fadeparams[3], fadeparams[4], + weaponDef.projectilespeed or 1, + isCylinder, + weaponDef.heightBoostFactor or 0, + weaponDef.heightMod or 0, + groupselectionfadescale, + weaponType, + isDgun, + maxangledif } unitDefRings[unitDefID]['rings'][weaponNum] = ringParams end @@ -358,11 +331,6 @@ local GetActiveCommand = Spring.GetActiveCommand local GetSelectedUnits = Spring.GetSelectedUnits local chobbyInterface -local CMD_ATTACK = CMD.ATTACK -local CMD_FIGHT = CMD.FIGHT -local CMD_AREA_ATTACK = CMD.AREA_ATTACK -local CMD_MANUALFIRE = CMD.MANUALFIRE - function widget:TextCommand(command) local mycommand = false --buttonConfig["enemy"][tag] @@ -399,18 +367,18 @@ local largeCircleSegments = 512 local smallCircleVBO = nil local smallCircleSegments = 128 -local weaponTypeToString = { "ground", "nano", "AA", "cannon", 'lrpc' } +local weaponTypeToString = { "ground", "nano", "AA", "cannon", } local allyenemypairs = { "ally", "enemy" } local attackRangeClasses = { 'enemyground', 'enemyAA', 'enemynano', 'allyground', 'allyAA', 'enemycannon', 'allycannon', - 'allynano', 'allylrpc', 'enemylrpc' } + 'allynano' } local attackRangeVAOs = {} local circleInstanceVBOLayout = { - { id = 1, name = 'posscale', size = 4 }, -- abs pos for static units, offset for dynamic units, scale is actual range, Y is turretheight + { id = 1, name = 'posscale', size = 4 }, -- a vec4 for pos + scale { id = 2, name = 'color1', size = 4 }, -- vec4 the color of this new - { id = 3, name = 'visibility', size = 4 }, --- vec4 FadeStart, FadeEnd, StartAlpha, EndAlpha + { id = 3, name = 'visibility', size = 4 }, --- vec4 heightdrawstart, heightdrawend, fadefactorin, fadefactorout { id = 4, name = 'projectileParams', size = 4 }, --- heightboost gradient - { id = 5, name = 'additionalParams', size = 4 }, --- groupselectionfadescale, weaponType, ISDGUN, MAXANGLEDIF + { id = 5, name = 'additionalParams', size = 4 }, --- groupselectionfadescale, +3 additional reserved { id = 6, name = 'instData', size = 4, type = GL.UNSIGNED_INT }, } @@ -421,17 +389,12 @@ local attackRangeShader = nil local shaderSourceCache = { shaderName = 'Attack Range GL4', - vssrcpath = "LuaUI/Widgets/Shaders/weapon_range_rings_unified_gl4.vert.glsl", - fssrcpath = "LuaUI/Widgets/Shaders/weapon_range_rings_unified_gl4.frag.glsl", - shaderConfig = { - MYGRAVITY = Game.gravity + 0.1, - STATICUNITS = 0, - DEBUG = autoReload and 1 or 0, - }, + vssrcpath = "LuaUI/Widgets/Shaders/attack_range_gl4.vert.glsl", + fssrcpath = "LuaUI/Widgets/Shaders/attack_range_gl4.frag.glsl", + shaderConfig = {MYGRAVITY = Game.gravity + 0.1,}, uniformInt = { heightmapTex = 0, losTex = 1, - mapNormalTex = 2, }, uniformFloat = { lineAlphaUniform = 1, @@ -440,7 +403,6 @@ local shaderSourceCache = { drawMode = 0, selBuilderCount = 1.0, selUnitCount = 1.0, - inMiniMap = 0.0, }, } @@ -449,11 +411,38 @@ local function goodbye(reason) widgetHandler:RemoveWidget() end +local function makeCircleVBO(circleSegments) + circleSegments = circleSegments - 1 -- for po2 buffers + local circleVBO = gl.GetVBO(GL.ARRAY_BUFFER, true) + if circleVBO == nil then goodbye("Failed to create circleVBO") end + + local VBOLayout = { + { id = 0, name = "position", size = 4 }, + } + + local VBOData = {} + + for i = 0, circleSegments do -- this is +1 + VBOData[#VBOData + 1] = math.sin(math.pi * 2 * i / circleSegments) -- X + VBOData[#VBOData + 1] = math.cos(math.pi * 2 * i / circleSegments) -- Y + VBOData[#VBOData + 1] = i / circleSegments -- circumference [0-1] + VBOData[#VBOData + 1] = 0 + end + + circleVBO:Define( + circleSegments + 1, + VBOLayout + ) + circleVBO:Upload(VBOData) + return circleVBO +end + local cacheTable = {} for i = 1, 24 do cacheTable[i] = 0 end -- code for selected units start here + local selectedUnits = {} local selUnits = {} local updateSelection = false @@ -496,19 +485,9 @@ local function AddSelectedUnit(unitID, mouseover) if weapon.onlyTargets and weapon.onlyTargets.vtol then entry.weapons[weaponNum] = 3 -- weaponTypeMap[3] is "AA" elseif weaponDef.type == "Cannon" then - if weaponDef.range > 2000 then - entry.weapons[weaponNum] = 5 -- weaponTypeMap[5] is "lrpc" - else - entry.weapons[weaponNum] = 4 -- weaponTypeMap[4] is "cannon" - end - elseif weaponDef.type == "Melee" then - entry.weapons[weaponNum] = 1 -- weaponTypeMap[1] is "ground" + entry.weapons[weaponNum] = 4 -- weaponTypeMap[4] is "cannon" else - if weaponDef.range > 2000 then - entry.weapons[weaponNum] = 5 - else - entry.weapons[weaponNum] = 1 -- weaponTypeMap[1] is "ground" - end + entry.weapons[weaponNum] = 1 -- weaponTypeMap[1] is "ground" end end end @@ -524,7 +503,7 @@ local function AddSelectedUnit(unitID, mouseover) end - + local x, y, z, mpx, mpy, mpz, apx, apy, apz = spGetUnitPosition(unitID, true, true) --for weaponNum = 1, #weapons do local addedRings = 0 @@ -560,25 +539,8 @@ local function AddSelectedUnit(unitID, mouseover) local ringParams = unitDefRings[unitDefID]['rings'][j] if drawIt and ringParams[1] > 0 then - - local weaponID = j - -- TODO: - -- Weapons aim from their WPY positions, but that can change for e.g. popups! - -- This is quite important to pass in as posscale.y! - -- Need to cache weaponID of the respective weapon for this to work - -- also assumes that weapons are centered onto drawpos - local x, y, z, mpx, mpy, mpz, apx, apy, apz = spGetUnitPosition(unitID, true, true) - local wpx, wpy, wpz, wdx, wdy, wdz = Spring.GetUnitWeaponVectors(unitID, weaponID) - --Spring.Echo("unitID", unitID,"weaponID", weaponID, "y", y, "mpy", mpy,"wpy", wpy) - - -- Now this is a truly terrible hack, we cache each unitDefID's max weapon turret height at position 18 in the table - -- so it only goes up with popups - local turretHeight = math.max(ringParams[18] or 0, (wpy or mpy ) - y) - ringParams[18] = turretHeight - - cacheTable[1] = mpx - cacheTable[2] = turretHeight + cacheTable[2] = mpy cacheTable[3] = mpz local vaokey = allystring .. weaponTypeToString[weaponType] @@ -954,7 +916,7 @@ function widget:RecvLuaMsg(msg, playerID) end end -local drawcounts = {} +local drawcounts = {} local cameraHeightFactor = 0 @@ -963,7 +925,6 @@ local function GetCameraHeightFactor() end local groundnukeair = { "ground", "nano", "AA" } -local cannonlrpc = { "cannon", "lrpc" } local function DRAWRINGS(primitiveType, linethickness) if not show_selected_weapon_ranges and not isBuilding then return end local stencilMask @@ -987,39 +948,29 @@ local function DRAWRINGS(primitiveType, linethickness) attackRangeShader:SetUniform("cannonmode", 1) for i, allyState in ipairs(allyenemypairs) do - for j, wt in ipairs(cannonlrpc) do - if linethickness or wt == 'cannon' then - local atkRangeClass = allyState .. wt - local iT = attackRangeVAOs[atkRangeClass] - local stencilOffset = colorConfig.cannon_separate_stencil and 3 or 0 - stencilMask = 2 ^ (4 * (i - 1) + stencilOffset) -- if 0 then it's on the same as "ground" - drawcounts[stencilMask] = iT.usedElements - if iT.usedElements > 0 then - if linethickness then - glLineWidth(colorConfig[wt][linethickness] * cameraHeightFactor) - end - glStencilMask(stencilMask) - glStencilFunc(GL_NOTEQUAL, stencilMask, stencilMask) - iT.VAO:DrawArrays(primitiveType, iT.numVertices, 0, iT.usedElements, 0) -- +1!!! - end + local atkRangeClass = allyState .. "cannon" + local iT = attackRangeVAOs[atkRangeClass] + local stencilOffset = colorConfig.cannon_separate_stencil and 3 or 0 + stencilMask = 2 ^ (4 * (i - 1) + stencilOffset) -- if 0 then it's on the same as "ground" + drawcounts[stencilMask] = iT.usedElements + if iT.usedElements > 0 then + if linethickness then + glLineWidth(colorConfig['cannon'][linethickness] * cameraHeightFactor) end + glStencilMask(stencilMask) + glStencilFunc(GL_NOTEQUAL, stencilMask, stencilMask) + iT.VAO:DrawArrays(primitiveType, iT.numVertices, 0, iT.usedElements, 0) -- +1!!! end end end -function widget:DrawWorld(inMiniMap) - - if autoReload then - attackRangeShader = LuaShader.CheckShaderUpdates(shaderSourceCache) or attackRangeShader - end - +function widget:DrawWorldPreUnit() if chobbyInterface then return end if not Spring.IsGUIHidden() and (not WG['topbar'] or not WG['topbar'].showingQuit()) then cameraHeightFactor = GetCameraHeightFactor() * 0.5 + 0.5 glTexture(0, "$heightmap") glTexture(1, "$info") - glTexture(2, '$normals') - + -- Stencil Setup -- -- https://learnopengl.com/Advanced-OpenGL/Stencil-testing if colorConfig.drawStencil then @@ -1030,18 +981,17 @@ function widget:DrawWorld(inMiniMap) glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE) -- Set The Stencil Buffer To 1 Where Draw Any Polygon attackRangeShader:Activate() - + attackRangeShader:SetUniform("selUnitCount", selUnitCount) attackRangeShader:SetUniform("selBuilderCount", selBuilderCount) attackRangeShader:SetUniform("drawMode", 0.0) - attackRangeShader:SetUniform("inMiniMap", inMiniMap and 1.0 or 0.0) attackRangeShader:SetUniform("drawAlpha", colorConfig.fill_alpha) attackRangeShader:SetUniform("fadeDistOffset", colorConfig.outer_fade_height_difference) DRAWRINGS(GL_TRIANGLE_FAN) -- FILL THE CIRCLES glLineWidth(math.max(0.1, 4 + math.sin(gameFrame * 0.04) * 10)) glColorMask(true, true, true, true) -- re-enable color drawing - glStencilMask(0) + glStencilMask(0) attackRangeShader:SetUniform("lineAlphaUniform", colorConfig.externalalpha) @@ -1049,20 +999,20 @@ function widget:DrawWorld(inMiniMap) attackRangeShader:SetUniform("drawMode", 1.0) attackRangeShader:SetUniform("drawAlpha", 1.0) - DRAWRINGS(GL_LINE_LOOP, inMiniMap and 'minimapexternallinethickness' or 'externallinethickness') -- DRAW THE OUTER RINGS + DRAWRINGS(GL_LINE_LOOP, 'externallinethickness') -- DRAW THE OUTER RINGS -- This is the correct way to exit out of the stencil mode, to not break drawing of area commands: glStencilTest(false) glStencilMask(255) glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP) glClear(GL_STENCIL_BUFFER_BIT) - -- All the above are needed :() - end + -- All the above are needed :( + end if colorConfig.drawInnerRings then attackRangeShader:SetUniform("lineAlphaUniform", colorConfig.internalalpha) attackRangeShader:SetUniform("drawMode", 2.0) attackRangeShader:SetUniform("fadeDistOffset", 0) - DRAWRINGS(GL_LINE_LOOP, inMiniMap and 'minimapinternallinethickness' or 'internallinethickness') -- DRAW THE INNER RINGS + DRAWRINGS(GL_LINE_LOOP, 'internallinethickness') -- DRAW THE INNER RINGS end attackRangeShader:Deactivate() @@ -1073,13 +1023,6 @@ function widget:DrawWorld(inMiniMap) end end -function widget:DrawInMiniMap() - -- TODO: - -- do a sanity check and dont draw here if there are too many units selected... - widget:DrawWorld(true) -end - - -- Need to add all the callins for handling unit creation/destruction/gift of builders --[[ diff --git a/luaui/Widgets/gui_defenserange.lua b/luaui/Widgets/gui_defenserange.lua index 12f2d17d88..cb54f1c4bc 100644 --- a/luaui/Widgets/gui_defenserange.lua +++ b/luaui/Widgets/gui_defenserange.lua @@ -10,7 +10,7 @@ function widget:GetInfo() date = "October 21, 2007", license = "GNU GPL v2", layer = -100, - enabled = false + enabled = true } end diff --git a/luaui/Widgets/gui_defenserange_gl4.lua b/luaui/Widgets/gui_defenserange_gl4.lua index 3cfa2cc3e8..956f832be4 100644 --- a/luaui/Widgets/gui_defenserange_gl4.lua +++ b/luaui/Widgets/gui_defenserange_gl4.lua @@ -8,7 +8,7 @@ function widget:GetInfo() date = "2021.04.26", license = "Lua: GPLv2, GLSL: (c) Beherith (mysterme@gmail.com)", layer = -100, - enabled = true + enabled = false } end @@ -66,40 +66,40 @@ end local enabledAsSpec = true local buttonConfig = { - ally = { ground = false, air = false, nuke = true }, + ally = { ground = true, air = true, nuke = true }, enemy = { ground = true, air = true, nuke = true } } local colorConfig = { --An array of R, G, B, Alpha drawStencil = true, -- wether to draw the outer, merged rings (quite expensive!) drawInnerRings = true, -- wether to draw inner, per defense rings (very cheap) - externalalpha = 0.7, -- alpha of outer rings - internalalpha = 0.17, -- alpha of inner rings + externalalpha = 0.70, -- alpha of outer rings + internalalpha = 0.0, -- alpha of inner rings distanceScaleStart = 2000, -- Linewidth is 100% up to this camera height - distanceScaleEnd = 8000, -- Linewidth becomes 50% above this camera height + distanceScaleEnd = 4000, -- Linewidth becomes 50% above this camera height ground = { - color = {1.3, 0.18, 0.04, 0.74}, - fadeparams = { 2200, 5500, 1.0, 0.0}, -- FadeStart, FadeEnd, StartAlpha, EndAlpha - externallinethickness = 6.0, + color = {1.0, 0.2, 0.0, 1.0}, + fadeparams = { 2000, 5000, 1.0, 0.0}, -- FadeStart, FadeEnd, StartAlpha, EndAlpha + externallinethickness = 4.0, internallinethickness = 2.0, }, air = { - color = {0.8, 0.44, 1.6, 0.70}, - fadeparams = { 3200, 8000, 0.4, 0.0}, -- FadeStart, FadeEnd, StartAlpha, EndAlpha + color = {0.90, 0.45, 1.2, 1.0}, + fadeparams = { 2000, 5000, 0.4, 0.0}, -- FadeStart, FadeEnd, StartAlpha, EndAlpha externallinethickness = 4.0, internallinethickness = 2.0, }, nuke = { - color = {1.2, 1.0, 0.3, 0.8}, - fadeparams = {6000, 3000, 0.6, 0.0}, -- FadeStart, FadeEnd, StartAlpha, EndAlpha + color = {0.7, 0.8, 1.0, 1.0}, + fadeparams = {5000, 4000, 0.6, 0.0}, -- FadeStart, FadeEnd, StartAlpha, EndAlpha externallinethickness = 4.0, - internallinethickness = 1.0, + internallinethickness = 2.0, }, cannon = { - color = {1.3, 0.18, 0.04, 0.5}, - fadeparams = {7000, 6000, 0.8, 0.0}, -- FadeStart, FadeEnd, StartAlpha, EndAlpha - externallinethickness = 10.0, - internallinethickness = 1.0, + color = {1.0, 0.6, 0.0, 1.0}, + fadeparams = {3000, 6000, 0.8, 0.0}, -- FadeStart, FadeEnd, StartAlpha, EndAlpha + externallinethickness = 4.0, + internallinethickness = 2.0, }, } @@ -192,7 +192,7 @@ local function initUnitList() ['armllt'] = { weapons = { 1 } }, ['armbeamer'] = { weapons = { 1 } }, ['armhlt'] = { weapons = { 1 } }, - ['armguard'] = { weapons = { 1 } }, --4 + ['armguard'] = { weapons = { 4} }, ['armrl'] = { weapons = { 2 } }, --light aa ['armferret'] = { weapons = { 2 } }, ['armcir'] = { weapons = { 2 } }, --chainsaw @@ -204,16 +204,16 @@ local function initUnitList() ['armfflak'] = { weapons = { 2 } }, --floating flak AA ['armatl'] = { weapons = { 1 } }, --adv torpedo launcher - ['armamb'] = { weapons = { 1 } }, --ambusher 4 - ['armpb'] = { weapons = { 1 } }, --pitbull 4 + ['armamb'] = { weapons = { 4 } }, --ambusher + ['armpb'] = { weapons = { 4 } }, --pitbull ['armanni'] = { weapons = { 1 } }, ['armflak'] = { weapons = { 2 } }, ['armmercury'] = { weapons = { 2 } }, ['armemp'] = { weapons = { 1 } }, ['armamd'] = { weapons = { 3 } }, --antinuke - ['armbrtha'] = { weapons = { 4 } }, - ['armvulc'] = { weapons = { 4 } }, + ['armbrtha'] = { weapons = { 4 } }, + ['armvulc'] = { weapons = { 4 } }, -- CORTEX ['cormaw'] = { weapons = { 1 } }, @@ -222,7 +222,7 @@ local function initUnitList() ['corllt'] = { weapons = { 1 } }, ['corhllt'] = { weapons = { 1 } }, ['corhlt'] = { weapons = { 1 } }, - ['corpun'] = { weapons = { 1} }, --4 + ['corpun'] = { weapons = { 4} }, ['corrl'] = { weapons = { 2 } }, ['cormadsam'] = { weapons = { 2 } }, ['corerad'] = { weapons = { 2 } }, @@ -235,15 +235,15 @@ local function initUnitList() ['corfrt'] = { weapons = { 2 } }, --floating rocket laucher ['corenaa'] = { weapons = { 2 } }, --floating flak AA - ['cortoast'] = { weapons = { 1 } }, --4 + ['cortoast'] = { weapons = { 4 } }, ['corvipe'] = { weapons = { 1 } }, ['cordoom'] = { weapons = { 1, 1, 1} }, ['corflak'] = { weapons = { 2 } }, ['corscreamer'] = { weapons = { 2 } }, - ['cortron'] = { weapons = { 4 } }, + ['cortron'] = { weapons = { 1 } }, ['corfmd'] = { weapons = { 3 } }, - ['corint'] = { weapons = { 4 } }, - ['corbuzz'] = { weapons = { 4 } }, + ['corint'] = { weapons = { 4 } }, + ['corbuzz'] = { weapons = { 4 } }, ['armscab'] = { weapons = { 3 } }, ['armcarry'] = { weapons = { 3 } }, @@ -254,20 +254,7 @@ local function initUnitList() -- LEGION ['legabm'] = { weapons = { 3 } }, --antinuke - ['legrampart'] = { weapons = { 3, 1 } }, --rampart - ['legacluster'] = { weapons = { 1 } }, --T2 arty - ['leghive'] = { weapons = { 1 } }, --Drone-defense - ['legmg'] = { weapons = { 1 } }, --ground-AA MG defense - ['legbombard'] = { weapons = { 1 } }, --Grenadier defense - ['legbastion'] = { weapons = { 1 } }, --T2 Heatray Tower - ['legrl'] = { weapons = { 2 } }, --T1 AA - ['leglupara'] = { weapons = { 2 } }, --T1.5 AA - ['legrhapsis'] = { weapons = { 2 } }, --T1.5 AA - ['legflak'] = { weapons = { 2 } }, --T2 AA FLAK - ['leglraa'] = { weapons = { 2 } }, --T2 LR-AA - ['legperdition'] = { weapons = { 4 } }, --T2 LR-AA - ['legstarfall'] = { weapons = { 4 } }, - ['leglrpc'] = { weapons = { 4 } }, + ['legrampart'] = { weapons = { 3 } }, --rampart -- SCAVENGERS ['scavbeacon_t1_scav'] = { weapons = { 1 } }, @@ -397,10 +384,6 @@ function widget:TextCommand(command) end ------ GL4 THINGS ----- ---- - -local autoReload = false - -- nukes and cannons: local largeCircleVBO = nil local largeCircleSegments = 512 @@ -415,12 +398,10 @@ local defenseRangeClasses = {'enemyair','enemyground','enemynuke','allyair','all local defenseRangeVAOs = {} local circleInstanceVBOLayout = { - {id = 1, name = 'posscale', size = 4}, -- abs pos for static units, offset for dynamic units, scale is actual range, Y is turretheight + {id = 1, name = 'posscale', size = 4}, -- a vec4 for pos + scale {id = 2, name = 'color1', size = 4}, -- vec4 the color of this new - {id = 3, name = 'visibility', size = 4}, --- vec4 FadeStart, FadeEnd, StartAlpha, EndAlpha + {id = 3, name = 'visibility', size = 4}, --- vec4 heightdrawstart, heightdrawend, fadefactorin, fadefactorout {id = 4, name = 'projectileParams', size = 4}, --- heightboost gradient - {id = 5, name = 'additionalParams', size = 4 }, --- groupselectionfadescale, weaponType, ISDGUN, MAXANGLEDIF - {id = 6, name = 'instData', size = 4, type = GL.UNSIGNED_INT }, -- Currently unused within defense ranges, as they are forced-static } local luaShaderDir = "LuaUI/Widgets/Include/" @@ -428,40 +409,290 @@ local LuaShader = VFS.Include(luaShaderDir.."LuaShader.lua") VFS.Include(luaShaderDir.."instancevbotable.lua") local defenseRangeShader = nil -local shaderSourceCache = { - shaderName = 'Defense Range GL4', - vssrcpath = "LuaUI/Widgets/Shaders/weapon_range_rings_unified_gl4.vert.glsl", - fssrcpath = "LuaUI/Widgets/Shaders/weapon_range_rings_unified_gl4.frag.glsl", - shaderConfig = { - MYGRAVITY = Game.gravity + 0.1, - STATICUNITS = 1, - DEBUG = autoReload and 1 or 0, - }, - uniformInt = { - heightmapTex = 0, - losTex = 1, - mapNormalTex = 2, - }, - uniformFloat = { - lineAlphaUniform = 1, - cannonmode = 0, - fadeDistOffset = 0, - drawMode = 0, - selBuilderCount = 1.0, - selUnitCount = 1.0, - inMiniMap = 0.0, - }, -} - local function goodbye(reason) Spring.Echo("DefenseRange GL4 widget exiting with reason: "..reason) widgetHandler:RemoveWidget() end +local function makeCircleVBO(circleSegments) + circleSegments = circleSegments -1 -- for po2 buffers + local circleVBO = gl.GetVBO(GL.ARRAY_BUFFER,true) + if circleVBO == nil then goodbye("Failed to create circleVBO") end + + local VBOLayout = { + {id = 0, name = "position", size = 4}, + } + + local VBOData = {} + + for i = 0, circleSegments do -- this is +1 + VBOData[#VBOData+1] = math.sin(math.pi*2* i / circleSegments) -- X + VBOData[#VBOData+1] = math.cos(math.pi*2* i / circleSegments) -- Y + VBOData[#VBOData+1] = i / circleSegments -- circumference [0-1] + VBOData[#VBOData+1] = 0 + end + + circleVBO:Define( + circleSegments + 1, + VBOLayout + ) + circleVBO:Upload(VBOData) + return circleVBO +end + +local vsSrc = [[ +#version 420 +#line 10000 + +//__DEFINES__ + +layout (location = 0) in vec4 circlepointposition; +layout (location = 1) in vec4 posscale; +layout (location = 2) in vec4 color1; +layout (location = 3) in vec4 visibility; // FadeStart, FadeEnd, StartAlpha, EndAlpha +layout (location = 4) in vec4 projectileParams; // projectileSpeed, iscylinder!!!! , heightBoostFactor , heightMod + +uniform float lineAlphaUniform = 1.0; +uniform float cannonmode = 0.0; + +uniform sampler2D heightmapTex; +uniform sampler2D losTex; // hmm maybe? + +out DataVS { + flat vec4 blendedcolor; +}; + +//__ENGINEUNIFORMBUFFERDEFS__ + +#line 11000 + +float heightAtWorldPos(vec2 w){ + vec2 uvhm = heightmapUVatWorldPos(w); + return textureLod(heightmapTex, uvhm, 0.0).x; +} + +float GetRangeFactor(float projectileSpeed) { // returns >0 if weapon can shoot here, <0 if it cannot, 0 if just right + // on first run, with yDiff = 0, what do we get? + float speed2d = projectileSpeed * 0.707106; + float gravity = 120.0 * (0.001111111); + return ((speed2d * speed2d) * 2.0 ) / (gravity); +} + +float GetRange2DCannon(float yDiff,float projectileSpeed,float rangeFactor,float heightBoostFactor) { // returns >0 if weapon can shoot here, <0 if it cannot, 0 if just right + // on first run, with yDiff = 0, what do we get? + + //float factor = 0.707106; + float smoothHeight = 100.0; + float speed2d = projectileSpeed*0.707106; + float speed2dSq = speed2d * speed2d; + float gravity = -1.0* (120.0 /900); + + if (heightBoostFactor < 0){ + heightBoostFactor = (2.0 - rangeFactor) / sqrt(rangeFactor); + } + + if (yDiff < -100.0){ + yDiff = yDiff * heightBoostFactor; + }else { + if (yDiff < 0.0) { + yDiff = yDiff * (1.0 + (heightBoostFactor - 1.0 ) * (-1.0 * yDiff) * 0.01); + } + } + + float root1 = speed2dSq + 2 * gravity *yDiff; + if (root1 < 0.0 ){ + return 0.0; + }else{ + return rangeFactor * ( speed2dSq + speed2d * sqrt( root1 ) ) / (-1.0 * gravity); + } +} + +//float heightMod  default: 0.2 (0.8 for #Cannon, 1.0 for #BeamLaser and #LightningCannon) +//Changes the spherical weapon range into an ellipsoid. Values above 1.0 mean the weapon cannot target as high as it can far, values below 1.0 mean it can target higher than it can far. For example 0.5 would allow the weapon to target twice as high as far. + +//float heightBoostFactor default: -1.0 +//Controls the boost given to range by high terrain. Values > 1.0 result in increased range, 0.0 means the cannon has fixed range regardless of height difference to target. Any value < 0.0 (i.e. the default value) result in an automatically calculated value based on range and theoretical maximum range. + +#define RANGE posscale.w +#define PROJECTILESPEED projectileParams.x +#define ISCYLINDER projectileParams.y +#define HEIGHTBOOSTFACTOR projectileParams.z +#define HEIGHTMOD projectileParams.w +#define YGROUND posscale.y + +#define OUTOFBOUNDSALPHA alphaControl.y +#define FADEALPHA alphaControl.z +#define MOUSEALPHA alphaControl.w + + +void main() { + // translate to world pos: + vec4 circleWorldPos = vec4(1.0); + circleWorldPos.xz = circlepointposition.xy * RANGE + posscale.xz; + + vec4 alphaControl = vec4(1.0); + + // get heightmap + circleWorldPos.y = heightAtWorldPos(circleWorldPos.xz); + + + if (cannonmode > 0.5){ + + // BAR only has 3 distinct ballistic projectiles, heightBoostFactor is only a handful from -1 to 2.8 and 6 and 8 + // gravity we can assume to be linear + + float heightDiff = (circleWorldPos.y - YGROUND) * 0.5; + + float rangeFactor = RANGE / GetRangeFactor(PROJECTILESPEED); //correct + if (rangeFactor > 1.0 ) rangeFactor = 1.0; + if (rangeFactor <= 0.0 ) rangeFactor = 1.0; + float radius = RANGE;// - heightDiff; + float adjRadius = GetRange2DCannon(heightDiff * HEIGHTMOD, PROJECTILESPEED, rangeFactor, HEIGHTBOOSTFACTOR); + float adjustment = radius * 0.5; + float yDiff = 0; + float adds = 0; + //for (int i = 0; i < mod(timeInfo.x/8,16); i ++){ //i am a debugging god + for (int i = 0; i < 16; i ++){ + if (adjRadius > radius){ + radius = radius + adjustment; + adds = adds + 1; + }else{ + radius = radius - adjustment; + adds = adds - 1; + } + adjustment = adjustment * 0.5; + circleWorldPos.xz = circlepointposition.xy * radius + posscale.xz; + float newY = heightAtWorldPos(circleWorldPos.xz ); + yDiff = abs(circleWorldPos.y - newY); + circleWorldPos.y = max(0, newY); + heightDiff = circleWorldPos.y - posscale.y; + adjRadius = GetRange2DCannon(heightDiff * HEIGHTMOD, PROJECTILESPEED, rangeFactor, HEIGHTBOOSTFACTOR); + } + }else{ + if (ISCYLINDER < 0.5){ // isCylinder + //simple implementation, 4 samples per point + //for (int i = 0; i 0.5){ + // cannons should fade distance based on their range + float cvmin = max(visibility.x, 2* RANGE); + float cvmax = max(visibility.y, 4* RANGE); + //FADEALPHA = clamp((cvmin - distToCam)/(cvmax - cvmin + 1.0),visibility.z,visibility.w); + } + + blendedcolor = color1; + + // -- DARKEN OUT OF LOS + vec4 losTexSample = texture(losTex, vec2(circleWorldPos.x / mapSize.z, circleWorldPos.z / mapSize.w)); // lostex is PO2 + float inlos = dot(losTexSample.rgb,vec3(0.33)); + inlos = clamp(inlos*5 -1.4 , 0.5,1.0); // fuck if i know why, but change this if LOSCOLORS are changed! + blendedcolor.rgb *= inlos; + + // --- YES FOG + float fogDist = length((cameraView * vec4(circleWorldPos.xyz,1.0)).xyz); + float fogFactor = clamp((fogParams.y - fogDist) * fogParams.w, 0, 1); + blendedcolor.rgb = mix(fogColor.rgb, vec3(blendedcolor), fogFactor); + + + // -- IN-SHADER MOUSE-POS BASED HIGHLIGHTING + float disttomousefromunit = 1.0 - smoothstep(48, 64, length(posscale.xz - mouseWorldPos.xz)); + // this will be positive if in mouse, negative else + float highightme = clamp( (disttomousefromunit ) + 0.0, 0.0, 1.0); + MOUSEALPHA = highightme; + + // ------------ dump the stuff for FS -------------------- + //worldPos = circleWorldPos; + //worldPos.a = RANGE; + alphaControl.x = circlepointposition.z; // save circle progress here + gl_Position = cameraViewProj * vec4(circleWorldPos.xyz, 1.0); + + + //lets blend the alpha here, and save work in FS: + float outalpha = OUTOFBOUNDSALPHA * (MOUSEALPHA + FADEALPHA * lineAlphaUniform); + blendedcolor.a *= outalpha ; + //blendedcolor.rgb = vec3(fract(distToCam/100)); +} +]] + +local fsSrc = [[ +#version 330 + +#extension GL_ARB_uniform_buffer_object : require +#extension GL_ARB_shading_language_420pack: require + +//_DEFINES__ + +#line 20000 + + +//_ENGINEUNIFORMBUFFERDEFS__ + +in DataVS { + flat vec4 blendedcolor; +}; + +out vec4 fragColor; + +void main() { + fragColor = blendedcolor; // now pared down to only this, all work is done in vertex shader now +} +]] + + local function makeShaders() - defenseRangeShader = LuaShader.CheckShaderUpdates(shaderSourceCache, 0) - if not defenseRangeShader then + local engineUniformBufferDefs = LuaShader.GetEngineUniformBufferDefs() + vsSrc = vsSrc:gsub("//__ENGINEUNIFORMBUFFERDEFS__", engineUniformBufferDefs) + fsSrc = fsSrc:gsub("//__ENGINEUNIFORMBUFFERDEFS__", engineUniformBufferDefs) + defenseRangeShader = LuaShader( + { + vertex = vsSrc:gsub("//__DEFINES__", "#define MYGRAVITY "..tostring(Game.gravity+0.1)), + fragment = fsSrc, + --geometry = gsSrc, no geom shader for now + uniformInt = { + heightmapTex = 0, + losTex = 1, + }, + uniformFloat = { + lineAlphaUniform = 1, + cannonmode = 0, + }, + }, + "defenseRangeShader GL4" + ) + shaderCompiled = defenseRangeShader:Initialize() + if not shaderCompiled then goodbye("Failed to compile defenseRangeShader GL4 ") return false end @@ -524,7 +755,7 @@ local function hashPos(x,z) end local cacheTable = {} -for i=1,24 do cacheTable[i] = 0 end +for i=1,16 do cacheTable[i] = 0 end local function UnitDetected(unitID, unitDefID, unitTeam, noUpload) if unitDefRings[unitDefID] == nil then return end -- no rings for this @@ -543,24 +774,12 @@ local function UnitDetected(unitID, unitDefID, unitTeam, noUpload) local allystring = alliedUnit and "ally" or "enemy" if buttonConfig[allystring][buttonconfigmap[weaponType]] then --local weaponType = unitDefRings[unitDefID]['weapons'][weaponNum] - - local weaponID = i - local ringParams = unitDefRings[unitDefID]['rings'][i] - local x, y, z, mpx, mpy, mpz, apx, apy, apz = spGetUnitPosition(unitID, true, true) - local wpx, wpy, wpz, wdx, wdy, wdz = Spring.GetUnitWeaponVectors(unitID, weaponID) - --Spring.Echo("Defranges: unitID", unitID,x,y,z,"weaponID", weaponID, "y", y, "mpy", mpy,"wpy", wpy) - - -- Now this is a truly terrible hack, we cache each unitDefID's max weapon turret height at position 18 in the table - -- so it only goes up with popups - local turretHeight = math.max(ringParams[18] or 0, (wpy or mpy ) - y) - ringParams[18] = turretHeight - - cacheTable[1] = mpx - cacheTable[2] = turretHeight + cacheTable[2] = mpy cacheTable[3] = mpz local vaokey = allystring .. weaponTypeToString[weaponType] + local ringParams = unitDefRings[unitDefID]['rings'][i] for i = 1,13 do cacheTable[i+3] = ringParams[i] end @@ -845,10 +1064,6 @@ local function DRAWRINGS(primitiveType, linethickness) end defenseRangeShader:SetUniform("cannonmode",1) - if not linethickness then - -- NOTE: THIS IS THE WORLDS NASTIEST HACK TO PREVENT THE CANNON RINGS FROM BEING DRAWN STENCILED! - return - end for i,allyState in ipairs(allyenemypairs) do local defRangeClass = allyState.."cannon" local iT = defenseRangeVAOs[defRangeClass] @@ -856,7 +1071,7 @@ local function DRAWRINGS(primitiveType, linethickness) drawcounts[stencilMask] = iT.usedElements if iT.usedElements > 0 and buttonConfig[allyState]["ground"] then if linethickness then - glLineWidth(colorConfig['cannon'][linethickness] * cameraHeightFactor * 0.15) + glLineWidth(colorConfig['cannon'][linethickness] * cameraHeightFactor) end glStencilMask(stencilMask) glStencilFunc(GL.NOTEQUAL, stencilMask, stencilMask) @@ -865,16 +1080,10 @@ local function DRAWRINGS(primitiveType, linethickness) end end -function widget:DrawWorld() +function widget:DrawWorldPreUnit() --if fullview and not enabledAsSpec then -- return --end - - if autoReload then - defenseRangeShader = LuaShader.CheckShaderUpdates(shaderSourceCache) or defenseRangeShader - end - - if chobbyInterface then return end if not Spring.IsGUIHidden() and (not WG['topbar'] or not WG['topbar'].showingQuit()) then cameraHeightFactor = GetCameraHeightFactor() * 0.5 + 0.5 @@ -887,7 +1096,6 @@ function widget:DrawWorld() glClear(GL.STENCIL_BUFFER_BIT) -- clear prev stencil glDepthTest(false) -- always draw glColorMask(false, false, false, false) -- disable color drawing - glStencilTest(true) -- enable stencil test glStencilMask(255) -- all 8 bits glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE) -- Set The Stencil Buffer To 1 Where Draw Any Polygon @@ -935,6 +1143,7 @@ end + --SAVE / LOAD CONFIG FILE function widget:GetConfigData() local data = {} diff --git a/units/ArmBots/T2/armaak.lua b/units/ArmBots/T2/armaak.lua index 704c4af5f9..f9eaa7e58a 100644 --- a/units/ArmBots/T2/armaak.lua +++ b/units/ArmBots/T2/armaak.lua @@ -142,9 +142,6 @@ return { [2] = 0.33, [3] = 0.7, }, - customparams = { - bogus = 1 - }, }, armaabot_missile1 = { areaofeffect = 64, diff --git a/units/ArmBuildings/LandUtil/armmine1.lua b/units/ArmBuildings/LandUtil/armmine1.lua index a3b2e4ccd3..f84b6cc108 100644 --- a/units/ArmBuildings/LandUtil/armmine1.lua +++ b/units/ArmBuildings/LandUtil/armmine1.lua @@ -78,8 +78,6 @@ return { weapondefs = { minerange = { areaofeffect = 0, - avoidfeature = false, - avoidground = false, craterareaofeffect = 0, craterboost = 0, cratermult = 0, @@ -89,7 +87,7 @@ return { impulsefactor = 0, name = "Crawlingbomb Dummy Weapon", range = 64, - reloadtime = 0.1, + reloadtime = 1, soundhitwet = "", soundhitwetvolume = 0, tolerance = 1000000, @@ -106,7 +104,6 @@ return { weapons = { [1] = { def = "MINERANGE", - onlytargetcategory = "SURFACE", }, }, }, diff --git a/units/ArmBuildings/LandUtil/armmine2.lua b/units/ArmBuildings/LandUtil/armmine2.lua index 077a534e90..866395f2b7 100644 --- a/units/ArmBuildings/LandUtil/armmine2.lua +++ b/units/ArmBuildings/LandUtil/armmine2.lua @@ -104,7 +104,6 @@ return { weapons = { [1] = { def = "MINERANGE", - onlytargetcategory = "SURFACE", }, }, }, diff --git a/units/ArmBuildings/LandUtil/armmine3.lua b/units/ArmBuildings/LandUtil/armmine3.lua index a53afece60..3b8c19e84c 100644 --- a/units/ArmBuildings/LandUtil/armmine3.lua +++ b/units/ArmBuildings/LandUtil/armmine3.lua @@ -104,7 +104,6 @@ return { weapons = { [1] = { def = "MINERANGE", - onlytargetcategory = "SURFACE", }, }, }, diff --git a/units/ArmBuildings/SeaUtil/armfmine3.lua b/units/ArmBuildings/SeaUtil/armfmine3.lua index 79f18c97d9..101878c9ad 100644 --- a/units/ArmBuildings/SeaUtil/armfmine3.lua +++ b/units/ArmBuildings/SeaUtil/armfmine3.lua @@ -106,7 +106,6 @@ return { weapons = { [1] = { def = "MINERANGE", - onlytargetcategory = "SURFACE", }, }, }, diff --git a/units/ArmGantry/armthor.lua b/units/ArmGantry/armthor.lua index f5a98e2562..93c814519e 100644 --- a/units/ArmGantry/armthor.lua +++ b/units/ArmGantry/armthor.lua @@ -241,9 +241,6 @@ return { default = 300, subs = 30, }, - customparams = { - noattackrangearc= 1, - }, }, }, weapons = { diff --git a/units/ArmShips/T2/armbats.lua b/units/ArmShips/T2/armbats.lua index 7a3cdb135f..06d63c53c9 100644 --- a/units/ArmShips/T2/armbats.lua +++ b/units/ArmShips/T2/armbats.lua @@ -128,9 +128,6 @@ return { default = 300, vtol = 65, }, - customparams = { - noattackrangearc= 1, - }, }, }, weapons = { diff --git a/units/ArmShips/T2/armepoch.lua b/units/ArmShips/T2/armepoch.lua index 3eddfefc3c..8a67bb69d8 100644 --- a/units/ArmShips/T2/armepoch.lua +++ b/units/ArmShips/T2/armepoch.lua @@ -161,9 +161,6 @@ return { commanders = 1, vtol = 150, }, - customparams = { - noattackrangearc= 1, - }, }, flak = { accuracy = 1000, @@ -201,9 +198,6 @@ return { [2] = 0.33, [3] = 0.7, }, - customparams = { - noattackrangearc= 1, - }, }, heavyplasma = { accuracy = 600, @@ -234,9 +228,6 @@ return { default = 437, vtol = 200, }, - customparams = { - noattackrangearc= 1, - }, }, mediumplasma = { accuracy = 350, @@ -264,9 +255,6 @@ return { default = 270, vtol = 65, }, - customparams = { - noattackrangearc= 1, - }, }, }, weapons = { diff --git a/units/ArmShips/T2/armlship.lua b/units/ArmShips/T2/armlship.lua index fc5c134c43..4849418b84 100644 --- a/units/ArmShips/T2/armlship.lua +++ b/units/ArmShips/T2/armlship.lua @@ -188,7 +188,6 @@ return { spark_forkdamage = "0.5", spark_maxunits = "2", spark_range = "100", - noattackrangearc= 1, }, damage = { default = 35, diff --git a/units/ArmShips/T2/armmship.lua b/units/ArmShips/T2/armmship.lua index 18fe614b3e..f66770b311 100644 --- a/units/ArmShips/T2/armmship.lua +++ b/units/ArmShips/T2/armmship.lua @@ -195,7 +195,6 @@ return { speceffect = "split", splitexplosionceg = "genericshellexplosion-medium", when = "yvel<0", - noattackrangearc= 1, }, damage = { commanders = 350, diff --git a/units/ArmShips/armpship.lua b/units/ArmShips/armpship.lua index 2ecc6fd1b7..67646d4218 100644 --- a/units/ArmShips/armpship.lua +++ b/units/ArmShips/armpship.lua @@ -128,10 +128,6 @@ return { subs = 70, vtol = 37, }, - customparams = { - noattackrangearc= 1, - }, - }, }, weapons = { diff --git a/units/CorAircraft/T2/corcrwh.lua b/units/CorAircraft/T2/corcrwh.lua index 93ff6a9bb0..4e231f9493 100644 --- a/units/CorAircraft/T2/corcrwh.lua +++ b/units/CorAircraft/T2/corcrwh.lua @@ -127,9 +127,6 @@ return { damage = { vtol = 76, }, - customparams = { - noattackrangearc= 1, - }, }, dragonmawh = { accuracy = 700, @@ -176,9 +173,6 @@ return { default = 6, subs = 3, }, - customparams = { - noattackrangearc= 1, - }, }, krowlaser2 = { areaofeffect = 32, diff --git a/units/CorBots/T2/coraak.lua b/units/CorBots/T2/coraak.lua index 133680847e..a409995d91 100644 --- a/units/CorBots/T2/coraak.lua +++ b/units/CorBots/T2/coraak.lua @@ -141,9 +141,6 @@ return { [2] = 0.33, [3] = 0.7, }, - customparams = { - bogus = 1 - }, }, bogus_missile = { areaofeffect = 48, @@ -220,9 +217,6 @@ return { damage = { vtol = 80, }, - customparams = { - bogus = 1 - }, }, coraabot_missile2 = { areaofeffect = 24, @@ -270,9 +264,6 @@ return { damage = { vtol = 80, }, - customparams = { - bogus = 1 - }, }, coraabot_missile3 = { areaofeffect = 24, @@ -320,9 +311,6 @@ return { damage = { vtol = 80, }, - customparams = { - bogus = 1 - }, }, coraabot_missile4 = { areaofeffect = 64, diff --git a/units/CorBuildings/LandUtil/cormine1.lua b/units/CorBuildings/LandUtil/cormine1.lua index 458c9e320a..bcec924be0 100644 --- a/units/CorBuildings/LandUtil/cormine1.lua +++ b/units/CorBuildings/LandUtil/cormine1.lua @@ -105,7 +105,6 @@ return { weapons = { [1] = { def = "MINERANGE", - onlytargetcategory = "SURFACE", }, }, }, diff --git a/units/CorBuildings/LandUtil/cormine2.lua b/units/CorBuildings/LandUtil/cormine2.lua index 7a73dc82e9..2b7bb3b459 100644 --- a/units/CorBuildings/LandUtil/cormine2.lua +++ b/units/CorBuildings/LandUtil/cormine2.lua @@ -104,7 +104,6 @@ return { weapons = { [1] = { def = "MINERANGE", - onlytargetcategory = "SURFACE", }, }, }, diff --git a/units/CorBuildings/LandUtil/cormine3.lua b/units/CorBuildings/LandUtil/cormine3.lua index f701732a42..1384eafcb9 100644 --- a/units/CorBuildings/LandUtil/cormine3.lua +++ b/units/CorBuildings/LandUtil/cormine3.lua @@ -104,7 +104,6 @@ return { weapons = { [1] = { def = "MINERANGE", - onlytargetcategory = "SURFACE", }, }, }, diff --git a/units/CorBuildings/SeaUtil/corfmine3.lua b/units/CorBuildings/SeaUtil/corfmine3.lua index 2836d5790b..9d2e585926 100644 --- a/units/CorBuildings/SeaUtil/corfmine3.lua +++ b/units/CorBuildings/SeaUtil/corfmine3.lua @@ -106,7 +106,6 @@ return { weapons = { [1] = { def = "MINERANGE", - onlytargetcategory = "SURFACE", }, }, }, diff --git a/units/CorGantry/corjugg.lua b/units/CorGantry/corjugg.lua index aa4b7207a4..b6c5a885e2 100644 --- a/units/CorGantry/corjugg.lua +++ b/units/CorGantry/corjugg.lua @@ -139,9 +139,6 @@ return { damage = { default = 75, }, - customparams = { - noattackrangearc= 1, - }, }, juggernaut_fire = { areaofeffect = 65, @@ -212,9 +209,6 @@ return { damage = { default = 150, }, - customparams = { - noattackrangearc= 1, - }, }, }, weapons = { diff --git a/units/CorGantry/corkorg.lua b/units/CorGantry/corkorg.lua index e80711c726..da4b51671d 100644 --- a/units/CorGantry/corkorg.lua +++ b/units/CorGantry/corkorg.lua @@ -278,7 +278,6 @@ return { customparams = { lups_noshockwave = true, nofire = true, - noattackrangearc= 1, }, damage = { default = 150, diff --git a/units/CorShips/T2/corbats.lua b/units/CorShips/T2/corbats.lua index 212b9b710b..e53372cf0d 100644 --- a/units/CorShips/T2/corbats.lua +++ b/units/CorShips/T2/corbats.lua @@ -162,9 +162,6 @@ return { default = 300, vtol = 65, }, - customparams = { - noattackrangearc= 1, - }, }, }, weapons = { diff --git a/units/CorShips/T2/corblackhy.lua b/units/CorShips/T2/corblackhy.lua index cf0294fc5d..cfd775ee2d 100644 --- a/units/CorShips/T2/corblackhy.lua +++ b/units/CorShips/T2/corblackhy.lua @@ -192,10 +192,6 @@ return { damage = { vtol = 150, }, - - customparams = { - noattackrangearc= 1, - }, }, heavylaser = { areaofeffect = 8, @@ -231,9 +227,6 @@ return { default = 270, vtol = 65, }, - customparams = { - noattackrangearc= 1, - }, }, heavyplasma = { accuracy = 500, diff --git a/units/CorShips/T2/cormship.lua b/units/CorShips/T2/cormship.lua index bbb44d9407..83ff273b37 100644 --- a/units/CorShips/T2/cormship.lua +++ b/units/CorShips/T2/cormship.lua @@ -194,7 +194,6 @@ return { speceffect = "split", splitexplosionceg = "genericshellexplosion-medium", when = "yvel<0", - noattackrangearc= 1, }, damage = { commanders = 500, diff --git a/units/Legion/Air/T2 Air/legfort.lua b/units/Legion/Air/T2 Air/legfort.lua index 8cc11e1312..47ba633fb8 100644 --- a/units/Legion/Air/T2 Air/legfort.lua +++ b/units/Legion/Air/T2 Air/legfort.lua @@ -117,9 +117,6 @@ return { damage = { default = 36, }, - customparams = { - noattackrangearc= 1, - }, }, plasma = { accuracy = 960, @@ -148,9 +145,6 @@ return { subs = 50, vtol = 30, }, - customparams = { - noattackrangearc= 1, - }, }, aa_missiles = { areaofeffect = 16, diff --git a/units/Legion/Air/T2 Air/legheavydrone.lua b/units/Legion/Air/T2 Air/legheavydrone.lua index 5b0d4e0c75..648e983072 100644 --- a/units/Legion/Air/T2 Air/legheavydrone.lua +++ b/units/Legion/Air/T2 Air/legheavydrone.lua @@ -106,9 +106,6 @@ return { default = 10, vtol = 2, }, - customparams = { - noattackrangearc= 1, - }, }, }, weapons = { diff --git a/units/Legion/Air/T2 Air/legionnaire.lua b/units/Legion/Air/T2 Air/legionnaire.lua index 2e278fe254..cd9d33d0c5 100644 --- a/units/Legion/Air/T2 Air/legionnaire.lua +++ b/units/Legion/Air/T2 Air/legionnaire.lua @@ -122,9 +122,6 @@ return { default = 2, vtol = 80, }, - customparams = { - noattackrangearc= 1, - }, }, }, diff --git a/units/Legion/Air/T2 Air/legvenator.lua b/units/Legion/Air/T2 Air/legvenator.lua index 8e2506f6e3..d8e6f27eb3 100644 --- a/units/Legion/Air/T2 Air/legvenator.lua +++ b/units/Legion/Air/T2 Air/legvenator.lua @@ -111,9 +111,6 @@ return { default = 24, vtol = 480, }, - customparams = { - noattackrangearc= 1, - }, }, }, weapons = { diff --git a/units/Legion/Air/legdrone.lua b/units/Legion/Air/legdrone.lua index b45dd85d31..c67fdceead 100644 --- a/units/Legion/Air/legdrone.lua +++ b/units/Legion/Air/legdrone.lua @@ -137,9 +137,6 @@ return { default = 12, vtol = 4, }, - customparams = { - noattackrangearc= 1, - }, }, }, weapons = { diff --git a/units/Legion/Defenses/legbombard.lua b/units/Legion/Defenses/legbombard.lua index 9c3d2440cb..408ba096fb 100644 --- a/units/Legion/Defenses/legbombard.lua +++ b/units/Legion/Defenses/legbombard.lua @@ -186,7 +186,6 @@ return { subs = 300, }, customparams = { - noattackrangearc= 1, exclude_preaim = true } }, diff --git a/units/Legion/Ships/leghastatus.lua b/units/Legion/Ships/leghastatus.lua index e87ff3d9cb..d93b98b88a 100644 --- a/units/Legion/Ships/leghastatus.lua +++ b/units/Legion/Ships/leghastatus.lua @@ -127,9 +127,6 @@ return { default = 55, vtol = 30, }, - customparams = { - noattackrangearc= 1, - }, }, }, diff --git a/units/Legion/Ships/leghastatusalt.lua b/units/Legion/Ships/leghastatusalt.lua index e9b9d61b94..5e7bff0124 100644 --- a/units/Legion/Ships/leghastatusalt.lua +++ b/units/Legion/Ships/leghastatusalt.lua @@ -139,9 +139,6 @@ return { hvyboats = 11, vtol = 2, }, - customparams = { - noattackrangearc= 1, - }, }, }, weapons = { diff --git a/units/Legion/Ships/legportent.lua b/units/Legion/Ships/legportent.lua index 100ff55d5c..c968f930be 100644 --- a/units/Legion/Ships/legportent.lua +++ b/units/Legion/Ships/legportent.lua @@ -132,9 +132,6 @@ return { vtol = 30, sub = 30, }, - customparams = { - noattackrangearc= 1, - }, }, }, diff --git a/units/Legion/T3/legpede.lua b/units/Legion/T3/legpede.lua index d48cc724cc..d42db278fa 100644 --- a/units/Legion/T3/legpede.lua +++ b/units/Legion/T3/legpede.lua @@ -187,9 +187,6 @@ return { default = 21, vtol = 21, }, - customparams = { - noattackrangearc= 1, - }, }, railgunt2 = { areaofeffect = 16, From 0e4db0d5b04e75c6779a872ab8ae8c674eeb9118 Mon Sep 17 00:00:00 2001 From: WatchTheFort <36827423+WatchTheFort@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:14:56 -0500 Subject: [PATCH 05/21] Remove code to fix math.random returning float instead of int (#4051) Remove code to fix math.random returning float instead of int, engine ticket has been long since fixed --- unitbasedefs/lootboxes/lootboxnano.lua | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/unitbasedefs/lootboxes/lootboxnano.lua b/unitbasedefs/lootboxes/lootboxnano.lua index 62c424293f..bd3b5a3334 100644 --- a/unitbasedefs/lootboxes/lootboxnano.lua +++ b/unitbasedefs/lootboxes/lootboxnano.lua @@ -1,8 +1,3 @@ --- Workaround for engine bug https://github.com/beyond-all-reason/spring/issues/45 -local math_random = function(x, y) - return x + math.floor( y * math.random() ) -end - local tiers = { T1 = 1, T2 = 2, @@ -23,7 +18,7 @@ local createCustomBuildList = function(tier) local buildList = {} for i = 1, buildListSize do - local buildOption = buildOptions[tier][math_random(1, #buildOptions[tier])] + local buildOption = buildOptions[tier][math.random(1, #buildOptions[tier])] buildList[i] = buildOption end @@ -77,7 +72,7 @@ local function getRandomModel(tier) }, } - local randomModel = math_random(1, 2) + local randomModel = math.random(1, 2) return models[tier][randomModel].objectName, models[tier][randomModel].script end From 1f8184d5f0ae77fb3ef18e9ee39c1716b3a3cd87 Mon Sep 17 00:00:00 2001 From: Floris Date: Sat, 21 Dec 2024 16:14:38 +0100 Subject: [PATCH 06/21] dgun stall assist: minor code cleanup --- luaui/Widgets/unit_dgun_stall_assist.lua | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/luaui/Widgets/unit_dgun_stall_assist.lua b/luaui/Widgets/unit_dgun_stall_assist.lua index 5f2a1841fd..90aee129da 100644 --- a/luaui/Widgets/unit_dgun_stall_assist.lua +++ b/luaui/Widgets/unit_dgun_stall_assist.lua @@ -1,4 +1,3 @@ - function widget:GetInfo() return { name = "DGun Stall Assist", @@ -11,9 +10,6 @@ function widget:GetInfo() } end ----------------------------------------------------------------- --- Config ----------------------------------------------------------------- local targetEnergy = 600 local watchForTime = 5 @@ -22,14 +18,13 @@ local watchForTime = 5 ---------------------------------------------------------------- local watchTime = 0 local waitedUnits = nil -- nil / waitedUnits[1..n] = uID -local shouldWait = {} -- shouldWait[uDefID] = true / nil -local isFactory = {} -- isFactory[uDefID] = true / nil +local shouldWait = {} +local isFactory = {} local gameStarted local stallIds = {UnitDefNames['armcom'].id, UnitDefNames['corcom'].id, UnitDefNames['legcom'] and UnitDefNames['legcom'].id} - ---------------------------------------------------------------- -- Speedups ---------------------------------------------------------------- @@ -41,7 +36,6 @@ local spGetMyTeamID = Spring.GetMyTeamID local spGetTeamResources = Spring.GetTeamResources local spGetTeamUnits = Spring.GetTeamUnits local spGetUnitDefID = Spring.GetUnitDefID -local spGetSpectatingState = Spring.GetSpectatingState local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt local CMD_DGUN = CMD.DGUN @@ -75,7 +69,7 @@ function widget:Initialize() end for uDefID, uDef in pairs(UnitDefs) do - if (uDef.buildSpeed > 0) and uDef.canAssist and (not uDef.canManualFire) then + if uDef.buildSpeed > 0 and uDef.canAssist and not uDef.canManualFire then shouldWait[uDefID] = true if uDef.isFactory then isFactory[uDefID] = true @@ -97,13 +91,13 @@ function widget:Update(dt) end end - if (stallUnitSelected) then + if stallUnitSelected then watchTime = watchForTime end else watchTime = watchTime - dt - if waitedUnits and (watchTime < 0) then + if waitedUnits and watchTime < 0 then local toUnwait = {} for i = 1, #waitedUnits do @@ -127,11 +121,11 @@ function widget:Update(dt) end end - if (watchTime > 0) and (not waitedUnits) then + if watchTime > 0 and not waitedUnits then local myTeamID = spGetMyTeamID() local currentEnergy, energyStorage = spGetTeamResources(myTeamID, "energy") - if (currentEnergy < targetEnergy) and (energyStorage >= targetEnergy) then + if currentEnergy < targetEnergy and energyStorage >= targetEnergy then waitedUnits = {} local myUnits = spGetTeamUnits(myTeamID) From 02404a3bd99f29e9ddca1e79e94e47493ca72026 Mon Sep 17 00:00:00 2001 From: sprunk Date: Sat, 21 Dec 2024 20:32:53 +0100 Subject: [PATCH 07/21] Debris damage modrule (#4053) --- gamedata/modrules.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gamedata/modrules.lua b/gamedata/modrules.lua index c107556240..c08e0380e1 100644 --- a/gamedata/modrules.lua +++ b/gamedata/modrules.lua @@ -123,6 +123,10 @@ local modrules = { healthScale = XPValues.healthScale, -- Controls how gaining experience increases the maxDamage (total hitpoints) of the unit. The formula used is Health multiplier = healthScale * (1 + xp / (xp + 1)). reloadScale = XPValues.reloadScale, -- Controls how gaining experience decreases the reloadTime of the unit's weapons. The formula used is Rate of fire multiplier = reloadScale * (1 + xp / (xp + 1)). }, + + damage = { + debris = 0, -- body parts flying off dead units + }, } return modrules From f596825e539bd77a7f784f623d2d1fb2c1b782b9 Mon Sep 17 00:00:00 2001 From: Floris Date: Sat, 21 Dec 2024 20:36:44 +0100 Subject: [PATCH 08/21] removed engine hotfixes gadget and divide its functions to a new "footprint clearance" gadget and the "debris explosions" gadget (#4052) * removed engine hotfixes gadget and devide its functions to a new footprint clearance gadget and the debris explosions gadget * revert changes to debris explosion gadget: has already been in: #4053plemented as modrule in --- ...fixes.lua => unit_footprint_clearance.lua} | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) rename luarules/gadgets/{engine_hotfixes.lua => unit_footprint_clearance.lua} (64%) diff --git a/luarules/gadgets/engine_hotfixes.lua b/luarules/gadgets/unit_footprint_clearance.lua similarity index 64% rename from luarules/gadgets/engine_hotfixes.lua rename to luarules/gadgets/unit_footprint_clearance.lua index 4867fd32d9..eea1e715e3 100644 --- a/luarules/gadgets/engine_hotfixes.lua +++ b/luarules/gadgets/unit_footprint_clearance.lua @@ -1,9 +1,9 @@ function gadget:GetInfo() return { - name = 'Engine Hotfixes for Various Engine Kludges', - desc = '', + name = 'Footprint clearance', + desc = 'Clears ground under newly build units any features that are under its footprint', author = '', - version = 'v1.0', + version = '', date = 'April 2011', license = 'GNU GPL, v2 or later', layer = 0, @@ -15,13 +15,9 @@ if not gadgetHandler:IsSyncedCode() then return end -local unitTurnrate = {} local unitXsize5 = {} local unitZsize5 = {} for unitDefID, unitDef in pairs(UnitDefs) do - if unitDef.moveDef and unitDef.moveDef.type ~= nil then - unitTurnrate[unitDefID] = unitDef.turnRate - end if unitDef.isBuilding or unitDef.isFactory then unitXsize5[unitDefID] = unitDef.xsize * 5 unitZsize5[unitDefID] = unitDef.zsize * 5 @@ -36,12 +32,6 @@ end function gadget:UnitCreated(uID, uDefID, uTeam, bID) - --Fix for bad movement in 102 - --https://springrts.com/phpbb/viewtopic.php?f=12&t=34593 - --if unitTurnrate[uDefID] then -- all non-flying units - -- Spring.MoveCtrl.SetGroundMoveTypeData(uID, "turnAccel", unitTurnrate[uDefID]) - --end - --Instagibb any features that are unlucky enough to be in the build radius of new construction projects if unitXsize5[uDefID] then -- buildings/factories local xr, zr @@ -51,7 +41,7 @@ function gadget:UnitCreated(uID, uDefID, uTeam, bID) xr, zr = unitZsize5[uDefID], unitXsize5[uDefID] end - local ux, uy, uz = Spring.GetUnitPosition(uID) + local ux, _, uz = Spring.GetUnitPosition(uID) local features = Spring.GetFeaturesInRectangle(ux-xr, uz-zr, ux+xr, uz+zr) for i = 1, #features do if gibFeatureDefs[Spring.GetFeatureDefID(features[i])] then @@ -63,11 +53,3 @@ function gadget:UnitCreated(uID, uDefID, uTeam, bID) end end end - ---Remove damage hardcoded in the engine of gibbed pieces of units (hardcoded to 50 damage in engine) -function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam) - if weaponDefID == -1 then - return 0, 0 - end - return damage, 1 -end From 9750ca58dee17c4bf1193dbe968e5a2381839f5e Mon Sep 17 00:00:00 2001 From: Beherith Date: Sun, 22 Dec 2024 22:18:30 +0100 Subject: [PATCH 09/21] fix leglht heights (#4062) --- objects3d/Units/leglht.s3o | Bin 165242 -> 165242 bytes objects3d/Units/leglht_dead.s3o | Bin 165066 -> 165066 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/objects3d/Units/leglht.s3o b/objects3d/Units/leglht.s3o index 10765435014070f34efa9d3de83927b38a68bfc0..fb100ac2a4b3d8f7d5f0ef39b5a3f868f3937e4d 100644 GIT binary patch delta 21 ccmey>#r3O;Yl0Y4f>WbJs|4d#38ti009=0uQ~&?~ delta 21 ccmey>#r3O;Yl0Zl1II>*Rtd(f5==?00Ah3p(*OVf diff --git a/objects3d/Units/leglht_dead.s3o b/objects3d/Units/leglht_dead.s3o index c13f2b9994fd2f09630fb2ad685d9063aaabb19e..3c5f6abee1d581aa05fff45e216df09c13ed8823 100644 GIT binary patch delta 20 bcmX@r$#treYl0YKOrv Date: Mon, 23 Dec 2024 12:55:59 +0100 Subject: [PATCH 10/21] Localize Spring.GetUnitDefID for a minor optimization in frequently called function (#4064) From 31a68191e1d1b5fdae59cf55ca0687a796083111 Mon Sep 17 00:00:00 2001 From: saurtron Date: Mon, 23 Dec 2024 13:33:24 +0100 Subject: [PATCH 11/21] test_runner: Add 'timeout' parameter to SyncedRun. (#4057) --- luaui/Widgets/dbg_test_runner.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luaui/Widgets/dbg_test_runner.lua b/luaui/Widgets/dbg_test_runner.lua index 2c4bada6f2..033d8d1d0c 100644 --- a/luaui/Widgets/dbg_test_runner.lua +++ b/luaui/Widgets/dbg_test_runner.lua @@ -615,14 +615,14 @@ end SyncedProxy = createNestedProxy(Proxy.PREFIX.CALL) -SyncedRun = function(fn) +SyncedRun = function(fn, timeout) local serializedFn, returnID = rpc:serializeFunctionRun(fn, 3) returnState = { waitingForReturnID = returnID, success = nil, pendingValueOrError = nil, - timeoutExpireFrame = Spring.GetGameFrame() + config.returnTimeout, + timeoutExpireFrame = Spring.GetGameFrame() + (timeout or config.returnTimeout), } log(LOG.DEBUG, "[SyncedRun.send]") From a52eb97eab735dc8e3e720d0887dad8361c9cb28 Mon Sep 17 00:00:00 2001 From: Floris Date: Mon, 23 Dec 2024 20:03:13 +0100 Subject: [PATCH 12/21] increased height parameter for cornanot2 model --- objects3d/Units/cornanot2.s3o | Bin 45124 -> 45124 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/objects3d/Units/cornanot2.s3o b/objects3d/Units/cornanot2.s3o index 32252ba6840610c6d65fbf6c1918a5bdbe89b940..ea055da7f834fd1714ac73a5b4ef774be70e8a38 100644 GIT binary patch delta 303 zcmX@|fa%BsrU_!!M>T-Xn~^QOrUlU02zZ!gB%CuPhJ--qm~Mky#-YP zaL89HDX`@>Sy2t(!4+hFOY_T zA3*-v;K}C=#h7}dHy^fKq&P8GV)I|a6YTW|qalh;qR}8XfdEW=*36lE85jf{&zxE2 zn3|hel9!m5&+rebi8+RW!3?N_1xUj{0y6`{kwq{b*zpHIyyB9?ycCA%{A&*WdB4VS Ob4KP4x6Kct8+ZZVz&`2# From 0f461b628537110b8c9ff90c3f7c0abe3981ac25 Mon Sep 17 00:00:00 2001 From: Floris Date: Tue, 24 Dec 2024 02:02:31 +0100 Subject: [PATCH 13/21] crashing aircraft: increase crashing period grace period --- luarules/gadgets/unit_crashing_aircraft.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luarules/gadgets/unit_crashing_aircraft.lua b/luarules/gadgets/unit_crashing_aircraft.lua index 81827d794d..50f9c8b967 100644 --- a/luarules/gadgets/unit_crashing_aircraft.lua +++ b/luarules/gadgets/unit_crashing_aircraft.lua @@ -52,7 +52,7 @@ if gadgetHandler:IsSyncedCode() then end -- make it crash crashingCount = crashingCount + 1 - crashing[unitID] = Spring.GetGameFrame() + 230 + crashing[unitID] = Spring.GetGameFrame() + 450 Spring.SetUnitCOBValue(unitID, COB_CRASHING, 1) Spring.SetUnitNoSelect(unitID,true) Spring.SetUnitNoMinimap(unitID,true) From c8014b33c05cb9fe2e99e01d6d08d4caa2011f59 Mon Sep 17 00:00:00 2001 From: DKing <15340687+DKingAlpha@users.noreply.github.com> Date: Wed, 25 Dec 2024 00:23:59 +0800 Subject: [PATCH 14/21] bugfix: grid menu disappearing on non-english categories (#4070) --- luaui/configs/gridmenu_config.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/luaui/configs/gridmenu_config.lua b/luaui/configs/gridmenu_config.lua index 450107da54..7b37f39534 100644 --- a/luaui/configs/gridmenu_config.lua +++ b/luaui/configs/gridmenu_config.lua @@ -11,10 +11,10 @@ local homeGridPos = { } local unitCategories = {} -local BUILDCAT_ECONOMY = "Economy" -local BUILDCAT_COMBAT = "Combat" -local BUILDCAT_UTILITY = "Utility" -local BUILDCAT_PRODUCTION = "Build" +local BUILDCAT_ECONOMY = Spring.I18N("ui.buildMenu.category_econ") +local BUILDCAT_COMBAT = Spring.I18N("ui.buildMenu.category_combat") +local BUILDCAT_UTILITY = Spring.I18N("ui.buildMenu.category_utility") +local BUILDCAT_PRODUCTION = Spring.I18N("ui.buildMenu.category_production") local categories = { BUILDCAT_ECONOMY, From 5e79e78b65b77900666af938349270950094758f Mon Sep 17 00:00:00 2001 From: Floris Date: Thu, 26 Dec 2024 00:07:38 +0100 Subject: [PATCH 15/21] added armseadragon to nonukes modoption list --- gamedata/alldefs_post.lua | 77 ++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/gamedata/alldefs_post.lua b/gamedata/alldefs_post.lua index 6c05ff82e1..76d9879f33 100644 --- a/gamedata/alldefs_post.lua +++ b/gamedata/alldefs_post.lua @@ -263,6 +263,7 @@ function UnitDef_Post(name, uDef) armamd = true, armsilo = true, armscab = true, + armseadragon = true, corfmd = true, corsilo = true, cormabm = true, @@ -328,14 +329,14 @@ function UnitDef_Post(name, uDef) uDef.buildoptions[numBuildoptions + 1] = "comeffigylvl1" end end - - if modOptions.evocom then + + if modOptions.evocom then if uDef.customparams.evocomlvl or name == "armcom" or name == "corcom" or name == "legcom" then local comLevel = uDef.customparams.evocomlvl if modOptions.comrespawn == "all" or modOptions.comrespawn == "evocom" then--add effigy respawning, if enabled uDef.customparams.respawn_condition = "health" - + local numBuildoptions = #uDef.buildoptions if comLevel == 2 then uDef.buildoptions[numBuildoptions + 1] = "comeffigylvl1" @@ -351,13 +352,13 @@ function UnitDef_Post(name, uDef) end uDef.customparams.combatradius = 0 uDef.customparams.evolution_health_transfer = "percentage" - + if uDef.power then uDef.power = uDef.power/modOptions.evocomxpmultiplier else uDef.power = ((uDef.metalcost+(uDef.energycost/60))/modOptions.evocomxpmultiplier) end - + if name == "armcom" then uDef.customparams.evolution_target = "armcomlvl2" uDef.customparams.inheritxpratemultiplier = 0.5 @@ -374,7 +375,7 @@ function UnitDef_Post(name, uDef) if modOptions.evocomlevelupmethod == "dynamic" then uDef.customparams.evolution_condition = "power" - uDef.customparams.evolution_power_multiplier = 1 -- Scales the power calculated based on your own combined power. + uDef.customparams.evolution_power_multiplier = 1 -- Scales the power calculated based on your own combined power. local evolutionPowerThreshold = uDef.customparams.evolution_power_threshold or 10000 --sets threshold for level 1 commanders uDef.customparams.evolution_power_threshold = evolutionPowerThreshold*modOptions.evocomlevelupmultiplier elseif modOptions.evocomlevelupmethod == "timed" then @@ -760,7 +761,7 @@ function UnitDef_Post(name, uDef) ---------------------------------------------------------------------- -- CATEGORY ASSIGNER ---------------------------------------------------------------------- - + -- uDef.movementclass lists local hoverList = { HOVER2 = true, @@ -768,7 +769,7 @@ function UnitDef_Post(name, uDef) HHOVER4 = true, HOVER5 = true } - + local shipList = { BOAT3 = true, BOAT4 = true, @@ -776,12 +777,12 @@ function UnitDef_Post(name, uDef) BOAT8 = true, EPICSHIP = true } - + local subList = { UBOAT4 = true, EPICSUBMARINE = true } - + local amphibList = { VBOT5 = true, COMMANDERBOT = true, @@ -798,12 +799,12 @@ function UnitDef_Post(name, uDef) COMMANDERBOT = true, SCAVCOMMANDERBOT = true } - + local categories = {} -- Manual categories: OBJECT T4AIR LIGHTAIRSCOUT GROUNDSCOUT RAPTOR -- Deprecated caregories: BOT TANK PHIB NOTLAND SPACE - + categories["ALL"] = function() return true end categories["MOBILE"] = function(uDef) return uDef.speed and uDef.speed > 0 end categories["NOTMOBILE"] = function(uDef) return not categories.MOBILE(uDef) end @@ -822,7 +823,7 @@ function UnitDef_Post(name, uDef) categories["MINE"] = function(uDef) return uDef.weapondefs and uDef.weapondefs.minerange end categories["COMMANDER"] = function(uDef) return commanderList[uDef.movementclass] end categories["EMPABLE"] = function(uDef) return categories.SURFACE(uDef) and uDef.customparams and uDef.customparams.paralyzemultiplier ~= 0 end - + uDef.category = uDef.category or "" if not string.find(uDef.category, "OBJECT") then -- objects should not be targetable and therefore are not assigned any other category for categoryName, condition in pairs(categories) do @@ -841,7 +842,7 @@ function UnitDef_Post(name, uDef) uDef.collide = false end end - + if uDef.metalcost and uDef.health and uDef.canmove == true and uDef.mass == nil then local healthmass = math.ceil(uDef.health/6) uDef.mass = math.max(uDef.metalcost, healthmass) @@ -885,12 +886,12 @@ function UnitDef_Post(name, uDef) uDef.weapondefs.stiletto_bomb.burstrate = 0.3333 uDef.weapondefs.stiletto_bomb.edgeeffectiveness = 0.30 uDef.weapondefs.stiletto_bomb.damage.default = 3000 - uDef.weapondefs.stiletto_bomb.paralyzetime = 1 + uDef.weapondefs.stiletto_bomb.paralyzetime = 1 end if name == "armspid" then - uDef.weapondefs.spider.paralyzetime = 2 - uDef.weapondefs.spider.damage.vtol = 100 + uDef.weapondefs.spider.paralyzetime = 2 + uDef.weapondefs.spider.damage.vtol = 100 uDef.weapondefs.spider.damage.default = 600 uDef.weapondefs.spider.reloadtime = 1.495 end @@ -942,10 +943,10 @@ function UnitDef_Post(name, uDef) uDef.weapondefs.empmissile.areaofeffect = 250 uDef.weapondefs.empmissile.edgeeffectiveness = -0.50 uDef.weapondefs.empmissile.damage.default = 20000 - uDef.weapondefs.empmissile.paralyzetime = 5 + uDef.weapondefs.empmissile.paralyzetime = 5 uDef.weapondefs.emp.damage.default = 200 uDef.weapondefs.emp.reloadtime = .5 - uDef.weapondefs.emp.paralyzetime = 1 + uDef.weapondefs.emp.paralyzetime = 1 end if name == "corbw" then @@ -956,9 +957,9 @@ function UnitDef_Post(name, uDef) --uDef.weapondefs.bladewing_lyzer.beamdecay = 0.5 --uDef.weapondefs.bladewing_lyzer.beamtime = 0.03 --uDef.weapondefs.bladewing_lyzer.beamttl = 0.4 - + uDef.weapondefs.bladewing_lyzer.damage.default = 300 - uDef.weapondefs.bladewing_lyzer.paralyzetime = 1 + uDef.weapondefs.bladewing_lyzer.paralyzetime = 1 end @@ -969,15 +970,15 @@ function UnitDef_Post(name, uDef) if (name == "armvulc" or name == "corbuzz" or name == "legstarfall" or name == "corsilo" or name == "armsilo") then uDef.customparams.paralyzemultiplier = 2 end - + --if name == "corsumo" then --uDef.customparams.paralyzemultiplier = 0.9 --end - + if name == "armmar" then uDef.customparams.paralyzemultiplier = 0.8 end - + if name == "armbanth" then uDef.customparams.paralyzemultiplier = 1.6 end @@ -988,19 +989,19 @@ function UnitDef_Post(name, uDef) --if name == "armvang" then --uDef.customparams.paralyzemultiplier = 1.1 --end - + --if name == "armlun" then --uDef.customparams.paralyzemultiplier = 1.05 --end - + --if name == "corshiva" then --uDef.customparams.paralyzemultiplier = 1.1 --end - + --if name == "corcat" then --uDef.customparams.paralyzemultiplier = 1.05 --end - + --if name == "corkarg" then --uDef.customparams.paralyzemultiplier = 1.2 --end @@ -1325,14 +1326,14 @@ function UnitDef_Post(name, uDef) end uDef.customparams.vertdisp = 1.0 * vertexDisplacement uDef.customparams.healthlookmod = 0 - + -- Animation Cleanup - if modOptions.animationcleanup then - if uDef.script then + if modOptions.animationcleanup then + if uDef.script then local oldscript = uDef.script:lower() - if oldscript:find(".cob", nil, true) and (not oldscript:find("_clean.", nil, true)) then + if oldscript:find(".cob", nil, true) and (not oldscript:find("_clean.", nil, true)) then local newscript = string.sub(oldscript, 1, -5) .. "_clean.cob" - if VFS.FileExists('scripts/'..newscript) then + if VFS.FileExists('scripts/'..newscript) then Spring.Echo("Using new script for", name, oldscript, '->', newscript) uDef.script = newscript else @@ -1341,7 +1342,7 @@ function UnitDef_Post(name, uDef) end end end - + end local function ProcessSoundDefaults(wd) @@ -1388,7 +1389,7 @@ function WeaponDef_Post(name, wDef) if not SaveDefsToCustomParams then -------------- EXPERIMENTAL MODOPTIONS - + -- Standard Gravity local gravityOverwriteExemptions = { --add the name of the weapons (or just the name of the unit followed by _ ) to this table to exempt from gravity standardization. 'cormship_', 'armmship_' @@ -1406,8 +1407,8 @@ function WeaponDef_Post(name, wDef) wDef.mygravity = 0.1445 end end - - -- Accurate Lasers + + -- Accurate Lasers if modOptions.accuratelasers then if wDef.weapontype and wDef.weapontype == 'BeamLaser' then wDef.targetmoveerror = nil @@ -1486,7 +1487,7 @@ function WeaponDef_Post(name, wDef) -- VTOL's may or may not do full damage to shields if not defined in weapondefs local vtolShieldDamageMultiplier = 0 - local shieldCollisionExemptions = { --add the name of the weapons (or just the name of the unit followed by _ ) to this table to exempt from shield collision. + local shieldCollisionExemptions = { --add the name of the weapons (or just the name of the unit followed by _ ) to this table to exempt from shield collision. 'corsilo_', 'armsilo_', 'armthor_empmissile', 'armemp_', 'cortron_', 'corjuno_', 'armjuno_' } From 19a5ad0488a2391d3ce0ac4dcf2f7922c0ac2fac Mon Sep 17 00:00:00 2001 From: Floris Date: Thu, 26 Dec 2024 00:15:04 +0100 Subject: [PATCH 16/21] added cordesolator to nonukes modoption list --- gamedata/alldefs_post.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/gamedata/alldefs_post.lua b/gamedata/alldefs_post.lua index 76d9879f33..98277e7d04 100644 --- a/gamedata/alldefs_post.lua +++ b/gamedata/alldefs_post.lua @@ -264,6 +264,7 @@ function UnitDef_Post(name, uDef) armsilo = true, armscab = true, armseadragon = true, + cordesolator = true, corfmd = true, corsilo = true, cormabm = true, From ae92c85e19a069c6966d8cc6edbcfab71eff86aa Mon Sep 17 00:00:00 2001 From: kroIya <95887841+kroIya@users.noreply.github.com> Date: Thu, 26 Dec 2024 13:15:11 +0200 Subject: [PATCH 17/21] Allow gui_advplayerslist to display negative handicap (#4067) --- luaui/Widgets/gui_advplayerslist.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/luaui/Widgets/gui_advplayerslist.lua b/luaui/Widgets/gui_advplayerslist.lua index 991c7f6d17..1422162a6e 100644 --- a/luaui/Widgets/gui_advplayerslist.lua +++ b/luaui/Widgets/gui_advplayerslist.lua @@ -2626,9 +2626,14 @@ function DrawName(name, team, posY, dark, playerID, desynced) if desynced then font2:SetTextColor(1,0.45,0.45,1) font2:Print(Spring.I18N('ui.playersList.desynced'), m_name.posX + widgetPosX + 5 + xPadding + (font2:GetTextWidth(nameText)*14), posY + (5.7*playerScale) , 8, "o") - elseif player[playerID] and not player[playerID].dead and player[playerID].incomeMultiplier and player[playerID].incomeMultiplier > 1 then - font2:SetTextColor(0.5,1,0.5,1) - font2:Print('+'..math.floor((player[playerID].incomeMultiplier-1)*100)..'%', m_name.posX + widgetPosX + 5 + xPadding + (font2:GetTextWidth(nameText)*14), posY + (5.7*playerScale) , 8, "o") + elseif player[playerID] and not player[playerID].dead and player[playerID].incomeMultiplier and player[playerID].incomeMultiplier ~= 1 then + if player[playerID].incomeMultiplier > 1 then + font2:SetTextColor(0.5,1,0.5,1) + font2:Print('+'..math.floor((player[playerID].incomeMultiplier-1)*100)..'%', m_name.posX + widgetPosX + 5 + xPadding + (font2:GetTextWidth(nameText)*14), posY + (5.7*playerScale) , 8, "o") + else + font2:SetTextColor(1,0.5,0.5,1) + font2:Print(math.floor((player[playerID].incomeMultiplier-1)*100)..'%', m_name.posX + widgetPosX + 5 + xPadding + (font2:GetTextWidth(nameText)*14), posY + (5.7*playerScale) , 8, "o") + end end font2:End() From 4b99efbd21a78bfed5932ef6cfbfa7caa7b0f8bc Mon Sep 17 00:00:00 2001 From: saurtron Date: Thu, 26 Dec 2024 13:02:49 +0100 Subject: [PATCH 18/21] cmd_context_build: Avoid lua error because of missing hardcoded unitdefs. (#4078) --- luaui/Widgets/cmd_context_build.lua | 39 ++++++++++++++++++----------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/luaui/Widgets/cmd_context_build.lua b/luaui/Widgets/cmd_context_build.lua index 744ff10b2d..0cb7ea107e 100644 --- a/luaui/Widgets/cmd_context_build.lua +++ b/luaui/Widgets/cmd_context_build.lua @@ -22,6 +22,8 @@ end local isPregame = Spring.GetGameFrame() == 0 and not isSpec +local uDefNames = UnitDefNames + local GetActiveCommand = Spring.GetActiveCommand local SetActiveCommand = Spring.SetActiveCommand local spGetMouseState = Spring.GetMouseState @@ -283,6 +285,28 @@ function widget:GameStart() isPregame = false end +local function addUnitDefPair(firstUnitName, lastUnitName) + local firstUnitDef = uDefNames[firstUnitName] + local lastUnitDef = uDefNames[lastUnitName] + + if not (firstUnitDef and lastUnitDef and firstUnitDef.id and lastUnitDef.id) then + Spring.Echo(string.format("%s: can't add %s/%s pair", "cmd_context_build", firstUnitName, lastUnitName)) + return + end + + for i, unitDef in ipairs({firstUnitDef, lastUnitDef}) do + local unitDefID = unitDef.id + local isWater = i % 2 == 0 + + -- Break the unit list into two matching arrays + if isWater then + table.insert(waterBuildings, unitDefID) + else + table.insert(groundBuildings, unitDefID) + end + end +end + function widget:Initialize() if Spring.IsReplay() or Spring.GetGameFrame() > 0 then maybeRemoveSelf() @@ -295,20 +319,7 @@ function widget:Initialize() end - local uDefNames = UnitDefNames for _,unitNames in ipairs(unitlist) do - for i, unitName in ipairs(unitNames) do - local unitDefID = uDefNames[unitName].id - local isWater = i % 2 == 0 - - -- Break the unit list into two matching arrays - if unitDefID then - if isWater then - table.insert(waterBuildings, unitDefID) - else - table.insert(groundBuildings, unitDefID) - end - end - end + addUnitDefPair(unitNames[1], unitNames[2]) end end From c105923f9a88da96c60952637b58474914c51424 Mon Sep 17 00:00:00 2001 From: Beherith Date: Thu, 26 Dec 2024 15:11:39 +0100 Subject: [PATCH 19/21] jitter timer draw draw/sim histogram (#4080) --- luaui/Widgets/dbg_jitter_timer.lua | 38 +++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/luaui/Widgets/dbg_jitter_timer.lua b/luaui/Widgets/dbg_jitter_timer.lua index 702b9c3a15..10a749c22b 100644 --- a/luaui/Widgets/dbg_jitter_timer.lua +++ b/luaui/Widgets/dbg_jitter_timer.lua @@ -47,6 +47,7 @@ local drawframeload = 0 local gameframespread = 0 local drawframespread = 0 +local drawcounthist = {} local function Loadms(millisecs, spread) if spread ~= nil then millisecs = millisecs + math.min(10*spread, -1.0 * spread * math.log(1.0 - math.random())) end @@ -161,6 +162,7 @@ function widget:DrawScreen() elseif drawpersimframe ==4 then CTOError = 8 * math.min(math.min(math.abs(fto-0.25), math.abs(fto -0.5)), math.min(math.abs(fto), math.abs(fto-0.75))) end + drawcounthist[actualdrawspergameframe] = (drawcounthist[actualdrawspergameframe] or 0) + 1 --Spring.Echo(Spring.GetGameFrame(), fto, CTOError) gl.PushMatrix() @@ -175,21 +177,35 @@ function widget:DrawScreen() gl.Color(0.0, 0.5, 0.0, 1.0) gl.Rect(viewSizeX - (timerwidth*0.5),viewSizeY - timerYoffset ,viewSizeX + timerwidth * 0.5 - (timerwidth * (1.0 - spreadCTO)),viewSizeY - timerYoffset + timerheight / 2); - - - + local text = '' gl.Color(1.0, 1.0, 1.0, 1.0) - gl.Text(string.format("DrawFrame FTODelta = %.3f FTO = %.3f", currCTOdelta, fto), viewSizeX - timerwidth, viewSizeY - timerYoffset, 16, "d") - - gl.Text(string.format("deltajitter = %.3f d/s = %d", deltajitter * 30, actualdrawspergameframe), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight - 16, 16, "d") - gl.Text(string.format("mean jitter = %.3f ", avgjitter* 30), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight-32, 16, "d") - - gl.Text(string.format("averageCTO = %.3f, spreadCTO = %.3f ", averageCTO, spreadCTO ), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight-48, 16, "d") + text = text .. string.format("DrawFrame FTODelta = %.3f FTO = %.3f\n", currCTOdelta, fto) + local drawhisttotal = math.max(1,( + (drawcounthist[1] or 0 ) + (drawcounthist[2] or 0 ) + (drawcounthist[3] or 0) + (drawcounthist[4] or 0 ) ) ) + text = text .. string.format("dshist [1:%d, 2:%d, 3:%d, 4:%d, 5:%d, 6:%d] \n", + (drawcounthist[1] or 0) , + (drawcounthist[2] or 0) , + (drawcounthist[3] or 0) , + (drawcounthist[4] or 0) , + (drawcounthist[5] or 0) , + (drawcounthist[6] or 0) ) + text = text .. string.format("deltajitter = %.3f d/s = %d\n", deltajitter * 30, actualdrawspergameframe) + text = text .. string.format("mean jitter = %.3f \n", avgjitter* 30) + text = text .. string.format("averageCTO = %.3f, spreadCTO = %.3f \n", averageCTO, spreadCTO ) + text = text .. string.format("CamJitter = %.3f \n",camerarelativejitter) + text = text .. string.format("DrawFrame = %d \n",Spring.GetDrawFrame()) + gl.Text(text, viewSizeX - timerwidth, viewSizeY - timerYoffset + 48, 16, "d") + --gl.Text(string.format("DrawFrame FTODelta = %.3f FTO = %.3f", currCTOdelta, fto), viewSizeX - timerwidth, viewSizeY - timerYoffset, 16, "d") + + --gl.Text(string.format("deltajitter = %.3f d/s = %d", deltajitter * 30, actualdrawspergameframe), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight - 16, 16, "d") + --gl.Text(string.format("mean jitter = %.3f ", avgjitter* 30), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight-32, 16, "d") + + --gl.Text(string.format("averageCTO = %.3f, spreadCTO = %.3f ", averageCTO, spreadCTO ), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight-48, 16, "d") --gl.Text(string.format("CamSpread = %.3f, CamMean = %.3f deltacam = %.3f jitter = %.3f",cammovespread, cammovemean, deltacam,camerarelativejitter), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight-84, 16, "d") - gl.Text(string.format("CamJitter = %.3f",camerarelativejitter), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight-84, 16, "d") - gl.Text(string.format("DrawFrame = %d",Spring.GetDrawFrame()), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight-116, 32, "d") + --gl.Text(string.format("CamJitter = %.3f",camerarelativejitter), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight-84, 16, "d") + --gl.Text(string.format("DrawFrame = %d",Spring.GetDrawFrame()), viewSizeX - timerwidth, viewSizeY - timerYoffset + timerheight-116, 32, "d") gl.Color(1.0, 1.0, 1.0, 1.0) gl.PopMatrix() From 03b6a182096070df2ff1cf8618c4d6206b396bd0 Mon Sep 17 00:00:00 2001 From: saurtron Date: Thu, 26 Dec 2024 19:08:12 +0100 Subject: [PATCH 20/21] cmd_share_unit: Don't crash when hovering over a unit in front of sky. (#4079) --- luaui/Widgets/cmd_share_unit.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/luaui/Widgets/cmd_share_unit.lua b/luaui/Widgets/cmd_share_unit.lua index afdb4a63f3..38e213585f 100644 --- a/luaui/Widgets/cmd_share_unit.lua +++ b/luaui/Widgets/cmd_share_unit.lua @@ -130,7 +130,11 @@ local function getMouseTargetPosition() return mouseTarget[1], mouseTarget[2], mouseTarget[3] elseif mouseTargetType == "unit" then local _, coordinates = TraceScreenRay(mx, my, true) - return coordinates[1], coordinates[2], coordinates[3], mouseTarget + if coordinates then + return coordinates[1], coordinates[2], coordinates[3], mouseTarget + else + return nil, nil, nil, mouseTarget + end elseif mouseTargetType == "feature" then local _, coordinates = TraceScreenRay(mx, my, true) if coordinates then @@ -285,7 +289,7 @@ local function getSelectedTeam() local tx, ty, tz, targetUnitID = getMouseTargetPosition() - if (not tx) then + if (not tx and not targetUnitID) then return nil end From 590c3c88942066300530f95be73453dfa1dda467 Mon Sep 17 00:00:00 2001 From: saurtron Date: Thu, 26 Dec 2024 19:08:55 +0100 Subject: [PATCH 21/21] gui_transport_weight_limit: Fix typo later causing lua crash. (#4081) Fix typo at gui_transport_weight_limit later causing lua crash. --- luaui/Widgets/gui_transport_weight_limit.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luaui/Widgets/gui_transport_weight_limit.lua b/luaui/Widgets/gui_transport_weight_limit.lua index 6761d8622b..770e624cb4 100644 --- a/luaui/Widgets/gui_transport_weight_limit.lua +++ b/luaui/Widgets/gui_transport_weight_limit.lua @@ -110,8 +110,8 @@ function widget:SelectionChanged(sel) elseif selectedUnitsCount > 1 then for i = 1, #selectedUnits do local unitID = selectedUnits[i] - local unitdefID = Spring.GetUnitDefID(unitID) - if validTrans[unitdefID] then + local unitDefID = Spring.GetUnitDefID(unitID) + if validTrans[unitDefID] then transID = unitID transDefID = unitDefID unitcount = unitcount + 1