Commit c146c549 authored by wind2009's avatar wind2009

Merge branch 'develop'

parents 6f42241f 9f708498
...@@ -385,10 +385,9 @@ public: ...@@ -385,10 +385,9 @@ public:
int32 is_can_be_link_material(card* scard); int32 is_can_be_link_material(card* scard);
}; };
//Summon Type //Summon Type in summon_info
#define SUMMON_TYPE_NORMAL 0x10000000 #define SUMMON_TYPE_NORMAL 0x10000000
#define SUMMON_TYPE_ADVANCE 0x11000000 #define SUMMON_TYPE_ADVANCE 0x11000000
#define SUMMON_TYPE_DUAL 0x12000000
#define SUMMON_TYPE_FLIP 0x20000000 #define SUMMON_TYPE_FLIP 0x20000000
#define SUMMON_TYPE_SPECIAL 0x40000000 #define SUMMON_TYPE_SPECIAL 0x40000000
#define SUMMON_TYPE_FUSION 0x43000000 #define SUMMON_TYPE_FUSION 0x43000000
...@@ -398,8 +397,15 @@ public: ...@@ -398,8 +397,15 @@ public:
#define SUMMON_TYPE_PENDULUM 0x4a000000 #define SUMMON_TYPE_PENDULUM 0x4a000000
#define SUMMON_TYPE_LINK 0x4c000000 #define SUMMON_TYPE_LINK 0x4c000000
#define SUMMON_TYPE_MAIN 0xf0000000 //Gemini Summon
#define SUMMON_TYPE_LOCATION 0x00ff0000 #define SUMMON_TYPE_DUAL 0x12000000
//bitfield blocks
#define SUMMON_VALUE_MAIN_TYPE 0xf0000000
#define SUMMON_VALUE_SUB_TYPE 0x0f000000
#define SUMMON_VALUE_LOCATION 0x00ff0000
#define SUMMON_VALUE_CUSTOM_TYPE 0x0000ffff
constexpr uint32 DEFAULT_SUMMON_TYPE = SUMMON_VALUE_MAIN_TYPE | SUMMON_VALUE_SUB_TYPE | SUMMON_VALUE_CUSTOM_TYPE;
//Counter //Counter
#define COUNTER_WITHOUT_PERMIT 0x1000 #define COUNTER_WITHOUT_PERMIT 0x1000
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
#define MAX_COIN_COUNT 20 #define MAX_COIN_COUNT 20
//summon action type
#define SUMMON_IN_IDLE 0
#define SUMMON_IN_CHAIN 1
class card; class card;
struct card_data; struct card_data;
class duel; class duel;
...@@ -140,12 +144,16 @@ struct processor_unit { ...@@ -140,12 +144,16 @@ struct processor_unit {
uint16 step{ 0 }; uint16 step{ 0 };
effect* peffect{ nullptr }; effect* peffect{ nullptr };
group* ptarget{ nullptr }; group* ptarget{ nullptr };
int32 arg1{ 0 }; uint32 arg1{ 0 };
int32 arg2{ 0 }; uint32 arg2{ 0 };
int32 arg3{ 0 }; uint32 arg3{ 0 };
int32 arg4{ 0 }; uint32 arg4{ 0 };
void* ptr1{ nullptr }; void* ptr1{ nullptr };
void* ptr2{ nullptr }; void* ptr2{ nullptr };
int32 value1{ 0 };
int32 value2{ 0 };
int32 value3{ 0 };
int32 value4{ 0 };
}; };
union return_value { union return_value {
int8 bvalue[64]; int8 bvalue[64];
...@@ -552,9 +560,9 @@ public: ...@@ -552,9 +560,9 @@ public:
void draw(effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, int32 count); void draw(effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, int32 count);
void damage(effect* reason_effect, uint32 reason, uint32 reason_player, card* reason_card, uint32 playerid, int32 amount, uint32 is_step = FALSE); void damage(effect* reason_effect, uint32 reason, uint32 reason_player, card* reason_card, uint32 playerid, int32 amount, uint32 is_step = FALSE);
void recover(effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, int32 amount, uint32 is_step = FALSE); void recover(effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, int32 amount, uint32 is_step = FALSE);
void summon(uint32 sumplayer, card* target, effect* proc, uint32 ignore_count, uint32 min_tribute, uint32 zone = 0x1f); void summon(uint32 sumplayer, card* target, effect* proc, uint32 ignore_count, uint32 min_tribute, uint32 zone = 0x1f, uint32 action_type = SUMMON_IN_IDLE);
void mset(uint32 setplayer, card* target, effect* proc, uint32 ignore_count, uint32 min_tribute, uint32 zone = 0x1f); void mset(uint32 setplayer, card* target, effect* proc, uint32 ignore_count, uint32 min_tribute, uint32 zone = 0x1f, uint32 action_type = SUMMON_IN_IDLE);
void special_summon_rule(uint32 sumplayer, card* target, uint32 summon_type); void special_summon_rule(uint32 sumplayer, card* target, uint32 summon_type, uint32 action_type = SUMMON_IN_IDLE);
void special_summon(card_set* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone); void special_summon(card_set* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone);
void special_summon_step(card* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone); void special_summon_step(card* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone);
void special_summon_complete(effect* reason_effect, uint8 reason_player); void special_summon_complete(effect* reason_effect, uint8 reason_player);
...@@ -708,10 +716,6 @@ public: ...@@ -708,10 +716,6 @@ public:
#define GLOBALFLAG_ACTIVATION_COUNT 0x800 #define GLOBALFLAG_ACTIVATION_COUNT 0x800
// //
//summon action type
#define SUMMON_IN_IDLE 0
#define SUMMON_IN_CHAIN 1
#define PROCESSOR_ADJUST 1 #define PROCESSOR_ADJUST 1
#define PROCESSOR_HINT 2 #define PROCESSOR_HINT 2
#define PROCESSOR_TURN 3 #define PROCESSOR_TURN 3
...@@ -755,17 +759,17 @@ public: ...@@ -755,17 +759,17 @@ public:
#define PROCESSOR_DESTROY_REPLACE 56 #define PROCESSOR_DESTROY_REPLACE 56
#define PROCESSOR_RELEASE_REPLACE 57 #define PROCESSOR_RELEASE_REPLACE 57
#define PROCESSOR_SENDTO_REPLACE 58 #define PROCESSOR_SENDTO_REPLACE 58
#define PROCESSOR_SUMMON_RULE 60 #define PROCESSOR_SUMMON_RULE 60 //arg1, arg2
#define PROCESSOR_SPSUMMON_RULE 61 #define PROCESSOR_SPSUMMON_RULE 61 //arg1, arg2, arg3
#define PROCESSOR_SPSUMMON 62 #define PROCESSOR_SPSUMMON 62
#define PROCESSOR_FLIP_SUMMON 63 #define PROCESSOR_FLIP_SUMMON 63 //arg1, arg2
#define PROCESSOR_MSET 64 #define PROCESSOR_MSET 64 //arg1, arg2
#define PROCESSOR_SSET 65 #define PROCESSOR_SSET 65
#define PROCESSOR_SPSUMMON_STEP 66 #define PROCESSOR_SPSUMMON_STEP 66
#define PROCESSOR_SSET_G 67 #define PROCESSOR_SSET_G 67
#define PROCESSOR_DRAW 70 #define PROCESSOR_DRAW 70
#define PROCESSOR_DAMAGE 71 #define PROCESSOR_DAMAGE 71 //arg1, arg2, arg3
#define PROCESSOR_RECOVER 72 #define PROCESSOR_RECOVER 72 //arg1, arg2, arg3
#define PROCESSOR_EQUIP 73 #define PROCESSOR_EQUIP 73
#define PROCESSOR_GET_CONTROL 74 #define PROCESSOR_GET_CONTROL 74
#define PROCESSOR_SWAP_CONTROL 75 #define PROCESSOR_SWAP_CONTROL 75
......
...@@ -855,7 +855,7 @@ int32 scriptlib::card_get_summon_type(lua_State *L) { ...@@ -855,7 +855,7 @@ int32 scriptlib::card_get_summon_type(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
lua_pushinteger(L, pcard->summon_info & 0xff00ffff); lua_pushinteger(L, pcard->summon_info & DEFAULT_SUMMON_TYPE);
return 1; return 1;
} }
int32 scriptlib::card_get_summon_location(lua_State *L) { int32 scriptlib::card_get_summon_location(lua_State *L) {
...@@ -1281,7 +1281,7 @@ int32 scriptlib::card_is_summon_type(lua_State *L) { ...@@ -1281,7 +1281,7 @@ int32 scriptlib::card_is_summon_type(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**)lua_touserdata(L, 1); card* pcard = *(card**)lua_touserdata(L, 1);
uint32 ttype = (uint32)lua_tointeger(L, 2); uint32 ttype = (uint32)lua_tointeger(L, 2);
if(((pcard->summon_info & 0xff00ffff) & ttype) == ttype) if(((pcard->summon_info & DEFAULT_SUMMON_TYPE) & ttype) == ttype)
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
......
...@@ -299,13 +299,15 @@ int32 scriptlib::duel_summon(lua_State *L) { ...@@ -299,13 +299,15 @@ int32 scriptlib::duel_summon(lua_State *L) {
if(lua_gettop(L) >= 6) if(lua_gettop(L) >= 6)
zone = (uint32)lua_tointeger(L, 6); zone = (uint32)lua_tointeger(L, 6);
pduel->game_field->core.summon_cancelable = FALSE; pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->summon(playerid, pcard, peffect, ignore_count, min_tribute, zone);
if(pduel->game_field->core.current_chain.size()) { if(pduel->game_field->core.current_chain.size()) {
pduel->game_field->summon(playerid, pcard, peffect, ignore_count, min_tribute, zone, SUMMON_IN_CHAIN);
pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back(); pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back();
pduel->game_field->core.summon_reserved.arg3 = SUMMON_IN_CHAIN;
pduel->game_field->core.subunits.pop_back(); pduel->game_field->core.subunits.pop_back();
pduel->game_field->core.summoning_card = pcard; pduel->game_field->core.summoning_card = pcard;
} }
else {
pduel->game_field->summon(playerid, pcard, peffect, ignore_count, min_tribute, zone, SUMMON_IN_IDLE);
}
return lua_yield(L, 0); return lua_yield(L, 0);
} }
int32 scriptlib::duel_special_summon_rule(lua_State *L) { int32 scriptlib::duel_special_summon_rule(lua_State *L) {
...@@ -323,13 +325,15 @@ int32 scriptlib::duel_special_summon_rule(lua_State *L) { ...@@ -323,13 +325,15 @@ int32 scriptlib::duel_special_summon_rule(lua_State *L) {
if(lua_gettop(L) >= 3) if(lua_gettop(L) >= 3)
sumtype = (uint32)lua_tointeger(L, 3); sumtype = (uint32)lua_tointeger(L, 3);
pduel->game_field->core.summon_cancelable = FALSE; pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->special_summon_rule(playerid, pcard, sumtype);
if(pduel->game_field->core.current_chain.size()) { if(pduel->game_field->core.current_chain.size()) {
pduel->game_field->special_summon_rule(playerid, pcard, sumtype, SUMMON_IN_CHAIN);
pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back(); pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back();
pduel->game_field->core.summon_reserved.arg3 = SUMMON_IN_CHAIN;
pduel->game_field->core.subunits.pop_back(); pduel->game_field->core.subunits.pop_back();
pduel->game_field->core.summoning_card = pcard; pduel->game_field->core.summoning_card = pcard;
} }
else {
pduel->game_field->special_summon_rule(playerid, pcard, sumtype, SUMMON_IN_IDLE);
}
return lua_yield(L, 0); return lua_yield(L, 0);
} }
int32 scriptlib::duel_synchro_summon(lua_State *L) { int32 scriptlib::duel_synchro_summon(lua_State *L) {
...@@ -368,13 +372,15 @@ int32 scriptlib::duel_synchro_summon(lua_State *L) { ...@@ -368,13 +372,15 @@ int32 scriptlib::duel_synchro_summon(lua_State *L) {
pduel->game_field->core.limit_syn_minc = minc; pduel->game_field->core.limit_syn_minc = minc;
pduel->game_field->core.limit_syn_maxc = maxc; pduel->game_field->core.limit_syn_maxc = maxc;
pduel->game_field->core.summon_cancelable = FALSE; pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_SYNCHRO);
if(pduel->game_field->core.current_chain.size()) { if(pduel->game_field->core.current_chain.size()) {
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_SYNCHRO, SUMMON_IN_CHAIN);
pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back(); pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back();
pduel->game_field->core.summon_reserved.arg3 = SUMMON_IN_CHAIN;
pduel->game_field->core.subunits.pop_back(); pduel->game_field->core.subunits.pop_back();
pduel->game_field->core.summoning_card = pcard; pduel->game_field->core.summoning_card = pcard;
} }
else {
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_SYNCHRO, SUMMON_IN_IDLE);
}
return lua_yield(L, 0); return lua_yield(L, 0);
} }
int32 scriptlib::duel_xyz_summon(lua_State *L) { int32 scriptlib::duel_xyz_summon(lua_State *L) {
...@@ -405,13 +411,15 @@ int32 scriptlib::duel_xyz_summon(lua_State *L) { ...@@ -405,13 +411,15 @@ int32 scriptlib::duel_xyz_summon(lua_State *L) {
pduel->game_field->core.limit_xyz_minc = minc; pduel->game_field->core.limit_xyz_minc = minc;
pduel->game_field->core.limit_xyz_maxc = maxc; pduel->game_field->core.limit_xyz_maxc = maxc;
pduel->game_field->core.summon_cancelable = FALSE; pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_XYZ);
if(pduel->game_field->core.current_chain.size()) { if(pduel->game_field->core.current_chain.size()) {
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_XYZ, SUMMON_IN_CHAIN);
pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back(); pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back();
pduel->game_field->core.summon_reserved.arg3 = SUMMON_IN_CHAIN;
pduel->game_field->core.subunits.pop_back(); pduel->game_field->core.subunits.pop_back();
pduel->game_field->core.summoning_card = pcard; pduel->game_field->core.summoning_card = pcard;
} }
else {
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_XYZ, SUMMON_IN_IDLE);
}
return lua_yield(L, 0); return lua_yield(L, 0);
} }
int32 scriptlib::duel_link_summon(lua_State *L) { int32 scriptlib::duel_link_summon(lua_State *L) {
...@@ -450,13 +458,15 @@ int32 scriptlib::duel_link_summon(lua_State *L) { ...@@ -450,13 +458,15 @@ int32 scriptlib::duel_link_summon(lua_State *L) {
pduel->game_field->core.limit_link_minc = minc; pduel->game_field->core.limit_link_minc = minc;
pduel->game_field->core.limit_link_maxc = maxc; pduel->game_field->core.limit_link_maxc = maxc;
pduel->game_field->core.summon_cancelable = FALSE; pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_LINK);
if(pduel->game_field->core.current_chain.size()) { if(pduel->game_field->core.current_chain.size()) {
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_LINK, SUMMON_IN_CHAIN);
pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back(); pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back();
pduel->game_field->core.summon_reserved.arg3 = SUMMON_IN_CHAIN;
pduel->game_field->core.subunits.pop_back(); pduel->game_field->core.subunits.pop_back();
pduel->game_field->core.summoning_card = pcard; pduel->game_field->core.summoning_card = pcard;
} }
else {
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_LINK, SUMMON_IN_IDLE);
}
return lua_yield(L, 0); return lua_yield(L, 0);
} }
int32 scriptlib::duel_setm(lua_State *L) { int32 scriptlib::duel_setm(lua_State *L) {
...@@ -483,13 +493,15 @@ int32 scriptlib::duel_setm(lua_State *L) { ...@@ -483,13 +493,15 @@ int32 scriptlib::duel_setm(lua_State *L) {
if(lua_gettop(L) >= 6) if(lua_gettop(L) >= 6)
zone = (uint32)lua_tointeger(L, 6); zone = (uint32)lua_tointeger(L, 6);
pduel->game_field->core.summon_cancelable = FALSE; pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->mset(playerid, pcard, peffect, ignore_count, min_tribute, zone);
if(pduel->game_field->core.current_chain.size()) { if(pduel->game_field->core.current_chain.size()) {
pduel->game_field->mset(playerid, pcard, peffect, ignore_count, min_tribute, zone, SUMMON_IN_CHAIN);
pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back(); pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back();
pduel->game_field->core.summon_reserved.arg3 = SUMMON_IN_CHAIN;
pduel->game_field->core.subunits.pop_back(); pduel->game_field->core.subunits.pop_back();
pduel->game_field->core.summoning_card = pcard; pduel->game_field->core.summoning_card = pcard;
} }
else {
pduel->game_field->mset(playerid, pcard, peffect, ignore_count, min_tribute, zone, SUMMON_IN_IDLE);
}
return lua_yield(L, 0); return lua_yield(L, 0);
} }
int32 scriptlib::duel_sets(lua_State *L) { int32 scriptlib::duel_sets(lua_State *L) {
......
This diff is collapsed.
...@@ -364,7 +364,7 @@ uint32 field::process() { ...@@ -364,7 +364,7 @@ uint32 field::process() {
return pduel->message_buffer.size(); return pduel->message_buffer.size();
} }
case PROCESSOR_SUMMON_RULE: { case PROCESSOR_SUMMON_RULE: {
if (summon(it->step, it->arg1 & 0xff, (card*)it->ptarget, it->peffect, (it->arg1 >> 8) & 0xff, (it->arg1 >> 16) & 0xff, (it->arg1 >> 24) & 0xff, it->arg3)) if (summon(it->step, it->arg1 & 0xff, (card*)it->ptarget, it->peffect, (it->arg1 >> 8) & 0xff, (it->arg1 >> 16) & 0xff, (it->arg1 >> 24) & 0xff, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
...@@ -385,14 +385,14 @@ uint32 field::process() { ...@@ -385,14 +385,14 @@ uint32 field::process() {
return pduel->message_buffer.size(); return pduel->message_buffer.size();
} }
case PROCESSOR_FLIP_SUMMON: { case PROCESSOR_FLIP_SUMMON: {
if (flip_summon(it->step, it->arg1, (card*)(it->ptarget), it->arg3)) if (flip_summon(it->step, it->arg1, (card*)(it->ptarget), it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->message_buffer.size();
} }
case PROCESSOR_MSET: { case PROCESSOR_MSET: {
if (mset(it->step, it->arg1 & 0xff, (card*)it->ptarget, it->peffect, (it->arg1 >> 8) & 0xff, (it->arg1 >> 16) & 0xff, (it->arg1 >> 24) & 0xff, it->arg3)) if (mset(it->step, it->arg1 & 0xff, (card*)it->ptarget, it->peffect, (it->arg1 >> 8) & 0xff, (it->arg1 >> 16) & 0xff, (it->arg1 >> 24) & 0xff, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
...@@ -1638,8 +1638,8 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori ...@@ -1638,8 +1638,8 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
chain newchain; chain newchain;
if(core.ignition_priority_chains.size()) if(core.ignition_priority_chains.size())
core.select_chains.swap(core.ignition_priority_chains); core.select_chains.swap(core.ignition_priority_chains);
for(const auto* ev_list : { &core.point_event, &core.instant_event }) { for(const auto& ev_list : { core.point_event, core.instant_event }) {
for(const auto& ev : *ev_list) { for(const auto& ev : ev_list) {
auto pr = effects.activate_effect.equal_range(ev.event_code); auto pr = effects.activate_effect.equal_range(ev.event_code);
for(auto eit = pr.first; eit != pr.second;) { for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = eit->second; effect* peffect = eit->second;
......
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