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

Added buildradius checkbox to lobby options #14209

Merged
merged 1 commit into from Nov 1, 2017
Merged

Added buildradius checkbox to lobby options #14209

merged 1 commit into from Nov 1, 2017

Conversation

ghost
Copy link

@ghost ghost commented Oct 18, 2017

Implements #14203

@ghost
Copy link
Author

ghost commented Oct 18, 2017

sorry about dune2k commits, I do not know alot about it

@@ -164,7 +164,7 @@ public Actor FindBaseProvider(World world, Player p, CPos topLeft)

// Range is counted from the center of the actor, not from each cell.
var target = Target.FromPos(bp.Actor.CenterPosition);
if (target.IsInRange(center, bp.Trait.Info.Range))
if (target.IsInRange(center, bp.Trait.Info.Range) || !world.WorldActor.Trait<MapBuildRadius>().BuildRadiusEnabled)
Copy link
Member

Choose a reason for hiding this comment

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

We already query the MapBuildRadius trait above and should 'cache' it therefore, imho.
I.e. something like:

public Actor FindBaseProvider(World world, Player p, CPos topLeft)
{
	var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world);
	var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>();
	var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled;

	foreach (var bp in world.ActorsWithTrait<BaseProvider>())
	{
		[...]

		if (mapBuildRadius.BuildRadiusEnabled || target.IsInRange(center, bp.Trait.Info.Range))
			return bp.Actor;
	}

	return null;
}

@@ -45,6 +54,8 @@ void INotifyCreated.Created(Actor self)
{
AllyBuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
.OptionOrDefault("allybuild", info.AllyBuildRadiusEnabled);
BuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
.OptionOrDefault("buildradius", info.BuildRadiusEnabled);
Copy link
Member

Choose a reason for hiding this comment

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

Those spaces should be replaced by tabs.

@@ -80,7 +80,7 @@ bool ValidRenderPlayer()
public IEnumerable<IRenderable> RangeCircleRenderables(WorldRenderer wr)
{
// Visible to player and allies
if (!ValidRenderPlayer())
if (!ValidRenderPlayer() || !wr.World.WorldActor.Trait<MapBuildRadius>().BuildRadiusEnabled)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should cache BuildRadiusEnabled here as well as AllyBuildEnabled is already. (Also see the comment below.)

@abcdefg30
Copy link
Member

sorry about dune2k commits, I do not know alot about it

Don't worry. ^^ Just squash the commits together later on.
(Btw, if you got questions, feel free to reach out to me or someone else on our IRC channel #openra.)

@GraionDilach
Copy link
Contributor

This is fundamentally wrong and suffers from tunnel vision - the ticket would be the perfect case to be resolved akin with a mutator, since you're now propagating a trait used in a single mod to be disabled in every shipped and thirdparty one (you can't really disable lobby checkboxes).

@ghost
Copy link
Author

ghost commented Oct 18, 2017

is tarvis-ci failing at getting mono usual?

@pchote
Copy link
Member

pchote commented Oct 18, 2017

is tarvis-ci failing at getting mono usual?

No, this appears to be an upstream issue. I assume that they should fix it within a day or two.
In any case, the tests would fail because you're still using space indentation in a few places. Can you please fix that?

pchote
pchote previously requested changes Oct 18, 2017
@@ -48,6 +48,11 @@ Background@LOBBY_OPTIONS_BIN:
Width: 150
Height: 20
Text: Debug Menu
Checkbox@BUILDRADIUS_CHECKBOX:
Copy link
Member

Choose a reason for hiding this comment

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

Tiberian Sun doesn't include the base radius, so can you please duplicate the lobby-options.yaml into mods/ts/chrome and adjust its mod.yaml to use it, the same way d2k does?

Width: 150
Height: 20
Font: Regular
Text: Build Radius
Copy link
Member

Choose a reason for hiding this comment

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

"Build Radius" isn't a very obvious name. Can we change this to something like "Limit ConYard Area"?

@@ -46,6 +47,7 @@ public BaseProvider(Actor self, BaseProviderInfo info)
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
progress = total = info.InitialDelay;
allyBuildEnabled = self.World.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
buildRadiusEnabled = self.World.WorldActor.Trait<MapBuildRadius>().BuildRadiusEnabled;
Copy link
Member

Choose a reason for hiding this comment

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

Space indentation.

@@ -154,7 +154,9 @@ public WVec CenterOffset(World w)
public Actor FindBaseProvider(World world, Player p, CPos topLeft)
{
var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world);
var allyBuildEnabled = world.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>();
Copy link
Member

Choose a reason for hiding this comment

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

Space indentation.

@@ -45,6 +54,8 @@ void INotifyCreated.Created(Actor self)
{
AllyBuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
.OptionOrDefault("allybuild", info.AllyBuildRadiusEnabled);
BuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
.OptionOrDefault("buildradius", info.BuildRadiusEnabled);
Copy link
Member

Choose a reason for hiding this comment

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

Space indentation.

@pchote
Copy link
Member

pchote commented Oct 18, 2017

Looks good to me, otherwise.

@ghost
Copy link
Author

ghost commented Oct 18, 2017

fixing in few moments, there are no spacing problems on my local files

@pchote
Copy link
Member

pchote commented Oct 18, 2017

Sorry for the about face, but can you please duplicate the options yaml for ra instead of ts and keep the common copy unmodified? As @GraionDilach mentioned this probably doesnt want to be forced on downstream mods

@ghost
Copy link
Author

ghost commented Oct 18, 2017

@pchote done and working

Copy link
Member

@pchote pchote left a comment

Choose a reason for hiding this comment

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

Looks better, thanks. There are a couple more minor changes you can do to improve performance:

@@ -46,6 +47,7 @@ public BaseProvider(Actor self, BaseProviderInfo info)
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
progress = total = info.InitialDelay;
allyBuildEnabled = self.World.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
buildRadiusEnabled = self.World.WorldActor.Trait<MapBuildRadius>().BuildRadiusEnabled;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can you please define a var mapBuildRadius = self.World.WorldActor.Trait<MapBuildRadius>(); instead of doing two trait lookups?

@@ -80,7 +82,7 @@ bool ValidRenderPlayer()
public IEnumerable<IRenderable> RangeCircleRenderables(WorldRenderer wr)
{
// Visible to player and allies
if (!ValidRenderPlayer())
if (!ValidRenderPlayer() || !buildRadiusEnabled)
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to put this in ValidRenderPlayer so that it also applies to the selection bar.

@@ -164,7 +166,7 @@ public Actor FindBaseProvider(World world, Player p, CPos topLeft)

// Range is counted from the center of the actor, not from each cell.
var target = Target.FromPos(bp.Actor.CenterPosition);
if (target.IsInRange(center, bp.Trait.Info.Range))
if (target.IsInRange(center, bp.Trait.Info.Range) || !buildRadiusEnabled)
Copy link
Member

Choose a reason for hiding this comment

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

Please change this to return null before the loop if !buildRadiusEnabled, and then:

  1. Query MapBuildRadius in the Building constructor and store the result in a readonly bool buildRadiusEnabled.
  2. Check that value in IsCloseEnoughToBase to avoid calling this method entirely.

@@ -74,7 +78,7 @@ public bool Ready()

bool ValidRenderPlayer()
{
return self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer));
return buildRadiusEnabled ? self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)) : false;
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be simplified to return buildRadiusEnabled && (self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)));.

@@ -38,14 +39,17 @@ public class BaseProvider : ITick, INotifyCreated, IRenderAboveShroudWhenSelecte
int total;
int progress;
bool allyBuildEnabled;
bool buildRadiusEnabled;
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why this is not readonly?

Copy link
Author

Choose a reason for hiding this comment

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

Its not because allyBuildEnabled is not

Copy link
Member

Choose a reason for hiding this comment

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

Hm, I think you should make both readonly then. ^^
(They only get a value assigned in the constructor.)

@ghost
Copy link
Author

ghost commented Oct 19, 2017

Is this better?

Copy link
Member

@abcdefg30 abcdefg30 left a comment

Choose a reason for hiding this comment

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

Is this better?

Yes, just some more minor things and I hope we're done with changing the code back and forth. (Sorry for the hassle, btw...)


public BaseProvider(Actor self, BaseProviderInfo info)
{
Info = info;
this.self = self;
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
progress = total = info.InitialDelay;
allyBuildEnabled = self.World.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
mapBuildRadius = self.World.WorldActor.Trait<MapBuildRadius>();
Copy link
Member

Choose a reason for hiding this comment

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

Actually, we only use this in the constructor. So I'd suggest you make this a local var and drop the readonly MapBuildRadius mapBuildRadius;.

return self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer));
}
return buildRadiusEnabled && (self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)));
}
Copy link
Member

Choose a reason for hiding this comment

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

Somehow spaces sneaked in here again. Please change them to tabs.

@ghost
Copy link
Author

ghost commented Oct 19, 2017

@abcdefg30 done, I hope there is nothing else (expecially spaces)

Copy link
Member

@pchote pchote left a comment

Choose a reason for hiding this comment

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

LGTM aside from one last minor nit:

@@ -154,7 +154,8 @@ public WVec CenterOffset(World w)
public Actor FindBaseProvider(World world, Player p, CPos topLeft)
{
var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world);
var allyBuildEnabled = world.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>();
var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled;
Copy link
Member

Choose a reason for hiding this comment

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

Please add an

if (!mapBuildRadius)
	return null;

as there are no base providers if the build radius is disabled.

Copy link
Author

Choose a reason for hiding this comment

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

will do

@ghost
Copy link
Author

ghost commented Oct 20, 2017

@pchote is this good?

var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>();
var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled;

if (!mapBuildRadius.BuildRadiusEnabled)
Copy link
Member

Choose a reason for hiding this comment

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

These lines are now indented using spaces. Please replace them with tabs.

https://github.com/OpenRA/OpenRA/wiki/Coding-Standard includes a guide on how to configure Visual Studio to use tabs.

Copy link
Author

Choose a reason for hiding this comment

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

but I use linux

@ghost
Copy link
Author

ghost commented Oct 21, 2017

well great

Copy link
Contributor

@NethIafin NethIafin left a comment

Choose a reason for hiding this comment

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

Not a fan of this new row while there is just one item, but this works as advertised. LGTM

@pchote
Copy link
Member

pchote commented Oct 21, 2017

Not a fan of this new row while there is just one item

There are two other long thought about checkboxes that could be implemented by somebody to fill in the gaps (but certainly not in this PR!):

  • Kill bounties
  • Undeployable MCV (from the original games)

@NethIafin
Copy link
Contributor

Yeah, got it. Maybe @kosti1 can create separate pr for those, so in playtest we would have full row. Either way this is good as it is

@ghost
Copy link
Author

ghost commented Oct 22, 2017

will look in to it
I have already implemented bounty checkbox in my modded engine (but it might be very unoptimized)

@ghost ghost mentioned this pull request Oct 22, 2017
Copy link
Member

@MustaphaTR MustaphaTR left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@abcdefg30 abcdefg30 merged commit 6a750d7 into OpenRA:bleed Nov 1, 2017
@abcdefg30
Copy link
Member

Changelog

@GraionDilach
Copy link
Contributor

Congratulations to everyone for creating the worst precedent in regarding to customized lobby checkboxes! @pchote, since you were interested on the other day why I believe taht modder feedback is ignored in eaxact cases - here is one.

The CnCNetv5 client used by many TS/RA2 mods apply a rules edit behind the checkbox between the main rules and the map edits. That system should have been used here, not expanding the system with made-up arbitrary stuff.

@pchote
Copy link
Member

pchote commented Nov 1, 2017

@GraionDilach: I don't really understand your hostility towards this. This PR doesn't set a precident; it follows our conventions that were established in #11364 and prerequisite PRs. Asking a new contributor to implement a new low-level engine feature that completely changes our lobby options conventions doesn't make sense.

@GraionDilach
Copy link
Contributor

What does this PR does in effect on RA rules? Let me sum it up with two lines.

FACT:
	-BaseProvider:

Where this PR does set a precedent is that lousy hardcoded lobby checkboxes which should have been implemented via custom rules are acceptable as C# code fragments and encouraged to do so. This precedent is already utilized at #14245.

There wasn't a need to completely change the lobby options besides providing a secondary method. #9422 was filed exactly for lobby options causing this level of YAML edits. Ignoring it is convenient, blowing it to out-of-proportion levels is even more convenient - especially when one decides to ignore how CnCNet TS/YR is able to utilize said system for years now.

@penev92
Copy link
Member

penev92 commented Nov 2, 2017

OK, as for the help/feedback/attitude:

since you were interested on the other day why I believe taht modder feedback is ignored in eaxact cases - here is one.

I checked - all you said prior to merge is "this is bad". That's all the feedback.
Now, assuming you had linked to the ticket that you opened (which you didn't, so ... shame on everyone else for not making the connection?), that ticket still goes exactly ankle-deep in the issue - it more or less just says "hey guys, CnCNet use X, UT2004 uses Y; they look like this: <screenshots>". You scratch the surface of an actual explanation of implementation details but go no further.
In fact, the first time I can find you mentioning that you have an idea about how to implement it other than visually was yesterday on Discord after this PR was merged. Now that was some decent feedback, but perhaps just a tiny a bit late, no?

Now, as for the suggested implementation:

From what I've read that method sounds utterly unsupportable for more than 1 or 2 very simple mutators.
I don't know how CnCNet does it, maybe the inis there are better suited for the task, maybe it's a complete mess... but for the simplest of mutators you can easily need to have a copy of your mod's entire rules folder, just because it affects every actor you have.
So if you have 20 (again, simple mutators), you either have this folder setup in your mod:

rules_default
rules_mutator_1
rules_mutator_2
rules_mutator_3
...
rules_mutator_20

or you have these yamls in your rules folder along with all the others:

mutator1.yaml
mutator2.yaml
mutator3.yaml
...
mutator20.yaml

with each of those potentially having a 2-line entry (at best) for every actor in the mod.
I think you can see how that is going to become utterly unsupportable, unmaintainable, unmanageable...
Yes, it would be (somewhat) flexible (as long as you only want to tweak trait values, which is somewhat limited for a mutator), but the YAML overhead would be enough to completely negate any usefulness IMO.

In conclusion,

  1. I'm not saying the used approach is very good or scalable, but IMO neither is the one you're suggesting.
    and
  2. Please don't go all "I tried to help but they ignored my feedback so * them" again, since like I said, your feedback actually came after this was merged.

So how about we all do something constructive for a change and try to come up with an actually good approach together?

@MustaphaTR
Copy link
Member

MustaphaTR commented Nov 2, 2017

I think you can see how that is going to become utterly unsupportable, unmaintainable, unmanageable...

Sorry, but i can't. I agree with @GraionDilach that Mutators as CnCNet has would be way better alternative to this. I see no problem with having 20 mutator files, probably under rules/mutators folder not directly rules.

CnCNet aside even original RA2 had a similar logic, called Game Types. Only difference ypu can only appy one of those.

Plus we already have stuff like disable-player-experience or campaign-tooltip files.

@GraionDilach
Copy link
Contributor

I left a comment somewhere at @kosti1's repo on a commit weeks ago explaining this exact same thing I'm atm pissed on but apparently it was lost in a rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants