Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Changed things to do with Shroud to WRange. Updated Utility. #4694

Merged
merged 4 commits into from Mar 6, 2014

Conversation

Unit158
Copy link
Contributor

@Unit158 Unit158 commented Feb 21, 2014

Closes #4679

@Unit158
Copy link
Contributor Author

Unit158 commented Feb 21, 2014

wot

Trike has 2c0, when compared to the 2c512 of the soldier, stuff looks a lot nicer now.

@@ -24,6 +24,7 @@ public struct WPos
public WPos(WRange x, WRange y, WRange z) { X = x.Range; Y = y.Range; Z = z.Range; }

public static readonly WPos Zero = new WPos(0, 0, 0);
public static WPos FromCPos(CPos cell) { return new WPos(cell.X, cell.Y, 0); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the definition of our coordinate system. There is a scaling factor and offset between cell and world units, so you can't just convert between the two like this. Use CPos.CenterPosition instead.

@Unit158
Copy link
Contributor Author

Unit158 commented Feb 22, 2014

I swear I fixed that first one earlier today, maybe I just forgot to push.

@Unit158
Copy link
Contributor Author

Unit158 commented Feb 23, 2014

test
This is what happens when the following snippet

        static IEnumerable<CPos> FindVisibleTiles(World world, CPos position, WRange radius)
        {
            var r = (radius.Range + 1023) / 1024;
            var min = position - new CVec(r, r);
            var max = position + new CVec(r, r);

            if (min.X < world.Map.Bounds.Left - 1)
                min = new CPos(world.Map.Bounds.Left - 1, min.Y);

            if (min.Y < world.Map.Bounds.Top - 1)
                min = new CPos(min.X, world.Map.Bounds.Top - 1);

            if (max.X > world.Map.Bounds.Right)
                max = new CPos(world.Map.Bounds.Right + 1, max.Y);

            if (max.Y > world.Map.Bounds.Bottom)
                max = new CPos(max.X, world.Map.Bounds.Bottom + 1);

            var circleArea = r * r;
            for (var j = min.Y; j <= max.Y; j++)
                for (var i = min.X; i <= max.X; i++)
                    if (circleArea >= (new CPos(i, j) - position).LengthSquared)
                        yield return new CPos(i, j);
        }

Trike is 2c1, infantry is 3c512. I also changed infantry to 2c512 and the shroud rendered in what looked like a 3x3 square.

@pchote
Copy link
Member

pchote commented Feb 23, 2014

Your strange reveal circles are because your final filtering check is done in cell units.

The circleArea >= (new CPos(i, j) - position).LengthSquared line needs to change to something like (new CPos(i, j).CenterPosition - position.CenterPosition).LengthSquared <= radius.Range * radius.Range. You should pull the bits that don't change (radius.Range**2 and position.CenterPosition) into variables defined outside the loop to avoid unnecessary calculations.

{
foreach (var q in FindVisibleTiles(world, center, range))
explored[q.X, q.Y] = true;

var box = new Rectangle(center.X - range, center.Y - range, 2*range + 1, 2*range + 1);
var box = new Rectangle(center.X - (range.Range / 1024), center.Y - (range.Range / 1024), 2 * (range.Range / 1024) + 1, 2 * (range.Range / 1024) + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should define a variable for range.Range / 1024 (you may also want to round up using (range.Range + 1023) / 1024) to avoid unnecessary duplication.

@pchote
Copy link
Member

pchote commented Feb 24, 2014

Good job generalizing this ugly low-level code :)

Tentative 👍 once you

  • Run Utility --upgrade-mod to fix the rules in the default mods (add the changed mod/map yamls, but ignore the .oramaps).
  • Fix or explain the change to the bounds check.
  • Fix the comment in Shrould.AddVisibility.

@pchote
Copy link
Member

pchote commented Mar 1, 2014

As we discussed in IRC last week, you will still need to remove the unrelated changes that --upgrade-mod introduced. You will also need to rebase on to the latest bleed.

This is a fundamental change, so I would like to see a :+2: from another reviewer before we merge this.

@Unit158
Copy link
Contributor Author

Unit158 commented Mar 5, 2014

Alright, I think this is finally done...

@Mailaender
Copy link
Member

👎 crashes the RA shellmap:

Platform is Linux
Using SDL 2 with OpenGL renderer
ATTENTION: default value of option force_s3tc_enable overridden by environment.
Desktop resolution: 1366x768
Using resolution: 1360x720
Using OpenAL sound engine
Using default device
Available mods:
        cnc: Tiberian Dawn ({DEV_VERSION})
        d2k: Dune 2000 ({DEV_VERSION})
        ra: Red Alert ({DEV_VERSION})
        ts: Tiberian Sun ({DEV_VERSION})
Loading mod: ts
libpng warning: iCCP: known incorrect sRGB profile
Game started
Loading mod: ra
Exception of type `System.IndexOutOfRangeException`: Array index is out of range.
  at OpenRA.Traits.Shroud.AddVisibility (OpenRA.Actor a) [0x0013f] in /home/matthias/Projekte/OpenRA/OpenRA.Game/Traits/World/Shroud.cs:115 
  at (wrapper delegate-invoke) System.Action`1<OpenRA.Actor>:invoke_void__this___T (OpenRA.Actor)
  at (wrapper delegate-invoke) System.Action`1<OpenRA.Actor>:invoke_void__this___T (OpenRA.Actor)
  at OpenRA.World.Add (OpenRA.Actor a) [0x0001b] in /home/matthias/Projekte/OpenRA/OpenRA.Game/World.cs:165 
  at OpenRA.World.CreateActor (Boolean addToWorld, System.String name, OpenRA.FileFormats.TypeDictionary initDict) [0x00012] in /home/matthias/Projekte/OpenRA/OpenRA.Game/World.cs:157 
  at OpenRA.World.CreateActor (System.String name, OpenRA.FileFormats.TypeDictionary initDict) [0x00005] in /home/matthias/Projekte/OpenRA/OpenRA.Game/World.cs:150 
  at OpenRA.Mods.RA.SpawnMapActors.WorldLoaded (OpenRA.World world, OpenRA.Graphics.WorldRenderer wr) [0x00089] in /home/matthias/Projekte/OpenRA/OpenRA.Mods.RA/SpawnMapActors.cs:35 
  at OpenRA.World.LoadComplete (OpenRA.Graphics.WorldRenderer wr) [0x00022] in /home/matthias/Projekte/OpenRA/OpenRA.Game/World.cs:145 
  at OpenRA.Game.StartGame (System.String mapUID, Boolean isShellmap) [0x0005a] in /home/matthias/Projekte/OpenRA/OpenRA.Game/Game.cs:228 
  at OpenRA.Game.LoadShellMap () [0x00007] in /home/matthias/Projekte/OpenRA/OpenRA.Game/Game.cs:406 
  at OpenRA.Mods.RA.DefaultLoadScreen.TestAndContinue () [0x0009b] in /home/matthias/Projekte/OpenRA/OpenRA.Mods.RA/DefaultLoadScreen.cs:92 
  at OpenRA.Mods.RA.DefaultLoadScreen.StartGame () [0x00002] in /home/matthias/Projekte/OpenRA/OpenRA.Mods.RA/DefaultLoadScreen.cs:76 
  at OpenRA.Game.InitializeWithMod (System.String mod, System.String replay) [0x00279] in /home/matthias/Projekte/OpenRA/OpenRA.Game/Game.cs:397 
  at OpenRA.Mods.RA.Widgets.Logic.ModBrowserLogic+<LoadMod>c__AnonStorey2.<>m__0 () [0x00018] in /home/matthias/Projekte/OpenRA/OpenRA.Mods.RA/Widgets/Logic/ModBrowserLogic.cs:54 
  at (wrapper delegate-invoke) <Module>:invoke_void__this__ ()
  at OpenRA.FileFormats.ActionQueue.PerformActions () [0x00091] in /home/matthias/Projekte/OpenRA/OpenRA.FileFormats/Primitives/ActionQueue.cs:42 
  at OpenRA.Game.Tick (OpenRA.Network.OrderManager orderManager) [0x001f6] in /home/matthias/Projekte/OpenRA/OpenRA.Game/Game.cs:160 
  at OpenRA.Game.Run () [0x0007b] in /home/matthias/Projekte/OpenRA/OpenRA.Game/Game.cs:445 
  at OpenRA.Program.Run (System.String[] args) [0x00011] in /home/matthias/Projekte/OpenRA/OpenRA.Game/Support/Program.cs:114 
  at OpenRA.Program.Main (System.String[] args) [0x0005a] in /home/matthias/Projekte/OpenRA/OpenRA.Game/Support/Program.cs:38

@Unit158
Copy link
Contributor Author

Unit158 commented Mar 5, 2014

Fixed.

@Mailaender
Copy link
Member

👍 can't find any regressions. Checked both shroud reveal and gap generator.

Mailaender added a commit that referenced this pull request Mar 6, 2014
Changed things to do with Shroud to WRange. Updated Utility. Closes #4679
@Mailaender Mailaender merged commit a980d82 into OpenRA:bleed Mar 6, 2014
@Unit158
Copy link
Contributor Author

Unit158 commented Mar 6, 2014

Yay! Finally! Anyway, I will not be able to complete the d2k updates, I think I might as well just scrap the PR, as I am no longer interested in re-balancing the mod, as no one plays it.

@pchote
Copy link
Member

pchote commented Mar 6, 2014

I think I might as well just scrap the PR, as I am no longer interested in re-balancing the mod, as no one plays it.

That would be a shame. The impression I have is that one of the main reasons people don't play D2K is that our mod plays nothing like the original, but is instead a "ra with sand" style spam-fest. I was hoping that your balance changes would address that by resetting the balance and therefore gameplay closer to the original game.

@Mailaender
Copy link
Member

Others seem to want to take on that task http://www.sleipnirstuff.com/forum/viewtopic.php?f=83&t=16465

@Unit158 Unit158 deleted the fix branch March 16, 2014 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RevealShroud is in integer units
3 participants