Fluorohydride / ygopro-core

ygopro script engine.
MIT License
327 stars 134 forks source link

update sum_param of MSG_SELECT_SUM #493

Open mercury233 opened 1 year ago

mercury233 commented 1 year ago

fix https://github.com/Fluorohydride/ygopro-scripts/pull/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 https://github.com/Fluorohydride/ygopro-core/blob/bf2339ce96152b6825c5a4064ac669def6caf976/field.cpp#L2871-L2872

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 commented 1 year ago

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);