Commit a6ae651e authored by nanahira's avatar nanahira

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

parents 402ec51e 62fe61c7
......@@ -92,12 +92,12 @@ public:
std::set<ClientCard*> ownerTarget;
std::map<int, int> counters;
std::map<int, int> desc_hints;
wchar_t atkstring[16]{ 0 };
wchar_t defstring[16]{ 0 };
wchar_t lvstring[16]{ 0 };
wchar_t linkstring[16]{ 0 };
wchar_t lscstring[16]{ 0 };
wchar_t rscstring[16]{ 0 };
wchar_t atkstring[16]{};
wchar_t defstring[16]{};
wchar_t lvstring[16]{};
wchar_t linkstring[16]{};
wchar_t lscstring[16]{};
wchar_t rscstring[16]{};
ClientCard() = default;
~ClientCard();
......
......@@ -46,7 +46,7 @@ public:
std::vector<int> select_options;
std::vector<int> select_options_index;
std::vector<ChainInfo> chains;
int extra_p_count[2]{ 0 };
int extra_p_count[2]{};
size_t selected_option{ 0 };
ClientCard* attacker{ nullptr };
......@@ -77,7 +77,7 @@ public:
bool remove_act{ false };
bool deck_act{ false };
bool extra_act{ false };
bool pzone_act[2]{ false };
bool pzone_act[2]{};
bool conti_act{ false };
bool chain_forced{ false };
ChainInfo current_chain;
......
......@@ -74,23 +74,23 @@ struct DuelInfo {
bool isTag{ false };
bool isSingleMode{ false };
bool is_shuffling{ false };
bool tag_player[2]{ false };
bool tag_player[2]{};
bool isReplaySwapped{ false };
int lp[2]{ 0 };
int lp[2]{};
int start_lp{ 0 };
int duel_rule{ 0 };
int turn{ 0 };
short curMsg{ 0 };
wchar_t hostname[20]{ 0 };
wchar_t clientname[20]{ 0 };
wchar_t hostname_tag[20]{ 0 };
wchar_t clientname_tag[20]{ 0 };
wchar_t strLP[2][16]{ 0 };
wchar_t* vic_string{ 0 };
wchar_t hostname[20]{};
wchar_t clientname[20]{};
wchar_t hostname_tag[20]{};
wchar_t clientname_tag[20]{};
wchar_t strLP[2][16]{};
wchar_t* vic_string{ nullptr };
unsigned char player_type{ 0 };
unsigned char time_player{ 0 };
unsigned short time_limit{ 0 };
unsigned short time_left[2]{ 0 };
unsigned short time_left[2]{};
void Clear();
};
......
......@@ -12,16 +12,16 @@
namespace ygo {
struct HostInfo {
unsigned int lflist{ 0 };
unsigned char rule{ 0 };
unsigned char mode{ 0 };
unsigned char duel_rule{ 0 };
bool no_check_deck{ false };
bool no_shuffle_deck{ false };
unsigned int start_lp{ 0 };
unsigned char start_hand{ 0 };
unsigned char draw_count{ 0 };
unsigned short time_limit{ 0 };
unsigned int lflist;
unsigned char rule;
unsigned char mode;
unsigned char duel_rule;
bool no_check_deck;
bool no_shuffle_deck;
unsigned int start_lp;
unsigned char start_hand;
unsigned char draw_count;
unsigned short time_limit;
};
struct HostPacket {
unsigned short identifier;
......@@ -99,17 +99,22 @@ struct STOC_HS_WatchChange {
class DuelMode;
struct DuelPlayer {
unsigned short name[20]{ 0 };
DuelMode* game{ nullptr };
unsigned char player_id{ 0xff };
unsigned char type{ 0 };
unsigned char state{ 0 };
bufferevent* bev{ 0 };
unsigned short name[20];
DuelMode* game;
unsigned char type;
unsigned char state;
bufferevent* bev;
DuelPlayer() {
game = 0;
type = 0;
state = 0;
bev = 0;
}
};
class DuelMode {
public:
DuelMode(): host_player(nullptr), pduel(0), duel_stage(0) {}
DuelMode(): host_player(0), pduel(0), duel_stage(0) {}
virtual ~DuelMode() {}
virtual void Chat(DuelPlayer* dp, void* pdata, int len) {}
virtual void JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {}
......
......@@ -340,8 +340,6 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
hand_result[1] = 0;
players[0]->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;
}
void SingleDuel::HandResult(DuelPlayer* dp, unsigned char res) {
......@@ -389,6 +387,8 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
return;
duel_stage = DUEL_STAGE_DUELING;
bool swapped = false;
pplayer[0] = players[0];
pplayer[1] = players[1];
if((tp && dp->type == 1) || (!tp && dp->type == 0)) {
DuelPlayer* p = players[0];
players[0] = players[1];
......@@ -529,6 +529,15 @@ void SingleDuel::DuelEndProc() {
NetServer::ReSendToPlayer(*oit);
duel_stage = DUEL_STAGE_END;
} 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[1] = false;
players[0]->state = CTOS_UPDATE_DECK;
......@@ -542,7 +551,7 @@ void SingleDuel::DuelEndProc() {
}
}
void SingleDuel::Surrender(DuelPlayer* dp) {
if (dp->type > 1 || dp->player_id > 1 || !pduel)
if(dp->type > 1 || !pduel)
return;
unsigned char wbuf[3];
uint32 player = dp->type;
......@@ -553,9 +562,13 @@ void SingleDuel::Surrender(DuelPlayer* dp) {
NetServer::ReSendToPlayer(players[1]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
match_result[duel_count] = 1 - dp->player_id;
++duel_count;
if(players[player] == pplayer[player]) {
match_result[duel_count++] = 1 - player;
tp_player = player;
} else {
match_result[duel_count++] = player;
tp_player = 1 - player;
}
EndDuel();
DuelEndProc();
event_del(etimer);
......@@ -614,14 +627,15 @@ int SingleDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
if(player > 1) {
match_result[duel_count] = 2;
match_result[duel_count++] = 2;
tp_player = 1 - tp_player;
}
else {
match_result[duel_count] = players[player]->player_id;
} else if(players[player] == pplayer[player]) {
match_result[duel_count++] = player;
tp_player = 1 - player;
} else {
match_result[duel_count++] = 1 - player;
tp_player = player;
}
++duel_count;
EndDuel();
return 2;
}
......@@ -1580,9 +1594,13 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
NetServer::ReSendToPlayer(sd->players[1]);
for(auto oit = sd->observers.begin(); oit != sd->observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
sd->match_result[sd->duel_count] = sd->players[1 - player]->player_id;
++sd->duel_count;
if(sd->players[player] == sd->pplayer[player]) {
sd->match_result[sd->duel_count++] = 1 - player;
sd->tp_player = player;
} else {
sd->match_result[sd->duel_count++] = player;
sd->tp_player = 1 - player;
}
sd->EndDuel();
sd->DuelEndProc();
event_del(sd->etimer);
......
......@@ -45,11 +45,12 @@ private:
int WriteUpdateData(int& player, int location, int& flag, unsigned char*& qbuf, int& use_cache);
protected:
DuelPlayer* players[2]{ nullptr };
bool ready[2]{ false };
DuelPlayer* players[2]{};
DuelPlayer* pplayer[2]{};
bool ready[2]{};
Deck pdeck[2];
int deck_error[2]{ 0 };
unsigned char hand_result[2]{ 0 };
int deck_error[2]{};
unsigned char hand_result[2]{};
unsigned char last_response{ 0 };
std::set<DuelPlayer*> observers;
Replay last_replay;
......@@ -57,8 +58,8 @@ protected:
int match_kill{ 0 };
unsigned char duel_count{ 0 };
unsigned char tp_player{ 0 };
unsigned char match_result[3]{ 0 };
short time_limit[2]{ 0 };
unsigned char match_result[3]{};
short time_limit[2]{};
short time_elapsed{ 0 };
};
......
......@@ -1206,3 +1206,4 @@
!setname 0x1a5 于贝尔 ユベル
!setname 0x1a6 肃声 粛声
!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