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

Task mpl 2 #819

Merged
merged 11 commits into from
Dec 2, 2023
Merged

Task mpl 2 #819

merged 11 commits into from
Dec 2, 2023

Conversation

royfalk
Copy link
Contributor

@royfalk royfalk commented Nov 29, 2023

This is a reopening of #816.

This code decouple the MPL from rest of main body of code and make it and cargo part of resource lib. It makes it easier to test (some basic tests included) and also removes dependencies on the gfx folder among others.

This PR is part of a list of small PRs intended to come before #810. They are intended to clear the way for it and reduce the actual code in it to a manageable level. Note that #810 is a draft PR for review. Once these PR's are merged, I may break it up into smaller chunks for better processing.

Code Changes:

[x] Have the PR Validation Tests been run? See https://github.com/vegastrike/Vega-Strike-Engine-Source/wiki/Pull-Request-Validation

Issues:

  • Removed hard coded pilots, slaves and hitchhikers from the code. All items should be in the MPL json and we should trust it to be so. Pilots and slaves are there. Hitchhikers are not.
  • Removed dynamically generated items. There was code in unit_csv.cpp:1423 (UpdateMasterPartList) that added stuff missing from MPL upon docking. We should expect the MPL to keep a copy of all items in the game.
  • The code in script_call_unit_gen.cpp generated random cargo and had two fall backs. 1st looked for cargo with mission in the name for some reason. The 2nd just created a dummy cargo using new and let it leak with a comment that it won't. I replaced that with something I think is better and more consistent.
  • For some reason my PR's still carry more commits than the last one. It's as if I'm not pulling latest before but I did. Not sure why.

@royfalk royfalk self-assigned this Nov 29, 2023
@royfalk
Copy link
Contributor Author

royfalk commented Nov 29, 2023

Summarizing discussions from #816:
1. Is this code compatible with PWCU and with Black Paralysis? Not an issue for black paralysis.

Probably not an issue for WC but I will set aside time after lib component to stabilize WC and test it.
2. Do we still look for cargo with mission in the name? If so, I think I am good to approve this PR. Subject to the file conflicts being resolved, of course.

We don't.

This code is supposed to generate random cargo for a category. Its fallback is to generate random category with the mission in the name.

It has been replaced with code that generates cargo for a category with fallback to just random cargo.

I don't see how this change could impact gameplay.

@royfalk
Copy link
Contributor Author

royfalk commented Nov 29, 2023

I have no idea why this is failing.

/usr/include/c++/13/bits/alloc_traits.h:70:31: error: static assertion failed: allocator_traits::rebind_alloc<A::value_type> must be A
70 | _Tp>::value,
| ^~~~~
/usr/include/c++/13/bits/alloc_traits.h:70:31: note: 'std::integral_constant<bool, false>::value' evaluates to false

Decouple it from rest of code and make it and cargo part of resource lib.
@stephengtuggy
Copy link
Contributor

Summarizing discussions from #816: 1. Is this code compatible with PWCU and with Black Paralysis? Not an issue for black paralysis.

Probably not an issue for WC but I will set aside time after lib component to stabilize WC and test it. 2. Do we still look for cargo with mission in the name? If so, I think I am good to approve this PR. Subject to the file conflicts being resolved, of course.

We don't. This code is supposed to generate random cargo for a category. Its fallback is to generate random category with the mission in the name. It has been replaced with code that generates cargo for a category with fallback to just random cargo. I don't see how this change could impact gameplay.

Are you sure that generating random cargo with the mission in the name is just the fallback? Rather than one of the primary purposes of this code? If you're running a cargo mission, you need cargo to deliver, right? 🙂

Even if it is just a fallback, that would mean that we're changing code behavior with respect to an edge case. As a general rule, I think we're better off not changing effective code behavior during a refactor. Even in relatively minor ways. Separating out behavior changes from refactors can make things significantly easier to sort out later, it seems to me.

Of course, it's possible to be too pedantic about this. But what are your thoughts on the above?

@stephengtuggy
Copy link
Contributor

You are quite correct about that memory leak being there in the old code, comment notwithstanding. We should definitely avoid that. Perhaps log a fatal error and exit, if that code block ever gets hit?

Reintroduce mission based random cargo.
Copy link
Contributor

@stephengtuggy stephengtuggy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@stephengtuggy stephengtuggy merged commit 0245b88 into vegastrike:master Dec 2, 2023
@stephengtuggy
Copy link
Contributor

I especially like how you used the inline lambda function there. That adds a nice touch

@royfalk royfalk deleted the task_mpl_2 branch December 3, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants