-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Conversation
b2358ff
to
2154dbb
Compare
OpenRA.Game/Actor.cs
Outdated
@@ -279,30 +279,38 @@ public void Dispose() | |||
}); | |||
} | |||
|
|||
// TODO: move elsewhere. | |||
public void ChangeOwner(Player newOwner) | |||
private void ChangeOwnerInternal(Player newOwner, World world) |
There was a problem hiding this comment.
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.
OpenRA.Game/Actor.cs
Outdated
public void ChangeOwner(Player newOwner, World externalWorld = null) | ||
{ | ||
if (externalWorld == null) | ||
World.AddFrameEndTask(w => |
There was a problem hiding this comment.
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.
2154dbb
to
d13e83e
Compare
OpenRA.Game/Actor.cs
Outdated
@@ -280,29 +280,34 @@ public void Dispose() | |||
} | |||
|
|||
// TODO: move elsewhere. | |||
public void ChangeOwner(Player newOwner) | |||
public void ChangeOwner(Player newOwner, World externalWorld = null) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goddamm
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. |
@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 |
Totally fine then |
d13e83e
to
b6de1f0
Compare
can someone review this? @pchote @penev92 @MustaphaTR |
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. |
IMO that example actually demonstrates why this is a good idea. Right now |
There was a problem hiding this 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.
OpenRA.Game/Actor.cs
Outdated
|
||
var oldOwner = Owner; | ||
var wasInWorld = IsInWorld; | ||
public void ChangeOwnerSync(Player newOwner, World world) |
There was a problem hiding this comment.
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.
OpenRA.Game/Actor.cs
Outdated
@@ -284,25 +284,30 @@ public void ChangeOwner(Player newOwner) | |||
{ | |||
World.AddFrameEndTask(w => |
There was a problem hiding this comment.
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));
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. |
There was a problem hiding this 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
There was a problem hiding this 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.
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. |
Can not confirm on RA, but TD (after changing capturing to External). Looks like indeed something to do with Normal Production. |
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