Skip to content
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

Prevent vehicles spawning inside others #78406

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Procyonae
Copy link
Contributor

@Procyonae Procyonae commented Dec 7, 2024

Summary

None

Purpose of change

This is dumb
image
Having a hardcoded solution just for trying to spawn shopping carts on other vehicles (not even vice versa) is also dumb

Describe the solution

Prevent spawning vehicles if either vehicles tripoints are a subset of (or the same as) the others
Adds a unit test to check stuff is working properly

Describe alternatives you've considered

Ideally this would allow for crashes where one vehicle is a subset of the other but it still looks believable
eg

XXX
XXX
XXX

hits

...
YYY
YYY

like

XXX
ZZZ
ZZZ

But handling that without allowing other nonsense or making the check expensive seems difficult

Testing

Having some trouble with the normal intersection test, see unit test comments
Ok I'm extra confused, adding a check at the end for

a = veh_pointer_or_null( here.veh_at( tripoint_bub_ms( 61, 62, 0 ) ) );
REQUIRE( a );
if( a ) {
  CHECK( a->get_points().size() == 2 );
}

passes every time which makes it seem like it's just incorrectly returning nullptr but then if I load up the resulting test save (with the last two destroy_vehicle s commented out and tping the pc nearby) there's only 4 vehicle tiles in a square not the reported 5 in a U

Additional context

@github-actions github-actions bot added [JSON] Changes (can be) made in JSON Map / Mapgen Overmap, Mapgen, Map extras, Map display Vehicles Vehicles, parts, mechanics & interactions Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Dec 7, 2024
@Procyonae Procyonae force-pushed the PreventVehiclesSpawningInsideOthers branch from 3b62c80 to e791afc Compare December 7, 2024 16:26
@Maleclypse
Copy link
Member

Won’t this break car wreck extras?

@Procyonae
Copy link
Contributor Author

No (if it was working) it doesn't prevent partially overlapping vehicles spawning

@Bone-blood-moss
Copy link

Never encountered vehicle overlap. Will break wrecks though. Picture doesn't show vehicle overlap lookes like a crash.

@Procyonae
Copy link
Contributor Author

Procyonae commented Dec 9, 2024

Never encountered vehicle overlap. Will break wrecks though. Picture doesn't show vehicle overlap lookes like a crash.

Overlapping vehicles are how you form wrecks, the screenshot is courtesy of Maarifrah pointing out this is a problem for #78382, not a crash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Map / Mapgen Overmap, Mapgen, Map extras, Map display Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants