Commit 7f6e1a3b authored by Argon.Sun's avatar Argon.Sun

submodule branch

parent d0924379
project (ocgcore)
set (AUTO_FILES_RESULT)
AutoFiles("." "src" "\\.(cpp|c|h)$")
if (WIN32)
else ()
include_directories ( ${LUA_INCLUDE_DIR} )
endif ()
add_library (ocgcore STATIC ${AUTO_FILES_RESULT})
\ No newline at end of file
This diff is collapsed.
...@@ -18,20 +18,6 @@ class duel; ...@@ -18,20 +18,6 @@ class duel;
class effect; class effect;
class group; class group;
struct card_data {
uint32 code;
uint32 alias;
uint64 setcode;
uint32 type;
uint32 level;
uint32 attribute;
uint32 race;
int32 attack;
int32 defence;
uint32 lscale;
uint32 rscale;
};
struct card_state { struct card_state {
uint32 code; uint32 code;
uint32 code2; uint32 code2;
...@@ -62,6 +48,8 @@ struct query_cache { ...@@ -62,6 +48,8 @@ struct query_cache {
uint32 type; uint32 type;
uint32 level; uint32 level;
uint32 rank; uint32 rank;
uint32 lscale;
uint32 rscale;
uint32 attribute; uint32 attribute;
uint32 race; uint32 race;
int32 attack; int32 attack;
...@@ -69,10 +57,8 @@ struct query_cache { ...@@ -69,10 +57,8 @@ struct query_cache {
int32 base_attack; int32 base_attack;
int32 base_defence; int32 base_defence;
uint32 reason; uint32 reason;
int32 is_public; uint32 owner;
int32 is_disabled; uint32 status;
uint32 lscale;
uint32 rscale;
}; };
class card { class card {
...@@ -139,7 +125,8 @@ public: ...@@ -139,7 +125,8 @@ public:
~card(); ~card();
static bool card_operation_sort(card* c1, card* c2); static bool card_operation_sort(card* c1, card* c2);
uint32 get_infos(byte* buf, int32 query_flag, int32 use_cache = TRUE); void update_infos(int32 query_flag);
void update_infos_nocache(int32 query_flag);
uint32 get_info_location(); uint32 get_info_location();
uint32 get_code(); uint32 get_code();
uint32 get_another_code(); uint32 get_another_code();
...@@ -259,183 +246,6 @@ public: ...@@ -259,183 +246,6 @@ public:
int32 is_can_be_xyz_material(card* scard); int32 is_can_be_xyz_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_DEFENCE 0x4
#define POS_FACEDOWN_DEFENCE 0x8
#define POS_FACEUP 0x5
#define POS_FACEDOWN 0xa
#define POS_ATTACK 0x3
#define POS_DEFENCE 0xc
#define NO_FLIP_EFFECT 0x10000
//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 //
//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_PHANTOMDRAGON 0x800000 //
//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 //
//Summon Type
#define SUMMON_TYPE_NORMAL 0x10000000
#define SUMMON_TYPE_ADVANCE 0x11000000
#define SUMMON_TYPE_DUAL 0x12000000
#define SUMMON_TYPE_FLIP 0x20000000
#define SUMMON_TYPE_SPECIAL 0x40000000
#define SUMMON_TYPE_FUSION 0x43000000
#define SUMMON_TYPE_RITUAL 0x45000000
#define SUMMON_TYPE_SYNCHRO 0x46000000
#define SUMMON_TYPE_XYZ 0x49000000
#define SUMMON_TYPE_PENDULUM 0x4a000000
//Status
#define STATUS_DISABLED 0x0001 //
#define STATUS_TO_ENABLE 0x0002 //
#define STATUS_TO_DISABLE 0x0004 //
#define STATUS_PROC_COMPLETE 0x0008 //
#define STATUS_SET_TURN 0x0010 //
#define STATUS_NO_LEVEL 0x0020 //
#define STATUS_REVIVE_LIMIT 0x0040 //
#define STATUS_SPSUMMON_STEP 0x0080 //
#define STATUS_FORM_CHANGED 0x0100 //
#define STATUS_SUMMONING 0x0200 //
#define STATUS_EFFECT_ENABLED 0x0400 //
#define STATUS_SUMMON_TURN 0x0800 //
#define STATUS_DESTROY_CONFIRMED 0x1000 //
#define STATUS_LEAVE_CONFIRMED 0x2000 //
#define STATUS_BATTLE_DESTROYED 0x4000 //
#define STATUS_COPYING_EFFECT 0x8000 //
#define STATUS_CHAINING 0x10000 //
#define STATUS_SUMMON_DISABLED 0x20000 //
#define STATUS_ACTIVATE_DISABLED 0x40000 //
#define STATUS_UNSUMMONABLE_CARD 0x80000 //
#define STATUS_UNION 0x100000
#define STATUS_ATTACK_CANCELED 0x200000
#define STATUS_INITIALIZING 0x400000
#define STATUS_ACTIVATED 0x800000
#define STATUS_JUST_POS 0x1000000
#define STATUS_CONTINUOUS_POS 0x2000000
#define STATUS_IS_PUBLIC 0x4000000
#define STATUS_ACT_FROM_HAND 0x8000000
#define STATUS_OPPO_BATTLE 0x10000000
#define STATUS_FLIP_SUMMON_TURN 0x20000000
#define STATUS_SPSUMMON_TURN 0x40000000
//Counter
#define COUNTER_NEED_PERMIT 0x1000
#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_DEFENCE 0x200
#define QUERY_BASE_ATTACK 0x400
#define QUERY_BASE_DEFENCE 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 ASSUME_CODE 1 #define ASSUME_CODE 1
#define ASSUME_TYPE 2 #define ASSUME_TYPE 2
#define ASSUME_LEVEL 3 #define ASSUME_LEVEL 3
...@@ -444,4 +254,5 @@ public: ...@@ -444,4 +254,5 @@ public:
#define ASSUME_RACE 6 #define ASSUME_RACE 6
#define ASSUME_ATTACK 7 #define ASSUME_ATTACK 7
#define ASSUME_DEFENCE 8 #define ASSUME_DEFENCE 8
#endif /* CARD_H_ */ #endif /* CARD_H_ */
This diff is collapsed.
...@@ -18,6 +18,9 @@ duel::duel() { ...@@ -18,6 +18,9 @@ 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);
bufferlen = 0;
bufferp = buffer;
adapter = &defaultAdapter;
clear_buffer(); clear_buffer();
} }
duel::~duel() { duel::~duel() {
...@@ -48,7 +51,7 @@ card* duel::new_card(uint32 code) { ...@@ -48,7 +51,7 @@ card* duel::new_card(uint32 code) {
card* pcard = new card(this); card* pcard = new card(this);
cards.insert(pcard); cards.insert(pcard);
if(code) if(code)
::read_card(code, &(pcard->data)); adapter->ReadCard(code, &(pcard->data));
pcard->data.code = code; pcard->data.code = code;
lua->register_card(pcard); lua->register_card(pcard);
return pcard; return pcard;
...@@ -130,6 +133,15 @@ void duel::write_buffer8(uint8 value) { ...@@ -130,6 +133,15 @@ void duel::write_buffer8(uint8 value) {
bufferp += 1; bufferp += 1;
bufferlen += 1; bufferlen += 1;
} }
void duel::rollback_buffer(uint32 len) {
if(bufferlen >= len) {
bufferlen -= len;
bufferp -= len;
} else {
bufferlen = 0;
bufferp = buffer;
}
}
void duel::clear_buffer() { void duel::clear_buffer() {
bufferlen = 0; bufferlen = 0;
bufferp = buffer; bufferp = buffer;
......
...@@ -17,17 +17,19 @@ class group; ...@@ -17,17 +17,19 @@ class group;
class effect; class effect;
class field; class field;
class interpreter; class interpreter;
class ygoAdapter;
struct duel_arg { struct duel_arg {
int16 start_lp; int16 start_lp;
int8 start_hand; int8 start_hand;
int8 draw_count; int8 draw_count;
}; };
class duel { class duel {
public: public:
typedef std::set<card*, card_sort> card_set; typedef std::set<card*, card_sort> card_set;
char strbuffer[256]; char strbuffer[256];
byte buffer[0x1000]; byte buffer[0x2000];
uint32 bufferlen; uint32 bufferlen;
byte* bufferp; byte* bufferp;
interpreter* lua; interpreter* lua;
...@@ -39,7 +41,8 @@ public: ...@@ -39,7 +41,8 @@ public:
std::set<group*> sgroups; std::set<group*> sgroups;
std::set<effect*> effects; std::set<effect*> effects;
std::set<effect*> uncopy; std::set<effect*> uncopy;
ygoAdapter* adapter;
duel(); duel();
~duel(); ~duel();
void clear(); void clear();
...@@ -58,6 +61,7 @@ public: ...@@ -58,6 +61,7 @@ public:
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);
void rollback_buffer(uint32 len);
void clear_buffer(); void clear_buffer();
void set_responsei(uint32 resp); void set_responsei(uint32 resp);
void set_responseb(byte* resp); void set_responseb(byte* resp);
...@@ -86,4 +90,5 @@ private: ...@@ -86,4 +90,5 @@ private:
#define DUEL_PSEUDO_SHUFFLE 0x10 #define DUEL_PSEUDO_SHUFFLE 0x10
#define DUEL_TAG_MODE 0x20 #define DUEL_TAG_MODE 0x20
#define DUEL_SIMPLE_AI 0x40 #define DUEL_SIMPLE_AI 0x40
#endif /* DUEL_H_ */ #endif /* DUEL_H_ */
This diff is collapsed.
...@@ -205,6 +205,8 @@ struct processor { ...@@ -205,6 +205,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 update_single_card;
effect_set_v disfield_effects; effect_set_v disfield_effects;
effect_set_v extraz_effects; effect_set_v extraz_effects;
effect_set_v extraz_effects_e; effect_set_v extraz_effects_e;
...@@ -272,6 +274,7 @@ struct processor { ...@@ -272,6 +274,7 @@ struct processor {
uint8 deck_reversed; uint8 deck_reversed;
uint8 remove_brainwashing; uint8 remove_brainwashing;
uint8 flip_delayed; uint8 flip_delayed;
uint8 update_field;
uint8 damage_calculated; uint8 damage_calculated;
uint8 hand_adjusted; uint8 hand_adjusted;
uint8 summon_state_count[2]; uint8 summon_state_count[2];
...@@ -556,33 +559,6 @@ public: ...@@ -556,33 +559,6 @@ public:
#define CHAININFO_CHAIN_ID 0x800 #define CHAININFO_CHAIN_ID 0x800
#define CHAININFO_TYPE 0x1000 #define CHAININFO_TYPE 0x1000
#define CHAININFO_EXTTYPE 0x2000 #define CHAININFO_EXTTYPE 0x2000
//Timing
#define TIMING_DRAW_PHASE 0x1
#define TIMING_STANDBY_PHASE 0x2
#define TIMING_MAIN_END 0x4
#define TIMING_BATTLE_START 0x8
#define TIMING_BATTLE_END 0x10
#define TIMING_END_PHASE 0x20
#define TIMING_SUMMON 0x40
#define TIMING_SPSUMMON 0x80
#define TIMING_FLIPSUMMON 0x100
#define TIMING_MSET 0x200
#define TIMING_SSET 0x400
#define TIMING_POS_CHANGE 0x800
#define TIMING_ATTACK 0x1000
#define TIMING_DAMAGE_STEP 0x2000
#define TIMING_DAMAGE_CAL 0x4000
#define TIMING_CHAIN_END 0x8000
#define TIMING_DRAW 0x10000
#define TIMING_DAMAGE 0x20000
#define TIMING_RECOVER 0x40000
#define TIMING_DESTROY 0x80000
#define TIMING_REMOVE 0x100000
#define TIMING_TOHAND 0x200000
#define TIMING_TODECK 0x400000
#define TIMING_TOGRAVE 0x800000
#define TIMING_BATTLE_PHASE 0x1000000
#define TIMING_EQUIP 0x2000000
#define GLOBALFLAG_DECK_REVERSE_CHECK 0x1 #define GLOBALFLAG_DECK_REVERSE_CHECK 0x1
#define GLOBALFLAG_BRAINWASHING_CHECK 0x2 #define GLOBALFLAG_BRAINWASHING_CHECK 0x2
...@@ -706,112 +682,4 @@ public: ...@@ -706,112 +682,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
//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_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_NEW_TURN 40
#define MSG_NEW_PHASE 41
#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_ANNOUNCE_RACE 140
#define MSG_ANNOUNCE_ATTRIB 141
#define MSG_ANNOUNCE_CARD 142
#define MSG_ANNOUNCE_NUMBER 143
#define MSG_CARD_HINT 160
#define MSG_TAG_SWAP 161
#define MSG_RELOAD_FIELD 162
#define MSG_AI_NAME 163
#define MSG_SHOW_HINT 164
#define MSG_MATCH_KILL 170
#define MSG_CUSTOM_MSG 180
#endif /* FIELD_H_ */ #endif /* FIELD_H_ */
...@@ -629,14 +629,14 @@ void interpreter::unregister_group(group *pgroup) { ...@@ -629,14 +629,14 @@ void interpreter::unregister_group(group *pgroup) {
int32 interpreter::load_script(char* script_name) { int32 interpreter::load_script(char* script_name) {
int32 error; int32 error;
int32 len = 0; int32 len = 0;
byte* buffer = read_script(script_name, &len); byte* buffer = pduel->adapter->ReadScript(script_name, &len);
if (!buffer) if (!buffer)
return OPERATION_FAIL; return OPERATION_FAIL;
no_action++; no_action++;
error = luaL_loadbuffer(current_state, (const char*) buffer, len, (const char*) script_name) || lua_pcall(current_state, 0, 0, 0); error = luaL_loadbuffer(current_state, (const char*) buffer, len, (const char*) script_name) || lua_pcall(current_state, 0, 0, 0);
if (error) { if (error) {
sprintf(pduel->strbuffer, lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; no_action--;
return OPERATION_FAIL; return OPERATION_FAIL;
...@@ -745,20 +745,20 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) { ...@@ -745,20 +745,20 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) {
int32 interpreter::call_function(int32 f, uint32 param_count, uint32 ret_count) { int32 interpreter::call_function(int32 f, uint32 param_count, uint32 ret_count) {
if (!f) { if (!f) {
sprintf(pduel->strbuffer, "\"CallFunction\": attempt to call a null function."); sprintf(pduel->strbuffer, "\"CallFunction\": attempt to call a null function.");
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
if (param_count != params.size()) { if (param_count != params.size()) {
sprintf(pduel->strbuffer, "\"CallFunction\": incorrect parameter count (%d expected, %ud pushed)", param_count, params.size()); sprintf(pduel->strbuffer, "\"CallFunction\": incorrect parameter count (%d expected, %lud pushed)", param_count, params.size());
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
function2value(current_state, f); function2value(current_state, f);
if (!lua_isfunction(current_state, -1)) { if (!lua_isfunction(current_state, -1)) {
sprintf(pduel->strbuffer, "\"CallFunction\": attempt to call an error function"); sprintf(pduel->strbuffer, "\"CallFunction\": attempt to call an error function");
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
...@@ -767,8 +767,8 @@ int32 interpreter::call_function(int32 f, uint32 param_count, uint32 ret_count) ...@@ -767,8 +767,8 @@ int32 interpreter::call_function(int32 f, uint32 param_count, uint32 ret_count)
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, lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; no_action--;
call_depth--; call_depth--;
...@@ -789,7 +789,7 @@ int32 interpreter::call_function(int32 f, uint32 param_count, uint32 ret_count) ...@@ -789,7 +789,7 @@ int32 interpreter::call_function(int32 f, uint32 param_count, uint32 ret_count)
int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count, uint32 ret_count) { int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count, uint32 ret_count) {
if (param_count != params.size()) { if (param_count != params.size()) {
sprintf(pduel->strbuffer, "\"CallCardFunction\"(c%d.%s): incorrect parameter count", pcard->data.code, f); sprintf(pduel->strbuffer, "\"CallCardFunction\"(c%d.%s): incorrect parameter count", pcard->data.code, f);
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
...@@ -797,7 +797,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count, ...@@ -797,7 +797,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
lua_getfield(current_state, -1, f); lua_getfield(current_state, -1, f);
if (!lua_isfunction(current_state, -1)) { if (!lua_isfunction(current_state, -1)) {
sprintf(pduel->strbuffer, "\"CallCardFunction\"(c%d.%s): attempt to call an error function", pcard->data.code, f); sprintf(pduel->strbuffer, "\"CallCardFunction\"(c%d.%s): attempt to call an error function", pcard->data.code, f);
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
lua_pop(current_state, 2); lua_pop(current_state, 2);
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
...@@ -807,8 +807,8 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count, ...@@ -807,8 +807,8 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
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, lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; no_action--;
call_depth--; call_depth--;
...@@ -829,7 +829,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count, ...@@ -829,7 +829,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count, uint32 ret_count) { int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count, uint32 ret_count) {
if (param_count != params.size()) { if (param_count != params.size()) {
sprintf(pduel->strbuffer, "\"CallCodeFunction\": incorrect parameter count"); sprintf(pduel->strbuffer, "\"CallCodeFunction\": incorrect parameter count");
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
...@@ -837,7 +837,7 @@ int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count, ...@@ -837,7 +837,7 @@ int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count,
lua_getfield(current_state, -1, f); lua_getfield(current_state, -1, f);
if (!lua_isfunction(current_state, -1)) { if (!lua_isfunction(current_state, -1)) {
sprintf(pduel->strbuffer, "\"CallCodeFunction\": attempt to call an error function"); sprintf(pduel->strbuffer, "\"CallCodeFunction\": attempt to call an error function");
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
lua_pop(current_state, 2); lua_pop(current_state, 2);
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
...@@ -847,8 +847,8 @@ int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count, ...@@ -847,8 +847,8 @@ int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count,
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, lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; no_action--;
call_depth--; call_depth--;
...@@ -904,8 +904,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) { ...@@ -904,8 +904,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
for(int32 i = 0; i < extraargs; ++i) for(int32 i = 0; i < extraargs; ++i)
lua_pushvalue(current_state, (int32)(-extraargs - 2)); lua_pushvalue(current_state, (int32)(-extraargs - 2));
if (lua_pcall(current_state, 1 + extraargs, 1, 0)) { if (lua_pcall(current_state, 1 + extraargs, 1, 0)) {
sprintf(pduel->strbuffer, lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; no_action--;
call_depth--; call_depth--;
...@@ -936,8 +936,8 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg ...@@ -936,8 +936,8 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
for(int32 i = 0; i < extraargs; ++i) for(int32 i = 0; i < extraargs; ++i)
lua_pushvalue(current_state, (int32)(-extraargs - 2)); lua_pushvalue(current_state, (int32)(-extraargs - 2));
if (lua_pcall(current_state, 1 + extraargs, 1, 0)) { if (lua_pcall(current_state, 1 + extraargs, 1, 0)) {
sprintf(pduel->strbuffer, lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; no_action--;
call_depth--; call_depth--;
...@@ -991,13 +991,13 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -991,13 +991,13 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
*yield_value = 0; *yield_value = 0;
if (!f) { if (!f) {
sprintf(pduel->strbuffer, "\"CallCoroutine\": attempt to call a null function"); sprintf(pduel->strbuffer, "\"CallCoroutine\": attempt to call a null function");
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
if (param_count != params.size()) { if (param_count != params.size()) {
sprintf(pduel->strbuffer, "\"CallCoroutine\": incorrect parameter count"); sprintf(pduel->strbuffer, "\"CallCoroutine\": incorrect parameter count");
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
...@@ -1009,7 +1009,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -1009,7 +1009,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
function2value(rthread, f); function2value(rthread, f);
if(!lua_isfunction(rthread, -1)) { if(!lua_isfunction(rthread, -1)) {
sprintf(pduel->strbuffer, "\"CallCoroutine\": attempt to call an error function"); sprintf(pduel->strbuffer, "\"CallCoroutine\": attempt to call an error function");
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
...@@ -1019,7 +1019,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -1019,7 +1019,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
rthread = it->second; rthread = it->second;
if(step == 0) { if(step == 0) {
sprintf(pduel->strbuffer, "recursive event trigger detected."); sprintf(pduel->strbuffer, "recursive event trigger detected.");
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
params.clear(); params.clear();
call_depth--; call_depth--;
if(call_depth == 0) { if(call_depth == 0) {
...@@ -1047,8 +1047,8 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -1047,8 +1047,8 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
return COROUTINE_YIELD; return COROUTINE_YIELD;
} else { } else {
coroutines.erase(f); coroutines.erase(f);
sprintf(pduel->strbuffer, lua_tostring(rthread, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(rthread, -1));
handle_message(pduel, 1); pduel->adapter->HandleMessage(pduel, 1);
lua_pop(rthread, 1); lua_pop(rthread, 1);
current_state = lua_state; current_state = lua_state;
call_depth--; call_depth--;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define INTERPRETER_H_ #define INTERPRETER_H_
extern "C" { extern "C" {
#ifdef WIN32 #ifdef _WIN32
#include <lua/lua.h> #include <lua/lua.h>
#include <lua/lauxlib.h> #include <lua/lauxlib.h>
#include <lua/lualib.h> #include <lua/lualib.h>
......
...@@ -1710,7 +1710,7 @@ int32 scriptlib::card_is_public(lua_State *L) { ...@@ -1710,7 +1710,7 @@ int32 scriptlib::card_is_public(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);
if(pcard->is_status(STATUS_IS_PUBLIC)) if(pcard->is_position(POS_FACEUP))
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
......
...@@ -19,7 +19,7 @@ int32 scriptlib::debug_message(lua_State *L) { ...@@ -19,7 +19,7 @@ int32 scriptlib::debug_message(lua_State *L) {
lua_pushvalue(L, -2); lua_pushvalue(L, -2);
lua_pcall(L, 1, 1, 0); lua_pcall(L, 1, 1, 0);
sprintf(pduel->strbuffer, "%s", lua_tostring(L, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(L, -1));
handle_message(pduel, 2); pduel->adapter->HandleMessage(pduel, 2);
return 0; return 0;
} }
int32 scriptlib::debug_add_card(lua_State *L) { int32 scriptlib::debug_add_card(lua_State *L) {
......
...@@ -2900,7 +2900,8 @@ int32 scriptlib::duel_is_player_can_spsummon_monster(lua_State * L) { ...@@ -2900,7 +2900,8 @@ int32 scriptlib::duel_is_player_can_spsummon_monster(lua_State * L) {
} }
int32 code = lua_tointeger(L, 2); int32 code = lua_tointeger(L, 2);
card_data dat; card_data dat;
::read_card(code, &dat); duel* pduel = interpreter::get_duel_info(L);
pduel->adapter->ReadCard(code, &dat);
dat.code = code; dat.code = code;
dat.alias = 0; dat.alias = 0;
if(!lua_isnil(L, 3)) if(!lua_isnil(L, 3))
...@@ -2923,7 +2924,6 @@ int32 scriptlib::duel_is_player_can_spsummon_monster(lua_State * L) { ...@@ -2923,7 +2924,6 @@ int32 scriptlib::duel_is_player_can_spsummon_monster(lua_State * L) {
pos = lua_tointeger(L, 10); pos = lua_tointeger(L, 10);
if(lua_gettop(L) >= 11) if(lua_gettop(L) >= 11)
toplayer = lua_tointeger(L, 11); toplayer = lua_tointeger(L, 11);
duel* pduel = interpreter::get_duel_info(L);
lua_pushboolean(L, pduel->game_field->is_player_can_spsummon_monster(playerid, toplayer, pos, &dat)); lua_pushboolean(L, pduel->game_field->is_player_can_spsummon_monster(playerid, toplayer, pos, &dat));
return 1; return 1;
} }
......
This diff is collapsed.
...@@ -9,50 +9,45 @@ ...@@ -9,50 +9,45 @@
#define OCGAPI_H_ #define OCGAPI_H_
#include "common.h" #include "common.h"
#ifdef WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#define DECL_DLLEXPORT __declspec(dllexport) #define DECL_DLLEXPORT __declspec(dllexport)
#else #else
#define DECL_DLLEXPORT #define DECL_DLLEXPORT
#endif #endif
class card; class duel;
struct card_data; struct card_data;
struct card_info;
class group; class DECL_DLLEXPORT ygoAdapter {
class effect; public:
class interpreter; virtual byte* ReadScript(const char* script_name, int* len);
virtual uint32 ReadCard(uint32 code, card_data* data);
typedef byte* (*script_reader)(const char*, int*); virtual uint32 HandleMessage(void* msg, uint32 message_type);
typedef uint32 (*card_reader)(uint32, card_data*); };
typedef uint32 (*message_handler)(void*, uint32);
extern ygoAdapter defaultAdapter;
extern "C" DECL_DLLEXPORT void set_script_reader(script_reader f);
extern "C" DECL_DLLEXPORT void set_card_reader(card_reader f); class DECL_DLLEXPORT duelAdapter {
extern "C" DECL_DLLEXPORT void set_message_handler(message_handler f);
protected:
byte* read_script(const char* script_name, int* len); duel* pduel;
uint32 read_card(uint32 code, card_data* data);
uint32 handle_message(void* pduel, uint32 message_type); public:
duelAdapter(uint32 seed);
extern "C" DECL_DLLEXPORT ptr create_duel(uint32 seed); virtual ~duelAdapter();
extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int32 options); void start_duel(int32 options);
extern "C" DECL_DLLEXPORT void end_duel(ptr pduel); void set_player_info(int32 playerid, int32 lp, int32 startcount, int32 drawcount);
extern "C" DECL_DLLEXPORT void set_player_info(ptr pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount); void get_log_message(byte* buf);
extern "C" DECL_DLLEXPORT void get_log_message(ptr pduel, byte* buf); int32 get_message(byte* buf);
extern "C" DECL_DLLEXPORT int32 get_message(ptr pduel, byte* buf); int32 process();
extern "C" DECL_DLLEXPORT int32 process(ptr pduel); void new_card(uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position);
extern "C" DECL_DLLEXPORT void new_card(ptr pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position); void new_tag_card(uint32 code, uint8 owner, uint8 location);
extern "C" DECL_DLLEXPORT void new_tag_card(ptr pduel, uint32 code, uint8 owner, uint8 location); int32 query_field_info(byte* buf);
extern "C" DECL_DLLEXPORT int32 query_card(ptr pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache); void set_responsei(int32 value);
extern "C" DECL_DLLEXPORT int32 query_field_count(ptr pduel, uint8 playerid, uint8 location); void set_responseb(byte* buf);
extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache); int32 preload_script(char* script, int32 len);
extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf); void set_adapter(ygoAdapter*);
extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value); };
extern "C" DECL_DLLEXPORT void set_responseb(ptr pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 preload_script(ptr pduel, char* script, int32 len);
byte* default_script_reader(const char* script_name, int* len);
uint32 default_card_reader(uint32 code, card_data* data);
uint32 default_message_handler(void* pduel, uint32 msg_type);
#endif /* OCGAPI_H_ */ #endif /* OCGAPI_H_ */
This diff is collapsed.
...@@ -55,9 +55,8 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) { ...@@ -55,9 +55,8 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) {
} else { } else {
uint32 t = returns.ivalue[0] & 0xffff; uint32 t = returns.ivalue[0] & 0xffff;
uint32 s = returns.ivalue[0] >> 16; uint32 s = returns.ivalue[0] >> 16;
if(t < 0 || t > 3 || s < 0 if(t > 3 || (t == 0 && s >= core.select_chains.size())
|| (t == 0 && s >= core.select_chains.size()) || (t == 1 && s >= core.attackable_cards.size())
|| (t == 1 && s >= core.attackable_cards.size())
|| (t == 2 && !core.to_m2) || (t == 2 && !core.to_m2)
|| (t == 3 && !core.to_ep)) { || (t == 3 && !core.to_ep)) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
...@@ -71,9 +70,9 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -71,9 +70,9 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
uint32 i; uint32 i;
card* pcard; card* pcard;
effect* peffect; effect* peffect;
pduel->write_buffer8(MSG_SELECT_IDLECMD); pduel->write_buffer8(MSG_SELECT_MAINCMD);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
//idle summon //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(i = 0; i < core.summonable_cards.size(); ++i) {
pcard = core.summonable_cards[i]; pcard = core.summonable_cards[i];
...@@ -82,7 +81,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -82,7 +81,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->current.sequence); pduel->write_buffer8(pcard->current.sequence);
} }
//idle spsummon //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(i = 0; i < core.spsummonable_cards.size(); ++i) {
pcard = core.spsummonable_cards[i]; pcard = core.spsummonable_cards[i];
...@@ -91,7 +90,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -91,7 +90,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->current.sequence); pduel->write_buffer8(pcard->current.sequence);
} }
//idle pos change //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(i = 0; i < core.repositionable_cards.size(); ++i) {
pcard = core.repositionable_cards[i]; pcard = core.repositionable_cards[i];
...@@ -100,7 +99,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -100,7 +99,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->current.sequence); pduel->write_buffer8(pcard->current.sequence);
} }
//idle mset //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(i = 0; i < core.msetable_cards.size(); ++i) {
pcard = core.msetable_cards[i]; pcard = core.msetable_cards[i];
...@@ -109,7 +108,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -109,7 +108,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->current.sequence); pduel->write_buffer8(pcard->current.sequence);
} }
//idle sset //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(i = 0; i < core.ssetable_cards.size(); ++i) {
pcard = core.ssetable_cards[i]; pcard = core.ssetable_cards[i];
...@@ -118,7 +117,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -118,7 +117,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->current.sequence); pduel->write_buffer8(pcard->current.sequence);
} }
//idle activate //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(i = 0; i < core.select_chains.size(); ++i) {
...@@ -653,7 +652,7 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa ...@@ -653,7 +652,7 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa
count = scount; count = scount;
core.units.begin()->arg1 = (count << 16) + playerid; core.units.begin()->arg1 = (count << 16) + playerid;
} }
pduel->write_buffer8(MSG_ANNOUNCE_RACE); pduel->write_buffer8(MSG_DECLEAR_RACE);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
pduel->write_buffer8(count); pduel->write_buffer8(count);
pduel->write_buffer32(available); pduel->write_buffer32(available);
...@@ -692,7 +691,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a ...@@ -692,7 +691,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a
count = scount; count = scount;
core.units.begin()->arg1 = (count << 16) + playerid; core.units.begin()->arg1 = (count << 16) + playerid;
} }
pduel->write_buffer8(MSG_ANNOUNCE_ATTRIB); pduel->write_buffer8(MSG_DECLEAR_ATTRIB);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
pduel->write_buffer8(count); pduel->write_buffer8(count);
pduel->write_buffer32(available); pduel->write_buffer32(available);
...@@ -722,7 +721,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a ...@@ -722,7 +721,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a
} }
int32 field::announce_card(int16 step, uint8 playerid) { int32 field::announce_card(int16 step, uint8 playerid) {
if(step == 0) { if(step == 0) {
pduel->write_buffer8(MSG_ANNOUNCE_CARD); pduel->write_buffer8(MSG_DECLEAR_CARD);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
return FALSE; return FALSE;
} else { } else {
...@@ -736,7 +735,7 @@ int32 field::announce_card(int16 step, uint8 playerid) { ...@@ -736,7 +735,7 @@ int32 field::announce_card(int16 step, uint8 playerid) {
} }
int32 field::announce_number(int16 step, uint8 playerid) { int32 field::announce_number(int16 step, uint8 playerid) {
if(step == 0) { if(step == 0) {
pduel->write_buffer8(MSG_ANNOUNCE_NUMBER); pduel->write_buffer8(MSG_DECLEAR_NUMBER);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
pduel->write_buffer8(core.select_options.size()); pduel->write_buffer8(core.select_options.size());
for(uint32 i = 0; i < core.select_options.size(); ++i) for(uint32 i = 0; i < core.select_options.size(); ++i)
......
This diff is collapsed.
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