net: WAR: 通过 NET_FIGHT_SUPPORT 宏控制将网络对战功能禁用

因存在内存泄漏问题故暂时关闭。
This commit is contained in:
Calcitem 2020-10-06 21:59:10 +08:00
parent a52f9726a9
commit bb0c2f3a11
7 changed files with 29 additions and 0 deletions

View File

@ -30,6 +30,8 @@
//#define SELF_MOVE
//#define NET_FIGHT_SUPPORT
//#define MOBILE_APP_UI
//#define TRAINING_MODE

View File

@ -85,6 +85,7 @@ public:
string nextMove();
Depth adjustDepth();
#ifdef NET_FIGHT_SUPPORT
Server *getServer()
{
return server;
@ -94,6 +95,7 @@ public:
{
return client;
}
#endif
int getTimeLimit()
{

View File

@ -90,11 +90,13 @@ GameController::GameController(
connect(this->gameTest, SIGNAL(command(const string &, bool)),
this, SLOT(command(const string &, bool)));
#ifdef NET_FIGHT_SUPPORT
#ifndef TRAINING_MODE
// 关联AI和网络类的着法命令行
connect(aiThread[BLACK]->getClient(), SIGNAL(command(const string &, bool)),
this, SLOT(command(const string &, bool)));
#endif // TRAINING_MODE
#endif // NET_FIGHT_SUPPORT
#ifdef ENDGAME_LEARNING_FORCE
if (gameOptions.getLearnEndgameEnabled()) {
@ -1103,6 +1105,7 @@ bool GameController::command(const string &cmd, bool update /* = true */)
gameTest->writeToMemory(QString::fromStdString(cmd));
#ifdef NET_FIGHT_SUPPORT
#ifndef TRAINING_MODE
// 网络: 将着法放到服务器的发送列表中
if (isAiPlayer[BLACK]) {
@ -1111,6 +1114,7 @@ bool GameController::command(const string &cmd, bool update /* = true */)
aiThread[BLACK]->getServer()->setAction(QString::fromStdString(cmd)); // 注意: 同样是 aiThread[BLACK]
}
#endif // TRAINING_MODE
#endif
if (isAiPlayer[WHITE]) {
aiThread[WHITE]->analyze(WHITE);
@ -1315,6 +1319,7 @@ bool GameController::updateScence(Position &p)
return true;
}
#ifdef NET_FIGHT_SUPPORT
void GameController::showNetworkWindow()
{
#ifndef TRAINING_MODE
@ -1322,6 +1327,7 @@ void GameController::showNetworkWindow()
aiThread[BLACK]->getClient()->show();
#endif // TRAINING_MODE
}
#endif
void GameController::showTestWindow()
{

View File

@ -335,8 +335,10 @@ public slots:
bool updateScence();
bool updateScence(Position &position);
#ifdef NET_FIGHT_SUPPORT
// 显示网络配置窗口
void showNetworkWindow();
#endif
// 显示引擎对战窗口
void showTestWindow();

View File

@ -932,6 +932,7 @@ void MillGameWindow::on_actionLocal_L_triggered()
void MillGameWindow::on_actionInternet_I_triggered()
{
#ifdef NET_FIGHT_SUPPORT
ui.actionLocal_L->setChecked(false);
ui.actionEngineFight_E->setChecked(false);
ui.actionInternet_I->setChecked(true);
@ -939,6 +940,7 @@ void MillGameWindow::on_actionInternet_I_triggered()
gameController->getTest()->stop();
gameController->showNetworkWindow();
#endif
}
void MillGameWindow::on_actionEngineFight_E_triggered()

View File

@ -89,6 +89,13 @@ Server::Server(QWidget *parent, uint16_t port)
setWindowTitle(QGuiApplication::applicationDisplayName());
}
Server::~Server()
{
while (!actions.empty()) {
actions.pop();
}
}
void Server::sessionOpened()
{
// Save the used configuration
@ -153,6 +160,13 @@ void Server::sessionOpened()
void Server::setAction(const QString &a)
{
// TODO: WAR
if (actions.size() > 256) {
while (!actions.empty()) {
actions.pop();
}
}
actions.push(a);
}

View File

@ -42,6 +42,7 @@ class Server : public QDialog
public:
explicit Server(QWidget *parent = nullptr, uint16_t port = 33333);
~Server();
void setAction(const QString &action);
void setPort(uint16_t p)
{