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) { ...@@ -340,8 +340,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) {
...@@ -389,6 +387,8 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -389,6 +387,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];
...@@ -529,6 +529,15 @@ void SingleDuel::DuelEndProc() { ...@@ -529,6 +529,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;
...@@ -542,7 +551,7 @@ void SingleDuel::DuelEndProc() { ...@@ -542,7 +551,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;
...@@ -553,9 +562,13 @@ void SingleDuel::Surrender(DuelPlayer* dp) { ...@@ -553,9 +562,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);
...@@ -614,14 +627,15 @@ int SingleDuel::Analyze(unsigned char* msgbuffer, unsigned int len) { ...@@ -614,14 +627,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;
} }
...@@ -1580,9 +1594,13 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) { ...@@ -1580,9 +1594,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);
......
...@@ -46,6 +46,7 @@ private: ...@@ -46,6 +46,7 @@ private:
protected: protected:
DuelPlayer* players[2]{ nullptr }; DuelPlayer* players[2]{ nullptr };
DuelPlayer* pplayer[2]{nullptr};
bool ready[2]{ false }; bool ready[2]{ false };
Deck pdeck[2]; Deck pdeck[2];
int deck_error[2]{ 0 }; 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