-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
base: main
Are you sure you want to change the base?
Conversation
OR is not supported to be exact
@Pospelove ready for review |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
при таком сравнении для enum class сыпется ошибка, что нет такого оператора
There was a problem hiding this 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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
No description provided.