From dbb813a2a518ff456506ae0909aa588c28ae9fa0 Mon Sep 17 00:00:00 2001 From: purerosefallen <78877@qq.com> Date: Tue, 13 Feb 2018 00:21:43 +0800 Subject: [PATCH] sw_test --- gframe/client_field.cpp | 1 + gframe/duelclient.cpp | 7 +++++++ gframe/game.h | 1 + 3 files changed, 9 insertions(+) diff --git a/gframe/client_field.cpp b/gframe/client_field.cpp index 83bfa123e..1d01f500f 100644 --- a/gframe/client_field.cpp +++ b/gframe/client_field.cpp @@ -645,6 +645,7 @@ void ClientField::ReplaySwap() { (*cit)->is_moving = false; } mainGame->dInfo.isFirst = !mainGame->dInfo.isFirst; + mainGame->dInfo.isReplaySwapped = !mainGame->dInfo.isReplaySwapped; std::swap(mainGame->dInfo.lp[0], mainGame->dInfo.lp[1]); std::swap(mainGame->dInfo.strLP[0], mainGame->dInfo.strLP[1]); std::swap(mainGame->dInfo.hostname, mainGame->dInfo.clientname); diff --git a/gframe/duelclient.cpp b/gframe/duelclient.cpp index b9a7b02cc..c6999132d 100644 --- a/gframe/duelclient.cpp +++ b/gframe/duelclient.cpp @@ -592,6 +592,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { mainGame->dInfo.time_left[0] = 0; mainGame->dInfo.time_left[1] = 0; mainGame->dInfo.time_player = 2; + mainGame->dInfo.isReplaySwapped = false; mainGame->is_building = false; mainGame->wCardImg->setVisible(true); mainGame->wInfos->setVisible(true); @@ -1085,6 +1086,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { mainGame->dField.Initial(mainGame->LocalPlayer(1), deckc, extrac); mainGame->dInfo.turn = 0; mainGame->dInfo.is_shuffling = false; + if(mainGame->dInfo.isReplaySwapped) { + std::swap(mainGame->dInfo.hostname, mainGame->dInfo.clientname); + std::swap(mainGame->dInfo.hostname_tag, mainGame->dInfo.clientname_tag); + mainGame->dInfo.isReplaySwapped = false; + mainGame->dField.ReplaySwap(); + } mainGame->gMutex.Unlock(); return true; } diff --git a/gframe/game.h b/gframe/game.h index cfd5efc83..36fd4b012 100644 --- a/gframe/game.h +++ b/gframe/game.h @@ -73,6 +73,7 @@ struct DuelInfo { unsigned char time_player; unsigned short time_limit; unsigned short time_left[2]; + bool isReplaySwapped; }; struct BotInfo {