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);
......
This diff is collapsed.
......@@ -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