Commit 2a688aeb authored by Nanahira's avatar Nanahira Committed by GitHub

Merge pull request #31 from mycard/develop-8888

Develop 8888
parents 729aba23 c11af256
...@@ -24,7 +24,8 @@ jobs: ...@@ -24,7 +24,8 @@ jobs:
- name: Premake - name: Premake
run: | run: |
7z x temp\premake-5.0.0-beta2-windows.zip -opremake-5 mkdir premake-5
tar -C premake-5 -xzf temp/premake-5.0.0-beta2-windows.zip
copy premake\lua.lua lua\premake5.lua copy premake\lua.lua lua\premake5.lua
copy premake\dll.lua dll.lua copy premake\dll.lua dll.lua
.\premake-5\premake5.exe vs2022 --file=dll.lua .\premake-5\premake5.exe vs2022 --file=dll.lua
......
...@@ -128,17 +128,17 @@ bool card::card_operation_sort(card* c1, card* c2) { ...@@ -128,17 +128,17 @@ bool card::card_operation_sort(card* c1, card* c2) {
} }
if(c1->current.location != c2->current.location) if(c1->current.location != c2->current.location)
return c1->current.location < c2->current.location; return c1->current.location < c2->current.location;
if(c1->current.location & LOCATION_OVERLAY) { if(c1->current.location == LOCATION_OVERLAY) {
if(c1->overlay_target && c2->overlay_target && c1->overlay_target->current.sequence != c2->overlay_target->current.sequence) if(c1->overlay_target && c2->overlay_target && c1->overlay_target->current.sequence != c2->overlay_target->current.sequence)
return c1->overlay_target->current.sequence < c2->overlay_target->current.sequence; return c1->overlay_target->current.sequence < c2->overlay_target->current.sequence;
else else
return c1->current.sequence < c2->current.sequence; return c1->current.sequence < c2->current.sequence;
} else if (c1->current.location & LOCATION_DECK && pduel->game_field->is_select_hide_deck_sequence(cp1)) { } else if (c1->current.location == LOCATION_DECK && pduel->game_field->is_select_hide_deck_sequence(cp1)) {
// if deck reversed and the card being at the top, it should go first // if deck reversed and the card being at the top, it should go first
if(pduel->game_field->core.deck_reversed) { if(pduel->game_field->core.deck_reversed) {
if(c1->current.sequence == pduel->game_field->player[cp1].list_main.size() - 1) if(c1 == pduel->game_field->player[cp1].list_main.back())
return false; return false;
if(c2->current.sequence == pduel->game_field->player[cp2].list_main.size() - 1) if(c2 == pduel->game_field->player[cp2].list_main.back())
return true; return true;
} }
// faceup deck cards should go at the very first // faceup deck cards should go at the very first
...@@ -151,8 +151,8 @@ bool card::card_operation_sort(card* c1, card* c2) { ...@@ -151,8 +151,8 @@ bool card::card_operation_sort(card* c1, card* c2) {
return c2_faceup; return c2_faceup;
} }
// sort deck as card property // sort deck as card property
auto c1_type = c1->data.type & 0x7; auto c1_type = c1->data.type & (TYPE_MONSTER | TYPE_SPELL | TYPE_TRAP);
auto c2_type = c2->data.type & 0x7; auto c2_type = c2->data.type & (TYPE_MONSTER | TYPE_SPELL | TYPE_TRAP);
// monster should go before spell, and then trap // monster should go before spell, and then trap
if(c1_type != c2_type) if(c1_type != c2_type)
return c1_type > c2_type; return c1_type > c2_type;
...@@ -1021,13 +1021,13 @@ uint32_t card::get_level() { ...@@ -1021,13 +1021,13 @@ uint32_t card::get_level() {
temp.level = level + up; temp.level = level + up;
} }
level += up; level += up;
if(level < 1 && (get_type() & TYPE_MONSTER)) if (level < 1)
level = 1; level = 1;
temp.level = UINT32_MAX; temp.level = UINT32_MAX;
return level; return level;
} }
uint32_t card::get_rank() { uint32_t card::get_rank() {
if(!(data.type & TYPE_XYZ) || (status & STATUS_NO_LEVEL)) if (!(data.type & TYPE_XYZ))
return 0; return 0;
if(assume_type == ASSUME_RANK) if(assume_type == ASSUME_RANK)
return assume_value; return assume_value;
...@@ -1054,13 +1054,13 @@ uint32_t card::get_rank() { ...@@ -1054,13 +1054,13 @@ uint32_t card::get_rank() {
temp.level = rank + up; temp.level = rank + up;
} }
rank += up; rank += up;
if(rank < 1 && (get_type() & TYPE_MONSTER)) if (rank < 1)
rank = 1; rank = 1;
temp.level = UINT32_MAX; temp.level = UINT32_MAX;
return rank; return rank;
} }
uint32_t card::get_link() { uint32_t card::get_link() {
if(!(data.type & TYPE_LINK) || (status & STATUS_NO_LEVEL)) if (!(data.type & TYPE_LINK))
return 0; return 0;
return data.level; return data.level;
} }
...@@ -1113,22 +1113,43 @@ uint32_t card::check_xyz_level(card* pcard, uint32_t lv) { ...@@ -1113,22 +1113,43 @@ uint32_t card::check_xyz_level(card* pcard, uint32_t lv) {
uint32_t rlv = pduel->game_field->rose_level; uint32_t rlv = pduel->game_field->rose_level;
if(rcard == this && rlv == lv) if(rcard == this && rlv == lv)
return rlv; return rlv;
int32_t min_count = 0;
effect_set mset;
filter_effect(EFFECT_XYZ_MIN_COUNT, &mset);
for (int32_t i = 0; i < mset.size(); ++i) {
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(pcard, PARAM_TYPE_CARD);
int32_t count = mset[i]->get_value(2);
if (count > min_count)
min_count = count;
}
if (min_count > 0xf)
min_count = 0xf;
effect_set eset; effect_set eset;
filter_effect(EFFECT_XYZ_LEVEL, &eset); filter_effect(EFFECT_XYZ_LEVEL, &eset);
if(!eset.size()) { if(!eset.size()) {
uint32_t lev = get_level(); uint32_t card_lv = get_level();
if(lev == lv) if (card_lv == lv)
return lev; return (card_lv & MAX_XYZ_LEVEL) | ((uint32_t)min_count << 12);
return 0; return 0;
} }
for(int32_t i = 0; i < eset.size(); ++i) { for(int32_t i = 0; i < eset.size(); ++i) {
pduel->lua->add_param(this, PARAM_TYPE_CARD); pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(pcard, PARAM_TYPE_CARD); pduel->lua->add_param(pcard, PARAM_TYPE_CARD);
uint32_t lev = eset[i]->get_value(2); uint32_t lev = eset[i]->get_value(2);
if(((lev & 0xfff) == lv)) uint16_t lv1 = lev & MAX_XYZ_LEVEL;
return lev & 0xffff; uint16_t count1 = (lev & 0xf000) >> 12;
if(((lev >> 16) & 0xfff) == lv) if (count1 < min_count)
return (lev >> 16) & 0xffff; count1 = min_count;
if (lv1 == lv)
return lv1 | ((uint32_t)count1 << 12);
lev >>= 16;
uint16_t lv2 = lev & MAX_XYZ_LEVEL;
uint16_t count2 = (lev & 0xf000) >> 12;
if (count2 < min_count)
count2 = min_count;
if (lv2 == lv)
return lv2 | ((uint32_t)count2 << 12);
} }
return 0; return 0;
} }
...@@ -1475,7 +1496,7 @@ int32_t card::is_extra_link_state() { ...@@ -1475,7 +1496,7 @@ int32_t card::is_extra_link_state() {
uint32_t checking = linked_zone & ~checked; uint32_t checking = linked_zone & ~checked;
if(!checking) if(!checking)
return FALSE; return FALSE;
uint32_t rightmost = checking & (-checking); uint32_t rightmost = checking & (~checking + 1);
checked |= rightmost; checked |= rightmost;
if(rightmost < 0x10000U) { if(rightmost < 0x10000U) {
for(int32_t i = 0; i < 7; ++i) { for(int32_t i = 0; i < 7; ++i) {
......
...@@ -54,10 +54,10 @@ struct card_state { ...@@ -54,10 +54,10 @@ struct card_state {
uint8_t sequence{ 0 }; uint8_t sequence{ 0 };
uint8_t position{ 0 }; uint8_t position{ 0 };
uint32_t reason{ 0 }; uint32_t reason{ 0 };
bool pzone{ false };
card* reason_card{ nullptr }; card* reason_card{ nullptr };
uint8_t reason_player{ PLAYER_NONE };
effect* reason_effect{ nullptr }; effect* reason_effect{ nullptr };
uint8_t reason_player{ PLAYER_NONE };
bool pzone{ false };
bool is_location(uint32_t loc) const; bool is_location(uint32_t loc) const;
bool is_main_mzone() const { bool is_main_mzone() const {
...@@ -176,7 +176,7 @@ public: ...@@ -176,7 +176,7 @@ public:
uint8_t removed_overlay_count{}; uint8_t removed_overlay_count{};
uint8_t attack_all_target{}; uint8_t attack_all_target{};
uint8_t attack_controler{}; uint8_t attack_controler{};
uint16_t cardid{}; uint64_t cardid{};
uint32_t fieldid{}; uint32_t fieldid{};
uint32_t fieldid_r{}; uint32_t fieldid_r{};
uint16_t turnid{}; uint16_t turnid{};
......
...@@ -168,8 +168,8 @@ int32_t effect::check_count_limit(uint8_t playerid) { ...@@ -168,8 +168,8 @@ int32_t effect::check_count_limit(uint8_t playerid) {
return FALSE; return FALSE;
if(count_code) { if(count_code) {
uint32_t limit_code = count_code & MAX_CARD_ID; uint32_t limit_code = count_code & MAX_CARD_ID;
uint32_t limit_type = count_code & 0xf0000000; uint32_t limit_type = count_code & 0xf0000000U;
uint32_t count = count_limit_max; int32_t count = count_limit_max;
if(limit_code == EFFECT_COUNT_CODE_SINGLE) { if(limit_code == EFFECT_COUNT_CODE_SINGLE) {
if(pduel->game_field->get_effect_code(limit_type | get_handler()->fieldid, PLAYER_NONE) >= count) if(pduel->game_field->get_effect_code(limit_type | get_handler()->fieldid, PLAYER_NONE) >= count)
return FALSE; return FALSE;
......
...@@ -148,10 +148,10 @@ public: ...@@ -148,10 +148,10 @@ public:
//#define EFFECT_STATUS_ACTIVATED 0x0002 //#define EFFECT_STATUS_ACTIVATED 0x0002
#define EFFECT_STATUS_SPSELF 0x0004 #define EFFECT_STATUS_SPSELF 0x0004
#define EFFECT_COUNT_CODE_OATH 0x10000000 #define EFFECT_COUNT_CODE_OATH 0x10000000U
#define EFFECT_COUNT_CODE_DUEL 0x20000000 #define EFFECT_COUNT_CODE_DUEL 0x20000000U
#define EFFECT_COUNT_CODE_CHAIN 0x40000000 #define EFFECT_COUNT_CODE_CHAIN 0x40000000U
#define EFFECT_COUNT_CODE_SINGLE 0x1 #define EFFECT_COUNT_CODE_SINGLE 0x1U
//========== Reset ========== //========== Reset ==========
#define RESET_SELF_TURN 0x10000000 #define RESET_SELF_TURN 0x10000000
...@@ -549,6 +549,7 @@ const std::map<uint64_t, uint64_t> category_checklist{ ...@@ -549,6 +549,7 @@ const std::map<uint64_t, uint64_t> category_checklist{
#define EFFECT_TUNER 369 #define EFFECT_TUNER 369
#define EFFECT_KAISER_COLOSSEUM 370 #define EFFECT_KAISER_COLOSSEUM 370
#define EFFECT_REPLACE_DAMAGE 371 #define EFFECT_REPLACE_DAMAGE 371
#define EFFECT_XYZ_MIN_COUNT 372
//#define EVENT_STARTUP 1000 //#define EVENT_STARTUP 1000
#define EVENT_FLIP 1001 #define EVENT_FLIP 1001
...@@ -626,12 +627,15 @@ const std::map<uint64_t, uint64_t> category_checklist{ ...@@ -626,12 +627,15 @@ const std::map<uint64_t, uint64_t> category_checklist{
#define EVENT_REMOVE_COUNTER 0x20000 #define EVENT_REMOVE_COUNTER 0x20000
#define EVENT_CUSTOM 0x10000000 #define EVENT_CUSTOM 0x10000000
constexpr int32_t DOUBLE_DAMAGE = 0x80000000; constexpr int32_t DOUBLE_DAMAGE = INT32_MIN;
constexpr int32_t HALF_DAMAGE = 0x80000001; constexpr int32_t HALF_DAMAGE = INT32_MIN + 1;
constexpr uint32_t MAX_PARAMETER = 0xffffU;
constexpr uint32_t MAX_XYZ_LEVEL = 0x0fffU;
// flag effect // flag effect
#define EFFECT_FLAG_EFFECT 0x20000000 #define EFFECT_FLAG_EFFECT 0x20000000U
#define MAX_CARD_ID 0xfffffff #define MAX_CARD_ID 0x0fffffffU
// The type of effect code // The type of effect code
enum code_type : int32_t { enum code_type : int32_t {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "effect.h" #include "effect.h"
#include "interpreter.h" #include "interpreter.h"
#include <cstring> #include <cstring>
#include <algorithm>
int32_t field::field_used_count[32] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5}; int32_t field::field_used_count[32] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5};
...@@ -902,7 +903,7 @@ int32_t field::check_extra_link(int32_t playerid) { ...@@ -902,7 +903,7 @@ int32_t field::check_extra_link(int32_t playerid) {
uint32_t checking = linked_zone & ~checked; uint32_t checking = linked_zone & ~checked;
if(!checking) if(!checking)
return FALSE; return FALSE;
uint32_t rightmost = checking & (-checking); uint32_t rightmost = checking & (~checking + 1);
checked |= rightmost; checked |= rightmost;
if(rightmost < 0x10000U) { if(rightmost < 0x10000U) {
for(int32_t i = 0; i < 7; ++i) { for(int32_t i = 0; i < 7; ++i) {
...@@ -1120,11 +1121,9 @@ void field::reverse_deck(uint8_t playerid) { ...@@ -1120,11 +1121,9 @@ void field::reverse_deck(uint8_t playerid) {
if(count == 0) if(count == 0)
return; return;
for(int32_t i = 0; i < count / 2; ++i) { for(int32_t i = 0; i < count / 2; ++i) {
card* tmp = player[playerid].list_main[i]; player[playerid].list_main[i]->current.sequence = count - 1 - i;
tmp->current.sequence = count - 1 - i;
player[playerid].list_main[count - 1 - i]->current.sequence = i; player[playerid].list_main[count - 1 - i]->current.sequence = i;
player[playerid].list_main[i] = player[playerid].list_main[count - 1 - i]; std::swap(player[playerid].list_main[i], player[playerid].list_main[count - 1 - i]);
player[playerid].list_main[count - 1 - i] = tmp;
} }
} }
void field::refresh_player_info(uint8_t playerid) { void field::refresh_player_info(uint8_t playerid) {
...@@ -1356,36 +1355,42 @@ void field::reset_chain() { ...@@ -1356,36 +1355,42 @@ void field::reset_chain() {
(*rm)->handler->remove_effect((*rm)); (*rm)->handler->remove_effect((*rm));
} }
} }
void field::add_effect_code(uint32_t code, uint32_t playerid) { void field::add_effect_code(uint32_t code, int32_t playerid) {
auto* count_map = &core.effect_count_code; if (playerid < 0 || playerid > PLAYER_NONE)
if(code & EFFECT_COUNT_CODE_DUEL) return;
count_map = &core.effect_count_code_duel; auto count_map = &core.effect_count_code[playerid];
else if(code & EFFECT_COUNT_CODE_CHAIN) if (code & EFFECT_COUNT_CODE_DUEL)
count_map = &core.effect_count_code_chain; count_map = &core.effect_count_code_duel[playerid];
(*count_map)[code + (playerid << 30)]++; else if (code & EFFECT_COUNT_CODE_CHAIN)
} count_map = &core.effect_count_code_chain[playerid];
uint32_t field::get_effect_code(uint32_t code, uint32_t playerid) { (*count_map)[code]++;
auto* count_map = &core.effect_count_code; }
int32_t field::get_effect_code(uint32_t code, int32_t playerid) {
if (playerid < 0 || playerid > PLAYER_NONE)
return 0;
auto count_map = &core.effect_count_code[playerid];
if(code & EFFECT_COUNT_CODE_DUEL) if(code & EFFECT_COUNT_CODE_DUEL)
count_map = &core.effect_count_code_duel; count_map = &core.effect_count_code_duel[playerid];
else if(code & EFFECT_COUNT_CODE_CHAIN) else if(code & EFFECT_COUNT_CODE_CHAIN)
count_map = &core.effect_count_code_chain; count_map = &core.effect_count_code_chain[playerid];
auto iter = count_map->find(code + (playerid << 30)); auto iter = count_map->find(code);
if(iter == count_map->end()) if(iter == count_map->end())
return 0; return 0;
return iter->second; return iter->second;
} }
void field::dec_effect_code(uint32_t code, uint32_t playerid) { void field::dec_effect_code(uint32_t code, int32_t playerid) {
auto* count_map = &core.effect_count_code; if (playerid < 0 || playerid > PLAYER_NONE)
if(code & EFFECT_COUNT_CODE_DUEL) return;
count_map = &core.effect_count_code_duel; auto count_map = &core.effect_count_code[playerid];
else if(code & EFFECT_COUNT_CODE_CHAIN) if (code & EFFECT_COUNT_CODE_DUEL)
count_map = &core.effect_count_code_chain; count_map = &core.effect_count_code_duel[playerid];
auto iter = count_map->find(code + (playerid << 30)); else if (code & EFFECT_COUNT_CODE_CHAIN)
count_map = &core.effect_count_code_chain[playerid];
auto iter = count_map->find(code);
if(iter == count_map->end()) if(iter == count_map->end())
return; return;
if(iter->second > 0) if (iter->second > 0)
--iter->second; iter->second--;
} }
void field::filter_field_effect(uint32_t code, effect_set* eset, uint8_t sort) { void field::filter_field_effect(uint32_t code, effect_set* eset, uint8_t sort) {
auto rg = effects.aura_effect.equal_range(code); auto rg = effects.aura_effect.equal_range(code);
......
...@@ -123,11 +123,11 @@ struct field_effect { ...@@ -123,11 +123,11 @@ struct field_effect {
grant_effect_container grant_effect; grant_effect_container grant_effect;
}; };
struct field_info { struct field_info {
uint64_t card_id{ 1 };
int32_t field_id{ 1 }; int32_t field_id{ 1 };
uint16_t copy_id{ 1 }; uint16_t copy_id{ 1 };
uint16_t turn_id{}; uint16_t turn_id{};
uint16_t turn_id_by_player[2]{}; uint16_t turn_id_by_player[2]{};
uint16_t card_id{ 1 };
uint16_t phase{}; uint16_t phase{};
uint8_t turn_player{}; uint8_t turn_player{};
uint8_t priorities[2]{}; uint8_t priorities[2]{};
...@@ -255,9 +255,9 @@ struct processor { ...@@ -255,9 +255,9 @@ struct processor {
std::set<effect*> reseted_effects; std::set<effect*> reseted_effects;
std::unordered_map<card*, uint32_t> readjust_map; std::unordered_map<card*, uint32_t> readjust_map;
std::unordered_set<card*> unique_cards[2]; std::unordered_set<card*> unique_cards[2];
std::unordered_map<uint32_t, uint32_t> effect_count_code; std::unordered_map<uint32_t, int32_t> effect_count_code[3];
std::unordered_map<uint32_t, uint32_t> effect_count_code_duel; std::unordered_map<uint32_t, int32_t> effect_count_code_duel[3];
std::unordered_map<uint32_t, uint32_t> effect_count_code_chain; std::unordered_map<uint32_t, int32_t> effect_count_code_chain[3];
std::unordered_map<uint32_t, uint32_t> spsummon_once_map[2]; std::unordered_map<uint32_t, uint32_t> spsummon_once_map[2];
std::multimap<int32_t, card*, std::greater<int32_t>> xmaterial_lst; std::multimap<int32_t, card*, std::greater<int32_t>> xmaterial_lst;
...@@ -348,7 +348,7 @@ struct processor { ...@@ -348,7 +348,7 @@ struct processor {
uint8_t current_player{ PLAYER_NONE }; uint8_t current_player{ PLAYER_NONE };
uint8_t conti_player{ PLAYER_NONE }; uint8_t conti_player{ PLAYER_NONE };
uint8_t select_deck_sequence_revealed{ FALSE }; uint8_t select_deck_sequence_revealed{ FALSE };
uint8_t selecting_player{ PLAYER_NONE }; uint8_t selecting_player{ 0 };
activity_map summon_counter; activity_map summon_counter;
activity_map normalsummon_counter; activity_map normalsummon_counter;
activity_map spsummon_counter; activity_map spsummon_counter;
...@@ -418,9 +418,9 @@ public: ...@@ -418,9 +418,9 @@ public:
void release_oath_relation(effect* reason_effect); void release_oath_relation(effect* reason_effect);
void reset_phase(uint32_t phase); void reset_phase(uint32_t phase);
void reset_chain(); void reset_chain();
void add_effect_code(uint32_t code, uint32_t playerid); void add_effect_code(uint32_t code, int32_t playerid);
uint32_t get_effect_code(uint32_t code, uint32_t playerid); int32_t get_effect_code(uint32_t code, int32_t playerid);
void dec_effect_code(uint32_t code, uint32_t playerid); void dec_effect_code(uint32_t code, int32_t playerid);
void filter_field_effect(uint32_t code, effect_set* eset, uint8_t sort = TRUE); void filter_field_effect(uint32_t code, effect_set* eset, uint8_t sort = TRUE);
void filter_affected_cards(effect* peffect, card_set* cset); void filter_affected_cards(effect* peffect, card_set* cset);
......
...@@ -18,17 +18,17 @@ class duel; ...@@ -18,17 +18,17 @@ class duel;
using card_set = std::set<card*, card_sort>; using card_set = std::set<card*, card_sort>;
constexpr int GTYPE_DEFAULT = 0; constexpr uint32_t GTYPE_DEFAULT = 0;
constexpr int GTYPE_READ_ONLY = 1; constexpr uint32_t GTYPE_READ_ONLY = 1;
constexpr int GTYPE_KEEP_ALIVE = 2; constexpr uint32_t GTYPE_KEEP_ALIVE = 2;
class group { class alignas(8) group {
public: public:
int32_t ref_handle{ 0 };
uint32_t is_readonly{ GTYPE_DEFAULT };
duel* pduel; duel* pduel;
card_set container; card_set container;
card_set::iterator it; card_set::iterator it;
int32_t ref_handle{ 0 };
uint32_t is_readonly{ GTYPE_DEFAULT };
bool is_iterator_dirty{ true }; bool is_iterator_dirty{ true };
bool has_card(card* c) { bool has_card(card* c) {
......
...@@ -196,7 +196,7 @@ int32_t scriptlib::effect_set_count_limit(lua_State *L) { ...@@ -196,7 +196,7 @@ int32_t scriptlib::effect_set_count_limit(lua_State *L) {
if(v == 0) if(v == 0)
v = 1; v = 1;
if(code == EFFECT_COUNT_CODE_CHAIN) if(code == EFFECT_COUNT_CODE_CHAIN)
code = EFFECT_COUNT_CODE_CHAIN + EFFECT_COUNT_CODE_SINGLE; code = EFFECT_COUNT_CODE_CHAIN | EFFECT_COUNT_CODE_SINGLE;
peffect->flag[0] |= EFFECT_FLAG_COUNT_LIMIT; peffect->flag[0] |= EFFECT_FLAG_COUNT_LIMIT;
peffect->count_limit = v; peffect->count_limit = v;
peffect->count_limit_max = v; peffect->count_limit_max = v;
......
...@@ -261,10 +261,10 @@ int32_t field::select_card(uint16_t step, uint8_t playerid, uint8_t cancelable, ...@@ -261,10 +261,10 @@ int32_t field::select_card(uint16_t step, uint8_t playerid, uint8_t cancelable,
pduel->write_buffer8(min); pduel->write_buffer8(min);
pduel->write_buffer8(max); pduel->write_buffer8(max);
pduel->write_buffer8((uint8_t)core.select_cards.size()); pduel->write_buffer8((uint8_t)core.select_cards.size());
uint8_t deck_seq_pointer = 0; uint8_t deck_seq = 0;
for(auto& pcard : core.select_cards) { for(auto& pcard : core.select_cards) {
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
pduel->write_buffer32(pcard->get_select_info_location(&deck_seq_pointer)); pduel->write_buffer32(pcard->get_select_info_location(&deck_seq));
} }
return FALSE; return FALSE;
} else { } else {
...@@ -305,15 +305,15 @@ int32_t field::select_unselect_card(uint16_t step, uint8_t playerid, uint8_t can ...@@ -305,15 +305,15 @@ int32_t field::select_unselect_card(uint16_t step, uint8_t playerid, uint8_t can
pduel->write_buffer8(min); pduel->write_buffer8(min);
pduel->write_buffer8(max); pduel->write_buffer8(max);
pduel->write_buffer8((uint8_t)core.select_cards.size()); pduel->write_buffer8((uint8_t)core.select_cards.size());
uint8_t deck_seq_pointer = 0; uint8_t deck_seq = 0;
for(auto& pcard : core.select_cards) { for(auto& pcard : core.select_cards) {
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
pduel->write_buffer32(pcard->get_select_info_location(&deck_seq_pointer)); pduel->write_buffer32(pcard->get_select_info_location(&deck_seq));
} }
pduel->write_buffer8((uint8_t)core.unselect_cards.size()); pduel->write_buffer8((uint8_t)core.unselect_cards.size());
for(auto& pcard : core.unselect_cards) { for(auto& pcard : core.unselect_cards) {
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
pduel->write_buffer32(pcard->get_select_info_location(&deck_seq_pointer)); pduel->write_buffer32(pcard->get_select_info_location(&deck_seq));
} }
return FALSE; return FALSE;
} else { } else {
...@@ -530,12 +530,12 @@ int32_t field::select_tribute(uint16_t step, uint8_t playerid, uint8_t cancelabl ...@@ -530,12 +530,12 @@ int32_t field::select_tribute(uint16_t step, uint8_t playerid, uint8_t cancelabl
pduel->write_buffer8(min); pduel->write_buffer8(min);
pduel->write_buffer8(max); pduel->write_buffer8(max);
pduel->write_buffer8((uint8_t)core.select_cards.size()); pduel->write_buffer8((uint8_t)core.select_cards.size());
uint8_t deck_seq_pointer = 0; uint8_t deck_seq = 0;
for(auto& pcard : core.select_cards) { for(auto& pcard : core.select_cards) {
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.controler);
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->get_select_sequence(&deck_seq_pointer)); pduel->write_buffer8(pcard->get_select_sequence(&deck_seq));
pduel->write_buffer8(pcard->release_param); pduel->write_buffer8(pcard->release_param);
} }
return FALSE; return FALSE;
...@@ -605,12 +605,12 @@ int32_t field::select_counter(uint16_t step, uint8_t playerid, uint16_t countert ...@@ -605,12 +605,12 @@ int32_t field::select_counter(uint16_t step, uint8_t playerid, uint16_t countert
pduel->write_buffer8((uint8_t)core.select_cards.size()); pduel->write_buffer8((uint8_t)core.select_cards.size());
core.selecting_player = playerid; core.selecting_player = playerid;
std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort); std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort);
uint8_t deck_seq_pointer = 0; uint8_t deck_seq = 0;
for(auto& pcard : core.select_cards) { for(auto& pcard : core.select_cards) {
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.controler);
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->get_select_sequence(&deck_seq_pointer)); pduel->write_buffer8(pcard->get_select_sequence(&deck_seq));
pduel->write_buffer16(pcard->get_counter(countertype)); pduel->write_buffer16(pcard->get_counter(countertype));
} }
return FALSE; return FALSE;
...@@ -663,12 +663,12 @@ int32_t field::select_with_sum_limit(int16_t step, uint8_t playerid, int32_t acc ...@@ -663,12 +663,12 @@ int32_t field::select_with_sum_limit(int16_t step, uint8_t playerid, int32_t acc
pduel->write_buffer8(min); pduel->write_buffer8(min);
pduel->write_buffer8(max); pduel->write_buffer8(max);
pduel->write_buffer8((uint8_t)core.must_select_cards.size()); pduel->write_buffer8((uint8_t)core.must_select_cards.size());
uint8_t deck_seq_pointer = 0; uint8_t deck_seq = 0;
for(auto& pcard : core.must_select_cards) { for(auto& pcard : core.must_select_cards) {
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.controler);
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->get_select_sequence(&deck_seq_pointer)); pduel->write_buffer8(pcard->get_select_sequence(&deck_seq));
pduel->write_buffer32(pcard->sum_param); pduel->write_buffer32(pcard->sum_param);
} }
pduel->write_buffer8((uint8_t)core.select_cards.size()); pduel->write_buffer8((uint8_t)core.select_cards.size());
...@@ -676,7 +676,7 @@ int32_t field::select_with_sum_limit(int16_t step, uint8_t playerid, int32_t acc ...@@ -676,7 +676,7 @@ int32_t field::select_with_sum_limit(int16_t step, uint8_t playerid, int32_t acc
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.controler);
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->get_select_sequence(&deck_seq_pointer)); pduel->write_buffer8(pcard->get_select_sequence(&deck_seq));
pduel->write_buffer32(pcard->sum_param); pduel->write_buffer32(pcard->sum_param);
} }
return FALSE; return FALSE;
......
...@@ -1498,7 +1498,9 @@ int32_t field::process_point_event(int16_t step, int32_t skip_trigger, int32_t s ...@@ -1498,7 +1498,9 @@ int32_t field::process_point_event(int16_t step, int32_t skip_trigger, int32_t s
for(auto& ch_lim_p : core.chain_limit_p) for(auto& ch_lim_p : core.chain_limit_p)
luaL_unref(pduel->lua->lua_state, LUA_REGISTRYINDEX, ch_lim_p.function); luaL_unref(pduel->lua->lua_state, LUA_REGISTRYINDEX, ch_lim_p.function);
core.chain_limit_p.clear(); core.chain_limit_p.clear();
core.effect_count_code_chain.clear(); core.effect_count_code_chain[0].clear();
core.effect_count_code_chain[1].clear();
core.effect_count_code_chain[PLAYER_NONE].clear();
reset_chain(); reset_chain();
returns.ivalue[0] = FALSE; returns.ivalue[0] = FALSE;
} }
...@@ -3681,7 +3683,9 @@ int32_t field::process_turn(uint16_t step, uint8_t turn_player) { ...@@ -3681,7 +3683,9 @@ int32_t field::process_turn(uint16_t step, uint8_t turn_player) {
pduel->delete_effect(peffect); pduel->delete_effect(peffect);
} }
core.reseted_effects.clear(); core.reseted_effects.clear();
core.effect_count_code.clear(); core.effect_count_code[0].clear();
core.effect_count_code[1].clear();
core.effect_count_code[PLAYER_NONE].clear();
for(uint8_t p = 0; p < 2; ++p) { for(uint8_t p = 0; p < 2; ++p) {
for(auto& pcard : player[p].list_mzone) { for(auto& pcard : player[p].list_mzone) {
if(!pcard) if(!pcard)
...@@ -4558,7 +4562,9 @@ int32_t field::solve_chain(uint16_t step, uint32_t chainend_arg1, uint32_t chain ...@@ -4558,7 +4562,9 @@ int32_t field::solve_chain(uint16_t step, uint32_t chainend_arg1, uint32_t chain
for(auto& ch_lim_p : core.chain_limit_p) for(auto& ch_lim_p : core.chain_limit_p)
luaL_unref(pduel->lua->lua_state, LUA_REGISTRYINDEX, ch_lim_p.function); luaL_unref(pduel->lua->lua_state, LUA_REGISTRYINDEX, ch_lim_p.function);
core.chain_limit_p.clear(); core.chain_limit_p.clear();
core.effect_count_code_chain.clear(); core.effect_count_code_chain[0].clear();
core.effect_count_code_chain[1].clear();
core.effect_count_code_chain[PLAYER_NONE].clear();
reset_chain(); reset_chain();
if (core.summoning_card) if (core.summoning_card)
core.subunits.push_back(core.summon_reserved); core.subunits.push_back(core.summon_reserved);
......
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