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

update sum_param of MSG_SELECT_SUM #493

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mercury233
Copy link
Collaborator

fix Fluorohydride/ygopro-scripts#1785

Problem:
Some cards have 2 levels when using them as material, such as Tuningware.
The implement of Group.CheckWithSum... or Group.SelectWithSum... function use one unsigned int32 to handle this, use 16 bit of this param to store the normal level, and another 16 bit to store the another level:
https://github.com/Fluorohydride/ygopro-scripts/blob/master/c92676637.lua#L25

ygopro-core/field.cpp

Lines 2871 to 2872 in bf2339c

int32 op1 = mats[index]->sum_param & 0xffff;
int32 op2 = (mats[index]->sum_param >> 16) & 0xffff;

This will work for level because as most times the level of one monster won't reach the limit of 16 bit, which is 65535, let alone when using as material.
But attack & defense may go beyond the limit.

Solution:
No monster need 2 attack values to calc sum. So we can use the first bit of opParam as mark, if it is 1, treat the other 31 bit of
opParam as the value.

@salix5
Copy link
Collaborator

salix5 commented Apr 24, 2023

Maybe we can change get_sum_params() into a static member function of field, and we don't need 2 copies of the same function.

in field.h

static void get_sum_params(uint32 sum_param, int32& op1, int32& op2);

in field.cpp

void get_sum_params(uint32 sum_param, int32& op1, int32& op2)

in static int32 select_sum_check1()

field::get_sum_params(oparam[index], o1, o2);

int32 o1 = oparam[index] & 0xffff;
int32 o2 = oparam[index] >> 16;
int32 o1, o2;
get_sum_params(oparam[index], o1, o2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we use static member:

field::get_sum_params(oparam[index], o1, o2);

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