Commit bb79d3bc authored by nanahira's avatar nanahira

merge

parents 5d43ab2b 2ca88956
This diff is collapsed.
...@@ -124,7 +124,6 @@ public: ...@@ -124,7 +124,6 @@ public:
uint8 location; uint8 location;
uint8 sequence; uint8 sequence;
}; };
int32 scrtype;
int32 ref_handle; int32 ref_handle;
duel* pduel; duel* pduel;
card_data data; card_data data;
...@@ -188,6 +187,7 @@ public: ...@@ -188,6 +187,7 @@ public:
explicit card(duel* pd); explicit card(duel* pd);
~card(); ~card();
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)); }
uint32 get_infos(byte* buf, int32 query_flag, int32 use_cache = TRUE); uint32 get_infos(byte* buf, int32 query_flag, int32 use_cache = TRUE);
uint32 get_info_location(); uint32 get_info_location();
...@@ -232,8 +232,8 @@ public: ...@@ -232,8 +232,8 @@ public:
void set_status(uint32 status, int32 enabled); void set_status(uint32 status, int32 enabled);
int32 get_status(uint32 status); int32 get_status(uint32 status);
int32 is_status(uint32 status); int32 is_status(uint32 status);
uint32 get_column_zone(int32 loc1, int32 left, int32 right); uint32 get_column_zone(int32 location);
void get_column_cards(card_set* cset, int32 left, int32 right); 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);
...@@ -276,6 +276,7 @@ public: ...@@ -276,6 +276,7 @@ public:
void set_material(card_set* materials); void set_material(card_set* materials);
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 filter_effect(int32 code, effect_set* eset, uint8 sort = TRUE); void filter_effect(int32 code, effect_set* eset, uint8 sort = TRUE);
void filter_single_effect(int32 code, effect_set* eset, uint8 sort = TRUE); void filter_single_effect(int32 code, effect_set* eset, uint8 sort = TRUE);
...@@ -345,119 +346,6 @@ public: ...@@ -345,119 +346,6 @@ public:
int32 is_can_be_link_material(card* scard); int32 is_can_be_link_material(card* scard);
}; };
//Locations
#define LOCATION_DECK 0x01 //
#define LOCATION_HAND 0x02 //
#define LOCATION_MZONE 0x04 //
#define LOCATION_SZONE 0x08 //
#define LOCATION_GRAVE 0x10 //
#define LOCATION_REMOVED 0x20 //
#define LOCATION_EXTRA 0x40 //
#define LOCATION_OVERLAY 0x80 //
#define LOCATION_ONFIELD 0x0c //
#define LOCATION_FZONE 0x100 //
#define LOCATION_PZONE 0x200 //
//Positions
#define POS_FACEUP_ATTACK 0x1
#define POS_FACEDOWN_ATTACK 0x2
#define POS_FACEUP_DEFENSE 0x4
#define POS_FACEDOWN_DEFENSE 0x8
#define POS_FACEUP 0x5
#define POS_FACEDOWN 0xa
#define POS_ATTACK 0x3
#define POS_DEFENSE 0xc
//Flip effect flags
#define NO_FLIP_EFFECT 0x10000
#define FLIP_SET_AVAILABLE 0x20000
//Types
#define TYPE_MONSTER 0x1 //
#define TYPE_SPELL 0x2 //
#define TYPE_TRAP 0x4 //
#define TYPE_NORMAL 0x10 //
#define TYPE_EFFECT 0x20 //
#define TYPE_FUSION 0x40 //
#define TYPE_RITUAL 0x80 //
#define TYPE_TRAPMONSTER 0x100 //
#define TYPE_SPIRIT 0x200 //
#define TYPE_UNION 0x400 //
#define TYPE_DUAL 0x800 //
#define TYPE_TUNER 0x1000 //
#define TYPE_SYNCHRO 0x2000 //
#define TYPE_TOKEN 0x4000 //
#define TYPE_QUICKPLAY 0x10000 //
#define TYPE_CONTINUOUS 0x20000 //
#define TYPE_EQUIP 0x40000 //
#define TYPE_FIELD 0x80000 //
#define TYPE_COUNTER 0x100000 //
#define TYPE_FLIP 0x200000 //
#define TYPE_TOON 0x400000 //
#define TYPE_XYZ 0x800000 //
#define TYPE_PENDULUM 0x1000000 //
#define TYPE_SPSUMMON 0x2000000 //
#define TYPE_LINK 0x4000000 //
//Attributes
#define ATTRIBUTE_EARTH 0x01 //
#define ATTRIBUTE_WATER 0x02 //
#define ATTRIBUTE_FIRE 0x04 //
#define ATTRIBUTE_WIND 0x08 //
#define ATTRIBUTE_LIGHT 0x10 //
#define ATTRIBUTE_DARK 0x20 //
#define ATTRIBUTE_DEVINE 0x40 //
//Races
#define RACE_WARRIOR 0x1 //
#define RACE_SPELLCASTER 0x2 //
#define RACE_FAIRY 0x4 //
#define RACE_FIEND 0x8 //
#define RACE_ZOMBIE 0x10 //
#define RACE_MACHINE 0x20 //
#define RACE_AQUA 0x40 //
#define RACE_PYRO 0x80 //
#define RACE_ROCK 0x100 //
#define RACE_WINDBEAST 0x200 //
#define RACE_PLANT 0x400 //
#define RACE_INSECT 0x800 //
#define RACE_THUNDER 0x1000 //
#define RACE_DRAGON 0x2000 //
#define RACE_BEAST 0x4000 //
#define RACE_BEASTWARRIOR 0x8000 //
#define RACE_DINOSAUR 0x10000 //
#define RACE_FISH 0x20000 //
#define RACE_SEASERPENT 0x40000 //
#define RACE_REPTILE 0x80000 //
#define RACE_PSYCHO 0x100000 //
#define RACE_DEVINE 0x200000 //
#define RACE_CREATORGOD 0x400000 //
#define RACE_WYRM 0x800000 //
#define RACE_CYBERSE 0x1000000 //
//Reason
#define REASON_DESTROY 0x1 //
#define REASON_RELEASE 0x2 //
#define REASON_TEMPORARY 0x4 //
#define REASON_MATERIAL 0x8 //
#define REASON_SUMMON 0x10 //
#define REASON_BATTLE 0x20 //
#define REASON_EFFECT 0x40 //
#define REASON_COST 0x80 //
#define REASON_ADJUST 0x100 //
#define REASON_LOST_TARGET 0x200 //
#define REASON_RULE 0x400 //
#define REASON_SPSUMMON 0x800 //
#define REASON_DISSUMMON 0x1000 //
#define REASON_FLIP 0x2000 //
#define REASON_DISCARD 0x4000 //
#define REASON_RDAMAGE 0x8000 //
#define REASON_RRECOVER 0x10000 //
#define REASON_RETURN 0x20000 //
#define REASON_FUSION 0x40000 //
#define REASON_SYNCHRO 0x80000 //
#define REASON_RITUAL 0x100000 //
#define REASON_XYZ 0x200000 //
#define REASON_REPLACE 0x1000000 //
#define REASON_DRAW 0x2000000 //
#define REASON_REDIRECT 0x4000000 //
//#define REASON_REVEAL 0x8000000 //
#define REASON_LINK 0x10000000 //
//Summon Type //Summon Type
#define SUMMON_TYPE_NORMAL 0x10000000 #define SUMMON_TYPE_NORMAL 0x10000000
#define SUMMON_TYPE_ADVANCE 0x11000000 #define SUMMON_TYPE_ADVANCE 0x11000000
...@@ -505,31 +393,6 @@ public: ...@@ -505,31 +393,6 @@ public:
//Counter //Counter
#define COUNTER_WITHOUT_PERMIT 0x1000 #define COUNTER_WITHOUT_PERMIT 0x1000
#define COUNTER_NEED_ENABLE 0x2000 #define COUNTER_NEED_ENABLE 0x2000
//Query list
#define QUERY_CODE 0x1
#define QUERY_POSITION 0x2
#define QUERY_ALIAS 0x4
#define QUERY_TYPE 0x8
#define QUERY_LEVEL 0x10
#define QUERY_RANK 0x20
#define QUERY_ATTRIBUTE 0x40
#define QUERY_RACE 0x80
#define QUERY_ATTACK 0x100
#define QUERY_DEFENSE 0x200
#define QUERY_BASE_ATTACK 0x400
#define QUERY_BASE_DEFENSE 0x800
#define QUERY_REASON 0x1000
#define QUERY_REASON_CARD 0x2000
#define QUERY_EQUIP_CARD 0x4000
#define QUERY_TARGET_CARD 0x8000
#define QUERY_OVERLAY_CARD 0x10000
#define QUERY_COUNTERS 0x20000
#define QUERY_OWNER 0x40000
#define QUERY_IS_DISABLED 0x80000
#define QUERY_IS_PUBLIC 0x100000
#define QUERY_LSCALE 0x200000
#define QUERY_RSCALE 0x400000
#define QUERY_LINK 0x800000
#define ASSUME_CODE 1 #define ASSUME_CODE 1
#define ASSUME_TYPE 2 #define ASSUME_TYPE 2
...@@ -540,13 +403,4 @@ public: ...@@ -540,13 +403,4 @@ public:
#define ASSUME_ATTACK 7 #define ASSUME_ATTACK 7
#define ASSUME_DEFENSE 8 #define ASSUME_DEFENSE 8
#define LINK_MARKER_BOTTOM_LEFT 0001
#define LINK_MARKER_BOTTOM 0002
#define LINK_MARKER_BOTTOM_RIGHT 0004
#define LINK_MARKER_LEFT 0010
#define LINK_MARKER_RIGHT 0040
#define LINK_MARKER_TOP_LEFT 0100
#define LINK_MARKER_TOP 0200
#define LINK_MARKER_TOP_RIGHT 0400
#endif /* CARD_H_ */ #endif /* CARD_H_ */
...@@ -42,4 +42,321 @@ struct card_sort { ...@@ -42,4 +42,321 @@ struct card_sort {
bool operator()(void* const & c1, void* const & c2) const; bool operator()(void* const & c1, void* const & c2) const;
}; };
//Locations
#define LOCATION_DECK 0x01 //
#define LOCATION_HAND 0x02 //
#define LOCATION_MZONE 0x04 //
#define LOCATION_SZONE 0x08 //
#define LOCATION_GRAVE 0x10 //
#define LOCATION_REMOVED 0x20 //
#define LOCATION_EXTRA 0x40 //
#define LOCATION_OVERLAY 0x80 //
#define LOCATION_ONFIELD 0x0c //
#define LOCATION_FZONE 0x100 //
#define LOCATION_PZONE 0x200 //
//Positions
#define POS_FACEUP_ATTACK 0x1
#define POS_FACEDOWN_ATTACK 0x2
#define POS_FACEUP_DEFENSE 0x4
#define POS_FACEDOWN_DEFENSE 0x8
#define POS_FACEUP 0x5
#define POS_FACEDOWN 0xa
#define POS_ATTACK 0x3
#define POS_DEFENSE 0xc
//Flip effect flags
#define NO_FLIP_EFFECT 0x10000
#define FLIP_SET_AVAILABLE 0x20000
//Types
#define TYPE_MONSTER 0x1 //
#define TYPE_SPELL 0x2 //
#define TYPE_TRAP 0x4 //
#define TYPE_NORMAL 0x10 //
#define TYPE_EFFECT 0x20 //
#define TYPE_FUSION 0x40 //
#define TYPE_RITUAL 0x80 //
#define TYPE_TRAPMONSTER 0x100 //
#define TYPE_SPIRIT 0x200 //
#define TYPE_UNION 0x400 //
#define TYPE_DUAL 0x800 //
#define TYPE_TUNER 0x1000 //
#define TYPE_SYNCHRO 0x2000 //
#define TYPE_TOKEN 0x4000 //
#define TYPE_QUICKPLAY 0x10000 //
#define TYPE_CONTINUOUS 0x20000 //
#define TYPE_EQUIP 0x40000 //
#define TYPE_FIELD 0x80000 //
#define TYPE_COUNTER 0x100000 //
#define TYPE_FLIP 0x200000 //
#define TYPE_TOON 0x400000 //
#define TYPE_XYZ 0x800000 //
#define TYPE_PENDULUM 0x1000000 //
#define TYPE_SPSUMMON 0x2000000 //
#define TYPE_LINK 0x4000000 //
//Attributes
#define ATTRIBUTE_EARTH 0x01 //
#define ATTRIBUTE_WATER 0x02 //
#define ATTRIBUTE_FIRE 0x04 //
#define ATTRIBUTE_WIND 0x08 //
#define ATTRIBUTE_LIGHT 0x10 //
#define ATTRIBUTE_DARK 0x20 //
#define ATTRIBUTE_DEVINE 0x40 //
//Races
#define RACE_WARRIOR 0x1 //
#define RACE_SPELLCASTER 0x2 //
#define RACE_FAIRY 0x4 //
#define RACE_FIEND 0x8 //
#define RACE_ZOMBIE 0x10 //
#define RACE_MACHINE 0x20 //
#define RACE_AQUA 0x40 //
#define RACE_PYRO 0x80 //
#define RACE_ROCK 0x100 //
#define RACE_WINDBEAST 0x200 //
#define RACE_PLANT 0x400 //
#define RACE_INSECT 0x800 //
#define RACE_THUNDER 0x1000 //
#define RACE_DRAGON 0x2000 //
#define RACE_BEAST 0x4000 //
#define RACE_BEASTWARRIOR 0x8000 //
#define RACE_DINOSAUR 0x10000 //
#define RACE_FISH 0x20000 //
#define RACE_SEASERPENT 0x40000 //
#define RACE_REPTILE 0x80000 //
#define RACE_PSYCHO 0x100000 //
#define RACE_DEVINE 0x200000 //
#define RACE_CREATORGOD 0x400000 //
#define RACE_WYRM 0x800000 //
#define RACE_CYBERSE 0x1000000 //
//Reason
#define REASON_DESTROY 0x1 //
#define REASON_RELEASE 0x2 //
#define REASON_TEMPORARY 0x4 //
#define REASON_MATERIAL 0x8 //
#define REASON_SUMMON 0x10 //
#define REASON_BATTLE 0x20 //
#define REASON_EFFECT 0x40 //
#define REASON_COST 0x80 //
#define REASON_ADJUST 0x100 //
#define REASON_LOST_TARGET 0x200 //
#define REASON_RULE 0x400 //
#define REASON_SPSUMMON 0x800 //
#define REASON_DISSUMMON 0x1000 //
#define REASON_FLIP 0x2000 //
#define REASON_DISCARD 0x4000 //
#define REASON_RDAMAGE 0x8000 //
#define REASON_RRECOVER 0x10000 //
#define REASON_RETURN 0x20000 //
#define REASON_FUSION 0x40000 //
#define REASON_SYNCHRO 0x80000 //
#define REASON_RITUAL 0x100000 //
#define REASON_XYZ 0x200000 //
#define REASON_REPLACE 0x1000000 //
#define REASON_DRAW 0x2000000 //
#define REASON_REDIRECT 0x4000000 //
//#define REASON_REVEAL 0x8000000 //
#define REASON_LINK 0x10000000 //
//Query list
#define QUERY_CODE 0x1
#define QUERY_POSITION 0x2
#define QUERY_ALIAS 0x4
#define QUERY_TYPE 0x8
#define QUERY_LEVEL 0x10
#define QUERY_RANK 0x20
#define QUERY_ATTRIBUTE 0x40
#define QUERY_RACE 0x80
#define QUERY_ATTACK 0x100
#define QUERY_DEFENSE 0x200
#define QUERY_BASE_ATTACK 0x400
#define QUERY_BASE_DEFENSE 0x800
#define QUERY_REASON 0x1000
#define QUERY_REASON_CARD 0x2000
#define QUERY_EQUIP_CARD 0x4000
#define QUERY_TARGET_CARD 0x8000
#define QUERY_OVERLAY_CARD 0x10000
#define QUERY_COUNTERS 0x20000
#define QUERY_OWNER 0x40000
#define QUERY_IS_DISABLED 0x80000
#define QUERY_IS_PUBLIC 0x100000
#define QUERY_LSCALE 0x200000
#define QUERY_RSCALE 0x400000
#define QUERY_LINK 0x800000
//Link markers
#define LINK_MARKER_BOTTOM_LEFT 0001
#define LINK_MARKER_BOTTOM 0002
#define LINK_MARKER_BOTTOM_RIGHT 0004
#define LINK_MARKER_LEFT 0010
#define LINK_MARKER_RIGHT 0040
#define LINK_MARKER_TOP_LEFT 0100
#define LINK_MARKER_TOP 0200
#define LINK_MARKER_TOP_RIGHT 0400
//Messages
#define MSG_RETRY 1
#define MSG_HINT 2
#define MSG_WAITING 3
#define MSG_START 4
#define MSG_WIN 5
#define MSG_UPDATE_DATA 6
#define MSG_UPDATE_CARD 7
#define MSG_REQUEST_DECK 8
#define MSG_SELECT_BATTLECMD 10
#define MSG_SELECT_IDLECMD 11
#define MSG_SELECT_EFFECTYN 12
#define MSG_SELECT_YESNO 13
#define MSG_SELECT_OPTION 14
#define MSG_SELECT_CARD 15
#define MSG_SELECT_CHAIN 16
#define MSG_SELECT_PLACE 18
#define MSG_SELECT_POSITION 19
#define MSG_SELECT_TRIBUTE 20
#define MSG_SORT_CHAIN 21
#define MSG_SELECT_COUNTER 22
#define MSG_SELECT_SUM 23
#define MSG_SELECT_DISFIELD 24
#define MSG_SORT_CARD 25
#define MSG_SELECT_UNSELECT_CARD 26
#define MSG_CONFIRM_DECKTOP 30
#define MSG_CONFIRM_CARDS 31
#define MSG_SHUFFLE_DECK 32
#define MSG_SHUFFLE_HAND 33
#define MSG_REFRESH_DECK 34
#define MSG_SWAP_GRAVE_DECK 35
#define MSG_SHUFFLE_SET_CARD 36
#define MSG_REVERSE_DECK 37
#define MSG_DECK_TOP 38
#define MSG_SHUFFLE_EXTRA 39
#define MSG_NEW_TURN 40
#define MSG_NEW_PHASE 41
#define MSG_CONFIRM_EXTRATOP 42
#define MSG_MOVE 50
#define MSG_POS_CHANGE 53
#define MSG_SET 54
#define MSG_SWAP 55
#define MSG_FIELD_DISABLED 56
#define MSG_SUMMONING 60
#define MSG_SUMMONED 61
#define MSG_SPSUMMONING 62
#define MSG_SPSUMMONED 63
#define MSG_FLIPSUMMONING 64
#define MSG_FLIPSUMMONED 65
#define MSG_CHAINING 70
#define MSG_CHAINED 71
#define MSG_CHAIN_SOLVING 72
#define MSG_CHAIN_SOLVED 73
#define MSG_CHAIN_END 74
#define MSG_CHAIN_NEGATED 75
#define MSG_CHAIN_DISABLED 76
#define MSG_CARD_SELECTED 80
#define MSG_RANDOM_SELECTED 81
#define MSG_BECOME_TARGET 83
#define MSG_DRAW 90
#define MSG_DAMAGE 91
#define MSG_RECOVER 92
#define MSG_EQUIP 93
#define MSG_LPUPDATE 94
#define MSG_UNEQUIP 95
#define MSG_CARD_TARGET 96
#define MSG_CANCEL_TARGET 97
#define MSG_PAY_LPCOST 100
#define MSG_ADD_COUNTER 101
#define MSG_REMOVE_COUNTER 102
#define MSG_ATTACK 110
#define MSG_BATTLE 111
#define MSG_ATTACK_DISABLED 112
#define MSG_DAMAGE_STEP_START 113
#define MSG_DAMAGE_STEP_END 114
#define MSG_MISSED_EFFECT 120
#define MSG_BE_CHAIN_TARGET 121
#define MSG_CREATE_RELATION 122
#define MSG_RELEASE_RELATION 123
#define MSG_TOSS_COIN 130
#define MSG_TOSS_DICE 131
#define MSG_ROCK_PAPER_SCISSORS 132
#define MSG_HAND_RES 133
#define MSG_ANNOUNCE_RACE 140
#define MSG_ANNOUNCE_ATTRIB 141
#define MSG_ANNOUNCE_CARD 142
#define MSG_ANNOUNCE_NUMBER 143
#define MSG_ANNOUNCE_CARD_FILTER 144
#define MSG_CARD_HINT 160
#define MSG_TAG_SWAP 161
#define MSG_RELOAD_FIELD 162 // Debug.ReloadFieldEnd()
#define MSG_AI_NAME 163
#define MSG_SHOW_HINT 164
#define MSG_PLAYER_HINT 165
#define MSG_MATCH_KILL 170
#define MSG_CUSTOM_MSG 180
//Hints
#define HINT_EVENT 1
#define HINT_MESSAGE 2
#define HINT_SELECTMSG 3
#define HINT_OPSELECTED 4
#define HINT_EFFECT 5
#define HINT_RACE 6
#define HINT_ATTRIB 7
#define HINT_CODE 8
#define HINT_NUMBER 9
#define HINT_CARD 10
//
#define CHINT_TURN 1
#define CHINT_CARD 2
#define CHINT_RACE 3
#define CHINT_ATTRIBUTE 4
#define CHINT_NUMBER 5
#define CHINT_DESC_ADD 6
#define CHINT_DESC_REMOVE 7
//
#define PHINT_DESC_ADD 6
#define PHINT_DESC_REMOVE 7
//
#define EDESC_OPERATION 1
#define EDESC_RESET 2
//
#define OPCODE_ADD 0x40000000
#define OPCODE_SUB 0x40000001
#define OPCODE_MUL 0x40000002
#define OPCODE_DIV 0x40000003
#define OPCODE_AND 0x40000004
#define OPCODE_OR 0x40000005
#define OPCODE_NEG 0x40000006
#define OPCODE_NOT 0x40000007
#define OPCODE_ISCODE 0x40000100
#define OPCODE_ISSETCARD 0x40000101
#define OPCODE_ISTYPE 0x40000102
#define OPCODE_ISRACE 0x40000103
#define OPCODE_ISATTRIBUTE 0x40000104
//Player
#define PLAYER_NONE 2 //
#define PLAYER_ALL 3 //
//Phase
#define PHASE_DRAW 0x01
#define PHASE_STANDBY 0x02
#define PHASE_MAIN1 0x04
#define PHASE_BATTLE_START 0x08
#define PHASE_BATTLE_STEP 0x10
#define PHASE_DAMAGE 0x20
#define PHASE_DAMAGE_CAL 0x40
#define PHASE_BATTLE 0x80
#define PHASE_MAIN2 0x100
#define PHASE_END 0x200
//Options
#define DUEL_TEST_MODE 0x01
#define DUEL_ATTACK_FIRST_TURN 0x02
//#define DUEL_NO_CHAIN_HINT 0x04
#define DUEL_OBSOLETE_RULING 0x08
#define DUEL_PSEUDO_SHUFFLE 0x10
#define DUEL_TAG_MODE 0x20
#define DUEL_SIMPLE_AI 0x40
#endif /* COMMON_H_ */ #endif /* COMMON_H_ */
...@@ -116,17 +116,17 @@ void duel::restore_assumes() { ...@@ -116,17 +116,17 @@ void duel::restore_assumes() {
assumes.clear(); assumes.clear();
} }
void duel::write_buffer32(uint32 value) { void duel::write_buffer32(uint32 value) {
*((uint32*)bufferp) = value; std::memcpy(bufferp, &value, sizeof(value));
bufferp += 4; bufferp += 4;
bufferlen += 4; bufferlen += 4;
} }
void duel::write_buffer16(uint16 value) { void duel::write_buffer16(uint16 value) {
*((uint16*)bufferp) = value; std::memcpy(bufferp, &value, sizeof(value));
bufferp += 2; bufferp += 2;
bufferlen += 2; bufferlen += 2;
} }
void duel::write_buffer8(uint8 value) { void duel::write_buffer8(uint8 value) {
*((uint8*)bufferp) = value; std::memcpy(bufferp, &value, sizeof(value));
bufferp += 1; bufferp += 1;
bufferlen += 1; bufferlen += 1;
} }
......
...@@ -62,26 +62,4 @@ private: ...@@ -62,26 +62,4 @@ private:
group* register_group(group* pgroup); group* register_group(group* pgroup);
}; };
//Player
#define PLAYER_NONE 2 //
#define PLAYER_ALL 3 //
//Phase
#define PHASE_DRAW 0x01
#define PHASE_STANDBY 0x02
#define PHASE_MAIN1 0x04
#define PHASE_BATTLE_START 0x08
#define PHASE_BATTLE_STEP 0x10
#define PHASE_DAMAGE 0x20
#define PHASE_DAMAGE_CAL 0x40
#define PHASE_BATTLE 0x80
#define PHASE_MAIN2 0x100
#define PHASE_END 0x200
//Options
#define DUEL_TEST_MODE 0x01
#define DUEL_ATTACK_FIRST_TURN 0x02
//#define DUEL_NO_CHAIN_HINT 0x04
#define DUEL_OBSOLETE_RULING 0x08
#define DUEL_PSEUDO_SHUFFLE 0x10
#define DUEL_TAG_MODE 0x20
#define DUEL_SIMPLE_AI 0x40
#endif /* DUEL_H_ */ #endif /* DUEL_H_ */
...@@ -15,7 +15,6 @@ bool effect_sort_id(const effect* e1, const effect* e2) { ...@@ -15,7 +15,6 @@ bool effect_sort_id(const effect* e1, const effect* e2) {
return e1->id < e2->id; return e1->id < e2->id;
}; };
effect::effect(duel* pd) { effect::effect(duel* pd) {
scrtype = 3;
ref_handle = 0; ref_handle = 0;
pduel = pd; pduel = pd;
owner = 0; owner = 0;
...@@ -229,7 +228,7 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -229,7 +228,7 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
ecode = EFFECT_TRAP_ACT_IN_SET_TURN; ecode = EFFECT_TRAP_ACT_IN_SET_TURN;
} }
if(ecode) { if(ecode) {
int32 available = false; bool available = false;
effect_set eset; effect_set eset;
handler->filter_effect(ecode, &eset); handler->filter_effect(ecode, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
...@@ -268,7 +267,7 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -268,7 +267,7 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
} }
if(phandler->current.location == LOCATION_OVERLAY) if(phandler->current.location == LOCATION_OVERLAY)
return FALSE; return FALSE;
if((type & EFFECT_TYPE_FIELD) && (phandler->current.controler != playerid) && !is_flag(EFFECT_FLAG_BOTH_SIDE)) 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))
return FALSE; return FALSE;
......
...@@ -27,7 +27,6 @@ enum effect_flag2 : uint32; ...@@ -27,7 +27,6 @@ enum effect_flag2 : uint32;
class effect { class effect {
public: public:
int32 scrtype;
int32 ref_handle; int32 ref_handle;
duel* pduel; duel* pduel;
card* owner; card* owner;
...@@ -111,6 +110,7 @@ public: ...@@ -111,6 +110,7 @@ public:
//status //status
#define EFFECT_STATUS_AVAILABLE 0x0001 #define EFFECT_STATUS_AVAILABLE 0x0001
//#define EFFECT_STATUS_ACTIVATED 0x0002 //#define EFFECT_STATUS_ACTIVATED 0x0002
#define EFFECT_STATUS_SPSELF 0x0004
#define EFFECT_COUNT_CODE_OATH 0x10000000 #define EFFECT_COUNT_CODE_OATH 0x10000000
#define EFFECT_COUNT_CODE_DUEL 0x20000000 #define EFFECT_COUNT_CODE_DUEL 0x20000000
...@@ -183,14 +183,14 @@ enum effect_flag : uint32 { ...@@ -183,14 +183,14 @@ enum effect_flag : uint32 {
EFFECT_FLAG_OWNER_RELATE = 0x1000000, EFFECT_FLAG_OWNER_RELATE = 0x1000000,
EFFECT_FLAG_AVAILABLE_BD = 0x2000000, EFFECT_FLAG_AVAILABLE_BD = 0x2000000,
EFFECT_FLAG_CLIENT_HINT = 0x4000000, EFFECT_FLAG_CLIENT_HINT = 0x4000000,
EFFECT_FLAG_CHAIN_UNIQUE = 0x8000000, // EFFECT_FLAG_CHAIN_UNIQUE = 0x8000000,
// EFFECT_FLAG_NAGA = 0x10000000, // EFFECT_FLAG_NAGA = 0x10000000,
// EFFECT_FLAG_COF = 0x20000000, // EFFECT_FLAG_COF = 0x20000000,
EFFECT_FLAG_CVAL_CHECK = 0x40000000, // EFFECT_FLAG_CVAL_CHECK = 0x40000000,
EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000, EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000,
}; };
enum effect_flag2 : uint32 { enum effect_flag2 : uint32 {
EFFECT_FLAG2_NAGA = 0x0001, // EFFECT_FLAG2_NAGA = 0x0001,
EFFECT_FLAG2_COF = 0x0002, EFFECT_FLAG2_COF = 0x0002,
}; };
inline effect_flag operator|(effect_flag flag1, effect_flag flag2) inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
...@@ -344,6 +344,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -344,6 +344,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_CANNOT_M2 186 #define EFFECT_CANNOT_M2 186
#define EFFECT_CANNOT_EP 187 #define EFFECT_CANNOT_EP 187
#define EFFECT_SKIP_TURN 188 #define EFFECT_SKIP_TURN 188
#define EFFECT_SKIP_EP 189
#define EFFECT_DEFENSE_ATTACK 190 #define EFFECT_DEFENSE_ATTACK 190
#define EFFECT_MUST_ATTACK 191 #define EFFECT_MUST_ATTACK 191
#define EFFECT_FIRST_ATTACK 192 #define EFFECT_FIRST_ATTACK 192
......
This diff is collapsed.
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <functional> #include <functional>
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include <cmath> #include <cmath>
class card; class card;
struct card_data; struct card_data;
...@@ -192,8 +192,6 @@ struct processor { ...@@ -192,8 +192,6 @@ struct processor {
event_list sub_solving_event; event_list sub_solving_event;
chain_array select_chains; chain_array select_chains;
chain_array current_chain; chain_array current_chain;
chain_list tpchain;
chain_list ntpchain;
chain_list continuous_chain; chain_list continuous_chain;
chain_list desrep_chain; chain_list desrep_chain;
chain_list new_fchain; chain_list new_fchain;
...@@ -227,7 +225,8 @@ struct processor { ...@@ -227,7 +225,8 @@ struct processor {
card_set discarded_set; card_set discarded_set;
card_set destroy_canceled; card_set destroy_canceled;
card_set delayed_enable_set; card_set delayed_enable_set;
card_set temp_set; card_set set_group_pre_set;
card_set set_group_set;
effect_set_v disfield_effects; effect_set_v disfield_effects;
effect_set_v extram_effects; effect_set_v extram_effects;
effect_set_v extras_effects; effect_set_v extras_effects;
...@@ -278,6 +277,8 @@ struct processor { ...@@ -278,6 +277,8 @@ struct processor {
uint32 copy_reset; uint32 copy_reset;
uint8 copy_reset_count; uint8 copy_reset_count;
uint32 last_control_changed_id; uint32 last_control_changed_id;
uint32 set_group_used_zones;
uint8 set_group_seq[7];
uint8 dice_result[5]; uint8 dice_result[5];
uint8 coin_result[5]; uint8 coin_result[5];
uint8 to_bp; uint8 to_bp;
...@@ -495,7 +496,6 @@ public: ...@@ -495,7 +496,6 @@ public:
int32 process_turn(uint16 step, uint8 turn_player); int32 process_turn(uint16 step, uint8 turn_player);
int32 add_chain(uint16 step); int32 add_chain(uint16 step);
int32 sort_chain(uint16 step, uint8 tp);
int32 solve_continuous(uint16 step, effect* peffect, uint8 triggering_player); int32 solve_continuous(uint16 step, effect* peffect, uint8 triggering_player);
int32 solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2); int32 solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2);
int32 break_effect(); int32 break_effect();
...@@ -554,7 +554,7 @@ public: ...@@ -554,7 +554,7 @@ public:
int32 flip_summon(uint16 step, uint8 sumplayer, card* target); int32 flip_summon(uint16 step, uint8 sumplayer, card* target);
int32 mset(uint16 step, uint8 setplayer, card* ptarget, effect* proc, uint8 ignore_count, uint8 min_tribute, uint32 zone); int32 mset(uint16 step, uint8 setplayer, card* ptarget, effect* proc, uint8 ignore_count, uint8 min_tribute, uint32 zone);
int32 sset(uint16 step, uint8 setplayer, uint8 toplayer, card* ptarget); int32 sset(uint16 step, uint8 setplayer, uint8 toplayer, card* ptarget);
int32 sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget); int32 sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget, uint8 confirm);
int32 special_summon_rule(uint16 step, uint8 sumplayer, card* target, uint32 summon_type); int32 special_summon_rule(uint16 step, uint8 sumplayer, card* target, uint32 summon_type);
int32 special_summon_step(uint16 step, group* targets, card* target, uint32 zone); int32 special_summon_step(uint16 step, group* targets, card* target, uint32 zone);
int32 special_summon(uint16 step, effect* reason_effect, uint8 reason_player, group* targets, uint32 zone); int32 special_summon(uint16 step, effect* reason_effect, uint8 reason_player, group* targets, uint32 zone);
...@@ -606,6 +606,8 @@ public: ...@@ -606,6 +606,8 @@ public:
#define CHAIN_HAND_EFFECT 0x04 #define CHAIN_HAND_EFFECT 0x04
#define CHAIN_CONTINUOUS_CARD 0x08 #define CHAIN_CONTINUOUS_CARD 0x08
#define CHAIN_ACTIVATING 0x10 #define CHAIN_ACTIVATING 0x10
#define CHAIN_HAND_TRIGGER 0x20
#define CHAIN_DECK_EFFECT 0x40
#define CHAININFO_CHAIN_COUNT 0x01 #define CHAININFO_CHAIN_COUNT 0x01
#define CHAININFO_TRIGGERING_EFFECT 0x02 #define CHAININFO_TRIGGERING_EFFECT 0x02
#define CHAININFO_TRIGGERING_PLAYER 0x04 #define CHAININFO_TRIGGERING_PLAYER 0x04
...@@ -682,7 +684,7 @@ public: ...@@ -682,7 +684,7 @@ public:
#define PROCESSOR_SELECT_PLACE 18 #define PROCESSOR_SELECT_PLACE 18
#define PROCESSOR_SELECT_POSITION 19 #define PROCESSOR_SELECT_POSITION 19
#define PROCESSOR_SELECT_TRIBUTE_P 20 #define PROCESSOR_SELECT_TRIBUTE_P 20
#define PROCESSOR_SORT_CHAIN 21 //#define PROCESSOR_SORT_CHAIN 21
#define PROCESSOR_SELECT_COUNTER 22 #define PROCESSOR_SELECT_COUNTER 22
#define PROCESSOR_SELECT_SUM 23 #define PROCESSOR_SELECT_SUM 23
#define PROCESSOR_SELECT_DISFIELD 24 #define PROCESSOR_SELECT_DISFIELD 24
...@@ -777,140 +779,4 @@ public: ...@@ -777,140 +779,4 @@ public:
#define PROCESSOR_REMOVEOL_S 160 #define PROCESSOR_REMOVEOL_S 160
#define PROCESSOR_MOVETOFIELD_S 161 #define PROCESSOR_MOVETOFIELD_S 161
//Hints
#define HINT_EVENT 1
#define HINT_MESSAGE 2
#define HINT_SELECTMSG 3
#define HINT_OPSELECTED 4
#define HINT_EFFECT 5
#define HINT_RACE 6
#define HINT_ATTRIB 7
#define HINT_CODE 8
#define HINT_NUMBER 9
#define HINT_CARD 10
//
#define CHINT_TURN 1
#define CHINT_CARD 2
#define CHINT_RACE 3
#define CHINT_ATTRIBUTE 4
#define CHINT_NUMBER 5
#define CHINT_DESC_ADD 6
#define CHINT_DESC_REMOVE 7
//
#define PHINT_DESC_ADD 6
#define PHINT_DESC_REMOVE 7
//
#define EDESC_OPERATION 1
#define EDESC_RESET 2
//
#define OPCODE_ADD 0x40000000
#define OPCODE_SUB 0x40000001
#define OPCODE_MUL 0x40000002
#define OPCODE_DIV 0x40000003
#define OPCODE_AND 0x40000004
#define OPCODE_OR 0x40000005
#define OPCODE_NEG 0x40000006
#define OPCODE_NOT 0x40000007
#define OPCODE_ISCODE 0x40000100
#define OPCODE_ISSETCARD 0x40000101
#define OPCODE_ISTYPE 0x40000102
#define OPCODE_ISRACE 0x40000103
#define OPCODE_ISATTRIBUTE 0x40000104
//Messages
#define MSG_RETRY 1
#define MSG_HINT 2
#define MSG_WAITING 3
#define MSG_START 4
#define MSG_WIN 5
#define MSG_UPDATE_DATA 6
#define MSG_UPDATE_CARD 7
#define MSG_REQUEST_DECK 8
#define MSG_SELECT_BATTLECMD 10
#define MSG_SELECT_IDLECMD 11
#define MSG_SELECT_EFFECTYN 12
#define MSG_SELECT_YESNO 13
#define MSG_SELECT_OPTION 14
#define MSG_SELECT_CARD 15
#define MSG_SELECT_CHAIN 16
#define MSG_SELECT_PLACE 18
#define MSG_SELECT_POSITION 19
#define MSG_SELECT_TRIBUTE 20
#define MSG_SORT_CHAIN 21
#define MSG_SELECT_COUNTER 22
#define MSG_SELECT_SUM 23
#define MSG_SELECT_DISFIELD 24
#define MSG_SORT_CARD 25
#define MSG_SELECT_UNSELECT_CARD 26
#define MSG_CONFIRM_DECKTOP 30
#define MSG_CONFIRM_CARDS 31
#define MSG_SHUFFLE_DECK 32
#define MSG_SHUFFLE_HAND 33
#define MSG_REFRESH_DECK 34
#define MSG_SWAP_GRAVE_DECK 35
#define MSG_SHUFFLE_SET_CARD 36
#define MSG_REVERSE_DECK 37
#define MSG_DECK_TOP 38
#define MSG_SHUFFLE_EXTRA 39
#define MSG_NEW_TURN 40
#define MSG_NEW_PHASE 41
#define MSG_CONFIRM_EXTRATOP 42
#define MSG_MOVE 50
#define MSG_POS_CHANGE 53
#define MSG_SET 54
#define MSG_SWAP 55
#define MSG_FIELD_DISABLED 56
#define MSG_SUMMONING 60
#define MSG_SUMMONED 61
#define MSG_SPSUMMONING 62
#define MSG_SPSUMMONED 63
#define MSG_FLIPSUMMONING 64
#define MSG_FLIPSUMMONED 65
#define MSG_CHAINING 70
#define MSG_CHAINED 71
#define MSG_CHAIN_SOLVING 72
#define MSG_CHAIN_SOLVED 73
#define MSG_CHAIN_END 74
#define MSG_CHAIN_NEGATED 75
#define MSG_CHAIN_DISABLED 76
#define MSG_CARD_SELECTED 80
#define MSG_RANDOM_SELECTED 81
#define MSG_BECOME_TARGET 83
#define MSG_DRAW 90
#define MSG_DAMAGE 91
#define MSG_RECOVER 92
#define MSG_EQUIP 93
#define MSG_LPUPDATE 94
#define MSG_UNEQUIP 95
#define MSG_CARD_TARGET 96
#define MSG_CANCEL_TARGET 97
#define MSG_PAY_LPCOST 100
#define MSG_ADD_COUNTER 101
#define MSG_REMOVE_COUNTER 102
#define MSG_ATTACK 110
#define MSG_BATTLE 111
#define MSG_ATTACK_DISABLED 112
#define MSG_DAMAGE_STEP_START 113
#define MSG_DAMAGE_STEP_END 114
#define MSG_MISSED_EFFECT 120
#define MSG_BE_CHAIN_TARGET 121
#define MSG_CREATE_RELATION 122
#define MSG_RELEASE_RELATION 123
#define MSG_TOSS_COIN 130
#define MSG_TOSS_DICE 131
#define MSG_ROCK_PAPER_SCISSORS 132
#define MSG_HAND_RES 133
#define MSG_ANNOUNCE_RACE 140
#define MSG_ANNOUNCE_ATTRIB 141
#define MSG_ANNOUNCE_CARD 142
#define MSG_ANNOUNCE_NUMBER 143
#define MSG_ANNOUNCE_CARD_FILTER 144
#define MSG_CARD_HINT 160
#define MSG_TAG_SWAP 161
#define MSG_RELOAD_FIELD 162 // Debug.ReloadFieldEnd()
#define MSG_AI_NAME 163
#define MSG_SHOW_HINT 164
#define MSG_PLAYER_HINT 165
#define MSG_MATCH_KILL 170
#define MSG_CUSTOM_MSG 180
#endif /* FIELD_H_ */ #endif /* FIELD_H_ */
...@@ -10,20 +10,17 @@ ...@@ -10,20 +10,17 @@
#include "duel.h" #include "duel.h"
group::group(duel* pd) { group::group(duel* pd) {
scrtype = 2;
ref_handle = 0; ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE; is_readonly = FALSE;
} }
group::group(duel* pd, card* pcard) { group::group(duel* pd, card* pcard) {
container.insert(pcard); container.insert(pcard);
scrtype = 2;
ref_handle = 0; ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE; is_readonly = FALSE;
} }
group::group(duel* pd, const card_set& cset): container(cset) { group::group(duel* pd, const card_set& cset): container(cset) {
scrtype = 2;
ref_handle = 0; ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE; is_readonly = FALSE;
......
...@@ -18,7 +18,6 @@ class duel; ...@@ -18,7 +18,6 @@ class duel;
class group { class group {
public: public:
typedef std::set<card*, card_sort> card_set; typedef std::set<card*, card_sort> card_set;
int32 scrtype;
int32 ref_handle; int32 ref_handle;
duel* pduel; duel* pduel;
card_set container; card_set container;
......
...@@ -562,6 +562,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -562,6 +562,7 @@ static const struct luaL_Reg duellib[] = {
{ "IsPlayerCanSendtoHand", scriptlib::duel_is_player_can_send_to_hand }, { "IsPlayerCanSendtoHand", scriptlib::duel_is_player_can_send_to_hand },
{ "IsPlayerCanSendtoGrave", scriptlib::duel_is_player_can_send_to_grave }, { "IsPlayerCanSendtoGrave", scriptlib::duel_is_player_can_send_to_grave },
{ "IsPlayerCanSendtoDeck", scriptlib::duel_is_player_can_send_to_deck }, { "IsPlayerCanSendtoDeck", scriptlib::duel_is_player_can_send_to_deck },
{ "IsPlayerCanAdditionalSummon", scriptlib::duel_is_player_can_additional_summon },
{ "IsChainNegatable", scriptlib::duel_is_chain_negatable }, { "IsChainNegatable", scriptlib::duel_is_chain_negatable },
{ "IsChainDisablable", scriptlib::duel_is_chain_disablable }, { "IsChainDisablable", scriptlib::duel_is_chain_disablable },
{ "CheckChainTarget", scriptlib::duel_check_chain_target }, { "CheckChainTarget", scriptlib::duel_check_chain_target },
...@@ -631,7 +632,7 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -631,7 +632,7 @@ interpreter::interpreter(duel* pd): coroutines(256) {
//extra scripts //extra scripts
load_script((char*) "./script/constant.lua"); load_script((char*) "./script/constant.lua");
load_script((char*) "./script/utility.lua"); load_script((char*) "./script/utility.lua");
load_script((char*) "./specials/special.lua"); load_script((char*) "./script/special.lua");
} }
interpreter::~interpreter() { interpreter::~interpreter() {
lua_close(lua_state); lua_close(lua_state);
...@@ -744,16 +745,9 @@ int32 interpreter::load_card_script(uint32 code) { ...@@ -744,16 +745,9 @@ int32 interpreter::load_card_script(uint32 code) {
lua_pushstring(current_state, "__index"); lua_pushstring(current_state, "__index");
lua_pushvalue(current_state, -2); lua_pushvalue(current_state, -2);
lua_rawset(current_state, -3); lua_rawset(current_state, -3);
//load special and extra scripts first sprintf(script_name, "./script/c%d.lua", code);
sprintf(script_name, "./specials/c%d.lua", code); if(!load_script(script_name)) {
if (!load_script(script_name)) { return OPERATION_FAIL;
sprintf(script_name, "./expansions/script/c%d.lua", code);
if (!load_script(script_name)) {
sprintf(script_name, "./script/c%d.lua", code);
if (!load_script(script_name)) {
return OPERATION_FAIL;
}
}
} }
} }
return OPERATION_SUCCESS; return OPERATION_SUCCESS;
......
...@@ -424,14 +424,8 @@ int32 scriptlib::card_get_column_group(lua_State *L) { ...@@ -424,14 +424,8 @@ int32 scriptlib::card_get_column_group(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);
int32 left = 0;
int32 right = 0;
if(lua_gettop(L) >= 2)
left = lua_tointeger(L, 2);
if(lua_gettop(L) >= 3)
right = lua_tointeger(L, 3);
card::card_set cset; card::card_set cset;
pcard->get_column_cards(&cset, left, right); pcard->get_column_cards(&cset);
group* pgroup = pcard->pduel->new_group(cset); group* pgroup = pcard->pduel->new_group(cset);
interpreter::group2value(L, pgroup); interpreter::group2value(L, pgroup);
return 1; return 1;
...@@ -440,14 +434,8 @@ int32 scriptlib::card_get_column_group_count(lua_State *L) { ...@@ -440,14 +434,8 @@ int32 scriptlib::card_get_column_group_count(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);
int32 left = 0;
int32 right = 0;
if(lua_gettop(L) >= 2)
left = lua_tointeger(L, 2);
if(lua_gettop(L) >= 3)
right = lua_tointeger(L, 3);
card::card_set cset; card::card_set cset;
pcard->get_column_cards(&cset, left, right); pcard->get_column_cards(&cset);
lua_pushinteger(L, cset.size()); lua_pushinteger(L, cset.size());
return 1; return 1;
} }
...@@ -456,16 +444,10 @@ int32 scriptlib::card_get_column_zone(lua_State *L) { ...@@ -456,16 +444,10 @@ int32 scriptlib::card_get_column_zone(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);
int32 loc = lua_tointeger(L, 2); int32 loc = lua_tointeger(L, 2);
int32 left = 0;
int32 right = 0;
int32 cp = pcard->current.controler; int32 cp = pcard->current.controler;
if(lua_gettop(L) >= 3) if(lua_gettop(L) >= 3 && !lua_isnil(L, 3))
left = lua_tointeger(L, 3); cp = lua_tointeger(L, 3);
if(lua_gettop(L) >= 4) uint32 zone = pcard->get_column_zone(loc);
right = lua_tointeger(L, 4);
if(lua_gettop(L) >= 5 && !lua_isnil(L, 5))
cp = lua_tointeger(L, 5);
uint32 zone = pcard->get_column_zone(loc, left, right);
if(cp == 1 - pcard->current.controler) if(cp == 1 - pcard->current.controler)
lua_pushinteger(L, (((zone & 0xffff) << 16) | (zone >> 16))); lua_pushinteger(L, (((zone & 0xffff) << 16) | (zone >> 16)));
else else
...@@ -2112,7 +2094,7 @@ int32 scriptlib::card_is_able_to_deck_or_extra_as_cost(lua_State *L) { ...@@ -2112,7 +2094,7 @@ int32 scriptlib::card_is_able_to_deck_or_extra_as_cost(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 p = pcard->pduel->game_field->core.reason_player; uint32 p = pcard->pduel->game_field->core.reason_player;
int32 val = (pcard->data.type & 0x4802040) ? pcard->is_capable_cost_to_extra(p) : pcard->is_capable_cost_to_deck(p); int32 val = pcard->is_extra_deck_monster() ? pcard->is_capable_cost_to_extra(p) : pcard->is_capable_cost_to_deck(p);
if(val) if(val)
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
......
...@@ -377,6 +377,9 @@ int32 scriptlib::duel_sets(lua_State *L) { ...@@ -377,6 +377,9 @@ int32 scriptlib::duel_sets(lua_State *L) {
toplayer = lua_tointeger(L, 3); toplayer = lua_tointeger(L, 3);
if(toplayer != 0 && toplayer != 1) if(toplayer != 0 && toplayer != 1)
toplayer = playerid; toplayer = playerid;
uint32 confirm = TRUE;
if(lua_gettop(L) > 3)
confirm = lua_toboolean(L, 4);
card* pcard = 0; card* pcard = 0;
group* pgroup = 0; group* pgroup = 0;
duel* pduel = 0; duel* pduel = 0;
...@@ -385,13 +388,20 @@ int32 scriptlib::duel_sets(lua_State *L) { ...@@ -385,13 +388,20 @@ int32 scriptlib::duel_sets(lua_State *L) {
pduel = pcard->pduel; pduel = pcard->pduel;
} else if(check_param(L, PARAM_TYPE_GROUP, 2, TRUE)) { } else if(check_param(L, PARAM_TYPE_GROUP, 2, TRUE)) {
pgroup = *(group**) lua_touserdata(L, 2); pgroup = *(group**) lua_touserdata(L, 2);
pduel = pgroup->pduel; if(pgroup->container.empty()) {
return 0;
} else if(pgroup->container.size() == 1) {
pcard = *pgroup->container.begin();
pduel = pcard->pduel;
} else {
pduel = pgroup->pduel;
}
} else } else
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2);
if(pcard) if(pcard)
pduel->game_field->add_process(PROCESSOR_SSET, 0, 0, (group*)pcard, playerid, toplayer); pduel->game_field->add_process(PROCESSOR_SSET, 0, 0, (group*)pcard, playerid, toplayer);
else else
pduel->game_field->add_process(PROCESSOR_SSET_G, 0, 0, pgroup, playerid, toplayer); pduel->game_field->add_process(PROCESSOR_SSET_G, 0, 0, pgroup, playerid, toplayer, confirm);
return lua_yield(L, 0); return lua_yield(L, 0);
} }
int32 scriptlib::duel_create_token(lua_State *L) { int32 scriptlib::duel_create_token(lua_State *L) {
...@@ -435,9 +445,9 @@ int32 scriptlib::duel_special_summon(lua_State *L) { ...@@ -435,9 +445,9 @@ int32 scriptlib::duel_special_summon(lua_State *L) {
if(lua_gettop(L) >= 8) if(lua_gettop(L) >= 8)
zone = lua_tointeger(L, 8); zone = lua_tointeger(L, 8);
if(pcard) { if(pcard) {
pduel->game_field->core.temp_set.clear(); field::card_set cset;
pduel->game_field->core.temp_set.insert(pcard); cset.insert(pcard);
pduel->game_field->special_summon(&pduel->game_field->core.temp_set, sumtype, sumplayer, playerid, nocheck, nolimit, positions, zone); pduel->game_field->special_summon(&cset, sumtype, sumplayer, playerid, nocheck, nolimit, positions, zone);
} else } else
pduel->game_field->special_summon(&(pgroup->container), sumtype, sumplayer, playerid, nocheck, nolimit, positions, zone); pduel->game_field->special_summon(&(pgroup->container), sumtype, sumplayer, playerid, nocheck, nolimit, positions, zone);
pduel->game_field->core.subunits.back().type = PROCESSOR_SPSUMMON_S; pduel->game_field->core.subunits.back().type = PROCESSOR_SPSUMMON_S;
...@@ -629,9 +639,9 @@ int32 scriptlib::duel_change_form(lua_State *L) { ...@@ -629,9 +639,9 @@ int32 scriptlib::duel_change_form(lua_State *L) {
if(top > 5 && lua_toboolean(L, 6)) flag |= NO_FLIP_EFFECT; if(top > 5 && lua_toboolean(L, 6)) flag |= NO_FLIP_EFFECT;
if(top > 6 && lua_toboolean(L, 7)) flag |= FLIP_SET_AVAILABLE; if(top > 6 && lua_toboolean(L, 7)) flag |= FLIP_SET_AVAILABLE;
if(pcard) { if(pcard) {
pduel->game_field->core.temp_set.clear(); field::card_set cset;
pduel->game_field->core.temp_set.insert(pcard); cset.insert(pcard);
pduel->game_field->change_position(&pduel->game_field->core.temp_set, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE); pduel->game_field->change_position(&cset, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE);
} else } else
pduel->game_field->change_position(&(pgroup->container), pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE); pduel->game_field->change_position(&(pgroup->container), pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE);
pduel->game_field->core.subunits.back().type = PROCESSOR_CHANGEPOS_S; pduel->game_field->core.subunits.back().type = PROCESSOR_CHANGEPOS_S;
...@@ -927,7 +937,7 @@ int32 scriptlib::duel_raise_event(lua_State *L) { ...@@ -927,7 +937,7 @@ int32 scriptlib::duel_raise_event(lua_State *L) {
check_param_count(L, 7); check_param_count(L, 7);
card* pcard = 0; card* pcard = 0;
group* pgroup = 0; group* pgroup = 0;
duel* pduel; duel* pduel = 0;
if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) { if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) {
pcard = *(card**) lua_touserdata(L, 1); pcard = *(card**) lua_touserdata(L, 1);
pduel = pcard->pduel; pduel = pcard->pduel;
...@@ -935,7 +945,7 @@ int32 scriptlib::duel_raise_event(lua_State *L) { ...@@ -935,7 +945,7 @@ int32 scriptlib::duel_raise_event(lua_State *L) {
pgroup = *(group**) lua_touserdata(L, 1); pgroup = *(group**) lua_touserdata(L, 1);
pduel = pgroup->pduel; pduel = pgroup->pduel;
} else } else
return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
uint32 code = lua_tointeger(L, 2); uint32 code = lua_tointeger(L, 2);
effect* peffect = 0; effect* peffect = 0;
if(!lua_isnil(L, 3)) { if(!lua_isnil(L, 3)) {
...@@ -1188,7 +1198,7 @@ int32 scriptlib::duel_get_control(lua_State *L) { ...@@ -1188,7 +1198,7 @@ int32 scriptlib::duel_get_control(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
card* pcard = 0; card* pcard = 0;
group* pgroup = 0; group* pgroup = 0;
duel* pduel; duel* pduel = 0;
if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) { if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) {
pcard = *(card**) lua_touserdata(L, 1); pcard = *(card**) lua_touserdata(L, 1);
pduel = pcard->pduel; pduel = pcard->pduel;
...@@ -1196,7 +1206,7 @@ int32 scriptlib::duel_get_control(lua_State *L) { ...@@ -1196,7 +1206,7 @@ int32 scriptlib::duel_get_control(lua_State *L) {
pgroup = *(group**) lua_touserdata(L, 1); pgroup = *(group**) lua_touserdata(L, 1);
pduel = pgroup->pduel; pduel = pgroup->pduel;
} else } else
return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
uint32 playerid = lua_tointeger(L, 2); uint32 playerid = lua_tointeger(L, 2);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
...@@ -1223,7 +1233,7 @@ int32 scriptlib::duel_swap_control(lua_State *L) { ...@@ -1223,7 +1233,7 @@ int32 scriptlib::duel_swap_control(lua_State *L) {
card* pcard2 = 0; card* pcard2 = 0;
group* pgroup1 = 0; group* pgroup1 = 0;
group* pgroup2 = 0; group* pgroup2 = 0;
duel* pduel; duel* pduel = 0;
if(check_param(L, PARAM_TYPE_CARD, 1, TRUE) && check_param(L, PARAM_TYPE_CARD, 2, TRUE)) { if(check_param(L, PARAM_TYPE_CARD, 1, TRUE) && check_param(L, PARAM_TYPE_CARD, 2, TRUE)) {
pcard1 = *(card**) lua_touserdata(L, 1); pcard1 = *(card**) lua_touserdata(L, 1);
pcard2 = *(card**) lua_touserdata(L, 2); pcard2 = *(card**) lua_touserdata(L, 2);
...@@ -1657,7 +1667,7 @@ int32 scriptlib::duel_get_location_count(lua_State *L) { ...@@ -1657,7 +1667,7 @@ int32 scriptlib::duel_get_location_count(lua_State *L) {
zone = lua_tointeger(L, 5); zone = lua_tointeger(L, 5);
uint32 list = 0; uint32 list = 0;
lua_pushinteger(L, pduel->game_field->get_useable_count(NULL, playerid, location, uplayer, reason, zone, &list)); lua_pushinteger(L, pduel->game_field->get_useable_count(NULL, playerid, location, uplayer, reason, zone, &list));
lua_pushinteger(L, list); lua_pushinteger(L, list);
return 2; return 2;
} }
int32 scriptlib::duel_get_mzone_count(lua_State *L) { int32 scriptlib::duel_get_mzone_count(lua_State *L) {
...@@ -1761,7 +1771,7 @@ int32 scriptlib::duel_get_location_count_fromex(lua_State *L) { ...@@ -1761,7 +1771,7 @@ int32 scriptlib::duel_get_location_count_fromex(lua_State *L) {
uint32 zone = 0xff; uint32 zone = 0xff;
if(lua_gettop(L) >= 5) if(lua_gettop(L) >= 5)
zone = lua_tointeger(L, 5); zone = lua_tointeger(L, 5);
uint32 list = 0; uint32 list = 0;
lua_pushinteger(L, pduel->game_field->get_useable_count_fromex(scard, playerid, uplayer, zone, &list)); lua_pushinteger(L, pduel->game_field->get_useable_count_fromex(scard, playerid, uplayer, zone, &list));
lua_pushinteger(L, list); lua_pushinteger(L, list);
if(swapped) { if(swapped) {
...@@ -1976,6 +1986,8 @@ int32 scriptlib::duel_skip_phase(lua_State *L) { ...@@ -1976,6 +1986,8 @@ int32 scriptlib::duel_skip_phase(lua_State *L) {
code = EFFECT_SKIP_BP; code = EFFECT_SKIP_BP;
else if(phase == PHASE_MAIN2) else if(phase == PHASE_MAIN2)
code = EFFECT_SKIP_M2; code = EFFECT_SKIP_M2;
else if(phase == PHASE_END)
code = EFFECT_SKIP_EP;
else else
return 0; return 0;
effect* peffect = pduel->new_effect(); effect* peffect = pduel->new_effect();
...@@ -3354,7 +3366,7 @@ int32 scriptlib::duel_set_dice_result(lua_State * L) { ...@@ -3354,7 +3366,7 @@ int32 scriptlib::duel_set_dice_result(lua_State * L) {
int32 res; int32 res;
for(int32 i = 0; i < 5; ++i) { for(int32 i = 0; i < 5; ++i) {
res = lua_tointeger(L, i + 1); res = lua_tointeger(L, i + 1);
if(res < 1 || res > 6) if(res < 1 || res > 255)
res = 1; res = 1;
pduel->game_field->core.dice_result[i] = res; pduel->game_field->core.dice_result[i] = res;
} }
...@@ -3591,48 +3603,48 @@ int32 scriptlib::duel_is_player_can_send_to_deck(lua_State * L) { ...@@ -3591,48 +3603,48 @@ int32 scriptlib::duel_is_player_can_send_to_deck(lua_State * L) {
lua_pushboolean(L, pduel->game_field->is_player_can_send_to_deck(playerid, pcard)); lua_pushboolean(L, pduel->game_field->is_player_can_send_to_deck(playerid, pcard));
return 1; return 1;
} }
int32 scriptlib::duel_is_player_can_additional_summon(lua_State * L) {
check_param_count(L, 1);
int32 playerid = lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1) {
lua_pushboolean(L, 0);
return 1;
}
duel* pduel = interpreter::get_duel_info(L);
if(pduel->game_field->core.extra_summon[playerid] == 0)
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
int32 scriptlib::duel_is_chain_negatable(lua_State * L) { int32 scriptlib::duel_is_chain_negatable(lua_State * L) {
check_param_count(L, 1); check_param_count(L, 1);
int32 chaincount = lua_tointeger(L, 1); int32 chaincount = lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
int32 res = 0; chain* ch = pduel->game_field->get_chain(chaincount);
if(chaincount < 0 || chaincount > (int32)pduel->game_field->core.current_chain.size()) if(!ch)
res = FALSE; return 0;
else { if(ch->flag & CHAIN_DECK_EFFECT)
effect* peffect; lua_pushboolean(L, 0);
if(chaincount == 0) else
peffect = pduel->game_field->core.current_chain.back().triggering_effect; lua_pushboolean(L, 1);
else
peffect = pduel->game_field->core.current_chain[chaincount - 1].triggering_effect;
if(peffect->is_flag(EFFECT_FLAG2_NAGA))
res = FALSE;
else
res = TRUE;
}
lua_pushboolean(L, res);
return 1; return 1;
} }
int32 scriptlib::duel_is_chain_disablable(lua_State * L) { int32 scriptlib::duel_is_chain_disablable(lua_State * L) {
check_param_count(L, 1); check_param_count(L, 1);
int32 chaincount = lua_tointeger(L, 1); int32 chaincount = lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
int32 res = 0; if(pduel->game_field->core.chain_solving) {
if(chaincount < 0 || chaincount > (int32)pduel->game_field->core.current_chain.size()) lua_pushboolean(L, pduel->game_field->is_chain_disablable(chaincount));
res = FALSE; return 1;
else {
effect* peffect;
if(chaincount == 0)
peffect = pduel->game_field->core.current_chain.back().triggering_effect;
else
peffect = pduel->game_field->core.current_chain[chaincount - 1].triggering_effect;
if(peffect->is_flag(EFFECT_FLAG2_NAGA))
res = FALSE;
else
res = TRUE;
if(pduel->game_field->core.chain_solving)
res = pduel->game_field->is_chain_disablable(chaincount);
} }
lua_pushboolean(L, res); chain* ch = pduel->game_field->get_chain(chaincount);
if(!ch)
return 0;
if(ch->flag & CHAIN_DECK_EFFECT)
lua_pushboolean(L, 0);
else
lua_pushboolean(L, 1);
return 1; return 1;
} }
int32 scriptlib::duel_check_chain_target(lua_State *L) { int32 scriptlib::duel_check_chain_target(lua_State *L) {
......
...@@ -42,7 +42,7 @@ int32 scriptlib::effect_reset(lua_State *L) { ...@@ -42,7 +42,7 @@ int32 scriptlib::effect_reset(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
if(peffect->owner == 0) if(peffect->owner == 0 || peffect->handler == 0)
return 0; return 0;
if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
peffect->pduel->game_field->remove_effect(peffect); peffect->pduel->game_field->remove_effect(peffect);
......
...@@ -30,9 +30,9 @@ int32 scriptlib::group_from_cards(lua_State *L) { ...@@ -30,9 +30,9 @@ int32 scriptlib::group_from_cards(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
for(int32 i = 0; i < lua_gettop(L); ++i) { for(int32 i = 0; i < lua_gettop(L); ++i) {
void* p = lua_touserdata(L, i + 1); if(!lua_isnil(L, i + 1)) {
if(p) { check_param(L, PARAM_TYPE_CARD, i + 1);
card* pcard = *(card**)p; card* pcard = *(card**) lua_touserdata(L, i + 1);
pgroup->container.insert(pcard); pgroup->container.insert(pcard);
} }
} }
...@@ -656,7 +656,7 @@ int32 scriptlib::group_meta_add(lua_State* L) { ...@@ -656,7 +656,7 @@ int32 scriptlib::group_meta_add(lua_State* L) {
if(!check_param(L, PARAM_TYPE_CARD, 1, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 1, TRUE)) if(!check_param(L, PARAM_TYPE_CARD, 1, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 1, TRUE))
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
if(!check_param(L, PARAM_TYPE_CARD, 2, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 2, TRUE)) if(!check_param(L, PARAM_TYPE_CARD, 2, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 2, TRUE))
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) { if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) {
...@@ -683,7 +683,7 @@ int32 scriptlib::group_meta_sub(lua_State* L) { ...@@ -683,7 +683,7 @@ int32 scriptlib::group_meta_sub(lua_State* L) {
if(!check_param(L, PARAM_TYPE_CARD, 1, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 1, TRUE)) if(!check_param(L, PARAM_TYPE_CARD, 1, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 1, TRUE))
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
if(!check_param(L, PARAM_TYPE_CARD, 2, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 2, TRUE)) if(!check_param(L, PARAM_TYPE_CARD, 2, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 2, TRUE))
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) { if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) {
...@@ -710,7 +710,7 @@ int32 scriptlib::group_meta_band(lua_State* L) { ...@@ -710,7 +710,7 @@ int32 scriptlib::group_meta_band(lua_State* L) {
if(!check_param(L, PARAM_TYPE_CARD, 1, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 1, TRUE)) if(!check_param(L, PARAM_TYPE_CARD, 1, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 1, TRUE))
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
if(!check_param(L, PARAM_TYPE_CARD, 2, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 2, TRUE)) if(!check_param(L, PARAM_TYPE_CARD, 2, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 2, TRUE))
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
field::card_set check_set; field::card_set check_set;
...@@ -739,7 +739,7 @@ int32 scriptlib::group_meta_bxor(lua_State* L) { ...@@ -739,7 +739,7 @@ int32 scriptlib::group_meta_bxor(lua_State* L) {
if(!check_param(L, PARAM_TYPE_CARD, 1, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 1, TRUE)) if(!check_param(L, PARAM_TYPE_CARD, 1, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 1, TRUE))
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
if(!check_param(L, PARAM_TYPE_CARD, 2, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 2, TRUE)) if(!check_param(L, PARAM_TYPE_CARD, 2, TRUE) && !check_param(L, PARAM_TYPE_GROUP, 2, TRUE))
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) { if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) {
......
...@@ -63,7 +63,7 @@ extern "C" DECL_DLLEXPORT ptr create_duel(uint32 seed) { ...@@ -63,7 +63,7 @@ extern "C" DECL_DLLEXPORT ptr create_duel(uint32 seed) {
pduel->random.reset(seed); pduel->random.reset(seed);
return (ptr)pduel; return (ptr)pduel;
} }
extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int options) { extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int32 options) {
duel* pd = (duel*)pduel; duel* pd = (duel*)pduel;
pd->game_field->core.duel_options |= options & 0xffff; pd->game_field->core.duel_options |= options & 0xffff;
int32 duel_rule = options >> 16; int32 duel_rule = options >> 16;
...@@ -269,7 +269,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint ...@@ -269,7 +269,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
} }
} }
} else { } else {
field::card_vector* lst; field::card_vector* lst = 0;
if(location == LOCATION_HAND) if(location == LOCATION_HAND)
lst = &player.list_hand; lst = &player.list_hand;
else if(location == LOCATION_GRAVE) else if(location == LOCATION_GRAVE)
...@@ -291,18 +291,22 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) { ...@@ -291,18 +291,22 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
duel* ptduel = (duel*)pduel; duel* ptduel = (duel*)pduel;
*buf++ = MSG_RELOAD_FIELD; *buf++ = MSG_RELOAD_FIELD;
*buf++ = ptduel->game_field->core.duel_rule; *buf++ = ptduel->game_field->core.duel_rule;
int32 ct = 2;
for(int playerid = 0; playerid < 2; ++playerid) { for(int playerid = 0; playerid < 2; ++playerid) {
auto& player = ptduel->game_field->player[playerid]; auto& player = ptduel->game_field->player[playerid];
*((int*)(buf)) = player.lp; *((int*)(buf)) = player.lp;
buf += 4; buf += 4;
ct += 4;
for(auto cit = player.list_mzone.begin(); cit != player.list_mzone.end(); ++cit) { for(auto cit = player.list_mzone.begin(); cit != player.list_mzone.end(); ++cit) {
card* pcard = *cit; card* pcard = *cit;
if(pcard) { if(pcard) {
*buf++ = 1; *buf++ = 1;
*buf++ = pcard->current.position; *buf++ = pcard->current.position;
*buf++ = pcard->xyz_materials.size(); *buf++ = pcard->xyz_materials.size();
ct += 3;
} else { } else {
*buf++ = 0; *buf++ = 0;
ct++;
} }
} }
for(auto cit = player.list_szone.begin(); cit != player.list_szone.end(); ++cit) { for(auto cit = player.list_szone.begin(); cit != player.list_szone.end(); ++cit) {
...@@ -310,8 +314,10 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) { ...@@ -310,8 +314,10 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
if(pcard) { if(pcard) {
*buf++ = 1; *buf++ = 1;
*buf++ = pcard->current.position; *buf++ = pcard->current.position;
ct += 2;
} else { } else {
*buf++ = 0; *buf++ = 0;
ct++;
} }
} }
*buf++ = player.list_main.size(); *buf++ = player.list_main.size();
...@@ -320,8 +326,10 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) { ...@@ -320,8 +326,10 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
*buf++ = player.list_remove.size(); *buf++ = player.list_remove.size();
*buf++ = player.list_extra.size(); *buf++ = player.list_extra.size();
*buf++ = player.extra_p_count; *buf++ = player.extra_p_count;
ct += 6;
} }
*buf++ = ptduel->game_field->core.current_chain.size(); *buf++ = ptduel->game_field->core.current_chain.size();
ct++;
for(auto chit = ptduel->game_field->core.current_chain.begin(); chit != ptduel->game_field->core.current_chain.end(); ++chit) { for(auto chit = ptduel->game_field->core.current_chain.begin(); chit != ptduel->game_field->core.current_chain.end(); ++chit) {
effect* peffect = chit->triggering_effect; effect* peffect = chit->triggering_effect;
*((int*)(buf)) = peffect->get_handler()->data.code; *((int*)(buf)) = peffect->get_handler()->data.code;
...@@ -333,8 +341,9 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) { ...@@ -333,8 +341,9 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
*buf++ = chit->triggering_sequence; *buf++ = chit->triggering_sequence;
*((int*)(buf)) = peffect->description; *((int*)(buf)) = peffect->description;
buf += 4; buf += 4;
ct += 15;
} }
return 0; return ct;
} }
extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value) { extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value) {
((duel*)pduel)->set_responsei(value); ((duel*)pduel)->set_responsei(value);
......
This diff is collapsed.
...@@ -19,15 +19,12 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) { ...@@ -19,15 +19,12 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) {
if(step == 0) { if(step == 0) {
pduel->write_buffer8(MSG_SELECT_BATTLECMD); pduel->write_buffer8(MSG_SELECT_BATTLECMD);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
uint32 i;
card* pcard;
effect* peffect;
//Activatable //Activatable
pduel->write_buffer8(core.select_chains.size()); pduel->write_buffer8(core.select_chains.size());
std::sort(core.select_chains.begin(), core.select_chains.end(), chain::chain_operation_sort); std::sort(core.select_chains.begin(), core.select_chains.end(), chain::chain_operation_sort);
for(i = 0; i < core.select_chains.size(); ++i) { for(uint32 i = 0; i < core.select_chains.size(); ++i) {
peffect = core.select_chains[i].triggering_effect; effect* peffect = core.select_chains[i].triggering_effect;
pcard = peffect->get_handler(); card* pcard = peffect->get_handler();
if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
else else
...@@ -39,8 +36,8 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) { ...@@ -39,8 +36,8 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) {
} }
//Attackable //Attackable
pduel->write_buffer8(core.attackable_cards.size()); pduel->write_buffer8(core.attackable_cards.size());
for(i = 0; i < core.attackable_cards.size(); ++i) { for(uint32 i = 0; i < core.attackable_cards.size(); ++i) {
pcard = core.attackable_cards[i]; card* pcard = core.attackable_cards[i];
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);
...@@ -73,15 +70,12 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) { ...@@ -73,15 +70,12 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) {
} }
int32 field::select_idle_command(uint16 step, uint8 playerid) { int32 field::select_idle_command(uint16 step, uint8 playerid) {
if(step == 0) { if(step == 0) {
uint32 i;
card* pcard;
effect* peffect;
pduel->write_buffer8(MSG_SELECT_IDLECMD); pduel->write_buffer8(MSG_SELECT_IDLECMD);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
//idle summon //idle summon
pduel->write_buffer8(core.summonable_cards.size()); pduel->write_buffer8(core.summonable_cards.size());
for(i = 0; i < core.summonable_cards.size(); ++i) { for(uint32 i = 0; i < core.summonable_cards.size(); ++i) {
pcard = core.summonable_cards[i]; card* pcard = core.summonable_cards[i];
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);
...@@ -89,8 +83,8 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -89,8 +83,8 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
} }
//idle spsummon //idle spsummon
pduel->write_buffer8(core.spsummonable_cards.size()); pduel->write_buffer8(core.spsummonable_cards.size());
for(i = 0; i < core.spsummonable_cards.size(); ++i) { for(uint32 i = 0; i < core.spsummonable_cards.size(); ++i) {
pcard = core.spsummonable_cards[i]; card* pcard = core.spsummonable_cards[i];
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);
...@@ -98,8 +92,8 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -98,8 +92,8 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
} }
//idle pos change //idle pos change
pduel->write_buffer8(core.repositionable_cards.size()); pduel->write_buffer8(core.repositionable_cards.size());
for(i = 0; i < core.repositionable_cards.size(); ++i) { for(uint32 i = 0; i < core.repositionable_cards.size(); ++i) {
pcard = core.repositionable_cards[i]; card* pcard = core.repositionable_cards[i];
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);
...@@ -107,8 +101,8 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -107,8 +101,8 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
} }
//idle mset //idle mset
pduel->write_buffer8(core.msetable_cards.size()); pduel->write_buffer8(core.msetable_cards.size());
for(i = 0; i < core.msetable_cards.size(); ++i) { for(uint32 i = 0; i < core.msetable_cards.size(); ++i) {
pcard = core.msetable_cards[i]; card* pcard = core.msetable_cards[i];
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);
...@@ -116,8 +110,8 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -116,8 +110,8 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
} }
//idle sset //idle sset
pduel->write_buffer8(core.ssetable_cards.size()); pduel->write_buffer8(core.ssetable_cards.size());
for(i = 0; i < core.ssetable_cards.size(); ++i) { for(uint32 i = 0; i < core.ssetable_cards.size(); ++i) {
pcard = core.ssetable_cards[i]; card* pcard = core.ssetable_cards[i];
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);
...@@ -126,9 +120,9 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -126,9 +120,9 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
//idle activate //idle activate
pduel->write_buffer8(core.select_chains.size()); pduel->write_buffer8(core.select_chains.size());
std::sort(core.select_chains.begin(), core.select_chains.end(), chain::chain_operation_sort); std::sort(core.select_chains.begin(), core.select_chains.end(), chain::chain_operation_sort);
for(i = 0; i < core.select_chains.size(); ++i) { for(uint32 i = 0; i < core.select_chains.size(); ++i) {
peffect = core.select_chains[i].triggering_effect; effect* peffect = core.select_chains[i].triggering_effect;
pcard = peffect->get_handler(); card* pcard = peffect->get_handler();
if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
else else
...@@ -749,9 +743,8 @@ int32 field::sort_card(int16 step, uint8 playerid, uint8 is_chain) { ...@@ -749,9 +743,8 @@ int32 field::sort_card(int16 step, uint8 playerid, uint8 is_chain) {
pduel->write_buffer8(MSG_SORT_CARD); pduel->write_buffer8(MSG_SORT_CARD);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
pduel->write_buffer8(core.select_cards.size()); pduel->write_buffer8(core.select_cards.size());
card* pcard;
for(uint32 i = 0; i < core.select_cards.size(); ++i) { for(uint32 i = 0; i < core.select_cards.size(); ++i) {
pcard = core.select_cards[i]; card* pcard = core.select_cards[i];
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);
......
This diff is collapsed.
...@@ -7,54 +7,64 @@ ...@@ -7,54 +7,64 @@
#include "scriptlib.h" #include "scriptlib.h"
#include "duel.h" #include "duel.h"
int32 scriptlib::check_data_type(lua_State* L, int32 index, const char* tname) {
int32 result = FALSE;
if(lua_getmetatable(L, index)) {
lua_getglobal(L, tname);
if(lua_rawequal(L, -1, -2))
result = TRUE;
lua_pop(L, 2);
}
return result;
}
int32 scriptlib::check_param(lua_State* L, int32 param_type, int32 index, int32 retfalse) { int32 scriptlib::check_param(lua_State* L, int32 param_type, int32 index, int32 retfalse) {
int32 result;
switch (param_type) { switch (param_type) {
case PARAM_TYPE_CARD: case PARAM_TYPE_CARD: {
if (lua_isuserdata(L, index)) { int32 result = FALSE;
result = **(int32**)lua_touserdata(L, index); if(lua_isuserdata(L, index) && lua_getmetatable(L, index)) {
if(result == 1) result = check_data_type(L, -1, "Card");
return TRUE; lua_pop(L, 1);
} }
if(result)
return TRUE;
if(retfalse) if(retfalse)
return FALSE; return FALSE;
luaL_error(L, "Parameter %d should be \"Card\".", index); luaL_error(L, "Parameter %d should be \"Card\".", index);
break; break;
case PARAM_TYPE_GROUP: }
if (lua_isuserdata(L, index)) { case PARAM_TYPE_GROUP: {
result = **(int32**)lua_touserdata(L, index); if(lua_isuserdata(L, index) && check_data_type(L, index, "Group"))
if(result == 2) return TRUE;
return TRUE;
}
if(retfalse) if(retfalse)
return FALSE; return FALSE;
luaL_error(L, "Parameter %d should be \"Group\".", index); luaL_error(L, "Parameter %d should be \"Group\".", index);
break; break;
case PARAM_TYPE_EFFECT: }
if (lua_isuserdata(L, index)) { case PARAM_TYPE_EFFECT: {
result = **(int32**)lua_touserdata(L, index); if(lua_isuserdata(L, index) && check_data_type(L, index, "Effect"))
if(result == 3) return TRUE;
return TRUE;
}
if(retfalse) if(retfalse)
return FALSE; return FALSE;
luaL_error(L, "Parameter %d should be \"Effect\".", index); luaL_error(L, "Parameter %d should be \"Effect\".", index);
break; break;
case PARAM_TYPE_FUNCTION: }
if (lua_isfunction(L, index)) case PARAM_TYPE_FUNCTION: {
if(lua_isfunction(L, index))
return TRUE; return TRUE;
if(retfalse) if(retfalse)
return FALSE; return FALSE;
luaL_error(L, "Parameter %d should be \"Function\".", index); luaL_error(L, "Parameter %d should be \"Function\".", index);
break; break;
case PARAM_TYPE_STRING: }
if (lua_isstring(L, index)) case PARAM_TYPE_STRING: {
if(lua_isstring(L, index))
return TRUE; return TRUE;
if(retfalse) if(retfalse)
return FALSE; return FALSE;
luaL_error(L, "Parameter %d should be \"String\".", index); luaL_error(L, "Parameter %d should be \"String\".", index);
break; break;
} }
}
return FALSE; return FALSE;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
class scriptlib { class scriptlib {
public: public:
static int32 check_data_type(lua_State* L, int32 index, const char* tname);
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, BOOL 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);
...@@ -556,6 +557,7 @@ public: ...@@ -556,6 +557,7 @@ public:
static int32 duel_is_player_can_send_to_hand(lua_State *L); static int32 duel_is_player_can_send_to_hand(lua_State *L);
static int32 duel_is_player_can_send_to_grave(lua_State *L); static int32 duel_is_player_can_send_to_grave(lua_State *L);
static int32 duel_is_player_can_send_to_deck(lua_State *L); static int32 duel_is_player_can_send_to_deck(lua_State *L);
static int32 duel_is_player_can_additional_summon(lua_State *L);
static int32 duel_is_chain_negatable(lua_State *L); static int32 duel_is_chain_negatable(lua_State *L);
static int32 duel_is_chain_disablable(lua_State *L); static int32 duel_is_chain_disablable(lua_State *L);
static int32 duel_check_chain_target(lua_State *L); static int32 duel_check_chain_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