diff --git a/lang/zh_CN.ts b/lang/zh_CN.ts
index 5c14e8f7..9c3251b3 100644
--- a/lang/zh_CN.ts
+++ b/lang/zh_CN.ts
@@ -29,6 +29,18 @@
+
+ Server
+
+
+ 玩家 <b>%1</b> 加入服务器
+
+
+
+ 玩家 <b>%1</b> 离开服务器
+
+
+
Init
diff --git a/src/server/server.cpp b/src/server/server.cpp
index e269ce3c..6e0157e3 100644
--- a/src/server/server.cpp
+++ b/src/server/server.cpp
@@ -81,7 +81,7 @@ Server::~Server() {
}
bool Server::listen(const QHostAddress &address, ushort port) {
- bool ret = server->listen(address, port);
+ bool ret = server->listen(address, port);
isListening = ret;
return ret;
}
@@ -330,6 +330,7 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name,
player->setScreenName(name);
player->setAvatar(obj["avatar"].toString());
player->setId(obj["id"].toString().toInt());
+ broadcast("ServerMessage", tr("%1 logged in").arg(player->getScreenName()));
players.insert(player->getId(), player);
// tell the lobby player's basic property
@@ -373,6 +374,7 @@ void Server::onRoomAbandoned() {
void Server::onUserDisconnected() {
ServerPlayer *player = qobject_cast(sender());
qInfo() << "Player" << player->getId() << "disconnected";
+ broadcast("ServerMessage", tr("%1 logged out").arg(player->getScreenName()));
Room *room = player->getRoom();
if (room->isStarted()) {
if (room->getObservers().contains(player)) {
@@ -401,6 +403,4 @@ void Server::readConfig() {
// defaults
}
-QJsonValue Server::getConfig(const QString &key) {
- return config.value(key);
-}
+QJsonValue Server::getConfig(const QString &key) { return config.value(key); }