From 5c06d700c3db42ff51ad0bb64c51d08f5ee7f641 Mon Sep 17 00:00:00 2001 From: mercury233 Date: Tue, 14 Dec 2021 21:03:29 +0800 Subject: [PATCH 1/2] revert 71d322a4df2e9521ba3a314fba8a08649cc2a8d9 --- field.cpp | 10 ++++------ field.h | 6 +++--- operations.cpp | 1 + processor.cpp | 8 ++++---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/field.cpp b/field.cpp index 03055fbe7..8b9717008 100644 --- a/field.cpp +++ b/field.cpp @@ -54,8 +54,8 @@ field::field(duel* pduel) { infos.phase = 0; infos.turn_player = 0; for (int32 i = 0; i < 2; ++i) { - //cost[i].count = 0; - //cost[i].amount = 0; + cost[i].count = 0; + cost[i].amount = 0; player[i].lp = 8000; player[i].start_count = 5; player[i].draw_count = 1; @@ -2297,12 +2297,11 @@ int32 field::check_lp_cost(uint8 playerid, uint32 lp, uint32 must_pay) { if(effect_replace_check(EFFECT_LPCOST_REPLACE, e)) return TRUE; } - //cost[playerid].amount += val; - if(val <= player[playerid].lp) + cost[playerid].amount += val; + if(cost[playerid].amount <= player[playerid].lp) return TRUE; return FALSE; } -/* void field::save_lp_cost() { for(uint8 playerid = 0; playerid < 2; ++playerid) { if(cost[playerid].count < 8) @@ -2317,7 +2316,6 @@ void field::restore_lp_cost() { cost[playerid].amount = cost[playerid].lpstack[cost[playerid].count]; } } -*/ uint32 field::get_field_counter(uint8 self, uint8 s, uint8 o, uint16 countertype) { uint8 c = s; uint32 count = 0; diff --git a/field.h b/field.h index 83c26f563..36cac8599 100644 --- a/field.h +++ b/field.h @@ -381,7 +381,7 @@ class field { player_info player[2]; card* temp_card; field_info infos; - //lpcost cost[2]; + lpcost cost[2]; field_effect effects; processor core; return_value returns; @@ -469,8 +469,8 @@ class field { int32 check_spsummon_counter(uint8 playerid, uint8 ct = 1); int32 check_lp_cost(uint8 playerid, uint32 cost, uint32 must_pay); - void save_lp_cost() {} - void restore_lp_cost() {} + void save_lp_cost(); + void restore_lp_cost(); int32 pay_lp_cost(uint32 step, uint8 playerid, uint32 cost, uint32 must_pay); uint32 get_field_counter(uint8 self, uint8 s, uint8 o, uint16 countertype); diff --git a/operations.cpp b/operations.cpp index 18c6e5617..a95cf66ad 100644 --- a/operations.cpp +++ b/operations.cpp @@ -653,6 +653,7 @@ int32 field::pay_lp_cost(uint32 step, uint8 playerid, uint32 cost, uint32 must_p effect* peffect = core.select_effects[returns.ivalue[0]]; if(!peffect) { player[playerid].lp -= cost; + this->cost[playerid].amount -= cost; pduel->write_buffer8(MSG_PAY_LPCOST); pduel->write_buffer8(playerid); pduel->write_buffer32(cost); diff --git a/processor.cpp b/processor.cpp index 3e2f52689..dcce82d71 100644 --- a/processor.cpp +++ b/processor.cpp @@ -817,10 +817,10 @@ int32 field::execute_operation(uint16 step, effect * triggering_effect, uint8 tr shuffle(0, LOCATION_DECK); if(core.shuffle_deck_check[1]) shuffle(1, LOCATION_DECK); - //cost[0].count = 0; - //cost[1].count = 0; - //cost[0].amount = 0; - //cost[1].amount = 0; + cost[0].count = 0; + cost[1].count = 0; + cost[0].amount = 0; + cost[1].amount = 0; } core.shuffle_check_disabled = (uint8)core.units.begin()->arg2; return TRUE; From 53385841712a1e8d0850fe0190085432bf93736d Mon Sep 17 00:00:00 2001 From: mercury233 Date: Tue, 14 Dec 2021 21:04:28 +0800 Subject: [PATCH 2/2] add missing --- card.cpp | 2 ++ field.cpp | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/card.cpp b/card.cpp index 6a8055bb2..9f6cee809 100644 --- a/card.cpp +++ b/card.cpp @@ -2867,10 +2867,12 @@ int32 card::fusion_check(group* fusion_m, card* cg, uint32 chkf, uint8 not_mater pduel->lua->add_param(chkf, PARAM_TYPE_INT); effect* oreason = pduel->game_field->core.reason_effect; uint8 op = pduel->game_field->core.reason_player; + pduel->game_field->save_lp_cost(); pduel->game_field->core.reason_effect = peffect; pduel->game_field->core.reason_player = peffect->get_handler_player(); pduel->game_field->core.not_material = not_material; int32 res = pduel->lua->check_condition(peffect->condition, 4); + pduel->game_field->restore_lp_cost(); pduel->game_field->core.reason_effect = oreason; pduel->game_field->core.reason_player = op; pduel->game_field->core.not_material = 0; diff --git a/field.cpp b/field.cpp index 8b9717008..c1befdbcc 100644 --- a/field.cpp +++ b/field.cpp @@ -2514,12 +2514,11 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32 pduel->lua->add_param(findex2, PARAM_TYPE_INDEX); pduel->lua->add_param(min, PARAM_TYPE_INT); pduel->lua->add_param(max, PARAM_TYPE_INT); - if(pduel->lua->check_condition(pcustom->target, 5)) { - pduel->restore_assumes(); - return TRUE; - } + pduel->game_field->save_lp_cost(); + int32 res = pduel->lua->check_condition(pcustom->target, 5); + pduel->game_field->restore_lp_cost(); pduel->restore_assumes(); - return FALSE; + return res; } int32 playerid = pcard->current.controler; int32 ct = get_spsummonable_count(pcard, playerid);