Commit 2980ab6a authored by salix5's avatar salix5

store pointer in void*

Now it does nor rely on the size of pointer.
Affected:
PROCESSOR_SELECT_FUSION, PROCESSOR_DESTROY_STEP, PROCESSOR_RELEASE_STEP,
PROCESSOR_SENDTO_STEP, PROCESSOR_OPERATION_REPLACE,
PROCESSOR_SPSUMMON_STEP, PROCESSOR_EQUIP, PROCESSOR_SWAP_CONTROL,
PROCESSOR_REMOVE_COUNTER

PROCESSOR_SPSUMMON_STEP_S, PROCESSOR_EQUIP_S, PROCESSOR_SWAP_CONTROL_S,
PROCESSOR_REMOVEOL_S, PROCESSOR_DISCARD_HAND_S
parent 9c0c3f6d
......@@ -2123,7 +2123,7 @@ effect* card::check_control_effect() {
}
return ret_effect;
}
int32 card::fusion_check(group* fusion_m, card* cg, int32 chkf) {
int32 card::fusion_check(group* fusion_m, card* cg, uint32 chkf) {
auto ecit = single_effect.find(EFFECT_FUSION_MATERIAL);
if(ecit == single_effect.end())
return FALSE;
......@@ -2136,12 +2136,12 @@ int32 card::fusion_check(group* fusion_m, card* cg, int32 chkf) {
pduel->lua->add_param(chkf, PARAM_TYPE_INT);
return pduel->lua->check_condition(peffect->condition, 4);
}
void card::fusion_select(uint8 playerid, group* fusion_m, card* cg, int32 chkf) {
void card::fusion_select(uint8 playerid, group* fusion_m, card* cg, uint32 chkf) {
effect* peffect = 0;
auto ecit = single_effect.find(EFFECT_FUSION_MATERIAL);
if(ecit != single_effect.end())
peffect = ecit->second;
pduel->game_field->add_process(PROCESSOR_SELECT_FUSION, 0, peffect, fusion_m, playerid + (chkf << 16), (ptr)cg);
pduel->game_field->add_process(PROCESSOR_SELECT_FUSION, 0, peffect, fusion_m, playerid + (chkf << 16), 0, 0, 0, cg);
}
int32 card::check_fusion_substitute(card* fcard) {
effect_set eset;
......@@ -2279,6 +2279,7 @@ int32 card::is_can_be_summoned(uint8 playerid, uint8 ignore_count, effect* peffe
pduel->game_field->restore_lp_cost();
return TRUE;
}
// return: the tribute count for ordinary advance summon
int32 card::get_summon_tribute_count() {
int32 min = 0, max = 0;
int32 minul = 0, maxul = 0;
......
......@@ -232,8 +232,8 @@ public:
effect* is_affected_by_effect(int32 code);
effect* is_affected_by_effect(int32 code, card* target);
effect* check_control_effect();
int32 fusion_check(group* fusion_m, card* cg, int32 chkf);
void fusion_select(uint8 playerid, group* fusion_m, card* cg, int32 chkf);
int32 fusion_check(group* fusion_m, card* cg, uint32 chkf);
void fusion_select(uint8 playerid, group* fusion_m, card* cg, uint32 chkf);
int32 check_fusion_substitute(card* fcard);
int32 is_equipable(card* pcard);
......
......@@ -132,6 +132,8 @@ struct processor_unit {
ptr arg2;
ptr arg3;
ptr arg4;
void* ptr1;
void* ptr2;
};
union return_value {
int8 bvalue[64];
......@@ -424,7 +426,7 @@ public:
int32 check_chain_target(uint8 chaincount, card* pcard);
int32 is_able_to_enter_bp();
void add_process(uint16 type, uint16 step, effect* peffect, group* target, ptr arg1, ptr arg2, ptr arg3 = 0, ptr arg4 = 0);
void add_process(uint16 type, uint16 step, effect* peffect, group* target, ptr arg1, ptr arg2, ptr arg3 = 0, ptr arg4 = 0, void* ptr1 = NULL, void* ptr2 = NULL);
int32 process();
int32 execute_cost(uint16 step, effect* peffect, uint8 triggering_player);
int32 execute_operation(uint16 step, effect* peffect, uint8 triggering_player);
......@@ -515,7 +517,7 @@ public:
int32 discard_deck(uint16 step, uint8 playerid, uint8 count, uint32 reason);
int32 move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, uint32 is_equip);
int32 change_position(uint16 step, group* targets, effect* reason_effect, uint8 reason_player, uint32 enable);
int32 operation_replace(uint16 step, effect* replace_effect, group* targets, ptr arg, ptr replace_type);
int32 operation_replace(uint16 step, effect* replace_effect, group* targets, card* arg, ptr replace_type);
int32 select_synchro_material(int16 step, uint8 playerid, card* pcard, int32 min, int32 max, card* smat, group* mg);
int32 select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* pcard, int32 min, int32 max);
int32 select_release_cards(int16 step, uint8 playerid, uint8 check_field, uint8 cancelable, int32 min, int32 max);
......
......@@ -634,7 +634,12 @@ int32 scriptlib::card_is_dual_state(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
lua_pushboolean(L, (ptr)pcard->is_affected_by_effect(EFFECT_DUAL_STATUS));
int32 ret = 0;
if(pcard->is_affected_by_effect(EFFECT_DUAL_STATUS))
ret = 1;
else
ret = 0;
lua_pushboolean(L, ret);
return 1;
}
int32 scriptlib::card_enable_dual_state(lua_State *L) {
......@@ -2012,7 +2017,7 @@ int32 scriptlib::card_check_fusion_material(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
int32 chkf = PLAYER_NONE;
uint32 chkf = PLAYER_NONE;
group* pgroup = 0;
if(lua_gettop(L) > 1 && !lua_isnil(L, 2)) {
check_param(L, PARAM_TYPE_GROUP, 2);
......
......@@ -1118,7 +1118,7 @@ int32 scriptlib::duel_discard_hand(lua_State *L) {
lua_pushinteger(L, 0);
return 1;
}
pduel->game_field->add_process(PROCESSOR_DISCARD_HAND_S, 0, 0, (group*)(size_t)reason, playerid, min + (max << 16));
pduel->game_field->add_process(PROCESSOR_DISCARD_HAND_S, 0, NULL, NULL, playerid, min + (max << 16), reason);
return lua_yield(L, 0);
}
int32 scriptlib::duel_disable_shuffle_check(lua_State *L) {
......@@ -2108,7 +2108,7 @@ int32 scriptlib::duel_select_fusion_material(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 2);
check_param(L, PARAM_TYPE_GROUP, 3);
card* cg = 0;
int32 chkf = PLAYER_NONE;
uint32 chkf = PLAYER_NONE;
if(lua_gettop(L) > 3 && !lua_isnil(L, 4)) {
check_param(L, PARAM_TYPE_CARD, 4);
cg = *(card**) lua_touserdata(L, 4);
......
......@@ -100,10 +100,10 @@ void field::change_target_param(uint8 chaincount, int32 param) {
core.current_chain[chaincount - 1].target_param = param;
}
void field::remove_counter(uint32 reason, card* pcard, uint32 rplayer, uint32 s, uint32 o, uint32 countertype, uint32 count) {
add_process(PROCESSOR_REMOVE_COUNTER, 0, (effect*)(size_t) reason, (group*)pcard, (rplayer << 16) + (s << 8) + o, countertype + (count << 16));
add_process(PROCESSOR_REMOVE_COUNTER, 0, NULL, (group*)pcard, (rplayer << 16) + (s << 8) + o, countertype + (count << 16), reason);
}
void field::remove_overlay_card(uint32 reason, card* pcard, uint32 rplayer, uint32 s, uint32 o, uint16 min, uint16 max) {
add_process(PROCESSOR_REMOVEOL_S, 0, (effect*)(size_t) reason, (group*)pcard, (rplayer << 16) + (s << 8) + o, (max << 16) + min);
add_process(PROCESSOR_REMOVEOL_S, 0, NULL, (group*)pcard, (rplayer << 16) + (s << 8) + o, (max << 16) + min, reason);
}
void field::get_control(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count) {
group* ng = pduel->new_group(*targets);
......@@ -116,10 +116,10 @@ void field::get_control(card* target, effect* reason_effect, uint32 reason_playe
get_control(&tset, reason_effect, reason_player, playerid, reset_phase, reset_count);
}
void field::swap_control(effect* reason_effect, uint32 reason_player, card* pcard1, card* pcard2, uint32 reset_phase, uint32 reset_count) {
add_process(PROCESSOR_SWAP_CONTROL, 0, reason_effect, (group*)pcard1, (ptr)pcard2, (reason_player << 28) + (reset_phase << 8) + reset_count);
add_process(PROCESSOR_SWAP_CONTROL, 0, reason_effect, (group*)pcard1, reason_player, reset_phase, reset_count, 0, pcard2);
}
void field::equip(uint32 equip_player, card* equip_card, card* target, uint32 up, uint32 is_step) {
add_process(PROCESSOR_EQUIP, 0, 0, (group*)target, (ptr)equip_card, equip_player + (up << 16) + (is_step << 24));
add_process(PROCESSOR_EQUIP, 0, NULL, (group*)target, 0, equip_player + (up << 16) + (is_step << 24), 0, 0, equip_card);
}
void field::draw(effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 count) {
add_process(PROCESSOR_DRAW, 0, reason_effect, 0, reason, (reason_player << 28) + (playerid << 24) + (count & 0xffffff));
......@@ -171,7 +171,7 @@ void field::special_summon_step(card* target, uint32 sumtype, uint32 sumplayer,
target->current.reason_effect = core.reason_effect;
target->current.reason_player = core.reason_player;
target->operation_param = (playerid << 24) + (nocheck << 16) + (nolimit << 8) + positions;
add_process(PROCESSOR_SPSUMMON_STEP, 0, core.reason_effect, 0, 0, (ptr)target);
add_process(PROCESSOR_SPSUMMON_STEP, 0, core.reason_effect, NULL, 0, 0, 0, 0, target);
}
void field::special_summon_complete(effect* reason_effect, uint8 reason_player) {
if(core.special_summoning.size() == 0)
......@@ -820,7 +820,7 @@ int32 field::get_control(uint16 step, effect* reason_effect, uint8 reason_player
switch(step) {
case 0: {
card_set* destroy_set = new card_set;
core.units.begin()->arg1 = (ptr)destroy_set;
core.units.begin()->ptr1 = destroy_set;
for(auto cit = targets->container.begin(); cit != targets->container.end();) {
auto rm = cit++;
card* pcard = *rm;
......@@ -864,7 +864,7 @@ int32 field::get_control(uint16 step, effect* reason_effect, uint8 reason_player
return FALSE;
}
case 1: {
card_set* destroy_set = (card_set*)core.units.begin()->arg1;
card_set* destroy_set = (card_set*)core.units.begin()->ptr1;
for(int32 i = 0; i < returns.bvalue[0]; ++i) {
card* pcard = core.select_cards[returns.bvalue[i + 1]];
destroy_set->insert(pcard);
......@@ -918,7 +918,7 @@ int32 field::get_control(uint16 step, effect* reason_effect, uint8 reason_player
return FALSE;
}
case 6: {
card_set* destroy_set = (card_set*)core.units.begin()->arg1;
card_set* destroy_set = (card_set*)core.units.begin()->ptr1;
if(destroy_set->size())
destroy(destroy_set, 0, REASON_RULE, PLAYER_NONE);
delete destroy_set;
......@@ -1480,7 +1480,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
target->current.reason_effect = 0;
target->current.reason_player = sumplayer;
core.units.begin()->step = 6;
core.units.begin()->arg2 = (ptr)pextra;
core.units.begin()->ptr1 = pextra;
return FALSE;
}
case 6: {
......@@ -1496,7 +1496,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
add_process(PROCESSOR_EXECUTE_OPERATION, 0, proc, 0, sumplayer, 0);
}
proc->dec_count(sumplayer);
core.units.begin()->arg2 = (ptr)pextra;
core.units.begin()->ptr1 = pextra;
return FALSE;
}
case 7: {
......@@ -1506,12 +1506,12 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
break_effect();
if(!ignore_count) {
returns.ivalue[0] = FALSE;
effect* pextra = (effect*)core.units.begin()->arg2;
effect* pextra = (effect*)core.units.begin()->ptr1;
if(pextra) {
if(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE) && (core.summon_count[sumplayer] < get_summon_count_limit(sumplayer)))
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 91);
else if(!pextra->is_flag(EFFECT_FLAG_FUNC_VALUE) && ((int32)target->material_cards.size() < pextra->get_value()))
core.units.begin()->arg2 = 0;
core.units.begin()->ptr1 = NULL;
else
returns.ivalue[0] = TRUE;
}
......@@ -1522,9 +1522,9 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
case 8: {
if(!returns.ivalue[0])
core.summon_count[sumplayer]++;
else if(core.units.begin()->arg2) {
else if(core.units.begin()->ptr1) {
core.extra_summon[sumplayer] = TRUE;
effect* pextra = (effect*)core.units.begin()->arg2;
effect* pextra = (effect*)core.units.begin()->ptr1;
pextra->get_value(target);
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_CARD);
......@@ -1562,12 +1562,12 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
deffect->description = 64;
deffect->reset_flag = RESET_EVENT + 0x1fe0000;
target->add_effect(deffect);
core.units.begin()->arg2 = 0;
core.units.begin()->ptr1 = NULL;
if(!ignore_count) {
returns.ivalue[0] = FALSE;
effect* pextra = core.extra_summon[sumplayer] ? 0 : target->is_affected_by_effect(EFFECT_EXTRA_SUMMON_COUNT);
if(pextra) {
core.units.begin()->arg2 = (ptr)pextra;
core.units.begin()->ptr1 = pextra;
if(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE) && (core.summon_count[sumplayer] < get_summon_count_limit(sumplayer)))
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 91);
else
......@@ -1580,9 +1580,9 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
case 10: {
if(!returns.ivalue[0])
core.summon_count[sumplayer]++;
else if(core.units.begin()->arg2) {
else if(core.units.begin()->ptr1) {
core.extra_summon[sumplayer] = TRUE;
effect* pextra = (effect*)core.units.begin()->arg2;
effect* pextra = (effect*)core.units.begin()->ptr1;
pextra->get_value(target);
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_CARD);
......@@ -1922,7 +1922,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui
target->current.reason_effect = 0;
target->current.reason_player = setplayer;
core.units.begin()->step = 6;
core.units.begin()->arg2 = (ptr)pextra;
core.units.begin()->ptr1 = pextra;
return FALSE;
}
case 6: {
......@@ -1937,19 +1937,19 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, proc, 0, setplayer, 0);
proc->dec_count(setplayer);
core.units.begin()->arg2 = (ptr)pextra;
core.units.begin()->ptr1 = pextra;
return FALSE;
}
case 7: {
break_effect();
if(!ignore_count) {
returns.ivalue[0] = FALSE;
effect* pextra = (effect*)core.units.begin()->arg2;
effect* pextra = (effect*)core.units.begin()->ptr1;
if(pextra) {
if(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE) && (core.summon_count[setplayer] < get_summon_count_limit(setplayer)))
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, setplayer, 91);
else if(!pextra->is_flag(EFFECT_FLAG_FUNC_VALUE) && ((int32)target->material_cards.size() < pextra->get_value()))
core.units.begin()->arg2 = 0;
core.units.begin()->ptr1 = NULL;
else
returns.ivalue[0] = TRUE;
}
......@@ -1960,9 +1960,9 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui
case 8: {
if(!returns.ivalue[0])
core.summon_count[setplayer]++;
else if(core.units.begin()->arg2) {
else if(core.units.begin()->ptr1) {
core.extra_summon[setplayer] = TRUE;
effect* pextra = (effect*)core.units.begin()->arg2;
effect* pextra = (effect*)core.units.begin()->ptr1;
pextra->get_value(target);
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_CARD);
......@@ -2597,14 +2597,14 @@ int32 field::special_summon(uint16 step, effect * reason_effect, uint8 reason_pl
std::sort(cvs.begin(), cvs.end(), card::card_operation_sort);
core.hint_timing[infos.turn_player] |= TIMING_SPSUMMON;
for(auto cvit = cvs.begin(); cvit != cvs.end(); ++cvit)
add_process(PROCESSOR_SPSUMMON_STEP, 0, 0, targets, 0, (ptr)(*cvit));
add_process(PROCESSOR_SPSUMMON_STEP, 0, NULL, targets, 0, 0, 0, 0, *cvit);
}
if(!cvo.empty()) {
if(cvo.size() > 1)
std::sort(cvo.begin(), cvo.end(), card::card_operation_sort);
core.hint_timing[1 - infos.turn_player] |= TIMING_SPSUMMON;
for(auto cvit = cvo.begin(); cvit != cvo.end(); ++cvit)
add_process(PROCESSOR_SPSUMMON_STEP, 0, 0, targets, 0, (ptr)(*cvit));
add_process(PROCESSOR_SPSUMMON_STEP, 0, NULL, targets, 0, 0, 0, 0, *cvit);
}
return FALSE;
}
......@@ -2690,12 +2690,14 @@ int32 field::destroy(uint16 step, group * targets, card * target, uint8 battle)
returns.ivalue[0] = FALSE;
effect_set eset;
target->filter_single_continuous_effect(EFFECT_DESTROY_REPLACE, &eset);
if(!battle)
if(!battle) {
for (int32 i = 0; i < eset.size(); ++i)
add_process(PROCESSOR_OPERATION_REPLACE, 0, eset[i], targets, (ptr)target, 1);
else
add_process(PROCESSOR_OPERATION_REPLACE, 0, eset[i], targets, 0, 1, 0, 0, target);
}
else {
for (int32 i = 0; i < eset.size(); ++i)
add_process(PROCESSOR_OPERATION_REPLACE, 10, eset[i], targets, (ptr)target, 1);
add_process(PROCESSOR_OPERATION_REPLACE, 10, eset[i], targets, 0, 1, 0, 0, target);
}
return TRUE;
}
// PROCESSOR_DESTROY goes here
......@@ -2835,7 +2837,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
}
case 1: {
for (auto cit = targets->container.begin(); cit != targets->container.end(); ++cit) {
add_process(PROCESSOR_DESTROY_STEP, 0, 0, targets, (ptr) (*cit), 0);
add_process(PROCESSOR_DESTROY_STEP, 0, NULL, targets, 0, 0, 0, 0, *cit);
}
return FALSE;
}
......@@ -3025,7 +3027,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
}
case 11: {
for (auto cit = targets->container.begin(); cit != targets->container.end(); ++cit) {
add_process(PROCESSOR_DESTROY_STEP, 0, 0, targets, (ptr) (*cit), TRUE);
add_process(PROCESSOR_DESTROY_STEP, 0, NULL, targets, 0, TRUE, 0, 0, *cit);
}
return FALSE;
}
......@@ -3038,6 +3040,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
}
return TRUE;
}
// PROCESSOR_RELEASE_STEP goes here
int32 field::release(uint16 step, group * targets, card * target) {
if(!(target->current.location & (LOCATION_ONFIELD | LOCATION_HAND))) {
target->current.reason = target->temp.reason;
......@@ -3053,14 +3056,14 @@ int32 field::release(uint16 step, group * targets, card * target) {
effect_set eset;
target->filter_single_continuous_effect(EFFECT_RELEASE_REPLACE, &eset);
for (int32 i = 0; i < eset.size(); ++i)
add_process(PROCESSOR_OPERATION_REPLACE, 0, eset[i], targets, (ptr)target, 0);
add_process(PROCESSOR_OPERATION_REPLACE, 0, eset[i], targets, 0, 0, 0, 0, target);
}
return TRUE;
}
// PROCESSOR_RELEASE goes here
int32 field::release(uint16 step, group * targets, effect * reason_effect, uint32 reason, uint8 reason_player) {
switch (step) {
case 0: {
//card_set extra;
for (auto cit = targets->container.begin(); cit != targets->container.end();) {
auto rm = cit++;
card* pcard = *rm;
......@@ -3084,7 +3087,7 @@ int32 field::release(uint16 step, group * targets, effect * reason_effect, uint3
}
case 1: {
for (auto cit = targets->container.begin(); cit != targets->container.end(); ++cit) {
add_process(PROCESSOR_RELEASE_STEP, 0, 0, targets, (ptr) (*cit), 0);
add_process(PROCESSOR_RELEASE_STEP, 0, NULL, targets, 0, 0, 0, 0, *cit);
}
return FALSE;
}
......@@ -3150,7 +3153,7 @@ int32 field::send_to(uint16 step, group * targets, card * target) {
effect_set eset;
target->filter_single_continuous_effect(EFFECT_SEND_REPLACE, &eset);
for (int32 i = 0; i < eset.size(); ++i)
add_process(PROCESSOR_OPERATION_REPLACE, 0, eset[i], targets, (ptr)target, 0);
add_process(PROCESSOR_OPERATION_REPLACE, 0, eset[i], targets, 0, 0, 0, 0, target);
}
return TRUE;
}
......@@ -3197,7 +3200,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
}
case 1: {
for(auto cit = targets->container.begin(); cit != targets->container.end(); ++cit) {
add_process(PROCESSOR_SENDTO_STEP, 0, 0, targets, (ptr)(*cit), 0);
add_process(PROCESSOR_SENDTO_STEP, 0, NULL, targets, 0, 0, 0, 0, *cit);
}
return FALSE;
}
......@@ -4034,14 +4037,14 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec
}
return TRUE;
}
int32 field::operation_replace(uint16 step, effect * replace_effect, group * targets, ptr arg1, ptr arg2) {
int32 field::operation_replace(uint16 step, effect * replace_effect, group * targets, card * arg1, ptr arg2) {
switch (step) {
case 0: {
if(returns.ivalue[0])
return TRUE;
if(!replace_effect->target)
return TRUE;
card* target = (card*)arg1;
card* target = arg1;
tevent e;
e.event_cards = targets;
e.event_player = replace_effect->get_handler_player();
......@@ -4070,7 +4073,7 @@ int32 field::operation_replace(uint16 step, effect * replace_effect, group * tar
return FALSE;
}
case 1: {
card* target = (card*)arg1;
card* target = arg1;
if (returns.ivalue[0]) {
targets->container.erase(target);
target->current.reason = target->temp.reason;
......@@ -4174,7 +4177,7 @@ int32 field::operation_replace(uint16 step, effect * replace_effect, group * tar
return TRUE;
if(!replace_effect->target)
return TRUE;
card* target = (card*)arg1;
card* target = arg1;
tevent e;
e.event_cards = targets;
e.event_player = replace_effect->get_handler_player();
......@@ -4202,7 +4205,7 @@ int32 field::operation_replace(uint16 step, effect * replace_effect, group * tar
return FALSE;
}
case 11: {
card* target = (card*)arg1;
card* target = arg1;
if (returns.ivalue[0]) {
targets->container.erase(target);
target->current.reason = target->temp.reason;
......
......@@ -14,7 +14,7 @@
#include "ocgapi.h"
#include <iterator>
void field::add_process(uint16 type, uint16 step, effect* peffect, group* target, ptr arg1, ptr arg2, ptr arg3, ptr arg4) {
void field::add_process(uint16 type, uint16 step, effect* peffect, group* target, ptr arg1, ptr arg2, ptr arg3, ptr arg4, void* ptr1, void* ptr2) {
processor_unit new_unit;
new_unit.type = type;
new_unit.step = step;
......@@ -24,6 +24,8 @@ void field::add_process(uint16 type, uint16 step, effect* peffect, group* target
new_unit.arg2 = arg2;
new_unit.arg3 = arg3;
new_unit.arg4 = arg4;
new_unit.ptr1 = ptr1;
new_unit.ptr2 = ptr2;
core.subunits.push_back(new_unit);
}
int32 field::process() {
......@@ -308,21 +310,21 @@ int32 field::process() {
return pduel->bufferlen;
}
case PROCESSOR_DESTROY_STEP: {
if(destroy(it->step, it->ptarget, (card*)it->arg1, it->arg2))
if(destroy(it->step, it->ptarget, (card*)it->ptr1, it->arg2))
core.units.pop_front();
else
it->step++;
return pduel->bufferlen;
}
case PROCESSOR_RELEASE_STEP: {
if (release(it->step, it->ptarget, (card*)it->arg1))
if (release(it->step, it->ptarget, (card*)it->ptr1))
core.units.pop_front();
else
it->step++;
return pduel->bufferlen;
}
case PROCESSOR_SENDTO_STEP: {
if (send_to(it->step, it->ptarget, (card*)it->arg1))
if (send_to(it->step, it->ptarget, (card*)it->ptr1))
core.units.pop_front();
else
it->step++;
......@@ -343,7 +345,7 @@ int32 field::process() {
return pduel->bufferlen;
}
case PROCESSOR_OPERATION_REPLACE: {
if (operation_replace(it->step, it->peffect, it->ptarget, it->arg1, it->arg2))
if (operation_replace(it->step, it->peffect, it->ptarget, (card*)it->ptr1, it->arg2))
core.units.pop_front();
else
it->step++;
......@@ -392,7 +394,7 @@ int32 field::process() {
return pduel->bufferlen;
}
case PROCESSOR_SPSUMMON_STEP: {
if (special_summon_step(it->step, it->ptarget, (card*)(it->arg2)))
if (special_summon_step(it->step, it->ptarget, (card*)(it->ptr1)))
core.units.pop_front();
else
it->step++;
......@@ -443,7 +445,7 @@ int32 field::process() {
return pduel->bufferlen;
}
case PROCESSOR_EQUIP: {
if (equip(it->step, it->arg2 & 0xffff, (card*)it->arg1, (card*)it->ptarget, (it->arg2 >> 16) & 0xff, (it->arg2 >> 24) & 0xff))
if (equip(it->step, it->arg2 & 0xffff, (card*)it->ptr1, (card*)it->ptarget, (it->arg2 >> 16) & 0xff, (it->arg2 >> 24) & 0xff))
core.units.pop_front();
else
it->step++;
......@@ -457,7 +459,7 @@ int32 field::process() {
return pduel->bufferlen;
}
case PROCESSOR_SWAP_CONTROL: {
if (swap_control(it->step, it->peffect, (it->arg2 >> 28) & 0xf, (card*)it->ptarget, (card*)it->arg1, (it->arg2 >> 8) & 0x3ff, it->arg2 & 0xff)) {
if (swap_control(it->step, it->peffect, it->arg1, (card*)it->ptarget, (card*)it->ptr1, it->arg2, it->arg3)) {
core.units.pop_front();
} else
it->step++;
......@@ -485,7 +487,7 @@ int32 field::process() {
return pduel->bufferlen;
}
case PROCESSOR_REMOVE_COUNTER: {
if (remove_counter(it->step, (ptr)it->peffect, (card*)it->ptarget, (it->arg1 >> 16) & 0xff, (it->arg1 >> 8) & 0xff, it->arg1 & 0xff, it->arg2 & 0xffff, it->arg2 >> 16)) {
if (remove_counter(it->step, it->arg3, (card*)it->ptarget, (it->arg1 >> 16) & 0xff, (it->arg1 >> 8) & 0xff, it->arg1 & 0xff, it->arg2 & 0xffff, it->arg2 >> 16)) {
pduel->lua->add_param(returns.ivalue[0], PARAM_TYPE_BOOLEAN);
core.units.pop_front();
} else
......@@ -765,7 +767,7 @@ int32 field::process() {
return pduel->bufferlen;
}
core.sub_solving_event.push_back(e);
pduel->lua->add_param(it->arg2, PARAM_TYPE_CARD);
pduel->lua->add_param(it->ptr1, PARAM_TYPE_CARD);
pduel->lua->add_param(it->arg1 >> 16, PARAM_TYPE_INT);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, it->peffect, 0, it->arg1 & 0xffff, 0);
it->step++;
......@@ -840,7 +842,7 @@ int32 field::process() {
}
case PROCESSOR_SPSUMMON_STEP_S: {
if(it->step == 0) {
add_process(PROCESSOR_SPSUMMON_STEP, 0, it->peffect, it->ptarget, it->arg1, it->arg2);
add_process(PROCESSOR_SPSUMMON_STEP, 0, it->peffect, it->ptarget, it->arg1, it->arg2, it->arg3, it->arg4, it->ptr1);
it->step++;
} else {
pduel->lua->add_param(returns.ivalue[0], PARAM_TYPE_BOOLEAN);
......@@ -929,7 +931,7 @@ int32 field::process() {
}
case PROCESSOR_EQUIP_S: {
if(it->step == 0) {
add_process(PROCESSOR_EQUIP, 0, it->peffect, it->ptarget, it->arg1, it->arg2);
add_process(PROCESSOR_EQUIP, 0, it->peffect, it->ptarget, it->arg1, it->arg2, it->arg3, it->arg4, it->ptr1);
it->step++;
} else {
pduel->lua->add_param(returns.ivalue[0], PARAM_TYPE_BOOLEAN);
......@@ -949,7 +951,7 @@ int32 field::process() {
}
case PROCESSOR_SWAP_CONTROL_S: {
if(it->step == 0) {
add_process(PROCESSOR_SWAP_CONTROL, 0, it->peffect, it->ptarget, it->arg1, it->arg2);
add_process(PROCESSOR_SWAP_CONTROL, 0, it->peffect, it->ptarget, it->arg1, it->arg2, it->arg3, it->arg4, it->ptr1);
it->step++;
} else {
pduel->lua->add_param(returns.ivalue[0], PARAM_TYPE_BOOLEAN);
......@@ -962,7 +964,7 @@ int32 field::process() {
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_SELECTMSG);
pduel->write_buffer8(it->arg1);
if(((ptr)it->ptarget) & REASON_DISCARD)
if(it->arg3 & REASON_DISCARD)
pduel->write_buffer32(501);
else
pduel->write_buffer32(504);
......@@ -976,7 +978,7 @@ int32 field::process() {
cset.insert(pcard);
}
if(cset.size())
send_to(&cset, core.reason_effect, (ptr)(it->ptarget), core.reason_player, it->arg1, LOCATION_GRAVE, 0, POS_FACEUP);
send_to(&cset, core.reason_effect, it->arg3, core.reason_player, it->arg1, LOCATION_GRAVE, 0, POS_FACEUP);
else
returns.ivalue[0] = 0;
it->step++;
......@@ -1038,7 +1040,7 @@ int32 field::process() {
return pduel->bufferlen;
}
case PROCESSOR_REMOVEOL_S: {
if(remove_overlay_card(it->step, (ptr)(it->peffect), (card*)(it->ptarget), it->arg1 >> 16,
if(remove_overlay_card(it->step, it->arg3, (card*)(it->ptarget), it->arg1 >> 16,
(it->arg1 >> 8) & 0xff, it->arg1 & 0xff, it->arg2 & 0xffff, it->arg2 >> 16)) {
pduel->lua->add_param(returns.ivalue[0], PARAM_TYPE_BOOLEAN);
core.units.pop_front();
......@@ -3447,7 +3449,7 @@ int32 field::process_battle_command(uint16 step) {
if(core.battle_destroy_rep.size())
destroy(&core.battle_destroy_rep, 0, REASON_EFFECT | REASON_REPLACE, PLAYER_NONE);
if(core.desrep_chain.size())
add_process(PROCESSOR_OPERATION_REPLACE, 15, 0, 0, 0, 0);
add_process(PROCESSOR_OPERATION_REPLACE, 15, NULL, NULL, 0, 0);
adjust_all();
return FALSE;
}
......@@ -4550,10 +4552,10 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
}
}
if(cait->replace_op) {
core.units.begin()->peffect = (effect*)(size_t)cait->triggering_effect->operation;
core.units.begin()->arg4 = cait->triggering_effect->operation;
cait->triggering_effect->operation = cait->replace_op;
} else
core.units.begin()->peffect = 0;
core.units.begin()->arg4 = 0;
if(cait->triggering_effect->operation) {
core.sub_solving_event.push_back(cait->evt);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, cait->triggering_effect, 0, cait->triggering_player, 0);
......@@ -4562,15 +4564,15 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
}
case 3: {
effect* peffect = cait->triggering_effect;
if(core.units.begin()->peffect) {
peffect->operation = (ptr)core.units.begin()->peffect;
if(core.units.begin()->arg4) {
peffect->operation = core.units.begin()->arg4;
}
core.special_summoning.clear();
core.equiping_cards.clear();
return FALSE;
}
case 4: {
if(core.units.begin()->peffect == 0) {
if(core.units.begin()->arg4 == 0) {
if(cait->opinfos.count(0x200)) {
if(core.spsummon_state_count_tmp[cait->triggering_player] == core.spsummon_state_count[cait->triggering_player])
set_spsummon_counter(cait->triggering_player);
......
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