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

Fixed issue with unit ready when capturing #14220

Merged
merged 1 commit into from
Jan 1, 2018

Conversation

NethIafin
Copy link
Contributor

Fixes #14219 and #13983 , hopefully without breaking anything else

Issue was with Actor.ChangeOwner being always scheduled last (since it was using World.AddFrameEndTask inside World.AddFrameEndTask) Modified the code so it now accepts current frame as an optional parameter and moved the actual transition of ownership to the bottom of the code.

Now... I don't know if this is the best solution, but it feels that way. Maybe we can move more actions inside of an Actor to proper "chain" from World.AddFrameEndTask. Maybe all this is a bogus idea, and should be denied

Either way - this fixes the issue, and initial tests shown that everything else works

@NethIafin NethIafin force-pushed the EnemyUnitReady branch 2 times, most recently from b2358ff to 2154dbb Compare October 19, 2017 20:09
@@ -279,30 +279,38 @@ public void Dispose()
});
}

// TODO: move elsewhere.
public void ChangeOwner(Player newOwner)
private void ChangeOwnerInternal(Player newOwner, World world)
Copy link
Member

Choose a reason for hiding this comment

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

Explicit private should be removed.

public void ChangeOwner(Player newOwner, World externalWorld = null)
{
if (externalWorld == null)
World.AddFrameEndTask(w =>
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 add braces to the if here as the body spans over multiple lines, imho.

@@ -280,29 +280,34 @@ public void Dispose()
}

// TODO: move elsewhere.
public void ChangeOwner(Player newOwner)
public void ChangeOwner(Player newOwner, World externalWorld = null)
Copy link
Member

Choose a reason for hiding this comment

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

This change/parameter doesn't seem to be used anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Goddamm

@netnazgul
Copy link
Contributor

So, now captured player will be punished twice - losing his building and producing a unit for enemy?

Also, what if player has multiple production buildings of that type and switches priority before the unit is finished?

Overall I'd suggest just destroying unit whatsoever instead of transferring ownership.

@NethIafin
Copy link
Contributor Author

@netnazgul it does not give unit to the player. If that was your last Barr or WF you lose the unit and unit queue, but refund your money. If this is not your only production building of this type, most likely you already produced it from another building

@netnazgul
Copy link
Contributor

Totally fine then

@NethIafin
Copy link
Contributor Author

can someone review this? @pchote @penev92 @MustaphaTR

@GraionDilach
Copy link
Contributor

See #11987 (comment) why this is a bad idea.

In any case, the issues feel like sideeffects of that goddamned hardcoded lock mechanism and that should be axed in favor of conditions or something, the power refactor should have brought in the necessary prerequisites.

@pchote
Copy link
Member

pchote commented Dec 29, 2017

IMO that example actually demonstrates why this is a good idea.

Right now ExternalCapture/Production is not robust against the order that notifications are called, which leads to #14219. A less invasive mod-level fix would be to wrap everything after the ChangeOwner in another FrameEndTask, but the fix here makes for cleaner code and logic. Because we are already inside a FrameEndTask there is no need to add an extra level or indirection.

@pchote pchote modified the milestone: Next release Dec 29, 2017
pchote
pchote previously approved these changes Dec 29, 2017
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, just two minor style nits.

To other reviewers: Add ?w=1 to the url to see that this is doesn't change anything outside the ExternalCapture case.


var oldOwner = Owner;
var wasInWorld = IsInWorld;
public void ChangeOwnerSync(Player newOwner, World world)
Copy link
Member

Choose a reason for hiding this comment

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

Style nit: we tend to put World first in methods like this.

@@ -284,25 +284,30 @@ public void ChangeOwner(Player newOwner)
{
World.AddFrameEndTask(w =>
Copy link
Member

Choose a reason for hiding this comment

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

Style nit: omit the braces for single line statements: World.AddFrameEndTask(w => ChangeOwnerSync(w, newOwner));

@pchote
Copy link
Member

pchote commented Dec 29, 2017

This is a pretty straightforward bug fix, so i'd like to get this in for the playtest. I won't add it to the milestone though, as I don't want to force delaying that any longer.

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.

I pushed a fixup with my requests above. LGTM now

Copy link
Contributor

@GraionDilach GraionDilach left a comment

Choose a reason for hiding this comment

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

Ah, I can see now why this will work - that call was already within a FrameEndTask by then.

LGTM.

@pchote pchote merged commit 11db40a into OpenRA:bleed Jan 1, 2018
@MustaphaTR
Copy link
Member

MustaphaTR commented Jan 2, 2018

Errm, isn't this PR meant to cancel the unit when the capture is done. Not tested on main mods yet, but on my mod (rebased it to bleed today), i'm getting enemy units while tring to capture them. Maybe related to ClassicProduction -> NormalProduction. I'll test on RA too.

@MustaphaTR
Copy link
Member

Can not confirm on RA, but TD (after changing capturing to External). Looks like indeed something to do with Normal Production.

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.

Enemy unit exits captured WF
6 participants