Commit 1143a24d authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:moecube/ygopro-core

parents 16af5ec2 2f0094c1
......@@ -399,6 +399,9 @@ public:
#define SUMMON_TYPE_PENDULUM 0x4a000000
#define SUMMON_TYPE_LINK 0x4c000000
#define SUMMON_TYPE_MAIN 0xf0000000
#define SUMMON_TYPE_LOCATION 0x00ff0000
//Counter
#define COUNTER_WITHOUT_PERMIT 0x1000
//#define COUNTER_NEED_ENABLE 0x2000
......@@ -413,7 +416,7 @@ public:
#define ASSUME_ATTACK 7
#define ASSUME_DEFENSE 8
//Summon info
//Special Summon effect info
#define SUMMON_INFO_CODE 0x01
#define SUMMON_INFO_CODE2 0x02
#define SUMMON_INFO_TYPE 0x04
......
......@@ -24,6 +24,10 @@ typedef signed char int8;
#define ADD_BIT(x,y) ((x)|=(y))
#define REMOVE_BIT(x,y) ((x)&=~(y))
constexpr bool match_all(uint32 x, uint32 y) {
return (x & y) == y;
}
#define OPERATION_SUCCESS 1
#define OPERATION_FAIL 0
#define OPERATION_CANCELED -1
......
......@@ -43,8 +43,6 @@ int32 effect::is_self_destroy_related() {
int32 effect::is_can_be_forbidden() {
if (is_flag(EFFECT_FLAG_CANNOT_DISABLE) && !is_flag(EFFECT_FLAG_CANNOT_NEGATE))
return FALSE;
if (code == EFFECT_CHANGE_CODE)
return FALSE;
return TRUE;
}
// check if a single/field/equip effect is available
......
......@@ -34,7 +34,7 @@ public:
uint8 effect_owner{ PLAYER_NONE };
uint32 description{ 0 };
uint32 code{ 0 };
uint32 flag[2]{ 0 };
uint32 flag[2]{};
uint32 id{ 0 };
uint16 type{ 0 };
uint16 copy_id{ 0 };
......@@ -47,7 +47,7 @@ public:
uint32 reset_flag{ 0 };
uint32 count_code{ 0 };
uint32 category{ 0 };
uint32 hint_timing[2]{ 0 };
uint32 hint_timing[2]{};
uint32 card_type{ 0 };
uint32 active_type{ 0 };
uint16 active_location{ 0 };
......
......@@ -540,10 +540,10 @@ card* field::get_field_card(uint32 playerid, uint32 location, uint32 sequence) {
case LOCATION_PZONE: {
if(sequence == 0) {
card* pcard = player[playerid].list_szone[core.duel_rule >= 4 ? 0 : 6];
return pcard && pcard->current.pzone ? pcard : 0;
return (pcard && pcard->current.pzone) ? pcard : 0;
} else if(sequence == 1) {
card* pcard = player[playerid].list_szone[core.duel_rule >= 4 ? 4 : 7];
return pcard && pcard->current.pzone ? pcard : 0;
return (pcard && pcard->current.pzone) ? pcard : 0;
} else
return nullptr;
break;
......@@ -1921,7 +1921,7 @@ void field::get_ritual_material(uint8 playerid, effect* peffect, card_set* mater
void field::get_fusion_material(uint8 playerid, card_set* material_all, card_set* material_base, uint32 location) {
if(location & LOCATION_MZONE) {
for(auto& pcard : player[playerid].list_mzone) {
if(pcard)
if(pcard && !pcard->is_status(STATUS_SUMMONING))
material_base->insert(pcard);
}
}
......
......@@ -123,17 +123,17 @@ struct field_info {
int32 field_id{ 0 };
int16 copy_id{ 0 };
int16 turn_id{ 0 };
int16 turn_id_by_player[2]{ 0 };
int16 turn_id_by_player[2]{};
int16 card_id{ 0 };
uint16 phase{ 0 };
uint8 turn_player{ 0 };
uint8 priorities[2]{ 0 };
uint8 priorities[2]{};
uint8 can_shuffle{ TRUE };
};
struct lpcost {
int32 count{ 0 };
int32 amount{ 0 };
int32 lpstack[8]{ 0 };
int32 lpstack[8]{};
};
struct processor_unit {
uint16 type{ 0 };
......@@ -249,9 +249,9 @@ struct processor {
std::unordered_map<uint32, uint32> spsummon_once_map[2];
std::multimap<int32, card*, std::greater<int32>> xmaterial_lst;
int32 temp_var[4]{ 0 };
int32 temp_var[4]{};
uint32 global_flag{ 0 };
uint16 pre_field[2]{ 0 };
uint16 pre_field[2]{};
std::set<uint16> opp_mzone;
chain_limit_list chain_limit;
chain_limit_list chain_limit_p;
......@@ -284,19 +284,19 @@ struct processor {
uint8 attack_cancelable{ FALSE };
uint8 attack_rollback{ FALSE };
uint8 effect_damage_step{ 0 };
int32 battle_damage[2]{ 0 };
int32 summon_count[2]{ 0 };
uint8 extra_summon[2]{ FALSE };
int32 spe_effect[2]{ 0 };
int32 battle_damage[2]{};
int32 summon_count[2]{};
uint8 extra_summon[2]{};
int32 spe_effect[2]{};
int32 duel_options{ 0 };
int32 duel_rule{ CURRENT_RULE }; //current rule: 5, Master Rule 2020
uint32 copy_reset{ 0 };
uint8 copy_reset_count{ 0 };
uint32 last_control_changed_id{ 0 };
uint32 set_group_used_zones{ 0 };
uint8 set_group_seq[7]{ 0 };
uint8 dice_result[5]{ 0 };
uint8 coin_result[MAX_COIN_COUNT]{ 0 };
uint8 set_group_seq[7]{};
uint8 dice_result[5]{};
uint8 coin_result[MAX_COIN_COUNT]{};
int32 coin_count{ 0 };
bool is_target_ready{ false };
......@@ -309,25 +309,25 @@ struct processor {
card* chain_attack_target{ nullptr };
uint8 attack_player{ PLAYER_NONE };
uint8 selfdes_disabled{ FALSE };
uint8 overdraw[2]{ FALSE };
uint8 overdraw[2]{};
int32 check_level{ 0 };
uint8 shuffle_check_disabled{ FALSE };
uint8 shuffle_hand_check[2]{ FALSE };
uint8 shuffle_deck_check[2]{ FALSE };
uint8 shuffle_hand_check[2]{};
uint8 shuffle_deck_check[2]{};
uint8 deck_reversed{ FALSE };
uint8 remove_brainwashing{ FALSE };
uint8 flip_delayed{ FALSE };
uint8 damage_calculated{ FALSE };
uint8 hand_adjusted{ FALSE };
uint8 summon_state_count[2]{ 0 };
uint8 normalsummon_state_count[2]{ 0 };
uint8 flipsummon_state_count[2]{ 0 };
uint8 spsummon_state_count[2]{ 0 };
uint8 attack_state_count[2]{ 0 };
uint8 battle_phase_count[2]{ 0 };
uint8 battled_count[2]{ 0 };
uint8 summon_state_count[2]{};
uint8 normalsummon_state_count[2]{};
uint8 flipsummon_state_count[2]{};
uint8 spsummon_state_count[2]{};
uint8 attack_state_count[2]{};
uint8 battle_phase_count[2]{};
uint8 battled_count[2]{};
uint8 phase_action{ FALSE };
uint32 hint_timing[2]{ 0 };
uint32 hint_timing[2]{};
uint8 current_player{ PLAYER_NONE };
uint8 conti_player{ PLAYER_NONE };
std::unordered_map<uint32, std::pair<uint32, uint32>> summon_counter;
......
......@@ -2042,14 +2042,14 @@ int32 scriptlib::duel_disable_summon(lua_State *L) {
sumplayer = pcard->summon_player;
pcard->set_status(STATUS_SUMMONING, FALSE);
pcard->set_status(STATUS_SUMMON_DISABLED, TRUE);
if((pcard->summon_info & SUMMON_TYPE_PENDULUM) != SUMMON_TYPE_PENDULUM)
if (!match_all(pcard->summon_info, SUMMON_TYPE_FLIP) && !match_all(pcard->summon_info, SUMMON_TYPE_DUAL))
pcard->set_status(STATUS_PROC_COMPLETE, FALSE);
} else {
for(auto& pcard : pgroup->container) {
sumplayer = pcard->summon_player;
pcard->set_status(STATUS_SUMMONING, FALSE);
pcard->set_status(STATUS_SUMMON_DISABLED, TRUE);
if((pcard->summon_info & SUMMON_TYPE_PENDULUM) != SUMMON_TYPE_PENDULUM)
if (!match_all(pcard->summon_info, SUMMON_TYPE_FLIP) && !match_all(pcard->summon_info, SUMMON_TYPE_DUAL))
pcard->set_status(STATUS_PROC_COMPLETE, FALSE);
}
}
......
......@@ -1938,7 +1938,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui
core.units.begin()->ptr2 = 0;
}
if(target->current.location == LOCATION_MZONE)
send_to(target, 0, REASON_RULE, sumplayer, sumplayer, LOCATION_GRAVE, 0, 0);
send_to(target, 0, REASON_RULE, PLAYER_NONE, sumplayer, LOCATION_GRAVE, 0, 0);
adjust_instant();
add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, FALSE, 0);
return TRUE;
......@@ -2045,7 +2045,7 @@ int32 field::flip_summon(uint16 step, uint8 sumplayer, card * target) {
core.units.begin()->ptr1 = 0;
}
if(target->current.location == LOCATION_MZONE)
send_to(target, 0, REASON_RULE, sumplayer, sumplayer, LOCATION_GRAVE, 0, 0);
send_to(target, 0, REASON_RULE, PLAYER_NONE, sumplayer, LOCATION_GRAVE, 0, 0);
add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, FALSE, 0);
return TRUE;
}
......@@ -2931,7 +2931,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin
core.units.begin()->ptr1 = 0;
}
if(target->current.location == LOCATION_MZONE)
send_to(target, 0, REASON_RULE, sumplayer, sumplayer, LOCATION_GRAVE, 0, 0);
send_to(target, 0, REASON_RULE, PLAYER_NONE, sumplayer, LOCATION_GRAVE, 0, 0);
adjust_instant();
add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, FALSE, 0);
return TRUE;
......@@ -3010,7 +3010,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin
|| check_unique_onfield(pcard, sumplayer, LOCATION_MZONE)
|| pcard->is_affected_by_effect(EFFECT_CANNOT_SPECIAL_SUMMON)) {
cit = pgroup->container.erase(cit);
continue;
continue;
}
effect_set eset;
pcard->filter_effect(EFFECT_SPSUMMON_COST, &eset);
......@@ -3123,7 +3123,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin
++cit;
}
if(cset.size()) {
send_to(&cset, 0, REASON_RULE, sumplayer, sumplayer, LOCATION_GRAVE, 0, 0);
send_to(&cset, 0, REASON_RULE, PLAYER_NONE, sumplayer, LOCATION_GRAVE, 0, 0);
adjust_instant();
}
if(pgroup->container.size() == 0) {
......@@ -3782,6 +3782,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
pcard->current.reason_player = pcard->temp.reason_player;
core.destroy_canceled.insert(pcard);
cit = targets->container.erase(cit);
continue;
}
}
++cit;
......@@ -3921,7 +3922,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
struct exargs {
group* targets{ nullptr };
card_set leave_field, leave_grave, leave_deck, detach;
bool show_decktop[2]{ false };
bool show_decktop[2]{};
card_vector cv;
card_vector::iterator cvit;
effect* predirect{ nullptr };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment