Remove property uid of serverplayer

This commit is contained in:
Notify-ctrl 2022-03-24 22:14:52 +08:00
parent 432a306de0
commit 3fb3570fa0
7 changed files with 11 additions and 19 deletions

View File

@ -5,3 +5,11 @@ ___
试图打造一个最适合diy玩家游玩的民间三国杀所有的一切都是为了更好的制作diy而设计的。
项目仍处于啥都没有的阶段。不过我为了整理思路,也写了点[文档](./doc/index.md)。
___
## 如何构建
安装Qt Creator和Qt 5.15.2。必要时自行配置CMake。
然后下载swig并为其配置环境变量即可构建FreeKill。

View File

@ -119,7 +119,7 @@ Item {
toast.show("Sucesessfully entered room.");
dashboardModel = {
general: config.avatar,
general: "liubei",
screenName: config.screenName,
role: "unknown",
kingdom: "qun",

View File

@ -159,7 +159,7 @@ void Router::handlePacket(const QByteArray& rawPacket)
// Add the uid of sender to jsonData
QJsonArray arr = QJsonDocument::fromJson(jsonData.toUtf8()).array();
arr.prepend(
(int)qobject_cast<ServerPlayer *>(parent())->getUid()
(int)qobject_cast<ServerPlayer *>(parent())->getId()
);
ServerInstance->callLua(command, QJsonDocument(arr).toJson());
}

View File

@ -188,7 +188,7 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString& name, co
player->setSocket(client);
client->disconnect(this);
connect(client, &ClientSocket::disconnected, this, [player](){
qDebug() << "Player" << player->getUid() << "disconnected";
qDebug() << "Player" << player->getId() << "disconnected";
});
player->setScreenName(name);
player->setAvatar(result["avatar"].toArray()[0].toString());

View File

@ -3,13 +3,7 @@
#include "server.h"
ServerPlayer::ServerPlayer(Room *room)
: uid(0)
{
static int m_playerid = 0;
m_playerid++;
uid = m_playerid;
socket = nullptr;
router = new Router(this, socket, Router::TYPE_SERVER);
@ -21,11 +15,6 @@ ServerPlayer::~ServerPlayer()
router->deleteLater();
}
uint ServerPlayer::getUid() const
{
return uid;
}
void ServerPlayer::setSocket(ClientSocket *socket)
{
this->socket = socket;

View File

@ -14,8 +14,6 @@ public:
explicit ServerPlayer(Room *room);
~ServerPlayer();
uint getUid() const;
void setSocket(ClientSocket *socket);
Server *getServer() const;
@ -32,7 +30,6 @@ public:
void prepareForRequest(const QString &command,
const QVariant &data = QVariant());
private:
uint uid;
ClientSocket *socket; // socket for communicating with client
Router *router;
Server *server;

View File

@ -39,8 +39,6 @@ extern ClientPlayer *Self;
%nodefaultdtor ServerPlayer;
class ServerPlayer : public Player {
public:
unsigned int getUid() const;
void setSocket(ClientSocket *socket);
Server *getServer() const;