Commit e677f04b authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro

parents 74a18ab3 62fe61c7
Pipeline #24692 failed with stages
in 42 seconds
...@@ -92,12 +92,12 @@ public: ...@@ -92,12 +92,12 @@ public:
std::set<ClientCard*> ownerTarget; std::set<ClientCard*> ownerTarget;
std::map<int, int> counters; std::map<int, int> counters;
std::map<int, int> desc_hints; std::map<int, int> desc_hints;
wchar_t atkstring[16]{ 0 }; wchar_t atkstring[16]{};
wchar_t defstring[16]{ 0 }; wchar_t defstring[16]{};
wchar_t lvstring[16]{ 0 }; wchar_t lvstring[16]{};
wchar_t linkstring[16]{ 0 }; wchar_t linkstring[16]{};
wchar_t lscstring[16]{ 0 }; wchar_t lscstring[16]{};
wchar_t rscstring[16]{ 0 }; wchar_t rscstring[16]{};
ClientCard() = default; ClientCard() = default;
~ClientCard(); ~ClientCard();
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
std::vector<int> select_options; std::vector<int> select_options;
std::vector<int> select_options_index; std::vector<int> select_options_index;
std::vector<ChainInfo> chains; std::vector<ChainInfo> chains;
int extra_p_count[2]{ 0 }; int extra_p_count[2]{};
size_t selected_option{ 0 }; size_t selected_option{ 0 };
ClientCard* attacker{ nullptr }; ClientCard* attacker{ nullptr };
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
bool remove_act{ false }; bool remove_act{ false };
bool deck_act{ false }; bool deck_act{ false };
bool extra_act{ false }; bool extra_act{ false };
bool pzone_act[2]{ false }; bool pzone_act[2]{};
bool conti_act{ false }; bool conti_act{ false };
bool chain_forced{ false }; bool chain_forced{ false };
ChainInfo current_chain; ChainInfo current_chain;
......
...@@ -81,31 +81,31 @@ struct DuelInfo { ...@@ -81,31 +81,31 @@ struct DuelInfo {
bool isSingleMode{ false }; bool isSingleMode{ false };
bool is_shuffling{ false }; bool is_shuffling{ false };
bool is_swapped{ false }; bool is_swapped{ false };
bool tag_player[2]{ false }; bool tag_player[2]{};
bool isReplaySwapped{ false }; bool isReplaySwapped{ false };
int lp[2]{ 0 }; int lp[2]{};
int start_lp{ 0 }; int start_lp{ 0 };
int card_count[2]{ 0 }; int card_count[2]{};
int total_attack[2]{ 0 }; int total_attack[2]{};
int duel_rule{ 0 }; int duel_rule{ 0 };
int turn{ 0 }; int turn{ 0 };
short curMsg{ 0 }; short curMsg{ 0 };
wchar_t hostname[20]{ 0 }; wchar_t hostname[20]{};
wchar_t clientname[20]{ 0 }; wchar_t clientname[20]{};
wchar_t hostname_tag[20]{ 0 }; wchar_t hostname_tag[20]{};
wchar_t clientname_tag[20]{ 0 }; wchar_t clientname_tag[20]{};
wchar_t strLP[2][16]{ 0 }; wchar_t strLP[2][16]{};
wchar_t* vic_string{ 0 }; wchar_t* vic_string{ nullptr };
unsigned char player_type{ 0 }; unsigned char player_type{ 0 };
unsigned char time_player{ 0 }; unsigned char time_player{ 0 };
unsigned short time_limit{ 0 }; unsigned short time_limit{ 0 };
unsigned short time_left[2]{ 0 }; unsigned short time_left[2]{};
wchar_t str_time_left[2][16]{ 0 }; wchar_t str_time_left[2][16]{};
video::SColor time_color[2]{ 0 }; video::SColor time_color[2]{};
wchar_t str_card_count[2][16]{ 0 }; wchar_t str_card_count[2][16]{};
wchar_t str_total_attack[2][16]{ 0 }; wchar_t str_total_attack[2][16]{};
video::SColor card_count_color[2]{ 0 }; video::SColor card_count_color[2]{};
video::SColor total_attack_color[2]{ 0 }; video::SColor total_attack_color[2]{};
std::vector<unsigned int> announce_cache; std::vector<unsigned int> announce_cache;
void Clear(); void Clear();
......
...@@ -12,16 +12,16 @@ ...@@ -12,16 +12,16 @@
namespace ygo { namespace ygo {
struct HostInfo { struct HostInfo {
unsigned int lflist{ 0 }; unsigned int lflist;
unsigned char rule{ 0 }; unsigned char rule;
unsigned char mode{ 0 }; unsigned char mode;
unsigned char duel_rule{ 0 }; unsigned char duel_rule;
bool no_check_deck{ false }; bool no_check_deck;
bool no_shuffle_deck{ false }; bool no_shuffle_deck;
unsigned int start_lp{ 0 }; unsigned int start_lp;
unsigned char start_hand{ 0 }; unsigned char start_hand;
unsigned char draw_count{ 0 }; unsigned char draw_count;
unsigned short time_limit{ 0 }; unsigned short time_limit;
}; };
struct HostPacket { struct HostPacket {
unsigned short identifier; unsigned short identifier;
...@@ -99,17 +99,22 @@ struct STOC_HS_WatchChange { ...@@ -99,17 +99,22 @@ struct STOC_HS_WatchChange {
class DuelMode; class DuelMode;
struct DuelPlayer { struct DuelPlayer {
unsigned short name[20]{ 0 }; unsigned short name[20];
DuelMode* game{ nullptr }; DuelMode* game;
unsigned char player_id{ 0xff }; unsigned char type;
unsigned char type{ 0 }; unsigned char state;
unsigned char state{ 0 }; bufferevent* bev;
bufferevent* bev{ 0 }; DuelPlayer() {
game = 0;
type = 0;
state = 0;
bev = 0;
}
}; };
class DuelMode { class DuelMode {
public: public:
DuelMode(): host_player(nullptr), pduel(0), duel_stage(0) {} DuelMode(): host_player(0), pduel(0), duel_stage(0) {}
virtual ~DuelMode() {} virtual ~DuelMode() {}
virtual void Chat(DuelPlayer* dp, void* pdata, int len) {} virtual void Chat(DuelPlayer* dp, void* pdata, int len) {}
virtual void JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {} virtual void JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {}
......
...@@ -342,8 +342,6 @@ void SingleDuel::StartDuel(DuelPlayer* dp) { ...@@ -342,8 +342,6 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
hand_result[1] = 0; hand_result[1] = 0;
players[0]->state = CTOS_HAND_RESULT; players[0]->state = CTOS_HAND_RESULT;
players[1]->state = CTOS_HAND_RESULT; players[1]->state = CTOS_HAND_RESULT;
players[0]->player_id = 0;
players[1]->player_id = 1;
duel_stage = DUEL_STAGE_FINGER; duel_stage = DUEL_STAGE_FINGER;
} }
void SingleDuel::HandResult(DuelPlayer* dp, unsigned char res) { void SingleDuel::HandResult(DuelPlayer* dp, unsigned char res) {
...@@ -391,6 +389,8 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -391,6 +389,8 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
return; return;
duel_stage = DUEL_STAGE_DUELING; duel_stage = DUEL_STAGE_DUELING;
bool swapped = false; bool swapped = false;
pplayer[0] = players[0];
pplayer[1] = players[1];
if((tp && dp->type == 1) || (!tp && dp->type == 0)) { if((tp && dp->type == 1) || (!tp && dp->type == 0)) {
DuelPlayer* p = players[0]; DuelPlayer* p = players[0];
players[0] = players[1]; players[0] = players[1];
...@@ -533,6 +533,15 @@ void SingleDuel::DuelEndProc() { ...@@ -533,6 +533,15 @@ void SingleDuel::DuelEndProc() {
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
duel_stage = DUEL_STAGE_END; duel_stage = DUEL_STAGE_END;
} else { } else {
if(players[0] != pplayer[0]) {
players[0] = pplayer[0];
players[1] = pplayer[1];
players[0]->type = 0;
players[1]->type = 1;
Deck d = pdeck[0];
pdeck[0] = pdeck[1];
pdeck[1] = d;
}
ready[0] = false; ready[0] = false;
ready[1] = false; ready[1] = false;
players[0]->state = CTOS_UPDATE_DECK; players[0]->state = CTOS_UPDATE_DECK;
...@@ -546,7 +555,7 @@ void SingleDuel::DuelEndProc() { ...@@ -546,7 +555,7 @@ void SingleDuel::DuelEndProc() {
} }
} }
void SingleDuel::Surrender(DuelPlayer* dp) { void SingleDuel::Surrender(DuelPlayer* dp) {
if (dp->type > 1 || dp->player_id > 1 || !pduel) if(dp->type > 1 || !pduel)
return; return;
unsigned char wbuf[3]; unsigned char wbuf[3];
uint32 player = dp->type; uint32 player = dp->type;
...@@ -557,9 +566,13 @@ void SingleDuel::Surrender(DuelPlayer* dp) { ...@@ -557,9 +566,13 @@ void SingleDuel::Surrender(DuelPlayer* dp) {
NetServer::ReSendToPlayer(players[1]); NetServer::ReSendToPlayer(players[1]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit) for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
match_result[duel_count] = 1 - dp->player_id; if(players[player] == pplayer[player]) {
++duel_count; match_result[duel_count++] = 1 - player;
tp_player = player; tp_player = player;
} else {
match_result[duel_count++] = player;
tp_player = 1 - player;
}
EndDuel(); EndDuel();
DuelEndProc(); DuelEndProc();
event_del(etimer); event_del(etimer);
...@@ -633,14 +646,15 @@ int SingleDuel::Analyze(unsigned char* msgbuffer, unsigned int len) { ...@@ -633,14 +646,15 @@ int SingleDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
for(auto oit = observers.begin(); oit != observers.end(); ++oit) for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
if(player > 1) { if(player > 1) {
match_result[duel_count] = 2; match_result[duel_count++] = 2;
tp_player = 1 - tp_player; tp_player = 1 - tp_player;
} } else if(players[player] == pplayer[player]) {
else { match_result[duel_count++] = player;
match_result[duel_count] = players[player]->player_id;
tp_player = 1 - player; tp_player = 1 - player;
} else {
match_result[duel_count++] = 1 - player;
tp_player = player;
} }
++duel_count;
EndDuel(); EndDuel();
return 2; return 2;
} }
...@@ -1599,9 +1613,13 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) { ...@@ -1599,9 +1613,13 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
NetServer::ReSendToPlayer(sd->players[1]); NetServer::ReSendToPlayer(sd->players[1]);
for(auto oit = sd->observers.begin(); oit != sd->observers.end(); ++oit) for(auto oit = sd->observers.begin(); oit != sd->observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
sd->match_result[sd->duel_count] = sd->players[1 - player]->player_id; if(sd->players[player] == sd->pplayer[player]) {
++sd->duel_count; sd->match_result[sd->duel_count++] = 1 - player;
sd->tp_player = player; sd->tp_player = player;
} else {
sd->match_result[sd->duel_count++] = player;
sd->tp_player = 1 - player;
}
sd->EndDuel(); sd->EndDuel();
sd->DuelEndProc(); sd->DuelEndProc();
event_del(sd->etimer); event_del(sd->etimer);
......
...@@ -45,11 +45,12 @@ private: ...@@ -45,11 +45,12 @@ private:
int WriteUpdateData(int& player, int location, int& flag, unsigned char*& qbuf, int& use_cache); int WriteUpdateData(int& player, int location, int& flag, unsigned char*& qbuf, int& use_cache);
protected: protected:
DuelPlayer* players[2]{ nullptr }; DuelPlayer* players[2]{};
bool ready[2]{ false }; DuelPlayer* pplayer[2]{};
bool ready[2]{};
Deck pdeck[2]; Deck pdeck[2];
int deck_error[2]{ 0 }; int deck_error[2]{};
unsigned char hand_result[2]{ 0 }; unsigned char hand_result[2]{};
unsigned char last_response{ 0 }; unsigned char last_response{ 0 };
std::set<DuelPlayer*> observers; std::set<DuelPlayer*> observers;
Replay last_replay; Replay last_replay;
...@@ -57,8 +58,8 @@ protected: ...@@ -57,8 +58,8 @@ protected:
int match_kill{ 0 }; int match_kill{ 0 };
unsigned char duel_count{ 0 }; unsigned char duel_count{ 0 };
unsigned char tp_player{ 0 }; unsigned char tp_player{ 0 };
unsigned char match_result[3]{ 0 }; unsigned char match_result[3]{};
short time_limit[2]{ 0 }; short time_limit[2]{};
short time_elapsed{ 0 }; short time_elapsed{ 0 };
}; };
......
Subproject commit a159e87ee061cd273568ce53d51ee52530335219 Subproject commit 16af5ec2714a40a7eef6a393a8724801bfcfa6a1
Subproject commit 5a38fb44ade94757f87226d16606787eb447c843 Subproject commit 7feb4173949fff6bbf7d698790217427adc772a6
...@@ -1214,3 +1214,4 @@ ...@@ -1214,3 +1214,4 @@
!setname 0x1a5 于贝尔 ユベル !setname 0x1a5 于贝尔 ユベル
!setname 0x1a6 肃声 粛声 !setname 0x1a6 肃声 粛声
!setname 0x1a7 白斗气 ホワイト・オーラ !setname 0x1a7 白斗气 ホワイト・オーラ
!setname 0x1a8 玩具 トイ
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