Commit 771bd5d3 authored by Chen Bill's avatar Chen Bill

Revert "match_result use player_id"

This reverts commit c4d7ca2d.
parent f7952c61
......@@ -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);
......
......@@ -46,6 +46,7 @@ private:
protected:
DuelPlayer* players[2]{ nullptr };
DuelPlayer* pplayer[2]{nullptr};
bool ready[2]{ false };
Deck pdeck[2];
int deck_error[2]{ 0 };
......
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