-
-
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
Move activity now uses ChildActivity #13749
Conversation
6b8117c
to
c771c3f
Compare
// will not end up in an odd place. | ||
if (ChildActivity != null) | ||
{ | ||
ActivityUtils.RunActivity(self, ChildActivity); |
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.
Shouldn't this be assigning the returned activity back to ChildActivity?
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 thought so, but in Transform.cs, they do this too.
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 looked into RunActivity and ChildActivity getting set implicitly but when I look at it now it is completely different. What did I see yesterday xD I must had been looking into something else.
Seems to be OuterTick that is doing this child activity management.
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.
https://github.com/OpenRA/OpenRA/blob/bleed/OpenRA.Game/Activities/Activity.cs#L180
I think it is wrong to do implicit management here
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 strongly think it wrong because that would prevent an activity from running multiple children activities properly. They do run, as you might see in my simultaneous reload + resupply code but ChildActivity pointer is invalid.
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.
Shouldn't this be assigning the returned activity back to ChildActivity?
You can, but it's not necessary. As forcecore found out, OuterTick
automatically makes sure that the parent's ChildActivity
pointer gets updated.
I think it is wrong to do implicit management here
It has to be done there, as there is no other place where that could happen for a CompositeActivity
. Your example shouldn't matter at all, as neither ChildActivity
nor Tick
's return value are used there. In fact, those resupplyActivities
aren't even a part of the graph, and their Parent
should be null. But let's discuss that in the other PR.
if (path != null) | ||
path.Clear(); | ||
|
||
if (keepQueue == false && NextActivity != 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.
if (!keepQueue && NextActivity != null)
// While carrying out one Move order, MoveSecondHalf finishes its work from time to time and returns null. | ||
// That causes the ChildActivity to be null and makes us return to this part of this function. | ||
// If we only queue the activity and not run it, units will pause for one tick! | ||
ActivityUtils.RunActivity(self, ChildActivity); |
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.
Likewise here?
MoveFirstHalf moves the actor from its start point (either its starting subcell or the edge of a cell for chained moves) to the edge of the next cell. MoveSecondHalf moves the actor from the edge of the cell back to a defined subcell. |
Suggestion: rename them |
I also tried to modify moveFraction to moveStep, TotalMoveFraction to TotalMoveSteps, as they have nothing to do with division. Then I changed my mind. I want to induce fewer changes so that the correctness is easier to be seen. I think it would be better to make rename PR right after this one. |
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.
Looks good so far, just one minor nit. Turning on the StrictActivityChecking
setting doesn't crash in Move
anymore, so that's a good. I'd like to do some more in-game testing, though.
path.Clear(); | ||
|
||
if (keepQueue == false && NextActivity != null) | ||
NextActivity.Cancel(self, keepQueue); |
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.
Use NextInQueue
here, not NextActivity
. You don't want to match against the parent. You can also just set it to null, it's unnecessary to cancel it.
Minor code correction reflecting comments above. |
My understanding is that @obrakmann has made some progress here, but is currently stalled on an unknown but possibly unrelated crash issue:
|
// While carrying out one Move order, MoveSecondHalf finishes its work from time to time and returns null. | ||
// That causes the ChildActivity to be null and makes us return to this part of this function. | ||
// If we only queue the activity and not run it, units will pause for one tick! | ||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity); |
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'm seeing a lot of pauses/stalls when units move, so I don't think this is sufficient to fix whatever the real problem is?
Repro case: build a ranger in RA and order it to move across the map. Works fine on bleed, unit pauses for a tick every few cells on this PR rebased against bleed.
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.
The problem might be with
If the path becomes invalid then it will stop and wait for the next tick before attempting to repath.
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.
It actually turns out that it is related to Turn child activity.
ab536f5
to
ac99ca1
Compare
Rebased to take advantage of any other Mobile related fixes. Fixed "turn pause". |
704bd8b
to
521f65d
Compare
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 have not tested this extensively (but someone else should!) but the code changes look sensible, and the basics (moving, turning, cancelling while moving or turning) all seem to work as expected.
Can you please squash your fixups in the the appropriate parent commits?
521f65d
to
d9074a2
Compare
Squashed |
I played a small test game. No crashes. It seemed at one point a stop command was ignored and the unit was accepting orders only until it moved to its destination. I don't think I can reproduce and I am not sure if that is related. It happened only once with a large group and narrow corridors so units took a detour. Looks good I guess. ✅ |
I see your bug: force fire on the ground to a place far away so that the unit will move. Then the stop order will be ignored. |
In MoveAdjacentTo (or any other activities that may use Move as its inner/Child activity), when Cancel() is called on Move, it will not think it is canceled as Move.cancel returns false. Is it possible to mark Move as "due to be canceled"? |
Sorry for the delay. The crash I encountered is also happening on bleed, just took a bit longer to appear there (~1h). |
Not currently, but I've come to realize that we need something like this. Really it's just required for |
The original goal was for the return value to be that check, and in cases like this |
Any progress here @forcecore? |
The best solution for now may simply be to lie: unconditionally |
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 have pushed over your branch to rebase and fix the activity cancellation as mentioned above.
I did some (admittedly limited) testing, and it now seems to behave as desired so 👍
Removing THE obstacle for waypoint visualization PR #13336.
In line 245, the tick runs the child activity before returning. I commented why. However, what I didn't write there is that it changes the behavior when the move order has first ticked to that part. It used to return MoveFirstHalf and not tick it.
I also tried to make Move activity more understandable but, I failed because I couldn't understand Move.cs. I am not even 50% sure what MoveFirstHalf and MoveSecondHalf are. No comments and not self-explanatory :( I'll just make minimal changes.