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

feat(skymp5-server): Recipe checks #1979

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

Conversation

ZikkeyLS
Copy link
Contributor

No description provided.

@ZikkeyLS
Copy link
Contributor Author

@Pospelove ready for review

Copy link
Contributor

@Pospelove Pospelove left a comment

Choose a reason for hiding this comment

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

answered in discord


if (CalculateOperationResult(itemCount, condition.comparisonValue,
condition.GetOperator()) == false) {
if (condition.GetFlags() != espm::CTDA::Flags::OR || requireAnd) {
Copy link
Contributor

Choose a reason for hiding this comment

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

если надо проверить выставлен ли флаг, надо проверять так condition.GetFlags() & espm::CTDA::Flags::OR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

при таком сравнении для enum class сыпется ошибка, что нет такого оператора

@ZikkeyLS ZikkeyLS requested a review from Pospelove May 22, 2024 23:46
Copy link
Contributor

@Pospelove Pospelove left a comment

Choose a reason for hiding this comment

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

Good job! just two things and we're going test this

@@ -456,8 +456,37 @@ void UseCraftRecipe(MpActor* me, const espm::COBJ* recipeUsed,
spdlog::info("Using craft recipe with EDID {} from espm file with index {}",
recipeUsed->GetEditorId(cache), espmIdx);

std::vector<Condition*> conditions;
Copy link
Contributor

Choose a reason for hiding this comment

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

raw pointer detected 🤖

please use std::unique_ptr/std::shared_ptr instead

This is how we usually do it + I see incorrect delete logic which is much easier to replace than fix, re-review, etc

bool requireAnd = false;
for (auto& cond : conditions) {
if (!cond->Evaluate(me)) {
if (cond->GetFlags() != espm::CTDA::Flags::OR || requireAnd) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want checking if the flag is set, we have to use & instead of != no matter how:

static_cast<uint32_t>(cond->GetFlags()) & static_cast<uint32_t>(espm::CTDA::Flags::OR)

== and & is not the same. the first one will check that ALL flags are in the same state

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