mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Minor changes
This commit is contained in:
parent
1455c65e1a
commit
6eb43d3834
@ -1,5 +1,6 @@
|
||||
#include "lobby_moc.h"
|
||||
#include "ui_lobby_moc.h"
|
||||
#include "../mainwindow_moc.h"
|
||||
#include "../lib/GameConstants.h"
|
||||
#include "../jsonutils.h"
|
||||
#include "../../lib/CConfigHandler.h"
|
||||
@ -106,6 +107,7 @@ Lobby::Lobby(QWidget *parent) :
|
||||
ui(new Ui::Lobby)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->buttonReady->setEnabled(false);
|
||||
|
||||
connect(&socketLobby, SIGNAL(text(QString)), this, SLOT(chatMessage(QString)));
|
||||
connect(&socketLobby, SIGNAL(receive(QString)), this, SLOT(dispatchMessage(QString)));
|
||||
@ -137,6 +139,7 @@ void Lobby::serverCommand(const ServerCommand & command) try
|
||||
hostSession = args[0];
|
||||
session = args[0];
|
||||
chatMessage("System: new session started");
|
||||
ui->buttonReady->setEnabled(true);
|
||||
break;
|
||||
|
||||
case SESSIONS:
|
||||
@ -172,6 +175,8 @@ void Lobby::serverCommand(const ServerCommand & command) try
|
||||
chatMessage(joinStr.arg("you", args[0]));
|
||||
session = args[0];
|
||||
ui->stackedWidget->setCurrentWidget(command.command == JOINED ? ui->roomPage : ui->sessionsPage);
|
||||
if(command.command == KICKED)
|
||||
ui->buttonReady->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -202,8 +207,11 @@ void Lobby::serverCommand(const ServerCommand & command) try
|
||||
node["server"].String() = ui->hostEdit->text().toStdString();
|
||||
node["serverport"].Integer() = ui->portEdit->text().toInt();
|
||||
node["uuid"].String() = args[0].toStdString();
|
||||
startGame = true;
|
||||
//on_startGameButton_clicked
|
||||
//node["names"].Vector().clear();
|
||||
//node["names"].Vector().pushBack(username.toStdString());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -247,6 +255,9 @@ void Lobby::dispatchMessage(QString txt) try
|
||||
ServerCommand cmd(ctype, parseArgs);
|
||||
serverCommand(cmd);
|
||||
}
|
||||
|
||||
if(startGame)
|
||||
qobject_cast<MainWindow *>(qApp->activeWindow())->on_startGameButton_clicked();
|
||||
}
|
||||
catch(const ProtocolError & e)
|
||||
{
|
||||
|
@ -123,6 +123,7 @@ private:
|
||||
QString hostSession;
|
||||
QString session;
|
||||
QString username;
|
||||
bool startGame = false;
|
||||
|
||||
private:
|
||||
void protocolAssert(bool);
|
||||
|
@ -35,6 +35,6 @@ public:
|
||||
explicit MainWindow(QWidget * parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
public slots:
|
||||
void on_startGameButton_clicked();
|
||||
};
|
||||
|
@ -207,13 +207,13 @@ def startSession(session: Session):
|
||||
session.started = True
|
||||
session.host_uuid = str(uuid.uuid4())
|
||||
hostMessage = f":>>HOST:{session.host_uuid}:{session.joined - 1}" #one client will be connected locally
|
||||
#host message must be before start message
|
||||
send(session.host, hostMessage)
|
||||
|
||||
for player in session.players:
|
||||
client_sockets[player]['uuid'] = str(uuid.uuid4())
|
||||
msg = f":>>START:{client_sockets[player]['uuid']}"
|
||||
send(player, msg)
|
||||
|
||||
#host message must be after start message
|
||||
send(session.host, hostMessage)
|
||||
|
||||
|
||||
def dispatch(client: socket, sender: dict, arr: bytes):
|
||||
@ -355,6 +355,8 @@ def dispatch(client: socket, sender: dict, arr: bytes):
|
||||
return
|
||||
|
||||
sender["session"].total = int(tag_value)
|
||||
message = f":>>CREATED:{sender['session'].name}"
|
||||
send(client, message)
|
||||
#now session is ready to be broadcasted
|
||||
message = f":>>JOIN:{sender['session'].name}:{sender['username']}"
|
||||
send(client, message)
|
||||
|
@ -170,8 +170,12 @@ void CVCMIServer::run()
|
||||
#endif
|
||||
|
||||
startAsyncAccept();
|
||||
if(!remoteConnectionsThread)
|
||||
if(!remoteConnectionsThread && !settings["server"]["lobby"].isNull() && settings["server"]["lobby"].Bool())
|
||||
{
|
||||
remoteConnectionsThread = vstd::make_unique<boost::thread>(&CVCMIServer::establishRemoteConnections, this);
|
||||
Settings node = settings.write["server"]["lobby"];
|
||||
node->Bool() = false;
|
||||
}
|
||||
|
||||
#if defined(VCMI_ANDROID)
|
||||
CAndroidVMHelper vmHelper;
|
||||
@ -199,12 +203,6 @@ void CVCMIServer::run()
|
||||
|
||||
void CVCMIServer::establishRemoteConnections()
|
||||
{
|
||||
if(settings["server"]["lobby"].isNull() || !settings["server"]["lobby"].Bool())
|
||||
return;
|
||||
|
||||
Settings node = settings.write["server"];
|
||||
node["lobby"].Bool() = false;
|
||||
|
||||
uuid = settings["server"]["host"]["uuid"].String();
|
||||
int numOfConnections = settings["server"]["host"]["connections"].Integer();
|
||||
auto address = settings["server"]["server"].String();
|
||||
|
Loading…
Reference in New Issue
Block a user