Skip to content

Conversation

winterheart
Copy link
Collaborator

Pull Request Type

  • GitHub Workflow changes
  • Documentation or Wiki changes
  • Build and Dependency changes
  • Runtime changes
    • Render changes
    • Audio changes
    • Input changes
    • Network changes
    • Other changes

Description

Remove ddio_MakePath() from Descent3 code. Reduce ddio_SplitPath() usage.

ddio_MakePath() is still in use in Editor, cleanup will be finished in next run.

Related Issues

Screenshots (if applicable)

Checklist

  • I have tested my changes locally and verified that they work as intended.
  • I have documented any new or modified functionality.
  • I have reviewed the changes to ensure they do not introduce any unnecessary complexity or duplicate code.
  • I understand that by submitting this pull request, I am agreeing to license my contributions under the project's license.

Additional Comments

@winterheart winterheart force-pushed the ddio_makepath_remove branch from fd0b883 to 1ac163f Compare May 24, 2025 12:35

// Set output size to minimum of trimmed string length and buffer size minus 1
out_size = (end - src) < destlen - 1 ? (end - src) : destlen - 1;
out_size = static_cast<size_t>(end - src) < destlen - 1 ? (end - src) : destlen - 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider providing the exact compiler warning message in the commit log so later onlookers can establish that the chosen solution was indeed the right choice.

Copy link
Member

@Lgt2x Lgt2x left a comment

Choose a reason for hiding this comment

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

A few forward-compatibility suggestions for cpp20

LOG_INFO.printf("Compiling: %s[%s] to %d", AddOnDataTables[tf].Addon_tracklocks[i].name,
(curr_tablefile == 1) ? TableFilename : AddOnDataTables[curr_tablefile - 2].AddOnTableFilename,
page_pos);
(curr_tablefile == 1) ? TableFilename.u8string().c_str()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(curr_tablefile == 1) ? TableFilename.u8string().c_str()
(curr_tablefile == 1) ? (const char*)TableFilename.u8string().c_str()

(cf #712)

Copy link
Contributor

Choose a reason for hiding this comment

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

Everyone should strive to reduce casts, not add more ones, especially not the old C-style cast. C++ has four much better ones. (hence #712)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't see why we need const char * cast here, .c_str() already have const CharT* qualifier in retern.

Copy link
Member

Choose a reason for hiding this comment

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

With C++20 and later, .c_str() on a std::u8string returns const char8_t*, so we need a cast to get a const char* here to be compatible with later C++ standards (see error #706 (comment)), either the C-style one or C++-style as suggested by @jengelh / #712

rend_Flip();

int ret = zfile.ExtractFile(ze, output_filename);
int ret = zfile.ExtractFile(ze, output_filename.u8string().c_str());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
int ret = zfile.ExtractFile(ze, output_filename.u8string().c_str());
int ret = zfile.ExtractFile(ze, (const char*)output_filename.u8string().c_str());

if (strnicmp(szcrc, file + (strlen(file) - 9), 9) != 0) {
LOG_WARNING.printf("Bad CRC on file %s! It must be corrupt! File will not be used, and is being deleted!", p);
ddio_DeleteFile(p);
std::vector<std::string> parts = StringSplit(p.stem().u8string(), "_");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
std::vector<std::string> parts = StringSplit(p.stem().u8string(), "_");
std::vector<std::string> parts = StringSplit(p.stem().string(), "_");

or use std::u8string? C++20 strings are quite a ride... https://stackoverflow.com/questions/55556200/convert-between-stdu8string-and-stdstring

else
strcpy(newfile, file);
std::filesystem::path FixFilenameCase(const std::filesystem::path &filename) {
std::string local_file = filename.filename().u8string();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
std::string local_file = filename.filename().u8string();
std::string local_file = filename.filename().string();

or use std::u8string

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.

3 participants