Commit dfcff86f authored by argon.sun's avatar argon.sun

compatible with libevent

parent dbeeeac5
......@@ -101,7 +101,7 @@ int32 effect::is_available() {
}
return TRUE;
}
int32 effect::is_activateable(uint8 playerid, event& e, int32 neglect_cond, int32 neglect_cost, int32 neglect_target) {
int32 effect::is_activateable(uint8 playerid, tevent& e, int32 neglect_cond, int32 neglect_cost, int32 neglect_target) {
if (!(type & EFFECT_TYPE_ACTIONS))
return FALSE;
if((flag & EFFECT_FLAG_COUNT_LIMIT) && (reset_count & 0xf00) == 0)
......@@ -206,7 +206,7 @@ int32 effect::is_action_check(uint8 playerid) {
}
return TRUE;
}
int32 effect::is_activate_ready(uint8 playerid, event& e, int32 neglect_cond, int32 neglect_cost, int32 neglect_target) {
int32 effect::is_activate_ready(uint8 playerid, tevent& e, int32 neglect_cond, int32 neglect_cost, int32 neglect_target) {
if (!neglect_cond && condition) {
pduel->lua->add_param(this, PARAM_TYPE_EFFECT);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
......@@ -250,7 +250,7 @@ int32 effect::is_activate_ready(uint8 playerid, event& e, int32 neglect_cond, in
}
return TRUE;
}
int32 effect::is_condition_check(uint8 playerid, event& e) {
int32 effect::is_condition_check(uint8 playerid, tevent& e) {
if ((handler->current.location & LOCATION_ONFIELD) && (type & EFFECT_TYPE_FIELD)
&& (!handler->is_position(POS_FACEUP) || !handler->is_status(STATUS_EFFECT_ENABLED)))
return FALSE;
......@@ -280,7 +280,7 @@ int32 effect::is_condition_check(uint8 playerid, event& e) {
pduel->game_field->core.reason_player = op;
return TRUE;
}
int32 effect::is_activate_check(uint8 playerid, event& e, int32 neglect_cond, int32 neglect_cost, int32 neglect_target) {
int32 effect::is_activate_check(uint8 playerid, tevent& e, int32 neglect_cond, int32 neglect_cost, int32 neglect_target) {
pduel->game_field->save_lp_cost();
effect* oreason = pduel->game_field->core.reason_effect;
uint8 op = pduel->game_field->core.reason_player;
......
......@@ -21,7 +21,7 @@ class card;
class duel;
class group;
class effect;
struct event;
struct tevent;
struct effect_set;
struct effect_set_v;
......@@ -59,11 +59,11 @@ public:
int32 is_disable_related();
int32 is_available();
int32 is_activateable(uint8 playerid, event& e, int32 neglect_cond = FALSE, int32 neglect_cost = FALSE, int32 neglect_target = FALSE);
int32 is_activateable(uint8 playerid, tevent& e, int32 neglect_cond = FALSE, int32 neglect_cost = FALSE, int32 neglect_target = FALSE);
int32 is_action_check(uint8 playerid);
int32 is_activate_ready(uint8 playerid, event& e, int32 neglect_cond = FALSE, int32 neglect_cost = FALSE, int32 neglect_target = FALSE);
int32 is_condition_check(uint8 playerid, event& e);
int32 is_activate_check(uint8 playerid, event& e, int32 neglect_cond = FALSE, int32 neglect_cost = FALSE, int32 neglect_target = FALSE);
int32 is_activate_ready(uint8 playerid, tevent& e, int32 neglect_cond = FALSE, int32 neglect_cost = FALSE, int32 neglect_target = FALSE);
int32 is_condition_check(uint8 playerid, tevent& e);
int32 is_activate_check(uint8 playerid, tevent& e, int32 neglect_cond = FALSE, int32 neglect_cost = FALSE, int32 neglect_target = FALSE);
int32 is_target(card* pcard);
int32 is_target_player(uint8 playerid);
int32 is_player_effect_target(card* pcard);
......
......@@ -450,7 +450,7 @@ void field::add_effect(effect* peffect, uint8 owner_player) {
it = effects.aura_effect.insert(make_pair(peffect->code, peffect));
else {
if (peffect->type & EFFECT_TYPE_IGNITION)
it = effects.startup_effect.insert(make_pair(peffect->code, peffect));
it = effects.ignition_effect.insert(make_pair(peffect->code, peffect));
else if (peffect->type & EFFECT_TYPE_ACTIVATE)
it = effects.activate_effect.insert(make_pair(peffect->code, peffect));
else if (peffect->type & EFFECT_TYPE_TRIGGER_O && peffect->type & EFFECT_TYPE_FIELD)
......@@ -458,9 +458,9 @@ void field::add_effect(effect* peffect, uint8 owner_player) {
else if (peffect->type & EFFECT_TYPE_TRIGGER_F && peffect->type & EFFECT_TYPE_FIELD)
it = effects.trigger_f_effect.insert(make_pair(peffect->code, peffect));
else if (peffect->type & EFFECT_TYPE_QUICK_O)
it = effects.instant_o_effect.insert(make_pair(peffect->code, peffect));
it = effects.quick_o_effect.insert(make_pair(peffect->code, peffect));
else if (peffect->type & EFFECT_TYPE_QUICK_F)
it = effects.instant_f_effect.insert(make_pair(peffect->code, peffect));
it = effects.quick_f_effect.insert(make_pair(peffect->code, peffect));
else if (peffect->type & EFFECT_TYPE_CONTINUOUS)
it = effects.continuous_effect.insert(make_pair(peffect->code, peffect));
}
......@@ -484,7 +484,7 @@ void field::remove_effect(effect* peffect) {
effects.aura_effect.erase(it);
else {
if (peffect->type & EFFECT_TYPE_IGNITION)
effects.startup_effect.erase(it);
effects.ignition_effect.erase(it);
else if (peffect->type & EFFECT_TYPE_ACTIVATE)
effects.activate_effect.erase(it);
else if (peffect->type & EFFECT_TYPE_TRIGGER_O)
......@@ -492,9 +492,9 @@ void field::remove_effect(effect* peffect) {
else if (peffect->type & EFFECT_TYPE_TRIGGER_F)
effects.trigger_f_effect.erase(it);
else if (peffect->type & EFFECT_TYPE_QUICK_O)
effects.instant_o_effect.erase(it);
effects.quick_o_effect.erase(it);
else if (peffect->type & EFFECT_TYPE_QUICK_F)
effects.instant_f_effect.erase(it);
effects.quick_f_effect.erase(it);
else if (peffect->type & EFFECT_TYPE_CONTINUOUS)
effects.continuous_effect.erase(it);
}
......@@ -543,7 +543,7 @@ void field::reset_effect(uint32 id, uint32 reset_type) {
effects.aura_effect.erase(pit);
} else {
if (peffect->type & EFFECT_TYPE_IGNITION)
effects.startup_effect.erase(pit);
effects.ignition_effect.erase(pit);
else if (peffect->type & EFFECT_TYPE_ACTIVATE)
effects.activate_effect.erase(pit);
else if (peffect->type & EFFECT_TYPE_TRIGGER_O)
......@@ -551,9 +551,9 @@ void field::reset_effect(uint32 id, uint32 reset_type) {
else if (peffect->type & EFFECT_TYPE_TRIGGER_F)
effects.trigger_f_effect.erase(pit);
else if (peffect->type & EFFECT_TYPE_QUICK_O)
effects.instant_o_effect.erase(pit);
effects.quick_o_effect.erase(pit);
else if (peffect->type & EFFECT_TYPE_QUICK_F)
effects.instant_f_effect.erase(pit);
effects.quick_f_effect.erase(pit);
else if (peffect->type & EFFECT_TYPE_CONTINUOUS)
effects.continuous_effect.erase(pit);
}
......@@ -1074,7 +1074,7 @@ int32 field::check_lp_cost(uint8 playerid, uint32 lp) {
if(val <= 0)
return TRUE;
}
event e;
tevent e;
e.event_cards = 0;
e.event_player = playerid;
e.event_value = lp;
......@@ -1121,12 +1121,10 @@ uint32 field::get_field_counter(uint8 self, uint8 s, uint8 o, uint16 countertype
}
return count;
}
int32 field::effect_replace_check(uint32 code, event e) {
pair<effect_container::iterator, effect_container::iterator> pr;
pr = effects.continuous_effect.equal_range(code);
effect* peffect;
int32 field::effect_replace_check(uint32 code, tevent& e) {
auto pr = effects.continuous_effect.equal_range(code);
for (; pr.first != pr.second; ++pr.first) {
peffect = pr.first->second;
effect* peffect = pr.first->second;
if(peffect->is_activateable(peffect->get_handler_player(), e))
return TRUE;
}
......@@ -1407,7 +1405,7 @@ int32 field::is_player_can_remove_counter(uint8 playerid, card * pcard, uint8 s,
pair<effect_container::iterator, effect_container::iterator> pr;
pr = effects.continuous_effect.equal_range(EFFECT_RCOUNTER_REPLACE + countertype);
effect* peffect;
event e;
tevent e;
e.event_cards = 0;
e.event_player = playerid;
e.event_value = count;
......@@ -1427,7 +1425,7 @@ int32 field::is_player_can_remove_overlay_card(uint8 playerid, card* pcard, uint
pair<effect_container::iterator, effect_container::iterator> pr;
pr = effects.continuous_effect.equal_range(EFFECT_OVERLAY_REMOVE_REPLACE);
effect* peffect;
event e;
tevent e;
e.event_cards = 0;
e.event_player = playerid;
e.event_value = min;
......
......@@ -22,7 +22,7 @@ class duel;
class group;
class effect;
struct event {
struct tevent {
uint32 event_code;
void* event_cards;
uint32 event_value;
......@@ -53,7 +53,7 @@ struct chain {
int32 target_param;
effect* disable_reason;
uint8 disable_player;
event evt;
tevent evt;
opmap opinfos;
uint32 flag;
static bool chain_operation_sort(chain c1, chain c2);
......@@ -81,12 +81,12 @@ struct field_effect {
typedef std::set<effect*> effect_collection;
effect_container aura_effect;
effect_container startup_effect;
effect_container ignition_effect;
effect_container activate_effect;
effect_container trigger_o_effect;
effect_container trigger_f_effect;
effect_container instant_o_effect;
effect_container instant_f_effect;
effect_container quick_o_effect;
effect_container quick_f_effect;
effect_container continuous_effect;
effect_indexer indexer;
oath_effects oath;
......@@ -131,7 +131,7 @@ struct processor {
typedef std::vector<card*> card_vector;
typedef std::vector<uint32> option_vector;
typedef std::list<card*> card_list;
typedef std::list<event> event_list;
typedef std::list<tevent> event_list;
typedef std::list<chain> chain_list;
typedef std::map<effect*, chain> instant_f_list;
typedef std::vector<chain> chain_array;
......@@ -172,7 +172,7 @@ struct processor {
chain_list new_ochain_b;
chain_list flip_chain_b;
chain_list new_chains;
instant_f_list instant_f_chain;
instant_f_list quick_f_chain;
card_set leave_confirmed;
card_set special_summoning;
card_list adjust_list;
......@@ -253,7 +253,7 @@ public:
typedef std::vector<card*> card_vector;
typedef std::vector<uint32> option_vector;
typedef std::list<card*> card_list;
typedef std::list<event> event_list;
typedef std::list<tevent> event_list;
typedef std::list<chain> chain_list;
typedef std::map<effect*, chain> instant_f_list;
typedef std::vector<chain> chain_array;
......@@ -268,7 +268,7 @@ public:
field_effect effects;
processor core;
return_value returns;
event nil_event;
tevent nil_event;
static int32 field_used_count[32];
field(duel* pduel);
......@@ -317,7 +317,7 @@ public:
int32 pay_lp_cost(uint32 step, uint8 playerid, uint32 cost);
uint32 get_field_counter(uint8 self, uint8 s, uint8 o, uint16 countertype);
int32 effect_replace_check(uint32 code, event e);
int32 effect_replace_check(uint32 code, tevent& e);
int32 get_attack_target(card* pcard, card_vector* v, uint8 chain_attack = FALSE);
int32 check_synchro_material(card* pcard, int32 findex1, int32 findex2, int32 min);
int32 check_tuner_material(card* pcard, card* tuner, int32 findex1, int32 findex2, int32 min);
......@@ -352,7 +352,7 @@ public:
void raise_event(card* event_card, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value);
void raise_event(card_set* event_cards, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value);
void raise_single_event(card* event_card, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value );
int32 check_event(uint32 code, event* pe = 0);
int32 check_event(uint32 code, tevent* pe = 0);
int32 check_hint_timing(effect* peffect);
int32 process_phase_event(int16 step, int32 phase_event);
int32 process_point_event(int16 step, int32 special, int32 skip_new);
......
......@@ -1601,6 +1601,7 @@ int32 scriptlib::card_trap_monster_block(lua_State *L) {
peffect->reset_flag = RESET_EVENT + 0x5fe0000;
peffect->value = 1 + (0x10000 << pcard->previous.sequence);
pcard->add_effect(peffect);
return 0;
}
int32 scriptlib::card_cancel_to_grave(lua_State *L) {
check_param_count(L, 1);
......
......@@ -487,7 +487,7 @@ int32 field::pay_lp_cost(uint32 step, uint8 playerid, uint32 cost) {
return TRUE;
}
core.units.begin()->arg2 = val;
event e;
tevent e;
e.event_cards = 0;
e.event_player = playerid;
e.event_value = val;
......@@ -529,7 +529,7 @@ int32 field::pay_lp_cost(uint32 step, uint8 playerid, uint32 cost) {
pduel->write_buffer32(cost);
return TRUE;
}
event e;
tevent e;
e.event_cards = 0;
e.event_player = playerid;
e.event_value = cost;
......@@ -555,7 +555,7 @@ int32 field::remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplay
pair<effect_container::iterator, effect_container::iterator> pr;
pr = effects.continuous_effect.equal_range(EFFECT_RCOUNTER_REPLACE + countertype);
effect* peffect;
event e;
tevent e;
e.event_cards = 0;
e.event_player = rplayer;
e.event_value = count;
......@@ -583,7 +583,7 @@ int32 field::remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplay
case 1: {
effect* peffect = core.select_effects[returns.ivalue[0]];
if(peffect) {
event e;
tevent e;
e.event_cards = 0;
e.event_player = rplayer;
e.event_value = count;
......@@ -657,7 +657,7 @@ int32 field::remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8
pair<effect_container::iterator, effect_container::iterator> pr;
pr = effects.continuous_effect.equal_range(EFFECT_OVERLAY_REMOVE_REPLACE);
effect* peffect;
event e;
tevent e;
e.event_cards = 0;
e.event_player = rplayer;
e.event_value = min;
......@@ -685,7 +685,7 @@ int32 field::remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8
case 1: {
effect* peffect = core.select_effects[returns.ivalue[0]];
if(peffect) {
event e;
tevent e;
e.event_cards = 0;
e.event_player = rplayer;
e.event_value = min + (max << 16);;
......@@ -2713,7 +2713,7 @@ int32 field::operation_replace(uint16 step, effect * replace_effect, group * tar
if(!replace_effect->target)
return TRUE;
card* target = (card*)arg1;
event e;
tevent e;
e.event_cards = targets;
e.event_player = replace_effect->get_handler_player();
e.event_value = 0;
......@@ -2774,7 +2774,7 @@ int32 field::operation_replace(uint16 step, effect * replace_effect, group * tar
return TRUE;
}
case 5: {
event e;
tevent e;
e.event_cards = targets;
e.event_player = replace_effect->get_handler_player();
e.event_value = 0;
......@@ -2849,7 +2849,7 @@ int32 field::operation_replace(uint16 step, effect * replace_effect, group * tar
if(!replace_effect->target)
return TRUE;
card* target = (card*)arg1;
event e;
tevent e;
e.event_cards = targets;
e.event_player = replace_effect->get_handler_player();
e.event_value = 0;
......@@ -2891,7 +2891,7 @@ int32 field::operation_replace(uint16 step, effect * replace_effect, group * tar
return TRUE;
}
case 12: {
event e;
tevent e;
e.event_cards = targets;
e.event_player = replace_effect->get_handler_player();
e.event_value = 0;
......@@ -3228,7 +3228,7 @@ int32 field::toss_coin(uint16 step, effect* reason_effect, uint8 reason_player,
case 0: {
effect_set eset;
effect* peffect = 0;
event e;
tevent e;
e.event_cards = 0;
e.reason_effect = core.reason_effect;
e.reason_player = core.reason_player;
......@@ -3273,7 +3273,7 @@ int32 field::toss_dice(uint16 step, effect* reason_effect, uint8 reason_player,
case 0: {
effect_set eset;
effect* peffect = 0;
event e;
tevent e;
e.event_cards = 0;
e.reason_effect = core.reason_effect;
e.reason_player = core.reason_player;
......
This diff is collapsed.
......@@ -609,7 +609,7 @@ end
function Auxiliary.FConditionCodeRep(code,cc,sub,insf)
return function(e,g,gc,chkf)
if g==nil then return insf end
if gc then return gc:IsHasEffect() and g:IsExists(Card.IsCode,cc-1,nil,code) end
if gc then return gc:IsHasEffect(EFFECT_FUSION_SUBSTITUTE) and g:IsExists(Card.IsCode,cc-1,nil,code) end
local g1=g:Filter(Card.IsCode,nil,code)
if not sub then
if chkf~=PLAYER_NONE then return g1:GetCount()>=cc and g1:FilterCount(Card.IsOnField,nil)~=0
......
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