-
Notifications
You must be signed in to change notification settings - Fork 136
Add ClearFactoryQueue logic, and hook it to INSERT/STOP/REMOVE combos #2154
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
Conversation
STOP should stay a no-op, add a modifier to REMOVE to allow span removal. |
Yeah, don't worry easy to delete from the PR, just trying different possibilities until this is settled. Already Implemented the REMOVE(meta) path for range removal. Seems to work fine, and also allows working with control modifier to select either queue, so pretty much a great solution. (code can still be refactored a little bit probably). So, with meta atm it accepts up to 2 params, being start, and end. Guess this could still accept more parameters, and then also do the So using like this to clear: spGiveOrderToUnit(unitID, CMD.REMOVE, nil, {'meta', 'ctrl'})
spGiveOrderToUnit(unitID, CMD.REMOVE, 1, {'meta', 'ctrl'}) Also tested with a queue having 100k commands and more, and didn't see any issues, works instantly, (thx to the STOP hax ofc), so likely not needing the alternative paths, those would help if not having the hax, but I think it's here to stay, so... |
Only thing I'm worried here, or maybe I'm missing something, is how the gui is supposed to be notified? You can see I added: commandQue.push_front(c);
FinishCommand(); After my loop, this makes UnitCmdDone called for the CMD_REMOVE here. Problem is this probably has a bunch of other side effects if the unit is actually doing something and we're not removing the first command. Without META it's not doing it, so here I probably also should not do it. So, the question is, without something like that, how is gui supposed to be notified? Maybe it is and I'm not looking for it properly, but see, the problem I have is otherwise gridmenu doesn't get notified, so everything works, but the numbers in the panel don't update. Not specific about gridmenu, but atm for tests I'm using UnitCmdDone to see if I should refresh. |
Regarding this, parameters could also be |
Added a new PR, #2156, with just the INSERT changes. Will close this soon, once conversations are settled. |
I don't mind either way, your call.
I think this spGiveOrderToUnit(unitID, CMD.REMOVE, {1, 3}, {'meta'}) would ideally produce the same events etc as: local _, _, tag1 = Spring.GetUnitCurrentCommand(unitID, 1)
local _, _, tag2 = Spring.GetUnitCurrentCommand(unitID, 2)
local _, _, tag3 = Spring.GetUnitCurrentCommand(unitID, 3)
spGiveOrderToUnit(unitID, CMD.REMOVE, {tag1, tag2, tag3}) |
Yeah, without the extra UnitCmdDone it should, since it does exactly the same. But is it actually sending anything? Asking because I'm not sure, in case you know, otherwise I'll find out. |
I don't know. I assume if you start removing from the 1st (but not from 2nd or later) then each command in turn will become active and produce some sort of "command done" event. I dislike this, but I also dislike iterating in different order than what exists so idk. Perhaps it's your call. |
When it's the first command there might be something, but in the general case, not really getting anything atm. In BAR, gridmenu atm just listens for Problem is currently dequeue cmdID has enough context to know how much to discount from each number, since you get a unitDefID and a count number to remove. When using the mechanics from this pr, it becomes trickier, since CMD_STOP_PRODUCTION doesn't have context any more (we will get the UnitCommand(REMOVE)), to know how many units to remove. What is worse, there is no clear indication of when the command finished, so you can update the queues, since REMOVE isn't doing any UnitCmdDone. So the gui can be left with needing to introduce some kind of delay, so it can check once the command is done. That's the situation I noticed that led me to introduce that (push REMOVE in queue + FinishCommand call), still, this could have unexpected side effects when clearing queue from non-factory unit, where pushing remove + FinishCommand will have too many side effects. In this case I believe it would be better to just run the callin directly (UnitCmdDone), so gui can react easily. Otherwise let me know if you can think of some other way to do it. Complicating things, previous per tag/cmdid behaviour also not doing this, so not sure I should be introducing this callin behaviour in general for Remove, or what'd be the optimal approach. |
Sounds good.
Sounds good. |
closing since this is superseded by #2156 and all conversations here settled. |
Work done
Work yet to be done in this PR
Related issues
Also see following "precursor" pr: #2137
Remarks
spGiveOrderToUnit(unitID, CMD.REMOVE, nil, {'meta', 'ctrl'})
spGiveOrderToUnit(unitID, CMD.REMOVE, 1, {'meta', 'ctrl'})
spGiveOrderToUnit(unitID, CMD.REMOVE, {1, 20}, {'meta', 'ctrl'})
spGiveOrderToUnit(unitID, CMD.INSERT, {index, CMD.STOP, 0}, {'ctrl', 'alt'})