Commit 17bfea47 authored by salix5's avatar salix5

Merge branch 'master' into patch-release

parents acb4cc0e 8657c2f2
This diff is collapsed.
...@@ -23,58 +23,61 @@ class group; ...@@ -23,58 +23,61 @@ class group;
struct chain; struct chain;
struct card_data { struct card_data {
uint32 code; uint32 code{ 0 };
uint32 alias; uint32 alias{ 0 };
uint64 setcode; uint64 setcode{ 0 };
uint32 type; uint32 type{ 0 };
uint32 level; uint32 level{ 0 };
uint32 attribute; uint32 attribute{ 0 };
uint32 race; uint32 race{ 0 };
int32 attack; int32 attack{ 0 };
int32 defense; int32 defense{ 0 };
uint32 lscale; uint32 lscale{ 0 };
uint32 rscale; uint32 rscale{ 0 };
uint32 link_marker; uint32 link_marker{ 0 };
void clear(); void clear();
}; };
struct card_state { struct card_state {
card_state() uint32 code{ 0 };
: code(0), code2(0), type(0), level(0), rank(0), link(0), lscale(0), rscale(0), attribute(0), race(0), attack(0), defense(0), base_attack(0), base_defense(0), uint32 code2{ 0 };
controler(PLAYER_NONE), location(0), sequence(0), position(0), reason(0), pzone(false), reason_card(nullptr), reason_player(PLAYER_NONE), reason_effect(nullptr) {}
uint32 code;
uint32 code2;
std::vector<uint32> setcode; std::vector<uint32> setcode;
uint32 type; uint32 type{ 0 };
uint32 level; uint32 level{ 0 };
uint32 rank; uint32 rank{ 0 };
uint32 link; uint32 link{ 0 };
uint32 lscale; uint32 lscale{ 0 };
uint32 rscale; uint32 rscale{ 0 };
uint32 attribute; uint32 attribute{ 0 };
uint32 race; uint32 race{ 0 };
int32 attack; int32 attack{ 0 };
int32 defense; int32 defense{ 0 };
int32 base_attack; int32 base_attack{ 0 };
int32 base_defense; int32 base_defense{ 0 };
uint8 controler; uint8 controler{ PLAYER_NONE };
uint8 location; uint8 location{ 0 };
uint8 sequence; uint8 sequence{ 0 };
uint8 position; uint8 position{ 0 };
uint32 reason; uint32 reason{ 0 };
bool pzone; bool pzone{ false };
card* reason_card; card* reason_card{ nullptr };
uint8 reason_player; uint8 reason_player{ PLAYER_NONE };
effect* reason_effect; effect* reason_effect{ nullptr };
bool is_location(int32 loc) const; bool is_location(int32 loc) const;
bool is_main_mzone() const {
return location == LOCATION_MZONE && sequence >= 0 && sequence <= 4;
}
bool is_stzone() const {
return location == LOCATION_SZONE && sequence >= 0 && sequence <= 4;
}
void init_state(); void init_state();
}; };
struct query_cache { struct query_cache {
uint32 code; uint32 info_location;
uint32 alias; uint32 current_code;
uint32 type; uint32 type;
uint32 level; uint32 level;
uint32 rank; uint32 rank;
...@@ -94,23 +97,19 @@ struct query_cache { ...@@ -94,23 +97,19 @@ struct query_cache {
struct material_info { struct material_info {
// Synchron // Synchron
card* limit_tuner; card* limit_tuner{ nullptr };
group* limit_syn; group* limit_syn{ nullptr };
int32 limit_syn_minc; int32 limit_syn_minc{ 0 };
int32 limit_syn_maxc; int32 limit_syn_maxc{ 0 };
// Xyz // Xyz
group* limit_xyz; group* limit_xyz{ nullptr };
int32 limit_xyz_minc; int32 limit_xyz_minc{ 0 };
int32 limit_xyz_maxc; int32 limit_xyz_maxc{ 0 };
// Link // Link
group* limit_link; group* limit_link{ nullptr };
card* limit_link_card; card* limit_link_card{ nullptr };
int32 limit_link_minc; int32 limit_link_minc{ 0 };
int32 limit_link_maxc; int32 limit_link_maxc{ 0 };
material_info()
: limit_tuner(nullptr), limit_syn(nullptr), limit_syn_minc(0), limit_syn_maxc(0), limit_xyz(nullptr), limit_xyz_minc(0), limit_xyz_maxc(0),
limit_link(nullptr), limit_link_card(nullptr), limit_link_minc(0), limit_link_maxc(0) {}
}; };
const material_info null_info; const material_info null_info;
...@@ -147,10 +146,10 @@ public: ...@@ -147,10 +146,10 @@ public:
location = 0; location = 0;
sequence = 0; sequence = 0;
} }
uint8 playerid; uint8 playerid{ 0 };
uint8 position; uint8 position{ 0 };
uint8 location; uint8 location{ 0 };
uint8 sequence; uint8 sequence{ 0 };
}; };
int32 ref_handle; int32 ref_handle;
duel* pduel; duel* pduel;
...@@ -158,6 +157,7 @@ public: ...@@ -158,6 +157,7 @@ public:
card_state previous; card_state previous;
card_state temp; card_state temp;
card_state current; card_state current;
card_state spsummon;
query_cache q_cache; query_cache q_cache;
uint8 owner; uint8 owner;
uint8 summon_player; uint8 summon_player;
...@@ -218,7 +218,7 @@ public: ...@@ -218,7 +218,7 @@ public:
static bool card_operation_sort(card* c1, card* c2); static bool card_operation_sort(card* c1, card* c2);
const bool is_extra_deck_monster() { return !!(data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)); } const bool is_extra_deck_monster() { return !!(data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)); }
uint32 get_infos(byte* buf, int32 query_flag, int32 use_cache = TRUE); int32 get_infos(byte* buf, uint32 query_flag, int32 use_cache = TRUE);
uint32 get_info_location(); uint32 get_info_location();
uint32 second_code(uint32 code); uint32 second_code(uint32 code);
uint32 get_code(); uint32 get_code();
...@@ -228,6 +228,7 @@ public: ...@@ -228,6 +228,7 @@ public:
int32 is_pre_set_card(uint32 set_code); int32 is_pre_set_card(uint32 set_code);
int32 is_fusion_set_card(uint32 set_code); int32 is_fusion_set_card(uint32 set_code);
int32 is_link_set_card(uint32 set_code); int32 is_link_set_card(uint32 set_code);
int32 is_special_summon_set_card(uint32 set_code);
uint32 get_type(); uint32 get_type();
uint32 get_fusion_type(); uint32 get_fusion_type();
uint32 get_synchro_type(); uint32 get_synchro_type();
...@@ -272,7 +273,7 @@ public: ...@@ -272,7 +273,7 @@ public:
void get_column_cards(card_set* cset); void get_column_cards(card_set* cset);
int32 is_all_column(); int32 is_all_column();
void equip(card *target, uint32 send_msg = TRUE); void equip(card* target, uint32 send_msg = TRUE);
void unequip(); void unequip();
int32 get_union_count(); int32 get_union_count();
int32 get_old_union_count(); int32 get_old_union_count();
...@@ -314,6 +315,7 @@ public: ...@@ -314,6 +315,7 @@ public:
void add_card_target(card* pcard); void add_card_target(card* pcard);
void cancel_card_target(card* pcard); void cancel_card_target(card* pcard);
void clear_card_target(); void clear_card_target();
void set_special_summon_status(effect* peffect);
void filter_effect(int32 code, effect_set* eset, uint8 sort = TRUE); void filter_effect(int32 code, effect_set* eset, uint8 sort = TRUE);
void filter_single_continuous_effect(int32 code, effect_set* eset, uint8 sort = TRUE); void filter_single_continuous_effect(int32 code, effect_set* eset, uint8 sort = TRUE);
...@@ -335,7 +337,7 @@ public: ...@@ -335,7 +337,7 @@ public:
int32 is_tuner(card* scard); int32 is_tuner(card* scard);
int32 check_unique_code(card* pcard); int32 check_unique_code(card* pcard);
void get_unique_target(card_set* cset, int32 controler, card* icard = 0); void get_unique_target(card_set* cset, int32 controler, card* icard = nullptr);
int32 check_cost_condition(int32 ecode, int32 playerid); int32 check_cost_condition(int32 ecode, int32 playerid);
int32 check_cost_condition(int32 ecode, int32 playerid, int32 sumtype); int32 check_cost_condition(int32 ecode, int32 playerid, int32 sumtype);
int32 is_summonable_card(); int32 is_summonable_card();
...@@ -382,7 +384,7 @@ public: ...@@ -382,7 +384,7 @@ public:
int32 is_capable_be_effect_target(effect* reason_effect, uint8 playerid); int32 is_capable_be_effect_target(effect* reason_effect, uint8 playerid);
int32 is_capable_overlay(uint8 playerid); int32 is_capable_overlay(uint8 playerid);
int32 is_can_be_fusion_material(card* fcard, uint32 summon_type); int32 is_can_be_fusion_material(card* fcard, uint32 summon_type);
int32 is_can_be_synchro_material(card* scard, card* tuner = 0); int32 is_can_be_synchro_material(card* scard, card* tuner = nullptr);
int32 is_can_be_ritual_material(card* scard); int32 is_can_be_ritual_material(card* scard);
int32 is_can_be_xyz_material(card* scard); int32 is_can_be_xyz_material(card* scard);
int32 is_can_be_link_material(card* scard); int32 is_can_be_link_material(card* scard);
...@@ -400,10 +402,12 @@ public: ...@@ -400,10 +402,12 @@ public:
#define SUMMON_TYPE_XYZ 0x49000000 #define SUMMON_TYPE_XYZ 0x49000000
#define SUMMON_TYPE_PENDULUM 0x4a000000 #define SUMMON_TYPE_PENDULUM 0x4a000000
#define SUMMON_TYPE_LINK 0x4c000000 #define SUMMON_TYPE_LINK 0x4c000000
//Counter //Counter
#define COUNTER_WITHOUT_PERMIT 0x1000 #define COUNTER_WITHOUT_PERMIT 0x1000
//#define COUNTER_NEED_ENABLE 0x2000 //#define COUNTER_NEED_ENABLE 0x2000
//Assume
#define ASSUME_CODE 1 #define ASSUME_CODE 1
#define ASSUME_TYPE 2 #define ASSUME_TYPE 2
#define ASSUME_LEVEL 3 #define ASSUME_LEVEL 3
...@@ -413,6 +417,18 @@ public: ...@@ -413,6 +417,18 @@ public:
#define ASSUME_ATTACK 7 #define ASSUME_ATTACK 7
#define ASSUME_DEFENSE 8 #define ASSUME_DEFENSE 8
//Summon info
#define SUMMON_INFO_CODE 0x01
#define SUMMON_INFO_CODE2 0x02
#define SUMMON_INFO_TYPE 0x04
#define SUMMON_INFO_LEVEL 0x08
#define SUMMON_INFO_RANK 0x10
#define SUMMON_INFO_ATTRIBUTE 0x20
#define SUMMON_INFO_RACE 0x40
#define SUMMON_INFO_ATTACK 0x80
#define SUMMON_INFO_DEFENSE 0x100
#define SUMMON_INFO_REASON_EFFECT 0x200
//double-name cards //double-name cards
#define CARD_MARINE_DOLPHIN 78734254 #define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930 #define CARD_TWINKLE_MOSS 13857930
......
...@@ -18,7 +18,6 @@ typedef long long int64; ...@@ -18,7 +18,6 @@ typedef long long int64;
typedef int int32; typedef int int32;
typedef short int16; typedef short int16;
typedef signed char int8; typedef signed char int8;
typedef int BOOL;
#define MATCH_ALL(x,y) (((x)&(y))==(y)) #define MATCH_ALL(x,y) (((x)&(y))==(y))
#define MATCH_ANY(x,y) ((x)&(y)) #define MATCH_ANY(x,y) ((x)&(y))
...@@ -30,6 +29,15 @@ typedef int BOOL; ...@@ -30,6 +29,15 @@ typedef int BOOL;
#define OPERATION_CANCELED -1 #define OPERATION_CANCELED -1
#define TRUE 1 #define TRUE 1
#define FALSE 0 #define FALSE 0
#define SIZE_MESSAGE_BUFFER 0x2000
#define SIZE_QUERY_BUFFER 0x4000
#define PROCESSOR_BUFFER_LEN 0x0fffffff
#define PROCESSOR_FLAG 0xf0000000
#define PROCESSOR_NONE 0
#define PROCESSOR_WAITING 0x10000000
#define PROCESSOR_END 0x20000000
#ifndef NULL #ifndef NULL
#define NULL 0 #define NULL 0
#endif #endif
...@@ -37,6 +45,8 @@ struct card_sort { ...@@ -37,6 +45,8 @@ struct card_sort {
bool operator()(void* const & c1, void* const & c2) const; bool operator()(void* const & c1, void* const & c2) const;
}; };
#define CURRENT_RULE 5
//Locations //Locations
#define LOCATION_DECK 0x01 // #define LOCATION_DECK 0x01 //
#define LOCATION_HAND 0x02 // #define LOCATION_HAND 0x02 //
...@@ -168,6 +178,8 @@ struct card_sort { ...@@ -168,6 +178,8 @@ struct card_sort {
#define REASON_MAINTENANCE 0x40000000 // #define REASON_MAINTENANCE 0x40000000 //
#define REASON_ACTION 0x80000000 // #define REASON_ACTION 0x80000000 //
#define REASONS_PROCEDURE (REASON_SYNCHRO | REASON_XYZ | REASON_LINK)
//Status //Status
#define STATUS_DISABLED 0x0001 // #define STATUS_DISABLED 0x0001 //
#define STATUS_TO_ENABLE 0x0002 // #define STATUS_TO_ENABLE 0x0002 //
...@@ -239,12 +251,12 @@ struct card_sort { ...@@ -239,12 +251,12 @@ struct card_sort {
//Messages //Messages
#define MSG_RETRY 1 #define MSG_RETRY 1
#define MSG_HINT 2 #define MSG_HINT 2
#define MSG_WAITING 3 //#define MSG_WAITING 3
#define MSG_START 4 //#define MSG_START 4
#define MSG_WIN 5 #define MSG_WIN 5
#define MSG_UPDATE_DATA 6 //#define MSG_UPDATE_DATA 6
#define MSG_UPDATE_CARD 7 //#define MSG_UPDATE_CARD 7
#define MSG_REQUEST_DECK 8 //#define MSG_REQUEST_DECK 8
#define MSG_SELECT_BATTLECMD 10 #define MSG_SELECT_BATTLECMD 10
#define MSG_SELECT_IDLECMD 11 #define MSG_SELECT_IDLECMD 11
#define MSG_SELECT_EFFECTYN 12 #define MSG_SELECT_EFFECTYN 12
...@@ -255,7 +267,6 @@ struct card_sort { ...@@ -255,7 +267,6 @@ struct card_sort {
#define MSG_SELECT_PLACE 18 #define MSG_SELECT_PLACE 18
#define MSG_SELECT_POSITION 19 #define MSG_SELECT_POSITION 19
#define MSG_SELECT_TRIBUTE 20 #define MSG_SELECT_TRIBUTE 20
//#define MSG_SORT_CHAIN 21
#define MSG_SELECT_COUNTER 22 #define MSG_SELECT_COUNTER 22
#define MSG_SELECT_SUM 23 #define MSG_SELECT_SUM 23
#define MSG_SELECT_DISFIELD 24 #define MSG_SELECT_DISFIELD 24
...@@ -265,7 +276,7 @@ struct card_sort { ...@@ -265,7 +276,7 @@ struct card_sort {
#define MSG_CONFIRM_CARDS 31 #define MSG_CONFIRM_CARDS 31
#define MSG_SHUFFLE_DECK 32 #define MSG_SHUFFLE_DECK 32
#define MSG_SHUFFLE_HAND 33 #define MSG_SHUFFLE_HAND 33
#define MSG_REFRESH_DECK 34 //#define MSG_REFRESH_DECK 34
#define MSG_SWAP_GRAVE_DECK 35 #define MSG_SWAP_GRAVE_DECK 35
#define MSG_SHUFFLE_SET_CARD 36 #define MSG_SHUFFLE_SET_CARD 36
#define MSG_REVERSE_DECK 37 #define MSG_REVERSE_DECK 37
...@@ -292,7 +303,7 @@ struct card_sort { ...@@ -292,7 +303,7 @@ struct card_sort {
#define MSG_CHAIN_END 74 #define MSG_CHAIN_END 74
#define MSG_CHAIN_NEGATED 75 #define MSG_CHAIN_NEGATED 75
#define MSG_CHAIN_DISABLED 76 #define MSG_CHAIN_DISABLED 76
#define MSG_CARD_SELECTED 80 //#define MSG_CARD_SELECTED 80
#define MSG_RANDOM_SELECTED 81 #define MSG_RANDOM_SELECTED 81
#define MSG_BECOME_TARGET 83 #define MSG_BECOME_TARGET 83
#define MSG_DRAW 90 #define MSG_DRAW 90
...@@ -300,7 +311,7 @@ struct card_sort { ...@@ -300,7 +311,7 @@ struct card_sort {
#define MSG_RECOVER 92 #define MSG_RECOVER 92
#define MSG_EQUIP 93 #define MSG_EQUIP 93
#define MSG_LPUPDATE 94 #define MSG_LPUPDATE 94
#define MSG_UNEQUIP 95 //#define MSG_UNEQUIP 95
#define MSG_CARD_TARGET 96 #define MSG_CARD_TARGET 96
#define MSG_CANCEL_TARGET 97 #define MSG_CANCEL_TARGET 97
#define MSG_PAY_LPCOST 100 #define MSG_PAY_LPCOST 100
...@@ -312,9 +323,9 @@ struct card_sort { ...@@ -312,9 +323,9 @@ struct card_sort {
#define MSG_DAMAGE_STEP_START 113 #define MSG_DAMAGE_STEP_START 113
#define MSG_DAMAGE_STEP_END 114 #define MSG_DAMAGE_STEP_END 114
#define MSG_MISSED_EFFECT 120 #define MSG_MISSED_EFFECT 120
#define MSG_BE_CHAIN_TARGET 121 //#define MSG_BE_CHAIN_TARGET 121
#define MSG_CREATE_RELATION 122 //#define MSG_CREATE_RELATION 122
#define MSG_RELEASE_RELATION 123 //#define MSG_RELEASE_RELATION 123
#define MSG_TOSS_COIN 130 #define MSG_TOSS_COIN 130
#define MSG_TOSS_DICE 131 #define MSG_TOSS_DICE 131
#define MSG_ROCK_PAPER_SCISSORS 132 #define MSG_ROCK_PAPER_SCISSORS 132
......
...@@ -17,7 +17,7 @@ duel::duel() { ...@@ -17,7 +17,7 @@ duel::duel() {
lua = new interpreter(this); lua = new interpreter(this);
game_field = new field(this); game_field = new field(this);
game_field->temp_card = new_card(0); game_field->temp_card = new_card(0);
clear_buffer(); message_buffer.reserve(SIZE_MESSAGE_BUFFER);
} }
duel::~duel() { duel::~duel() {
for(auto& pcard : cards) for(auto& pcard : cards)
...@@ -95,8 +95,9 @@ void duel::delete_effect(effect* peffect) { ...@@ -95,8 +95,9 @@ void duel::delete_effect(effect* peffect) {
delete peffect; delete peffect;
} }
int32 duel::read_buffer(byte* buf) { int32 duel::read_buffer(byte* buf) {
std::memcpy(buf, buffer, bufferlen); if(message_buffer.size())
return bufferlen; std::memcpy(buf, message_buffer.data(), message_buffer.size());
return (int32)message_buffer.size();
} }
void duel::release_script_group() { void duel::release_script_group() {
for(auto& pgroup : sgroups) { for(auto& pgroup : sgroups) {
...@@ -113,24 +114,20 @@ void duel::restore_assumes() { ...@@ -113,24 +114,20 @@ void duel::restore_assumes() {
pcard->assume_type = 0; pcard->assume_type = 0;
assumes.clear(); assumes.clear();
} }
void duel::write_buffer(const void* data, int size) {
write_buffer_vector(message_buffer, data, size);
}
void duel::write_buffer32(uint32 value) { void duel::write_buffer32(uint32 value) {
std::memcpy(bufferp, &value, sizeof(value)); write_buffer(&value, sizeof(value));
bufferp += 4;
bufferlen += 4;
} }
void duel::write_buffer16(uint16 value) { void duel::write_buffer16(uint16 value) {
std::memcpy(bufferp, &value, sizeof(value)); write_buffer(&value, sizeof(value));
bufferp += 2;
bufferlen += 2;
} }
void duel::write_buffer8(uint8 value) { void duel::write_buffer8(uint8 value) {
std::memcpy(bufferp, &value, sizeof(value)); write_buffer(&value, sizeof(value));
bufferp += 1;
bufferlen += 1;
} }
void duel::clear_buffer() { void duel::clear_buffer() {
bufferlen = 0; message_buffer.clear();
bufferp = buffer;
} }
void duel::set_responsei(uint32 resp) { void duel::set_responsei(uint32 resp) {
game_field->returns.ivalue[0] = resp; game_field->returns.ivalue[0] = resp;
......
...@@ -19,13 +19,19 @@ class effect; ...@@ -19,13 +19,19 @@ class effect;
class field; class field;
class interpreter; class interpreter;
inline void write_buffer_vector(std::vector<byte>& buffer, const void* data, int size) {
if (size > 0) {
const auto len = buffer.size();
buffer.resize(len + size);
std::memcpy(&buffer[len], data, size);
}
}
class duel { class duel {
public: public:
using card_set = std::set<card*, card_sort>; using card_set = std::set<card*, card_sort>;
char strbuffer[256]; char strbuffer[256];
byte buffer[0x1000]; std::vector<byte> message_buffer;
uint32 bufferlen;
byte* bufferp;
interpreter* lua; interpreter* lua;
field* game_field; field* game_field;
mt19937 random; mt19937 random;
...@@ -51,6 +57,7 @@ public: ...@@ -51,6 +57,7 @@ public:
void release_script_group(); void release_script_group();
void restore_assumes(); void restore_assumes();
int32 read_buffer(byte* buf); int32 read_buffer(byte* buf);
void write_buffer(const void* data, int size);
void write_buffer32(uint32 value); void write_buffer32(uint32 value);
void write_buffer16(uint16 value); void write_buffer16(uint16 value);
void write_buffer8(uint8 value); void write_buffer8(uint8 value);
......
...@@ -136,7 +136,9 @@ int32 effect::is_available(int32 neglect_disabled) { ...@@ -136,7 +136,9 @@ int32 effect::is_available(int32 neglect_disabled) {
return FALSE; return FALSE;
if(!phandler->get_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY)) if(!phandler->get_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY))
return FALSE; return FALSE;
if((phandler->current.location & LOCATION_ONFIELD) && !phandler->is_position(POS_FACEUP)) if (phandler->current.is_location(LOCATION_ONFIELD) && !phandler->is_position(POS_FACEUP))
return FALSE;
if (phandler->current.is_stzone() && (phandler->data.type & (TYPE_SPELL | TYPE_TRAP)) && phandler->is_affected_by_effect(EFFECT_CHANGE_TYPE))
return FALSE; return FALSE;
if(is_flag(EFFECT_FLAG_OWNER_RELATE) && is_can_be_forbidden() && powner->is_status(STATUS_FORBIDDEN)) if(is_flag(EFFECT_FLAG_OWNER_RELATE) && is_can_be_forbidden() && powner->is_status(STATUS_FORBIDDEN))
return FALSE; return FALSE;
...@@ -302,8 +304,6 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -302,8 +304,6 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
card* phandler = get_handler(); card* phandler = get_handler();
if(!(phandler->get_type() & TYPE_MONSTER) && (get_active_type() & TYPE_MONSTER)) if(!(phandler->get_type() & TYPE_MONSTER) && (get_active_type() & TYPE_MONSTER))
return FALSE; return FALSE;
if((phandler->get_type() & TYPE_CONTINUOUS) && (phandler->get_type() & TYPE_EQUIP))
return FALSE;
if((type & EFFECT_TYPE_QUICK_O) && is_flag(EFFECT_FLAG_DELAY) && !in_range(phandler)) if((type & EFFECT_TYPE_QUICK_O) && is_flag(EFFECT_FLAG_DELAY) && !in_range(phandler))
return FALSE; return FALSE;
if(!neglect_faceup && (phandler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))) { if(!neglect_faceup && (phandler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))) {
...@@ -327,6 +327,8 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -327,6 +327,8 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
if((type & EFFECT_TYPE_FIELD) && !(range & (LOCATION_DECK | LOCATION_EXTRA))) if((type & EFFECT_TYPE_FIELD) && !(range & (LOCATION_DECK | LOCATION_EXTRA)))
return FALSE; return FALSE;
} }
if (phandler->current.is_stzone() && (phandler->data.type & (TYPE_SPELL|TYPE_TRAP)) && phandler->is_affected_by_effect(EFFECT_CHANGE_TYPE))
return FALSE;
if((type & EFFECT_TYPE_FIELD) && (phandler->current.controler != playerid) && !is_flag(EFFECT_FLAG_BOTH_SIDE | EFFECT_FLAG_EVENT_PLAYER)) if((type & EFFECT_TYPE_FIELD) && (phandler->current.controler != playerid) && !is_flag(EFFECT_FLAG_BOTH_SIDE | EFFECT_FLAG_EVENT_PLAYER))
return FALSE; return FALSE;
if(phandler->is_status(STATUS_FORBIDDEN)) if(phandler->is_status(STATUS_FORBIDDEN))
...@@ -337,8 +339,9 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -337,8 +339,9 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
card* phandler = get_handler(); card* phandler = get_handler();
if((type & EFFECT_TYPE_FIELD) && phandler->is_status(STATUS_BATTLE_DESTROYED)) if((type & EFFECT_TYPE_FIELD) && phandler->is_status(STATUS_BATTLE_DESTROYED))
return FALSE; return FALSE;
if(((type & EFFECT_TYPE_FIELD) || ((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE))) && (phandler->current.location & LOCATION_ONFIELD) if(((type & EFFECT_TYPE_FIELD) || ((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE)))
&& (!phandler->is_position(POS_FACEUP) || !phandler->is_status(STATUS_EFFECT_ENABLED))) && (phandler->current.location & LOCATION_ONFIELD)
&& (!phandler->is_position(POS_FACEUP) || !phandler->is_status(STATUS_EFFECT_ENABLED)))
return FALSE; return FALSE;
if((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE) && !in_range(phandler)) if((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE) && !in_range(phandler))
return FALSE; return FALSE;
...@@ -640,7 +643,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) { ...@@ -640,7 +643,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
uint8 tp = handler->pduel->game_field->infos.turn_player; uint8 tp = handler->pduel->game_field->infos.turn_player;
if((((reset_flag & RESET_SELF_TURN) && pid == tp) || ((reset_flag & RESET_OPPO_TURN) && pid != tp)) if((((reset_flag & RESET_SELF_TURN) && pid == tp) || ((reset_flag & RESET_OPPO_TURN) && pid != tp))
&& (reset_level & 0x3ff & reset_flag)) && (reset_level & 0x3ff & reset_flag))
reset_count--; --reset_count;
if(reset_count == 0) if(reset_count == 0)
return TRUE; return TRUE;
return FALSE; return FALSE;
......
...@@ -18,8 +18,6 @@ class effect; ...@@ -18,8 +18,6 @@ class effect;
bool effect_sort_id(const effect* e1, const effect* e2); bool effect_sort_id(const effect* e1, const effect* e2);
struct effect_set { struct effect_set {
effect_set()
: count(0), container{ nullptr } {}
void add_item(effect* peffect) { void add_item(effect* peffect) {
if(count >= 64) return; if(count >= 64) return;
container[count++] = peffect; container[count++] = peffect;
...@@ -28,12 +26,12 @@ struct effect_set { ...@@ -28,12 +26,12 @@ struct effect_set {
if(index >= count) if(index >= count)
return; return;
if(index == count - 1) { if(index == count - 1) {
count--; --count;
return; return;
} }
for(int i = index; i < count - 1; ++i) for(int i = index; i < count - 1; ++i)
container[i] = container[i + 1]; container[i] = container[i + 1];
count--; --count;
} }
void clear() { void clear() {
count = 0; count = 0;
...@@ -65,12 +63,11 @@ struct effect_set { ...@@ -65,12 +63,11 @@ struct effect_set {
return container[index]; return container[index];
} }
private: private:
std::array<effect*, 64> container; std::array<effect*, 64> container{ nullptr };
int count; int count{ 0 };
}; };
struct effect_set_v { struct effect_set_v {
effect_set_v() {}
void add_item(effect* peffect) { void add_item(effect* peffect) {
container.push_back(peffect); container.push_back(peffect);
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -10,21 +10,15 @@ ...@@ -10,21 +10,15 @@
#include "duel.h" #include "duel.h"
group::group(duel* pd) { group::group(duel* pd) {
ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE;
it = container.begin(); it = container.begin();
} }
group::group(duel* pd, card* pcard) { group::group(duel* pd, card* pcard) {
container.insert(pcard); container.insert(pcard);
ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE;
it = container.begin(); it = container.begin();
} }
group::group(duel* pd, const card_set& cset): container(cset) { group::group(duel* pd, const card_set& cset): container(cset) {
ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE;
it = container.begin(); it = container.begin();
} }
...@@ -18,13 +18,14 @@ class duel; ...@@ -18,13 +18,14 @@ class duel;
class group { class group {
public: public:
using card_set = std::set<card*, card_sort>; using card_set = std::set<card*, card_sort>;
int32 ref_handle;
duel* pduel; duel* pduel;
card_set container; card_set container;
card_set::iterator it; card_set::iterator it;
uint32 is_readonly; int32 ref_handle{ 0 };
uint32 is_readonly{ 0 };
bool is_iterator_dirty{ true };
inline bool has_card(card* c) { bool has_card(card* c) {
return container.find(c) != container.end(); return container.find(c) != container.end();
} }
......
...@@ -127,16 +127,16 @@ int32 interpreter::load_script(const char* script_name) { ...@@ -127,16 +127,16 @@ int32 interpreter::load_script(const char* script_name) {
byte* buffer = read_script(script_name, &len); byte* buffer = read_script(script_name, &len);
if (!buffer) if (!buffer)
return OPERATION_FAIL; return OPERATION_FAIL;
no_action++; ++no_action;
int32 error = luaL_loadbuffer(current_state, (char*)buffer, len, script_name) || lua_pcall(current_state, 0, 0, 0); int32 error = luaL_loadbuffer(current_state, (char*)buffer, len, script_name) || lua_pcall(current_state, 0, 0, 0);
if (error) { if (error) {
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action--; --no_action;
return OPERATION_SUCCESS; return OPERATION_SUCCESS;
} }
int32 interpreter::load_card_script(uint32 code) { int32 interpreter::load_card_script(uint32 code) {
...@@ -243,7 +243,7 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) { ...@@ -243,7 +243,7 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) {
break; break;
} }
} }
pushed++; ++pushed;
} }
params.clear(); params.clear();
} }
...@@ -268,23 +268,23 @@ int32 interpreter::call_function(int32 f, uint32 param_count, int32 ret_count) { ...@@ -268,23 +268,23 @@ int32 interpreter::call_function(int32 f, uint32 param_count, int32 ret_count) {
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action++; ++no_action;
call_depth++; ++call_depth;
push_param(current_state); push_param(current_state);
if (lua_pcall(current_state, param_count, ret_count, 0)) { if (lua_pcall(current_state, param_count, ret_count, 0)) {
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
} }
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -308,24 +308,24 @@ int32 interpreter::call_card_function(card* pcard, const char* f, uint32 param_c ...@@ -308,24 +308,24 @@ int32 interpreter::call_card_function(card* pcard, const char* f, uint32 param_c
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action++; ++no_action;
call_depth++; ++call_depth;
lua_remove(current_state, -2); lua_remove(current_state, -2);
push_param(current_state); push_param(current_state);
if (lua_pcall(current_state, param_count, ret_count, 0)) { if (lua_pcall(current_state, param_count, ret_count, 0)) {
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
} }
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -350,23 +350,23 @@ int32 interpreter::call_code_function(uint32 code, const char* f, uint32 param_c ...@@ -350,23 +350,23 @@ int32 interpreter::call_code_function(uint32 code, const char* f, uint32 param_c
return OPERATION_FAIL; return OPERATION_FAIL;
} }
lua_remove(current_state, -2); lua_remove(current_state, -2);
no_action++; ++no_action;
call_depth++; ++call_depth;
push_param(current_state); push_param(current_state);
if (lua_pcall(current_state, param_count, ret_count, 0)) { if (lua_pcall(current_state, param_count, ret_count, 0)) {
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
} }
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -378,21 +378,21 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) { ...@@ -378,21 +378,21 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) {
params.clear(); params.clear();
return TRUE; return TRUE;
} }
no_action++; ++no_action;
call_depth++; ++call_depth;
if (call_function(f, param_count, 1)) { if (call_function(f, param_count, 1)) {
int32 result = lua_toboolean(current_state, -1); int32 result = lua_toboolean(current_state, -1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
} }
return result; return result;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -402,8 +402,8 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) { ...@@ -402,8 +402,8 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) {
int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) { int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
if(!findex || lua_isnil(current_state, findex)) if(!findex || lua_isnil(current_state, findex))
return TRUE; return TRUE;
no_action++; ++no_action;
call_depth++; ++call_depth;
luaL_checkstack(current_state, 1 + extraargs, NULL); luaL_checkstack(current_state, 1 + extraargs, NULL);
lua_pushvalue(current_state, findex); lua_pushvalue(current_state, findex);
interpreter::card2value(current_state, pcard); interpreter::card2value(current_state, pcard);
...@@ -413,8 +413,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) { ...@@ -413,8 +413,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -423,8 +423,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) { ...@@ -423,8 +423,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
} }
int32 result = lua_toboolean(current_state, -1); int32 result = lua_toboolean(current_state, -1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -434,8 +434,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) { ...@@ -434,8 +434,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraargs) { int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraargs) {
if(!findex || lua_isnil(current_state, findex)) if(!findex || lua_isnil(current_state, findex))
return 0; return 0;
no_action++; ++no_action;
call_depth++; ++call_depth;
luaL_checkstack(current_state, 1 + extraargs, NULL); luaL_checkstack(current_state, 1 + extraargs, NULL);
lua_pushvalue(current_state, findex); lua_pushvalue(current_state, findex);
interpreter::card2value(current_state, pcard); interpreter::card2value(current_state, pcard);
...@@ -445,8 +445,8 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg ...@@ -445,8 +445,8 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -455,8 +455,8 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg ...@@ -455,8 +455,8 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
} }
int32 result = lua_isinteger(current_state, -1) ? (int32)lua_tointeger(current_state, -1) : (int32)lua_tonumber(current_state, -1); int32 result = lua_isinteger(current_state, -1) ? (int32)lua_tointeger(current_state, -1) : (int32)lua_tonumber(current_state, -1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -468,8 +468,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) { ...@@ -468,8 +468,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
params.clear(); params.clear();
return 0; return 0;
} }
no_action++; ++no_action;
call_depth++; ++call_depth;
if (call_function(f, param_count, 1)) { if (call_function(f, param_count, 1)) {
int32 result = 0; int32 result = 0;
if(lua_isboolean(current_state, -1)) if(lua_isboolean(current_state, -1))
...@@ -479,16 +479,16 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) { ...@@ -479,16 +479,16 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
else else
result = (int32)lua_tonumber(current_state, -1); result = (int32)lua_tonumber(current_state, -1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
} }
return result; return result;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -502,8 +502,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i ...@@ -502,8 +502,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
return is_success; return is_success;
} }
int32 stack_top = lua_gettop(current_state); int32 stack_top = lua_gettop(current_state);
no_action++; ++no_action;
call_depth++; ++call_depth;
if (call_function(f, param_count, LUA_MULTRET)) { if (call_function(f, param_count, LUA_MULTRET)) {
int32 stack_newtop = lua_gettop(current_state); int32 stack_newtop = lua_gettop(current_state);
for (int32 index = stack_top + 1; index <= stack_newtop; ++index) { for (int32 index = stack_top + 1; index <= stack_newtop; ++index) {
...@@ -519,8 +519,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i ...@@ -519,8 +519,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
lua_settop(current_state, stack_top); lua_settop(current_state, stack_top);
is_success = OPERATION_SUCCESS; is_success = OPERATION_SUCCESS;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -552,7 +552,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -552,7 +552,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
call_depth++; ++call_depth;
coroutines.emplace(f, rthread); coroutines.emplace(f, rthread);
} else { } else {
rthread = it->second; rthread = it->second;
...@@ -560,7 +560,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -560,7 +560,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
sprintf(pduel->strbuffer, "recursive event trigger detected."); sprintf(pduel->strbuffer, "recursive event trigger detected.");
handle_message(pduel, 1); handle_message(pduel, 1);
params.clear(); params.clear();
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -589,7 +589,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -589,7 +589,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
*yield_value = (uint32)lua_tointeger(rthread, -1); *yield_value = (uint32)lua_tointeger(rthread, -1);
} }
current_state = lua_state; current_state = lua_state;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -603,7 +603,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -603,7 +603,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(rthread, 1); lua_pop(rthread, 1);
current_state = lua_state; current_state = lua_state;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
......
...@@ -68,7 +68,7 @@ int32 scriptlib::card_get_fusion_code(lua_State *L) { ...@@ -68,7 +68,7 @@ int32 scriptlib::card_get_fusion_code(lua_State *L) {
uint32 otcode = pcard->get_another_code(); uint32 otcode = pcard->get_another_code();
if(otcode) { if(otcode) {
lua_pushinteger(L, otcode); lua_pushinteger(L, otcode);
count++; ++count;
} }
if(pcard->pduel->game_field->core.not_material) if(pcard->pduel->game_field->core.not_material)
return count; return count;
...@@ -87,7 +87,7 @@ int32 scriptlib::card_get_link_code(lua_State *L) { ...@@ -87,7 +87,7 @@ int32 scriptlib::card_get_link_code(lua_State *L) {
uint32 otcode = pcard->get_another_code(); uint32 otcode = pcard->get_another_code();
if(otcode) { if(otcode) {
lua_pushinteger(L, otcode); lua_pushinteger(L, otcode);
count++; ++count;
} }
effect_set eset; effect_set eset;
pcard->filter_effect(EFFECT_ADD_LINK_CODE, &eset); pcard->filter_effect(EFFECT_ADD_LINK_CODE, &eset);
...@@ -245,6 +245,24 @@ int32 scriptlib::card_is_link_set_card(lua_State *L) { ...@@ -245,6 +245,24 @@ int32 scriptlib::card_is_link_set_card(lua_State *L) {
lua_pushboolean(L, result); lua_pushboolean(L, result);
return 1; return 1;
} }
int32 scriptlib::card_is_special_summon_set_card(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 count = lua_gettop(L) - 1;
uint32 result = FALSE;
for(uint32 i = 0; i < count; ++i) {
if(lua_isnil(L, i + 2))
continue;
uint32 set_code = (uint32)lua_tointeger(L, i + 2);
if(pcard->is_special_summon_set_card(set_code)) {
result = TRUE;
break;
}
}
lua_pushboolean(L, result);
return 1;
}
int32 scriptlib::card_get_type(lua_State *L) { int32 scriptlib::card_get_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);
...@@ -865,6 +883,51 @@ int32 scriptlib::card_get_summon_player(lua_State *L) { ...@@ -865,6 +883,51 @@ int32 scriptlib::card_get_summon_player(lua_State *L) {
lua_pushinteger(L, pcard->summon_player); lua_pushinteger(L, pcard->summon_player);
return 1; return 1;
} }
int32 scriptlib::card_get_special_summon_info(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 args = lua_gettop(L) - 1;
for(uint32 i = 0; i < args; ++i) {
uint32 flag = (uint32)lua_tointeger(L, 2 + i);
switch(flag) {
case SUMMON_INFO_CODE:
lua_pushinteger(L, pcard->spsummon.code);
break;
case SUMMON_INFO_CODE2:
lua_pushinteger(L, pcard->spsummon.code2);
break;
case SUMMON_INFO_TYPE:
lua_pushinteger(L, pcard->spsummon.type);
break;
case SUMMON_INFO_LEVEL:
lua_pushinteger(L, pcard->spsummon.level);
break;
case SUMMON_INFO_RANK:
lua_pushinteger(L, pcard->spsummon.rank);
break;
case SUMMON_INFO_ATTRIBUTE:
lua_pushinteger(L, pcard->spsummon.attribute);
break;
case SUMMON_INFO_RACE:
lua_pushinteger(L, pcard->spsummon.race);
break;
case SUMMON_INFO_ATTACK:
lua_pushinteger(L, pcard->spsummon.attack);
break;
case SUMMON_INFO_DEFENSE:
lua_pushinteger(L, pcard->spsummon.defense);
break;
case SUMMON_INFO_REASON_EFFECT:
interpreter::effect2value(L, pcard->spsummon.reason_effect);
break;
default:
lua_pushnil(L);
break;
}
}
return args;
}
int32 scriptlib::card_get_destination(lua_State *L) { int32 scriptlib::card_get_destination(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);
...@@ -1629,7 +1692,7 @@ int32 scriptlib::card_get_activate_effect(lua_State *L) { ...@@ -1629,7 +1692,7 @@ int32 scriptlib::card_get_activate_effect(lua_State *L) {
for(auto& eit : pcard->field_effect) { for(auto& eit : pcard->field_effect) {
if(eit.second->type & EFFECT_TYPE_ACTIVATE) { if(eit.second->type & EFFECT_TYPE_ACTIVATE) {
interpreter::effect2value(L, eit.second); interpreter::effect2value(L, eit.second);
count++; ++count;
} }
} }
return count; return count;
...@@ -1783,7 +1846,7 @@ int32 scriptlib::card_is_has_effect(lua_State *L) { ...@@ -1783,7 +1846,7 @@ int32 scriptlib::card_is_has_effect(lua_State *L) {
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
if(check_player == PLAYER_NONE || eset[i]->check_count_limit(check_player)) { if(check_player == PLAYER_NONE || eset[i]->check_count_limit(check_player)) {
interpreter::effect2value(L, eset[i]); interpreter::effect2value(L, eset[i]);
size++; ++size;
} }
} }
if(!size) { if(!size) {
...@@ -2047,7 +2110,7 @@ int32 scriptlib::card_is_disabled(lua_State *L) { ...@@ -2047,7 +2110,7 @@ int32 scriptlib::card_is_disabled(lua_State *L) {
int32 scriptlib::card_is_destructable(lua_State *L) { int32 scriptlib::card_is_destructable(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);
effect* peffect = 0; effect* peffect = nullptr;
if(lua_gettop(L) > 1) { if(lua_gettop(L) > 1) {
check_param(L, PARAM_TYPE_EFFECT, 2); check_param(L, PARAM_TYPE_EFFECT, 2);
peffect = *(effect**) lua_touserdata(L, 2); peffect = *(effect**) lua_touserdata(L, 2);
...@@ -2089,7 +2152,7 @@ int32 scriptlib::card_is_msetable(lua_State *L) { ...@@ -2089,7 +2152,7 @@ int32 scriptlib::card_is_msetable(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 p = pcard->pduel->game_field->core.reason_player; uint32 p = pcard->pduel->game_field->core.reason_player;
uint32 ign = lua_toboolean(L, 2); uint32 ign = lua_toboolean(L, 2);
effect* peffect = 0; effect* peffect = nullptr;
if(!lua_isnil(L, 3)) { if(!lua_isnil(L, 3)) {
check_param(L, PARAM_TYPE_EFFECT, 3); check_param(L, PARAM_TYPE_EFFECT, 3);
peffect = *(effect**)lua_touserdata(L, 3); peffect = *(effect**)lua_touserdata(L, 3);
...@@ -2133,8 +2196,8 @@ int32 scriptlib::card_is_synchro_summonable(lua_State *L) { ...@@ -2133,8 +2196,8 @@ int32 scriptlib::card_is_synchro_summonable(lua_State *L) {
lua_pushboolean(L, FALSE); lua_pushboolean(L, FALSE);
return 1; return 1;
} }
card* tuner = 0; card* tuner = nullptr;
group* mg = 0; group* mg = nullptr;
if(!lua_isnil(L, 2)) { if(!lua_isnil(L, 2)) {
check_param(L, PARAM_TYPE_CARD, 2); check_param(L, PARAM_TYPE_CARD, 2);
tuner = *(card**) lua_touserdata(L, 2); tuner = *(card**) lua_touserdata(L, 2);
...@@ -2169,7 +2232,7 @@ int32 scriptlib::card_is_xyz_summonable(lua_State *L) { ...@@ -2169,7 +2232,7 @@ int32 scriptlib::card_is_xyz_summonable(lua_State *L) {
lua_pushboolean(L, FALSE); lua_pushboolean(L, FALSE);
return 1; return 1;
} }
group* materials = 0; group* materials = nullptr;
if(!lua_isnil(L, 2)) { if(!lua_isnil(L, 2)) {
check_param(L, PARAM_TYPE_GROUP, 2); check_param(L, PARAM_TYPE_GROUP, 2);
materials = *(group**) lua_touserdata(L, 2); materials = *(group**) lua_touserdata(L, 2);
...@@ -2197,8 +2260,8 @@ int32 scriptlib::card_is_link_summonable(lua_State *L) { ...@@ -2197,8 +2260,8 @@ int32 scriptlib::card_is_link_summonable(lua_State *L) {
lua_pushboolean(L, FALSE); lua_pushboolean(L, FALSE);
return 1; return 1;
} }
group* materials = 0; group* materials = nullptr;
card* lcard = 0; card* lcard = nullptr;
if(!lua_isnil(L, 2)) { if(!lua_isnil(L, 2)) {
check_param(L, PARAM_TYPE_GROUP, 2); check_param(L, PARAM_TYPE_GROUP, 2);
materials = *(group**)lua_touserdata(L, 2); materials = *(group**)lua_touserdata(L, 2);
...@@ -2231,7 +2294,7 @@ int32 scriptlib::card_is_can_be_summoned(lua_State *L) { ...@@ -2231,7 +2294,7 @@ int32 scriptlib::card_is_can_be_summoned(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 p = pcard->pduel->game_field->core.reason_player; uint32 p = pcard->pduel->game_field->core.reason_player;
uint32 ign = lua_toboolean(L, 2); uint32 ign = lua_toboolean(L, 2);
effect* peffect = 0; effect* peffect = nullptr;
if(!lua_isnil(L, 3)) { if(!lua_isnil(L, 3)) {
check_param(L, PARAM_TYPE_EFFECT, 3); check_param(L, PARAM_TYPE_EFFECT, 3);
peffect = *(effect**)lua_touserdata(L, 3); peffect = *(effect**)lua_touserdata(L, 3);
...@@ -2804,7 +2867,7 @@ int32 scriptlib::card_remove_counter(lua_State *L) { ...@@ -2804,7 +2867,7 @@ int32 scriptlib::card_remove_counter(lua_State *L) {
check_action_permission(L); check_action_permission(L);
check_param_count(L, 5); check_param_count(L, 5);
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 rplayer = (uint32)lua_tointeger(L, 2); uint32 rplayer = (uint32)lua_tointeger(L, 2);
uint32 countertype = (uint32)lua_tointeger(L, 3); uint32 countertype = (uint32)lua_tointeger(L, 3);
uint32 count = (uint32)lua_tointeger(L, 4); uint32 count = (uint32)lua_tointeger(L, 4);
...@@ -2941,7 +3004,7 @@ int32 scriptlib::card_is_can_be_fusion_material(lua_State *L) { ...@@ -2941,7 +3004,7 @@ int32 scriptlib::card_is_can_be_fusion_material(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);
card* fcard = 0; card* fcard = nullptr;
if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) { if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) {
check_param(L, PARAM_TYPE_CARD, 2); check_param(L, PARAM_TYPE_CARD, 2);
fcard = *(card**)lua_touserdata(L, 2); fcard = *(card**)lua_touserdata(L, 2);
...@@ -2956,8 +3019,8 @@ int32 scriptlib::card_is_can_be_synchro_material(lua_State *L) { ...@@ -2956,8 +3019,8 @@ int32 scriptlib::card_is_can_be_synchro_material(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);
card* scard = 0; card* scard = nullptr;
card* tuner = 0; card* tuner = nullptr;
if(lua_gettop(L) >= 2) { if(lua_gettop(L) >= 2) {
check_param(L, PARAM_TYPE_CARD, 2); check_param(L, PARAM_TYPE_CARD, 2);
scard = *(card**) lua_touserdata(L, 2); scard = *(card**) lua_touserdata(L, 2);
...@@ -2973,7 +3036,7 @@ int32 scriptlib::card_is_can_be_ritual_material(lua_State *L) { ...@@ -2973,7 +3036,7 @@ int32 scriptlib::card_is_can_be_ritual_material(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
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);
card* scard = 0; card* scard = nullptr;
if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) { if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) {
check_param(L, PARAM_TYPE_CARD, 2); check_param(L, PARAM_TYPE_CARD, 2);
scard = *(card**) lua_touserdata(L, 2); scard = *(card**) lua_touserdata(L, 2);
...@@ -2985,7 +3048,7 @@ int32 scriptlib::card_is_can_be_xyz_material(lua_State *L) { ...@@ -2985,7 +3048,7 @@ int32 scriptlib::card_is_can_be_xyz_material(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
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);
card* scard = 0; card* scard = nullptr;
if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) { if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) {
check_param(L, PARAM_TYPE_CARD, 2); check_param(L, PARAM_TYPE_CARD, 2);
scard = *(card**) lua_touserdata(L, 2); scard = *(card**) lua_touserdata(L, 2);
...@@ -2997,7 +3060,7 @@ int32 scriptlib::card_is_can_be_link_material(lua_State *L) { ...@@ -2997,7 +3060,7 @@ int32 scriptlib::card_is_can_be_link_material(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
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);
card* scard = 0; card* scard = nullptr;
if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) { if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) {
check_param(L, PARAM_TYPE_CARD, 2); check_param(L, PARAM_TYPE_CARD, 2);
scard = *(card**) lua_touserdata(L, 2); scard = *(card**) lua_touserdata(L, 2);
...@@ -3010,12 +3073,12 @@ int32 scriptlib::card_check_fusion_material(lua_State *L) { ...@@ -3010,12 +3073,12 @@ int32 scriptlib::card_check_fusion_material(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 chkf = PLAYER_NONE; uint32 chkf = PLAYER_NONE;
group* pgroup = 0; group* pgroup = nullptr;
if(lua_gettop(L) > 1 && !lua_isnil(L, 2)) { if(lua_gettop(L) > 1 && !lua_isnil(L, 2)) {
check_param(L, PARAM_TYPE_GROUP, 2); check_param(L, PARAM_TYPE_GROUP, 2);
pgroup = *(group**) lua_touserdata(L, 2); pgroup = *(group**) lua_touserdata(L, 2);
} }
card* cg = 0; card* cg = nullptr;
if(lua_gettop(L) > 2 && !lua_isnil(L, 3)) { if(lua_gettop(L) > 2 && !lua_isnil(L, 3)) {
check_param(L, PARAM_TYPE_CARD, 3); check_param(L, PARAM_TYPE_CARD, 3);
cg = *(card**) lua_touserdata(L, 3); cg = *(card**) lua_touserdata(L, 3);
...@@ -3275,7 +3338,7 @@ int32 scriptlib::card_check_unique_onfield(lua_State *L) { ...@@ -3275,7 +3338,7 @@ int32 scriptlib::card_check_unique_onfield(lua_State *L) {
uint32 check_location = LOCATION_ONFIELD; uint32 check_location = LOCATION_ONFIELD;
if(lua_gettop(L) > 2) if(lua_gettop(L) > 2)
check_location = lua_tointeger(L, 3) & LOCATION_ONFIELD; check_location = lua_tointeger(L, 3) & LOCATION_ONFIELD;
card* icard = 0; card* icard = nullptr;
if(lua_gettop(L) > 3) { if(lua_gettop(L) > 3) {
if(check_param(L, PARAM_TYPE_CARD, 4, TRUE)) if(check_param(L, PARAM_TYPE_CARD, 4, TRUE))
icard = *(card**)lua_touserdata(L, 4); icard = *(card**)lua_touserdata(L, 4);
...@@ -3325,6 +3388,7 @@ static const struct luaL_Reg cardlib[] = { ...@@ -3325,6 +3388,7 @@ static const struct luaL_Reg cardlib[] = {
{ "IsPreviousSetCard", scriptlib::card_is_pre_set_card }, { "IsPreviousSetCard", scriptlib::card_is_pre_set_card },
{ "IsFusionSetCard", scriptlib::card_is_fusion_set_card }, { "IsFusionSetCard", scriptlib::card_is_fusion_set_card },
{ "IsLinkSetCard", scriptlib::card_is_link_set_card }, { "IsLinkSetCard", scriptlib::card_is_link_set_card },
{ "IsSpecialSummonSetCard", scriptlib::card_is_special_summon_set_card },
{ "GetType", scriptlib::card_get_type }, { "GetType", scriptlib::card_get_type },
{ "GetOriginalType", scriptlib::card_get_origin_type }, { "GetOriginalType", scriptlib::card_get_origin_type },
{ "GetFusionType", scriptlib::card_get_fusion_type }, { "GetFusionType", scriptlib::card_get_fusion_type },
...@@ -3398,6 +3462,7 @@ static const struct luaL_Reg cardlib[] = { ...@@ -3398,6 +3462,7 @@ static const struct luaL_Reg cardlib[] = {
{ "GetSummonType", scriptlib::card_get_summon_type }, { "GetSummonType", scriptlib::card_get_summon_type },
{ "GetSummonLocation", scriptlib::card_get_summon_location }, { "GetSummonLocation", scriptlib::card_get_summon_location },
{ "GetSummonPlayer", scriptlib::card_get_summon_player }, { "GetSummonPlayer", scriptlib::card_get_summon_player },
{ "GetSpecialSummonInfo", scriptlib::card_get_special_summon_info },
{ "GetDestination", scriptlib::card_get_destination }, { "GetDestination", scriptlib::card_get_destination },
{ "GetLeaveFieldDest", scriptlib::card_get_leave_field_dest }, { "GetLeaveFieldDest", scriptlib::card_get_leave_field_dest },
{ "GetTurnID", scriptlib::card_get_turnid }, { "GetTurnID", scriptlib::card_get_turnid },
......
...@@ -152,7 +152,7 @@ int32 scriptlib::debug_reload_field_begin(lua_State *L) { ...@@ -152,7 +152,7 @@ int32 scriptlib::debug_reload_field_begin(lua_State *L) {
else if (flag & DUEL_OBSOLETE_RULING) else if (flag & DUEL_OBSOLETE_RULING)
pduel->game_field->core.duel_rule = 1; pduel->game_field->core.duel_rule = 1;
else else
pduel->game_field->core.duel_rule = 5; pduel->game_field->core.duel_rule = CURRENT_RULE;
return 0; return 0;
} }
int32 scriptlib::debug_reload_field_end(lua_State *L) { int32 scriptlib::debug_reload_field_end(lua_State *L) {
...@@ -174,9 +174,7 @@ int32 scriptlib::debug_set_ai_name(lua_State *L) { ...@@ -174,9 +174,7 @@ int32 scriptlib::debug_set_ai_name(lua_State *L) {
if(len > 100) if(len > 100)
len = 100; len = 100;
pduel->write_buffer16(len); pduel->write_buffer16(len);
memcpy(pduel->bufferp, pstr, len); pduel->write_buffer(pstr, len);
pduel->bufferp += len;
pduel->bufferlen += len;
pduel->write_buffer8(0); pduel->write_buffer8(0);
return 0; return 0;
} }
...@@ -190,9 +188,7 @@ int32 scriptlib::debug_show_hint(lua_State *L) { ...@@ -190,9 +188,7 @@ int32 scriptlib::debug_show_hint(lua_State *L) {
if(len > 1024) if(len > 1024)
len = 1024; len = 1024;
pduel->write_buffer16(len); pduel->write_buffer16(len);
memcpy(pduel->bufferp, pstr, len); pduel->write_buffer(pstr, len);
pduel->bufferp += len;
pduel->bufferlen += len;
pduel->write_buffer8(0); pduel->write_buffer8(0);
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -574,7 +574,7 @@ int32 scriptlib::effect_use_count_limit(lua_State *L) { ...@@ -574,7 +574,7 @@ int32 scriptlib::effect_use_count_limit(lua_State *L) {
if (!oath_only || code & EFFECT_COUNT_CODE_OATH) if (!oath_only || code & EFFECT_COUNT_CODE_OATH)
while(count) { while(count) {
peffect->dec_count(p); peffect->dec_count(p);
count--; --count;
} }
return 0; return 0;
} }
......
...@@ -46,6 +46,7 @@ int32 scriptlib::group_delete(lua_State *L) { ...@@ -46,6 +46,7 @@ int32 scriptlib::group_delete(lua_State *L) {
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
if(pgroup->is_readonly != 2) if(pgroup->is_readonly != 2)
return 0; return 0;
pgroup->is_iterator_dirty = true;
pgroup->is_readonly = 0; pgroup->is_readonly = 0;
pduel->sgroups.insert(pgroup); pduel->sgroups.insert(pgroup);
return 0; return 0;
...@@ -66,6 +67,7 @@ int32 scriptlib::group_clear(lua_State *L) { ...@@ -66,6 +67,7 @@ int32 scriptlib::group_clear(lua_State *L) {
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
if (pgroup->is_readonly != 1) { if (pgroup->is_readonly != 1) {
pgroup->is_iterator_dirty = true;
pgroup->container.clear(); pgroup->container.clear();
} }
return 0; return 0;
...@@ -77,6 +79,7 @@ int32 scriptlib::group_add_card(lua_State *L) { ...@@ -77,6 +79,7 @@ int32 scriptlib::group_add_card(lua_State *L) {
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
card* pcard = *(card**) lua_touserdata(L, 2); card* pcard = *(card**) lua_touserdata(L, 2);
if (pgroup->is_readonly != 1) { if (pgroup->is_readonly != 1) {
pgroup->is_iterator_dirty = true;
pgroup->container.insert(pcard); pgroup->container.insert(pcard);
} }
return 0; return 0;
...@@ -88,6 +91,7 @@ int32 scriptlib::group_remove_card(lua_State *L) { ...@@ -88,6 +91,7 @@ int32 scriptlib::group_remove_card(lua_State *L) {
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
card* pcard = *(card**) lua_touserdata(L, 2); card* pcard = *(card**) lua_touserdata(L, 2);
if (pgroup->is_readonly != 1) { if (pgroup->is_readonly != 1) {
pgroup->is_iterator_dirty = true;
pgroup->container.erase(pcard); pgroup->container.erase(pcard);
} }
return 0; return 0;
...@@ -96,6 +100,9 @@ int32 scriptlib::group_get_next(lua_State *L) { ...@@ -96,6 +100,9 @@ int32 scriptlib::group_get_next(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
if (pgroup->is_iterator_dirty) {
return luaL_error(L, "Called Group.GetNext without calling Group.GetFirst first.");
}
if(pgroup->it == pgroup->container.end()) if(pgroup->it == pgroup->container.end())
lua_pushnil(L); lua_pushnil(L);
else { else {
...@@ -111,6 +118,7 @@ int32 scriptlib::group_get_first(lua_State *L) { ...@@ -111,6 +118,7 @@ int32 scriptlib::group_get_first(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
pgroup->is_iterator_dirty = false;
if (pgroup->container.size()) { if (pgroup->container.size()) {
pgroup->it = pgroup->container.begin(); pgroup->it = pgroup->container.begin();
interpreter::card2value(L, (*(pgroup->it))); interpreter::card2value(L, (*(pgroup->it)));
...@@ -185,7 +193,7 @@ int32 scriptlib::group_filter_count(lua_State *L) { ...@@ -185,7 +193,7 @@ int32 scriptlib::group_filter_count(lua_State *L) {
uint32 count = 0; uint32 count = 0;
for (auto& pcard : cset) { for (auto& pcard : cset) {
if(pduel->lua->check_matching(pcard, 2, extraargs)) if(pduel->lua->check_matching(pcard, 2, extraargs))
count++; ++count;
} }
lua_pushinteger(L, count); lua_pushinteger(L, count);
return 1; return 1;
...@@ -270,7 +278,7 @@ int32 scriptlib::group_select_unselect(lua_State *L) { ...@@ -270,7 +278,7 @@ int32 scriptlib::group_select_unselect(lua_State *L) {
check_param_count(L, 3); check_param_count(L, 3);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
group* select_group = *(group**)lua_touserdata(L, 1); group* select_group = *(group**)lua_touserdata(L, 1);
group* unselect_group = 0; group* unselect_group = nullptr;
if(check_param(L, PARAM_TYPE_GROUP, 2, TRUE)) if(check_param(L, PARAM_TYPE_GROUP, 2, TRUE))
unselect_group = *(group**)lua_touserdata(L, 2); unselect_group = *(group**)lua_touserdata(L, 2);
duel* pduel = select_group->pduel; duel* pduel = select_group->pduel;
...@@ -387,7 +395,7 @@ int32 scriptlib::group_is_exists(lua_State *L) { ...@@ -387,7 +395,7 @@ int32 scriptlib::group_is_exists(lua_State *L) {
uint32 result = FALSE; uint32 result = FALSE;
for (auto& pcard : cset) { for (auto& pcard : cset) {
if(pduel->lua->check_matching(pcard, 2, extraargs)) { if(pduel->lua->check_matching(pcard, 2, extraargs)) {
fcount++; ++fcount;
if(fcount >= count) { if(fcount >= count) {
result = TRUE; result = TRUE;
break; break;
...@@ -627,7 +635,7 @@ int32 scriptlib::group_remove(lua_State *L) { ...@@ -627,7 +635,7 @@ int32 scriptlib::group_remove(lua_State *L) {
check_param_count(L, 3); check_param_count(L, 3);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
check_param(L, PARAM_TYPE_FUNCTION, 2); check_param(L, PARAM_TYPE_FUNCTION, 2);
card* pexception = 0; card* pexception = nullptr;
if(!lua_isnil(L, 3)) { if(!lua_isnil(L, 3)) {
check_param(L, PARAM_TYPE_CARD, 3); check_param(L, PARAM_TYPE_CARD, 3);
pexception = *(card**) lua_touserdata(L, 3); pexception = *(card**) lua_touserdata(L, 3);
...@@ -637,11 +645,13 @@ int32 scriptlib::group_remove(lua_State *L) { ...@@ -637,11 +645,13 @@ int32 scriptlib::group_remove(lua_State *L) {
uint32 extraargs = lua_gettop(L) - 3; uint32 extraargs = lua_gettop(L) - 3;
if(pgroup->is_readonly == 1) if(pgroup->is_readonly == 1)
return 0; return 0;
pgroup->is_iterator_dirty = true;
for (auto cit = pgroup->container.begin(); cit != pgroup->container.end();) { for (auto cit = pgroup->container.begin(); cit != pgroup->container.end();) {
auto rm = cit++; if((*cit) != pexception && pduel->lua->check_matching(*cit, 2, extraargs)) {
if((*rm) != pexception && pduel->lua->check_matching(*rm, 2, extraargs)) { cit = pgroup->container.erase(cit);
pgroup->container.erase(rm);
} }
else
++cit;
} }
return 0; return 0;
} }
...@@ -653,6 +663,7 @@ int32 scriptlib::group_merge(lua_State *L) { ...@@ -653,6 +663,7 @@ int32 scriptlib::group_merge(lua_State *L) {
group* mgroup = *(group**) lua_touserdata(L, 2); group* mgroup = *(group**) lua_touserdata(L, 2);
if(pgroup->is_readonly == 1) if(pgroup->is_readonly == 1)
return 0; return 0;
pgroup->is_iterator_dirty = true;
pgroup->container.insert(mgroup->container.begin(), mgroup->container.end()); pgroup->container.insert(mgroup->container.begin(), mgroup->container.end());
return 0; return 0;
} }
...@@ -664,6 +675,7 @@ int32 scriptlib::group_sub(lua_State *L) { ...@@ -664,6 +675,7 @@ int32 scriptlib::group_sub(lua_State *L) {
group* sgroup = *(group**) lua_touserdata(L, 2); group* sgroup = *(group**) lua_touserdata(L, 2);
if(pgroup->is_readonly == 1) if(pgroup->is_readonly == 1)
return 0; return 0;
pgroup->is_iterator_dirty = true;
for (auto& pcard : sgroup->container) { for (auto& pcard : sgroup->container) {
pgroup->container.erase(pcard); pgroup->container.erase(pcard);
} }
...@@ -730,7 +742,7 @@ int32 scriptlib::group_get_bin_class_count(lua_State *L) { ...@@ -730,7 +742,7 @@ int32 scriptlib::group_get_bin_class_count(lua_State *L) {
int32 ans = 0; int32 ans = 0;
while(er) { while(er) {
er &= er - 1; er &= er - 1;
ans++; ++ans;
} }
lua_pushinteger(L, ans); lua_pushinteger(L, ans);
return 1; return 1;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#ifndef MTRANDOM_H_ #ifndef MTRANDOM_H_
#define MTRANDOM_H_ #define MTRANDOM_H_
#include <cstdint>
#include <random> #include <random>
class mt19937 { class mt19937 {
...@@ -15,30 +16,30 @@ public: ...@@ -15,30 +16,30 @@ public:
const unsigned int rand_max; const unsigned int rand_max;
mt19937() : mt19937() :
rng(), rand_max((rng.max)()) {} rng(), rand_max(rng.max()) {}
explicit mt19937(unsigned int seed) : explicit mt19937(uint_fast32_t seed) :
rng(seed), rand_max((rng.max)()) {} rng(seed), rand_max(rng.max()) {}
// mersenne_twister_engine // mersenne_twister_engine
void reset(unsigned int seed) { void reset(uint_fast32_t seed) {
rng.seed(seed); rng.seed(seed);
} }
unsigned int rand() { uint_fast32_t rand() {
return rng(); return rng();
} }
// uniform_int_distribution // uniform_int_distribution
int get_random_integer(int l, int h) { int get_random_integer(int l, int h) {
unsigned int range = (unsigned int)(h - l + 1); uint_fast32_t range = (uint_fast32_t)(h - l + 1);
unsigned int secureMax = rand_max - rand_max % range; uint_fast32_t secureMax = rng.max() - rng.max() % range;
unsigned int x; uint_fast32_t x;
do { do {
x = rng(); x = rng();
} while (x >= secureMax); } while (x >= secureMax);
return (int)(l + x % range); return l + (int)(x % range);
} }
int get_random_integer_old(int l, int h) { int get_random_integer_old(int l, int h) {
int result = (int)((double)rng() / rand_max * ((double)h - l + 1)) + l; int result = (int)((double)rng() / rng.max() * ((double)h - l + 1)) + l;
if (result > h) if (result > h)
result = h; result = h;
return result; return result;
......
...@@ -57,7 +57,7 @@ uint32 default_card_reader(uint32 code, card_data* data) { ...@@ -57,7 +57,7 @@ uint32 default_card_reader(uint32 code, card_data* data) {
uint32 default_message_handler(void* pduel, uint32 message_type) { uint32 default_message_handler(void* pduel, uint32 message_type) {
return 0; return 0;
} }
extern "C" DECL_DLLEXPORT intptr_t create_duel(uint32 seed) { extern "C" DECL_DLLEXPORT intptr_t create_duel(uint_fast32_t seed) {
duel* pduel = new duel(); duel* pduel = new duel();
duel_set.insert(pduel); duel_set.insert(pduel);
pduel->random.reset(seed); pduel->random.reset(seed);
...@@ -72,7 +72,7 @@ extern "C" DECL_DLLEXPORT void start_duel(intptr_t pduel, int32 options) { ...@@ -72,7 +72,7 @@ extern "C" DECL_DLLEXPORT void start_duel(intptr_t pduel, int32 options) {
else if(options & DUEL_OBSOLETE_RULING) //provide backward compatibility with replay else if(options & DUEL_OBSOLETE_RULING) //provide backward compatibility with replay
pd->game_field->core.duel_rule = 1; pd->game_field->core.duel_rule = 1;
else if(!pd->game_field->core.duel_rule) else if(!pd->game_field->core.duel_rule)
pd->game_field->core.duel_rule = 5; pd->game_field->core.duel_rule = CURRENT_RULE;
pd->game_field->core.shuffle_hand_check[0] = FALSE; pd->game_field->core.shuffle_hand_check[0] = FALSE;
pd->game_field->core.shuffle_hand_check[1] = FALSE; pd->game_field->core.shuffle_hand_check[1] = FALSE;
pd->game_field->core.shuffle_deck_check[0] = FALSE; pd->game_field->core.shuffle_deck_check[0] = FALSE;
...@@ -127,11 +127,12 @@ extern "C" DECL_DLLEXPORT int32 get_message(intptr_t pduel, byte* buf) { ...@@ -127,11 +127,12 @@ extern "C" DECL_DLLEXPORT int32 get_message(intptr_t pduel, byte* buf) {
((duel*)pduel)->clear_buffer(); ((duel*)pduel)->clear_buffer();
return len; return len;
} }
extern "C" DECL_DLLEXPORT int32 process(intptr_t pduel) { extern "C" DECL_DLLEXPORT uint32 process(intptr_t pduel) {
duel* pd = (duel*)pduel; duel* pd = (duel*)pduel;
int result = pd->game_field->process(); uint32 result = 0;
while((result & 0xffff) == 0 && (result & 0xf0000) == 0) do {
result = pd->game_field->process(); result = pd->game_field->process();
} while ((result & PROCESSOR_BUFFER_LEN) == 0 && (result & PROCESSOR_FLAG) == 0);
return result; return result;
} }
extern "C" DECL_DLLEXPORT void new_card(intptr_t pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position) { extern "C" DECL_DLLEXPORT void new_card(intptr_t pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position) {
...@@ -176,26 +177,28 @@ extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32 code, uint8 o ...@@ -176,26 +177,28 @@ extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32 code, uint8 o
} }
extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache) { extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache) {
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return LEN_FAIL;
duel* ptduel = (duel*)pduel; duel* ptduel = (duel*)pduel;
card* pcard = 0; card* pcard = nullptr;
location &= 0x7f; location &= 0x7f;
if(location & LOCATION_ONFIELD) if(location & LOCATION_ONFIELD)
pcard = ptduel->game_field->get_field_card(playerid, location, sequence); pcard = ptduel->game_field->get_field_card(playerid, location, sequence);
else { else {
field::card_vector* lst = 0; field::card_vector* lst = nullptr;
if(location == LOCATION_HAND) if (location == LOCATION_HAND)
lst = &ptduel->game_field->player[playerid].list_hand; lst = &ptduel->game_field->player[playerid].list_hand;
else if(location == LOCATION_GRAVE) else if (location == LOCATION_GRAVE)
lst = &ptduel->game_field->player[playerid].list_grave; lst = &ptduel->game_field->player[playerid].list_grave;
else if(location == LOCATION_REMOVED) else if (location == LOCATION_REMOVED)
lst = &ptduel->game_field->player[playerid].list_remove; lst = &ptduel->game_field->player[playerid].list_remove;
else if(location == LOCATION_EXTRA) else if (location == LOCATION_EXTRA)
lst = &ptduel->game_field->player[playerid].list_extra; lst = &ptduel->game_field->player[playerid].list_extra;
else if(location == LOCATION_DECK) else if (location == LOCATION_DECK)
lst = &ptduel->game_field->player[playerid].list_main; lst = &ptduel->game_field->player[playerid].list_main;
if(!lst || sequence >= lst->size()) else
pcard = 0; return LEN_FAIL;
if(sequence >= (int32)lst->size())
pcard = nullptr;
else else
pcard = (*lst)[sequence]; pcard = (*lst)[sequence];
} }
...@@ -203,8 +206,8 @@ extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8 ...@@ -203,8 +206,8 @@ extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8
return pcard->get_infos(buf, query_flag, use_cache); return pcard->get_infos(buf, query_flag, use_cache);
} }
else { else {
*((int32*)buf) = 4; *((int32*)buf) = LEN_EMPTY;
return 4; return LEN_EMPTY;
} }
} }
extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid, uint8 location) { extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid, uint8 location) {
...@@ -223,44 +226,46 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid ...@@ -223,44 +226,46 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid
if(location == LOCATION_DECK) if(location == LOCATION_DECK)
return (int32)player.list_main.size(); return (int32)player.list_main.size();
if(location == LOCATION_MZONE) { if(location == LOCATION_MZONE) {
uint32 count = 0; int32 count = 0;
for(auto& pcard : player.list_mzone) for(auto& pcard : player.list_mzone)
if(pcard) count++; if(pcard)
++count;
return count; return count;
} }
if(location == LOCATION_SZONE) { if(location == LOCATION_SZONE) {
uint32 count = 0; int32 count = 0;
for(auto& pcard : player.list_szone) for(auto& pcard : player.list_szone)
if(pcard) count++; if(pcard)
++count;
return count; return count;
} }
return 0; return 0;
} }
extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache) { extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, uint32 query_flag, byte* buf, int32 use_cache) {
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return LEN_FAIL;
duel* ptduel = (duel*)pduel; duel* ptduel = (duel*)pduel;
auto& player = ptduel->game_field->player[playerid]; auto& player = ptduel->game_field->player[playerid];
byte* p = buf; byte* p = buf;
if(location == LOCATION_MZONE) { if(location == LOCATION_MZONE) {
for(auto& pcard : player.list_mzone) { for(auto& pcard : player.list_mzone) {
if(pcard) { if(pcard) {
uint32 clen = pcard->get_infos(p, query_flag, use_cache); int32 clen = pcard->get_infos(p, query_flag, use_cache);
p += clen; p += clen;
} else { } else {
*((int32*)p) = 4; *((int32*)p) = LEN_EMPTY;
p += 4; p += LEN_EMPTY;
} }
} }
} }
else if(location == LOCATION_SZONE) { else if(location == LOCATION_SZONE) {
for(auto& pcard : player.list_szone) { for(auto& pcard : player.list_szone) {
if(pcard) { if(pcard) {
uint32 clen = pcard->get_infos(p, query_flag, use_cache); int32 clen = pcard->get_infos(p, query_flag, use_cache);
p += clen; p += clen;
} else { } else {
*((int32*)p) = 4; *((int32*)p) = LEN_EMPTY;
p += 4; p += LEN_EMPTY;
} }
} }
} }
...@@ -277,9 +282,9 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, ...@@ -277,9 +282,9 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
else if(location == LOCATION_DECK) else if(location == LOCATION_DECK)
lst = &player.list_main; lst = &player.list_main;
else else
return 0; return LEN_FAIL;
for(auto& pcard : *lst) { for(auto& pcard : *lst) {
uint32 clen = pcard->get_infos(p, query_flag, use_cache); int32 clen = pcard->get_infos(p, query_flag, use_cache);
p += clen; p += clen;
} }
} }
......
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
#define DECL_DLLEXPORT #define DECL_DLLEXPORT
#endif #endif
#define LEN_FAIL 0
#define LEN_EMPTY 4
#define LEN_HEADER 8
class card; class card;
struct card_data; struct card_data;
struct card_info; struct card_info;
...@@ -35,18 +39,18 @@ byte* read_script(const char* script_name, int* len); ...@@ -35,18 +39,18 @@ byte* read_script(const char* script_name, int* len);
uint32 read_card(uint32 code, card_data* data); uint32 read_card(uint32 code, card_data* data);
uint32 handle_message(void* pduel, uint32 message_type); uint32 handle_message(void* pduel, uint32 message_type);
extern "C" DECL_DLLEXPORT intptr_t create_duel(uint32 seed); extern "C" DECL_DLLEXPORT intptr_t create_duel(uint_fast32_t seed);
extern "C" DECL_DLLEXPORT void start_duel(intptr_t pduel, int32 options); extern "C" DECL_DLLEXPORT void start_duel(intptr_t pduel, int32 options);
extern "C" DECL_DLLEXPORT void end_duel(intptr_t pduel); extern "C" DECL_DLLEXPORT void end_duel(intptr_t pduel);
extern "C" DECL_DLLEXPORT void set_player_info(intptr_t pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount); extern "C" DECL_DLLEXPORT void set_player_info(intptr_t pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount);
extern "C" DECL_DLLEXPORT void get_log_message(intptr_t pduel, byte* buf); extern "C" DECL_DLLEXPORT void get_log_message(intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 get_message(intptr_t pduel, byte* buf); extern "C" DECL_DLLEXPORT int32 get_message(intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 process(intptr_t pduel); extern "C" DECL_DLLEXPORT uint32 process(intptr_t pduel);
extern "C" DECL_DLLEXPORT void new_card(intptr_t pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position); extern "C" DECL_DLLEXPORT void new_card(intptr_t pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position);
extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32 code, uint8 owner, uint8 location); extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32 code, uint8 owner, uint8 location);
extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache); extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache);
extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid, uint8 location); extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid, uint8 location);
extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache); extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, uint32 query_flag, byte* buf, int32 use_cache);
extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf); extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT void set_responsei(intptr_t pduel, int32 value); extern "C" DECL_DLLEXPORT void set_responsei(intptr_t pduel, int32 value);
extern "C" DECL_DLLEXPORT void set_responseb(intptr_t pduel, byte* buf); extern "C" DECL_DLLEXPORT void set_responseb(intptr_t pduel, byte* buf);
......
This diff is collapsed.
...@@ -755,7 +755,7 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa ...@@ -755,7 +755,7 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa
int32 scount = 0; int32 scount = 0;
for(int32 ft = 0x1; ft < (1 << RACES_COUNT); ft <<= 1) { for(int32 ft = 0x1; ft < (1 << RACES_COUNT); ft <<= 1) {
if(ft & available) if(ft & available)
scount++; ++scount;
} }
if(scount <= count) { if(scount <= count) {
count = scount; count = scount;
...@@ -775,7 +775,7 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa ...@@ -775,7 +775,7 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
sel++; ++sel;
} }
if(sel != count) { if(sel != count) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
...@@ -794,7 +794,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a ...@@ -794,7 +794,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a
int32 scount = 0; int32 scount = 0;
for(int32 ft = 0x1; ft != 0x80; ft <<= 1) { for(int32 ft = 0x1; ft != 0x80; ft <<= 1) {
if(ft & available) if(ft & available)
scount++; ++scount;
} }
if(scount <= count) { if(scount <= count) {
count = scount; count = scount;
...@@ -814,7 +814,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a ...@@ -814,7 +814,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
sel++; ++sel;
} }
if(sel != count) { if(sel != count) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
......
This diff is collapsed.
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class scriptlib { class scriptlib {
public: public:
static int32 check_param(lua_State* L, int32 param_type, int32 index, BOOL retfalse = FALSE); static int32 check_param(lua_State* L, int32 param_type, int32 index, int32 retfalse = FALSE);
static int32 check_param_count(lua_State* L, int32 count); static int32 check_param_count(lua_State* L, int32 count);
static int32 check_action_permission(lua_State* L); static int32 check_action_permission(lua_State* L);
...@@ -30,6 +30,7 @@ public: ...@@ -30,6 +30,7 @@ public:
static int32 card_is_pre_set_card(lua_State *L); static int32 card_is_pre_set_card(lua_State *L);
static int32 card_is_fusion_set_card(lua_State *L); static int32 card_is_fusion_set_card(lua_State *L);
static int32 card_is_link_set_card(lua_State *L); static int32 card_is_link_set_card(lua_State *L);
static int32 card_is_special_summon_set_card(lua_State *L);
static int32 card_get_type(lua_State *L); static int32 card_get_type(lua_State *L);
static int32 card_get_origin_type(lua_State *L); static int32 card_get_origin_type(lua_State *L);
static int32 card_get_fusion_type(lua_State *L); static int32 card_get_fusion_type(lua_State *L);
...@@ -133,6 +134,7 @@ public: ...@@ -133,6 +134,7 @@ public:
static int32 card_is_summon_type(lua_State *L); static int32 card_is_summon_type(lua_State *L);
static int32 card_is_summon_location(lua_State *L); static int32 card_is_summon_location(lua_State *L);
static int32 card_is_summon_player(lua_State *L); static int32 card_is_summon_player(lua_State *L);
static int32 card_get_special_summon_info(lua_State *L);
static int32 card_is_status(lua_State *L); static int32 card_is_status(lua_State *L);
static int32 card_is_not_tuner(lua_State *L); static int32 card_is_not_tuner(lua_State *L);
static int32 card_is_tuner(lua_State* L); static int32 card_is_tuner(lua_State* L);
...@@ -484,6 +486,7 @@ public: ...@@ -484,6 +486,7 @@ public:
static int32 duel_get_field_card(lua_State *L); static int32 duel_get_field_card(lua_State *L);
static int32 duel_check_location(lua_State *L); static int32 duel_check_location(lua_State *L);
static int32 duel_get_current_chain(lua_State *L); static int32 duel_get_current_chain(lua_State *L);
static int32 duel_get_ready_chain(lua_State* L);
static int32 duel_get_chain_info(lua_State *L); static int32 duel_get_chain_info(lua_State *L);
static int32 duel_get_chain_event(lua_State *L); static int32 duel_get_chain_event(lua_State *L);
static int32 duel_get_first_target(lua_State *L); static int32 duel_get_first_target(lua_State *L);
......
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