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

[CPP] Fix map crash when counting trusts #5847

Merged

Conversation

ampitere
Copy link
Contributor

I affirm:

  • I understand that if I do not agree to the following points by completing the checkboxes my PR will be ignored.
  • I understand I should leave resolving conversations to the LandSandBoat team so that reviewers won't miss what was said.
  • I have read and understood the Contributing Guide and the Code of Conduct.
  • I have tested my code and the things my code has changed since the last commit in the PR and will test after any later commits.

What does this pull request do?

Fixes a map crash due to party leader being null when they are initially zoning. Resolves #5844

Steps to test these changes

  1. Make a group with 2 or more
  2. Be in the same zone together and have the party leader zone out and in

@ampitere ampitere force-pushed the fix_map_crash_when_counting_trusts branch 2 times, most recently from c93308e to b4a5e99 Compare May 29, 2024 15:34
size_t trustCount = 0;
if (m_PLeader != nullptr)
{
std::vector<CTrustEntity*> PTrusts = static_cast<CCharEntity*>(m_PLeader)->PTrusts;
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to make a copy of the trusts vector here, same for below.

trustCount is init'd as zero:

size_t trustCount = 0;

The size of a vector is zero when it's empty.

So you can simplify this block (and below) with something like:

trustCount = static_cast<CCharEntity*>(m_PLeader)->PTrusts.size();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplified both this line and 867.

@ampitere ampitere force-pushed the fix_map_crash_when_counting_trusts branch from b4a5e99 to 0483505 Compare May 29, 2024 16:18
@claywar claywar merged commit 1c250d2 into LandSandBoat:base May 29, 2024
11 checks passed
@ampitere ampitere deleted the fix_map_crash_when_counting_trusts branch May 29, 2024 19:50
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.

🐛 Map.exe crash when party member zones.
3 participants