-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Overhaul faction mission travel. #77397
base: master
Are you sure you want to change the base?
Conversation
Please list the various changes in the "Describe the solution" section rather than providing something that says that a lot of stuff has been changed. You don't need to specify each individual change, but make each type its own point (there are a number of cases where strings have been added to queries, and they could all be a covered by a single point). If you're separating work duration from travel duration (which is a good thing), you ought to rename the "duration" parameter in various operations to "work_duration" or "work_time" to make it clear (I assume it's no longer total duration, so travel time would have to be deducted from it). I don't know if it matters, but it looks like you've separated work time from travel time in the food store reduction logic, but not in the companion time/exertion logic. If the companions end up being fed the same from the ether as being consumed by them it doesn't matter that the separation isn't repeated there, though. I would say "from %d to %d" in the changed logging query, as "between" is ambiguous whether it is inclusive or exclusive. Wait a minute: In faction_camp.cpp you feed "time_to_food" with total time, which includes travel time. If you're going to separate out travel time you really should only feed work time into the first parameter. I think it makes more sense to warn about forest roads changing into field roads without any visual cue (which you removed) than mentioning that forest might turn into fields (which you added, and which is visible). Why is the tree chopping call to "start_mission" different from the one for clear cutting (the latter uses an additional "travel_time" parameter on top of the total_time)? Corresponding comments for the hide site. I don't understand what "lesser direction" is in the comment "We get lesser direction for free". The "greater trips" in the original comment only made some kind of sense through the mentioning of the return trips, which I think means the "greater trips" are the ones where equipment is carried. And the same for hide site hauling. Does the changed permitted fortification location list really include forest trails and thick forest, or it it otherwise intended to exclude them? You don't need to check for an illegal "start" value in "start_fortifications", since you've already bailed out if that was the case (and is bailing out the correct action in the first place?). Fortification call to start_mission is the one without the travel time. recipe_batch_max: Why have you ditched work_days conversion? That would result in the use of less food? Replacing "base" with "previous point" is probably wrong. There doesn't seem to be any previous point, but rather a start point or origin. craft_description: workdays ditched again... OK, it seems the parameters are actually intended to be total time and travel time after all. It would still be helpful to name all the total_duration parameters accordingly, rather than retaining the generic duration one in the various operations that have changed parameters. recipe_group.cpp get_recipes_by_id: It's legal in C, but it's still misleading to check "limit" when you really should say "limit == 0". Don't know if the style orders demands that, though. savegame_json.cpp: You're not setting a default value for comp_miss_travel_time. Is time_duration one of these ugly things that has a hidden default value? simple_pathfinding.cpp: A bit odd to extend 3D cardinal directions with horizontal diagonals, but not diagonals with Z components. You'd eventually need these to deal with ramps. |
I'll be back soon with a better PR description, PR comments, and more replies. But to get started...
The original version of that function takes total time (often including travel time), then reverse engineers the "work days" math to figure out how much of the time was spent working vs idle vs sleeping. It took me a bit to wrap my head around that. Given that logic was already there, adding the travel time as an extra exceptional option (which isn't always used) seemed like the least intrusive fix. |
I think it's OK to retain the total time parameter, but it should be renamed to avoid confusion as to what it represents now when the travel time parameter has been introduced. That's mentioned further down in my comment, but I guess going through that isn't much more fun than going through the PR, so it won't be surprising if it's split up. |
Will do! My plan was to use the draft to add PR comments, then use the PR comments to re-draft the summary before submitting it for review.
Good call. I already made a few passes of making the naming and variable handling more consistent, and I'll aim for this in a next pass. My eventual goal would be deduplicate the logic in question, so there's just one
I tried to hit all the relevant spots. Can you point out the one that I overlooked?
I took the "between" language from the previous code. Happy to change it; I agree "from" is more clear. Also, to be clear, the min and max range are also displayed visually on the map with notes.
A further reply to this in addition to the above... I can't "only feed work time" because the first parameter already isn't just work or work+travel time time. It also includes idle and sleep time. I don't like this solution, and I tried to fix it, but when I saw how many other calculations mirror the same logic I decided against it.
I think I misunderstood what it was saying before. To be clear, they don't actually change terrain type, it's just saying they will be visually indistinguishable. One of my goals in this PR is to reduce the number of modal popup interruptions involved in all these interfaces. Maybe I can put the road-type-discernment advice in the mission description instead?
Oversight on my part. Of all the things I want to deduplicate, those two are near the top of the list. They have so much in common, and it's so easy to miss a single detail changed between them. Adding the travel time parameter to start_mission will cause the food consumption for the mission to honor the distinction between work exertion and travel exertion.
The trip calculation assumes you are making round trips with cargo one way and empty the other way. The mission sends items in both directions. So if the trip calculation says you need 5 round trips to take items to the hide site, and 3 round trips to bring items back from the hide side, you actually just need 5 round trips. I'm open to a more helpful concise comment to put there. I thought mine was an improvement, but maybe not.
I did intentionally expand the list. I think the shorter list predates the introduction of [some of] the new terrain types.
I don't think this is accurate. Could you comment within the PR changes where you see this?
Thanks. That's also one without the more recent "update the time based on the NPC chosen" code that a bunch of the others have.
You are correct. This is an error. I might not have fully grasped the work days conversions back and forth at that point.
I think I need to remove that. Neither wording works everywhere. I reworded it around the mutli-point scout/combat missions, but now it doesn't make sense for the single-point missions.
I, too, wasn't sure about style here. Happy to change it, though.
That's an excellent question. I've seen some used uninitialized, which made me guess they default to 0, but I haven't confirmed. And there are far more places they do get initialized to 0, so I should probably just follow that pattern.
Ramps seem very exceptional, while diagonal horizontal travel is very common. I'm comfortable with the pathfinding time/distance/cost being off by a few seconds/meters when a ramp is traversed, at least for now. |
e9cc67f
to
610514e
Compare
I tried to hit all the relevant spots. Can you point out the one that I overlooked? Having trouble finding the places (calling the total time "work_time" might have thrown me off), but:
I think I misunderstood what it was saying before. To be clear, they don't actually change terrain type, it's just saying they will be visually indistinguishable. One of my goals in this PR is to reduce the number of modal popup interruptions involved in all these interfaces. Maybe I can put the road-type-discernment advice in the mission description instead?
so it has to be valid or you'd have bailed out already.
|
610514e
to
1626903
Compare
Skipping some replies that I think are obsolete since I was pushing a commit as you were typing, to address maybe 3/4 of the previous concerns.
The call to feed_workers in start_mission uses the camp_food_supply overload that takes travel_time and passes it through to time_to_food, so the two exertion levels are handled correctly.
Done!
OK. I'm not sure how best to convey this concern. I still don't like the old wording. Do you have a suggestion, even just to go back to the old wording?
Done!
This "valid" check is determining whether the player pressed escape at the map tile selection interface. It doesn't assert anything about a tile that was chosen. The chosen tiles still need to be checked for type/etc. The check I modified already checks one of the two chosen tiles, and all the in between tiles, it just missed the other chosen tile due to an under-documented quirk of line_to. (which I'm about to rectify)
I'll test this. I don't know if it worked before. I don't think I changed it. |
Wording: I don't really have any good alternatives. What was there was my best attempt at it... (I'm not saying that can't be improved, just that I don't have any good ideas, and I'm not adverse to it being improved). "Valid" check: I think I'm doing a poor job communicating what I mean...:
could be reduced to:
as the setting of "stop" won't change the value of the already tested "start". I didn't mean the whole check was redundant, but I think I failed to convey that. |
Ahh, I thought you were talking about the terrain type check that I added farther down to account for line_to not returning its start position. You're right about the redundancy where you pointed it out. I added the earlier check and forgot to remove the later check. |
d90b4eb
to
72dbedd
Compare
Updated the PR description with a list of changes. |
9256692
to
0262c60
Compare
I'd like to add some tests, but the current lack of tests in this area gives me pause. Any suggestions where I should start? |
0262c60
to
67e0892
Compare
906d169
to
bba286a
Compare
bba286a
to
322fd2a
Compare
I'm moving this back to Draft while I break pieces out. The first four smaller PRs are linked above. When they get merged I'll rebase this one on them so I have a better base for the next round. I'll un-Draft this again when I think I've reached a point where everything left is too integrated to reasonably extract. |
322fd2a
to
4563d67
Compare
4563d67
to
854620e
Compare
I've extracted all the low hanging fruit. Breaking things out is becoming increasingly conflict-prone, so I'm marking this for review again. I have half a dozen more improvements I want to make here, but I know adding them to this PR would make it even harder to get reviewed and merged. |
Summary
Balance "Rework faction camp mission travel calculations"
Purpose of change
Faction mission travel is broken in many ways. Distances are wrong. Travel times don't make sense. Food consumption isn't consistent. There are numerous irritating prompts and back-to-the-start interface quirks.
Describe the solution
Here are the functional changes in this PR.
companion_travel_time_calc
no longer includes work time or any handling of "haulage". NPCs are just going to make multiple round trips to carry extra stuff. There are a few edge cases where hauling would make more sense, like small numbers of large items (maybe logs, definitely fridges), but I'm not planning to tackle that right now.pf::simple_path<tripoint_abs_omt>
, which contains the total traveled distance and the total pathfinder cost for the path in addition to thevector<tripoint_abs_omt>
that was passed previously.om_path_mark()
adds/removes map notes along a pathfinder path, similar to the oldom_line_mark()
.om_companion_path
now allows undoing selections. You have to press escape multiple times to undo then exit to cancel.Describe alternatives you've considered
I went through multiple variations of half of the changes here. I did not keep a list of what they were and why I switched away from them. I could probably work to remember it for any particular change if asked.
Testing
I've been playing with this since before I created the PR. I expect a few automated tests are in order as well, but I'm not sure where to start on that.
Additional context
This PR is shrinking as smaller PRs get split off from it, 8 so far. I've run out of low hanging fruit. I'll make another round of merge-conflict-heavy PRs if this is still too busy.