Skip to content

assorted const fixes#7282

Merged
Goober5000 merged 1 commit intoscp-fs2open:masterfrom
Goober5000:const_char_lookup
Mar 20, 2026
Merged

assorted const fixes#7282
Goober5000 merged 1 commit intoscp-fs2open:masterfrom
Goober5000:const_char_lookup

Conversation

@Goober5000
Copy link
Contributor

@Goober5000 Goober5000 commented Mar 12, 2026

  1. Change ai_profile_lookup and multi_xfer_lookup to use const char *, since all the other lookup functions do
  2. Remove several unneeded const_casts, some of which are now made possible by the non-const data() overload in C++17
  3. Change campaign_link to use const char*
  4. Use better string management in test::FSTestFixture::init_cmdline()

@Goober5000 Goober5000 added the cleanup A modification or rewrite of code to make it more understandable or easier to maintain. label Mar 12, 2026
@Goober5000 Goober5000 force-pushed the const_char_lookup branch 2 times, most recently from 9162878 to cf7a265 Compare March 13, 2026 04:59
Copy link
Member

@wookieejedi wookieejedi left a comment

Choose a reason for hiding this comment

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

Looks good but may want to consider holding off on merging until FRED SEXP refactor is in if it touches some of the same files?

@MjnMixael
Copy link
Contributor

Looks good but may want to consider holding off on merging until FRED SEXP refactor is in if it touches some of the same files?

I have reviewed this PR. The changes in sexp_tree files are already matched in #7301 's sexp_tree_opf.cpp at line 3245. So if the changes to both sexp_tree.cpp files in this PR are removed this can be safely merged without causing conflicts and the const fix will be in when the refactor is merged.

@Goober5000
Copy link
Contributor Author

Goober5000 commented Mar 20, 2026

Good plan. I'll remove the sexp_tree changes from this PR.

1. Change `ai_profile_lookup` and `multi_xfer_lookup` to use `const char *`, since all the other lookup functions do
2. Remove several unneeded `const_cast`s, some of which are now made possible by the non-const `data()` overload in C++17
3. Change `campaign_link` to use `const char*`
4. Use better string management in `test::FSTestFixture::init_cmdline()`
@wookieejedi
Copy link
Member

Updated looks good so feel free to merge when you're ready!

@Goober5000 Goober5000 merged commit b76e652 into scp-fs2open:master Mar 20, 2026
20 checks passed
@Goober5000 Goober5000 deleted the const_char_lookup branch March 20, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup A modification or rewrite of code to make it more understandable or easier to maintain.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants