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

Minor Fixes #296

Open
wants to merge 9 commits into
base: staging
Choose a base branch
from
Open

Minor Fixes #296

wants to merge 9 commits into from

Conversation

beelitzs
Copy link
Contributor

@beelitzs beelitzs commented Oct 4, 2024

PR to merge my fork back into staging.
Please squash before merging as I forgot to clean up the branch beforehand this time and continued using it.

Fixes:

  • Fixed an issue where a completed mission prevents obtaining a new mission from the same agent.
  • Fix issue where repeated checking of an empty system would crash a mission offer.
  • Allow inventory to be filled above base capacity. Eg. Skills & Cargo Expanders.
  • Consider ProductionEfficiency Skill for Manufacturing Jobs

Summary by Sourcery

Fix mission completion and system checking issues, enhance inventory capacity handling, and improve manufacturing job calculations by considering skill levels.

Bug Fixes:

  • Fix an issue where a completed mission prevents obtaining a new mission from the same agent by removing the mission offer after completion.
  • Resolve a crash when repeatedly checking an empty system during mission offers by ensuring systems are not rechecked once searched.

Enhancements:

  • Allow inventory to be filled above base capacity by using the client-provided capacity value.
  • Consider the ProductionEfficiency skill when calculating material multipliers for manufacturing jobs.

Copy link

sourcery-ai bot commented Oct 4, 2024

Reviewer's Guide by Sourcery

This pull request implements several minor fixes and improvements to the game's mission system, inventory management, and manufacturing process. The changes address issues with mission offers, inventory capacity, and production efficiency calculations.

Updated class diagram for RamMethods and related classes

classDiagram
    class RamMethods {
        +Calculate(args: Call_InstallJob, bpRef: BlueprintRef, pChar: Character)
    }
    class BlueprintRef {
        +productType(): Type
        +GetME(): float
    }
    class Character {
        +GetSkillLevel(skill: EvESkill): int
    }
    class Type {
        +productionTime(): float
        +productivityModifier(): float
    }
    RamMethods --> BlueprintRef
    RamMethods --> Character
    BlueprintRef --> Type
Loading

File-Level Changes

Change Details Files
Allow inventory to be filled above base capacity
  • Update capacity calculation to use float instead of integer
  • Set the calculated capacity as an attribute to avoid manual recalculation
src/eve-server/inventory/InventoryBound.cpp
Fix issue with repeated checking of empty systems in mission offers
  • Implement a system to prevent rechecking of already searched systems
  • Improve random system selection process
src/eve-server/map/MapData.cpp
Prevent obtaining a new mission from the same agent after completing a mission
  • Remove the mission offer after mission completion
src/eve-server/agents/AgentBound.cpp
Consider ProductionEfficiency skill for manufacturing jobs
  • Adjust material multiplier based on character's ProductionEfficiency skill level
src/eve-server/manufacturing/RamMethods.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @beelitzs - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding more detailed commit messages for each fix to improve traceability and understanding of changes.
  • The PR title 'Minor Fixes' doesn't accurately reflect the scope of changes. Consider a more descriptive title that summarizes the main improvements.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟡 Security: 1 issue found
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +293 to +294
capacity = PyRep::FloatValue(call.byname.find("capacity")->second);
m_self->SetAttribute(AttrCapacity, capacity); // The client is telling us the calculated capacity, lets use it to avoid manually calculating it.
Copy link

Choose a reason for hiding this comment

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

🚨 suggestion (security): Consider validating the client-provided capacity value

While using the client's calculation saves server-side computation, it's important to validate the input to prevent potential security risks. Consider adding a sanity check or setting a maximum allowed capacity.

const float MAX_CAPACITY = 1000000.0f; // Adjust this value as needed
float clientCapacity = PyRep::FloatValue(call.byname.find("capacity")->second);
float validatedCapacity = std::min(std::max(clientCapacity, 0.0f), MAX_CAPACITY);
m_self->SetAttribute(AttrCapacity, validatedCapacity);

Copy link

@charles-m-knox charles-m-knox Oct 4, 2024

Choose a reason for hiding this comment

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

Based on my experience so far, my server and client already correctly calculates the capacity (expanded cargo holds work and hauler skills increase cargo space; I've filled a hauler's cargo many times). This seems like it might not be needed. It's also a bad idea to trust what the client says - the server is responsible for calculating ship attributes.

Can you elaborate a little more on why this change was made?

Copy link

Choose a reason for hiding this comment

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

Hi @charles-m-knox! 👋

Only authors and team members can run @sourcery-ai commands on public repos.

@@ -166,6 +167,7 @@ void MapData::GetMissionDestination(Agent* pAgent, uint8 misionType, MissionOffe
_log(AGENT__ERROR, "Agent::GetMissionDestination() - no station found within 1 jump." );
return;
}
sysList.erase(sysList.begin() + randomIndex); // If we have searched a system already then do not try it again
Copy link

Choose a reason for hiding this comment

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

suggestion: Add a check for empty sysList to prevent potential issues

Consider adding a check to handle the case when sysList becomes empty after erasing all elements. This could prevent potential infinite loops or undefined behavior.

Suggested change
sysList.erase(sysList.begin() + randomIndex); // If we have searched a system already then do not try it again
if (!sysList.empty()) {
sysList.erase(sysList.begin() + randomIndex);
if (sysList.empty()) {
_log(AGENT__ERROR, "Agent::GetMissionDestination() - all systems searched, none suitable.");
return;
}
}

Copy link

@charles-m-knox charles-m-knox left a comment

Choose a reason for hiding this comment

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

The changes look good except I'm not sure about the cargo capacity calculation change. I think it is not needed, but maybe I am missing something. Can you elaborate on this part more?

Comment on lines +293 to +294
capacity = PyRep::FloatValue(call.byname.find("capacity")->second);
m_self->SetAttribute(AttrCapacity, capacity); // The client is telling us the calculated capacity, lets use it to avoid manually calculating it.
Copy link

@charles-m-knox charles-m-knox Oct 4, 2024

Choose a reason for hiding this comment

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

Based on my experience so far, my server and client already correctly calculates the capacity (expanded cargo holds work and hauler skills increase cargo space; I've filled a hauler's cargo many times). This seems like it might not be needed. It's also a bad idea to trust what the client says - the server is responsible for calculating ship attributes.

Can you elaborate a little more on why this change was made?

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