Commit c49edddf authored by nanahira's avatar nanahira

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

parents bb6e5c5f 610842f2
...@@ -288,52 +288,52 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint ...@@ -288,52 +288,52 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) { extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
duel* ptduel = (duel*)pduel; duel* ptduel = (duel*)pduel;
byte* p = buf; byte* p = buf;
*buf++ = MSG_RELOAD_FIELD; *p++ = MSG_RELOAD_FIELD;
*buf++ = ptduel->game_field->core.duel_rule; *p++ = ptduel->game_field->core.duel_rule;
for(int playerid = 0; playerid < 2; ++playerid) { for(int playerid = 0; playerid < 2; ++playerid) {
auto& player = ptduel->game_field->player[playerid]; auto& player = ptduel->game_field->player[playerid];
*((int*)buf) = player.lp; *((int*)p) = player.lp;
buf += 4; p += 4;
for(auto cit = player.list_mzone.begin(); cit != player.list_mzone.end(); ++cit) { for(auto cit = player.list_mzone.begin(); cit != player.list_mzone.end(); ++cit) {
card* pcard = *cit; card* pcard = *cit;
if(pcard) { if(pcard) {
*buf++ = 1; *p++ = 1;
*buf++ = pcard->current.position; *p++ = pcard->current.position;
*buf++ = pcard->xyz_materials.size(); *p++ = pcard->xyz_materials.size();
} else { } else {
*buf++ = 0; *p++ = 0;
} }
} }
for(auto cit = player.list_szone.begin(); cit != player.list_szone.end(); ++cit) { for(auto cit = player.list_szone.begin(); cit != player.list_szone.end(); ++cit) {
card* pcard = *cit; card* pcard = *cit;
if(pcard) { if(pcard) {
*buf++ = 1; *p++ = 1;
*buf++ = pcard->current.position; *p++ = pcard->current.position;
} else { } else {
*buf++ = 0; *p++ = 0;
} }
} }
*buf++ = player.list_main.size(); *p++ = player.list_main.size();
*buf++ = player.list_hand.size(); *p++ = player.list_hand.size();
*buf++ = player.list_grave.size(); *p++ = player.list_grave.size();
*buf++ = player.list_remove.size(); *p++ = player.list_remove.size();
*buf++ = player.list_extra.size(); *p++ = player.list_extra.size();
*buf++ = player.extra_p_count; *p++ = player.extra_p_count;
} }
*buf++ = ptduel->game_field->core.current_chain.size(); *p++ = ptduel->game_field->core.current_chain.size();
for(auto chit = ptduel->game_field->core.current_chain.begin(); chit != ptduel->game_field->core.current_chain.end(); ++chit) { for(auto chit = ptduel->game_field->core.current_chain.begin(); chit != ptduel->game_field->core.current_chain.end(); ++chit) {
effect* peffect = chit->triggering_effect; effect* peffect = chit->triggering_effect;
*((int*)buf) = peffect->get_handler()->data.code; *((int*)p) = peffect->get_handler()->data.code;
buf += 4; p += 4;
*((int*)buf) = peffect->get_handler()->get_info_location(); *((int*)p) = peffect->get_handler()->get_info_location();
buf += 4; p += 4;
*buf++ = chit->triggering_controler; *p++ = chit->triggering_controler;
*buf++ = (uint8)chit->triggering_location; *p++ = (uint8)chit->triggering_location;
*buf++ = chit->triggering_sequence; *p++ = chit->triggering_sequence;
*((int*)buf) = peffect->description; *((int*)p) = peffect->description;
buf += 4; p += 4;
} }
return (int32)(buf - p); return (int32)(p - buf);
} }
extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value) { extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value) {
((duel*)pduel)->set_responsei(value); ((duel*)pduel)->set_responsei(value);
......
...@@ -269,7 +269,7 @@ int32 field::select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 mi ...@@ -269,7 +269,7 @@ int32 field::select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 mi
byte c[64] = {}; byte c[64] = {};
uint8 m = core.select_cards.size(); uint8 m = core.select_cards.size();
for(int32 i = 0; i < returns.bvalue[0]; ++i) { for(int32 i = 0; i < returns.bvalue[0]; ++i) {
uint8 v = returns.bvalue[i + 1]; int8 v = returns.bvalue[i + 1];
if(v < 0 || v >= m || v >= 63 || c[v]) { if(v < 0 || v >= m || v >= 63 || c[v]) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
...@@ -747,12 +747,12 @@ int32 field::sort_card(int16 step, uint8 playerid, uint8 is_chain) { ...@@ -747,12 +747,12 @@ int32 field::sort_card(int16 step, uint8 playerid, uint8 is_chain) {
} }
return FALSE; return FALSE;
} else { } else {
if(returns.ivalue[0] == -1) if(returns.bvalue[0] == -1)
return TRUE; return TRUE;
byte c[64] = {}; byte c[64] = {};
uint8 m = core.select_cards.size(); uint8 m = core.select_cards.size();
for(uint8 i = 0; i < m; ++i) { for(uint8 i = 0; i < m; ++i) {
uint8 v = returns.bvalue[i]; int8 v = returns.bvalue[i];
if(v < 0 || v >= m || c[v]) { if(v < 0 || v >= m || c[v]) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
......
...@@ -674,9 +674,8 @@ int32 field::process() { ...@@ -674,9 +674,8 @@ int32 field::process() {
it->step++; it->step++;
} else { } else {
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
card* pcard;
for(int32 i = 0; i < returns.bvalue[0]; ++i) { for(int32 i = 0; i < returns.bvalue[0]; ++i) {
pcard = core.select_cards[returns.bvalue[i + 1]]; card* pcard = core.select_cards[returns.bvalue[i + 1]];
pgroup->container.insert(pcard); pgroup->container.insert(pcard);
} }
pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP); pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP);
...@@ -719,9 +718,8 @@ int32 field::process() { ...@@ -719,9 +718,8 @@ int32 field::process() {
it->step++; it->step++;
} else { } else {
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
card* pcard;
for(int32 i = 0; i < returns.bvalue[0]; ++i) { for(int32 i = 0; i < returns.bvalue[0]; ++i) {
pcard = core.select_cards[returns.bvalue[i + 1]]; card* pcard = core.select_cards[returns.bvalue[i + 1]];
pgroup->container.insert(pcard); pgroup->container.insert(pcard);
} }
pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP); pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP);
...@@ -735,9 +733,8 @@ int32 field::process() { ...@@ -735,9 +733,8 @@ int32 field::process() {
it->step++; it->step++;
} else { } else {
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
card* pcard;
for(int32 i = 0; i < returns.bvalue[0]; ++i) { for(int32 i = 0; i < returns.bvalue[0]; ++i) {
pcard = core.select_cards[returns.bvalue[i + 1]]; card* pcard = core.select_cards[returns.bvalue[i + 1]];
pgroup->container.insert(pcard); pgroup->container.insert(pcard);
} }
pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP); pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP);
...@@ -852,11 +849,11 @@ int32 field::process() { ...@@ -852,11 +849,11 @@ int32 field::process() {
int32 playerid = it->arg1; int32 playerid = it->arg1;
int32 count = it->arg3; int32 count = it->arg3;
int32 dfflag = 0; int32 dfflag = 0;
uint8 p, l, s, pa = 0; uint8 pa = 0;
for(int32 i = 0; i < count; ++i) { for(int32 i = 0; i < count; ++i) {
p = returns.bvalue[pa]; uint8 p = returns.bvalue[pa];
l = returns.bvalue[pa + 1]; uint8 l = returns.bvalue[pa + 1];
s = returns.bvalue[pa + 2]; uint8 s = returns.bvalue[pa + 2];
dfflag |= 0x1u << (s + (p == playerid ? 0 : 16) + (l == LOCATION_MZONE ? 0 : 8)); dfflag |= 0x1u << (s + (p == playerid ? 0 : 16) + (l == LOCATION_MZONE ? 0 : 8));
pa += 3; pa += 3;
} }
...@@ -1007,9 +1004,8 @@ int32 field::process() { ...@@ -1007,9 +1004,8 @@ int32 field::process() {
it->step++; it->step++;
} else if(it->step == 1) { } else if(it->step == 1) {
card_set cset; card_set cset;
card* pcard;
for(int32 i = 0; i < returns.bvalue[0]; ++i) { for(int32 i = 0; i < returns.bvalue[0]; ++i) {
pcard = core.select_cards[returns.bvalue[i + 1]]; card* pcard = core.select_cards[returns.bvalue[i + 1]];
cset.insert(pcard); cset.insert(pcard);
} }
if(cset.size()) if(cset.size())
...@@ -1050,7 +1046,7 @@ int32 field::process() { ...@@ -1050,7 +1046,7 @@ int32 field::process() {
for(i = 0; i < count; ++i) for(i = 0; i < count; ++i)
player[target_player].list_main.pop_back(); player[target_player].list_main.pop_back();
for(i = 0; i < count; ++i) for(i = 0; i < count; ++i)
tc[(int32)returns.bvalue[i]] = core.select_cards[i]; tc[(uint8)returns.bvalue[i]] = core.select_cards[i];
for(i = 0; i < count; ++i) { for(i = 0; i < count; ++i) {
player[target_player].list_main.push_back(tc[count - i - 1]); player[target_player].list_main.push_back(tc[count - i - 1]);
tc[count - i - 1]->current.sequence = player[target_player].list_main.size() - 1; tc[count - i - 1]->current.sequence = player[target_player].list_main.size() - 1;
...@@ -3095,7 +3091,8 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3095,7 +3091,8 @@ int32 field::process_battle_command(uint16 step) {
return FALSE; return FALSE;
} }
case 9: { case 9: {
if(is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_BP) || core.attack_rollback) { if(is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_BP)
|| core.attacker->is_status(STATUS_ATTACK_CANCELED) || core.attack_rollback) {
core.units.begin()->step = 10; core.units.begin()->step = 10;
return FALSE; return FALSE;
} }
...@@ -3126,17 +3123,12 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3126,17 +3123,12 @@ int32 field::process_battle_command(uint16 step) {
core.attacker->set_status(STATUS_ATTACK_CANCELED, TRUE); core.attacker->set_status(STATUS_ATTACK_CANCELED, TRUE);
} }
if(is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_BP) if(is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_BP)
|| !core.attacker->is_capable_attack() || core.attacker->is_status(STATUS_ATTACK_CANCELED) || core.attacker->is_status(STATUS_ATTACK_CANCELED)) {
|| core.attacker->current.controler != core.attacker->attack_controler
|| core.attacker->fieldid_r != core.pre_field[0]) {
core.units.begin()->step = 12; core.units.begin()->step = 12;
return FALSE; return FALSE;
} }
uint8 rollback = core.attack_rollback;
if(!confirm_attack_target())
rollback = TRUE;
// go to damage step // go to damage step
if(!rollback) { if(!core.attack_rollback) {
core.attacker->announce_count++; core.attacker->announce_count++;
core.attacker->announced_cards.addcard(core.attack_target); core.attacker->announced_cards.addcard(core.attack_target);
attack_all_target_check(); attack_all_target_check();
...@@ -5348,8 +5340,14 @@ int32 field::adjust_step(uint16 step) { ...@@ -5348,8 +5340,14 @@ int32 field::adjust_step(uint16 step) {
card* attacker = core.attacker; card* attacker = core.attacker;
if(!attacker) if(!attacker)
return FALSE; return FALSE;
if(attacker->is_affected_by_effect(EFFECT_CANNOT_ATTACK)) if(attacker->is_status(STATUS_ATTACK_CANCELED))
return FALSE;
if(!core.attacker->is_capable_attack()
|| core.attacker->current.controler != core.attacker->attack_controler
|| core.attacker->fieldid_r != core.pre_field[0]) {
attacker->set_status(STATUS_ATTACK_CANCELED, TRUE); attacker->set_status(STATUS_ATTACK_CANCELED, TRUE);
return FALSE;
}
if(core.attack_rollback) if(core.attack_rollback)
return FALSE; return FALSE;
std::set<uint16> fidset; std::set<uint16> fidset;
...@@ -5357,7 +5355,7 @@ int32 field::adjust_step(uint16 step) { ...@@ -5357,7 +5355,7 @@ int32 field::adjust_step(uint16 step) {
if(pcard) if(pcard)
fidset.insert(pcard->fieldid_r); fidset.insert(pcard->fieldid_r);
} }
if(fidset != core.opp_mzone) if(fidset != core.opp_mzone || !confirm_attack_target())
core.attack_rollback = TRUE; core.attack_rollback = TRUE;
return FALSE; return FALSE;
} }
......
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