scripts icon indicating copy to clipboard operation
scripts copied to clipboard

WIP Add reorderstops overlay

Open robob27 opened this issue 1 year ago • 6 comments

Need to do some testing with this and figure out if changing the ids breaks stuff, or if anything else needs to be cleared out like the guide paths. Putting up what I have for now.

robob27 avatar Nov 08 '23 07:11 robob27

I have to admit this scares me a little bit, but if @ab9rf gives the ok that we've handled all the potential places where the id is stored, then I'll allow it.

the function where this all takes place in the game is one of the monsters that ghidra cannot decompile (i left it running for six hours and it was unable to do so). clearing the guide path after reordering the stop resolved the odd behavior we were seeing previously. there aren't any other fields involved and since we're just reordering the elements in the vector, pointers to the individual stops are unaffected. stockpile links to hauling stops are by pointer, not by id, so changing the hauling stop id doesn't affect those

the one thing i'm not sure this covers is the vehicle_current_stop (bay12 name) vector in hauling_routest (also bay12 name). basically if you change the order of the stops, you also have to update hauling_route::vehicle_stops to reflect that the index where that vehicle is currently has changed. my brief review of this code suggests that this is not being done, but i might have missed it. basically you need to transform each element of this vector by the remapping involved in whatever reorder you do, so that the minecarts are reported as being at the right place. this is based entirely on bay12 information so you should investigate whether what i'm saying even makes sense before you implement as i could be misinterpreting toady's code entirely

ab9rf avatar Nov 09 '23 07:11 ab9rf

also, make sure you test to see what happens if a minecart is en route to a reordered stop, both in the pushing case and the guided case

myk002 avatar Nov 09 '23 15:11 myk002

Thanks to both of you! Will update and ensure to test these scenarios.

robgoodberry avatar Nov 09 '23 15:11 robgoodberry

I was wondering why I got a reply for my own notification, replied on my other account 😅 haha

robob27 avatar Nov 09 '23 16:11 robob27

I think the code now handles updating hauling_route::vehicle_stops properly when reordering stops within the same route. I don't currently do anything with hauling_route::vehicle_stops when swapping stops between different routes. I think this works out okay?

If I have this setup:

image

And I swap Stop 1 and Stop 4 (different physical locations):

image

From the same initial setup, if I swap Stop 1 and Stop 5 (same physical locations):

image

Again from that setup, if I swap Stop 2 and Stop 4 (different physical locations):

image

Again from that setup, if I swap Stop 1 and Stop 2 (same route, same result regardless of which stop is selected first):

image

So, if after swapping stops, the cart for that route is not physically at the stop index it was at before the swap, it will be moved there. If the swapped stop is at the same physical location, the cart will be considered in the right spot. If the stops are swapped within the same route, the vehicle index is updated appropriately.

Still working on more playtesting.

robob27 avatar Nov 11 '23 01:11 robob27

I have notes on the UX, but they can wait until you have the basic functionality tested

myk002 avatar Nov 18 '23 00:11 myk002