diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2007-07-19 21:35:34 +0400 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2007-07-19 21:35:34 +0400 |
commit | 62dbc00a2139e142c1030d7a51d4dfaaf78637c5 (patch) | |
tree | be6ffe31288f38b03181602ccc4524a3e0884ea4 | |
parent | 3621a6dda98f9ad29335e558b326c688381b1d47 (diff) |
sPlayerId => uiSession
git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@637 05730e5d-ab1b-0410-a4ac-84af385074fa
-rw-r--r-- | src/Message.cpp | 69 | ||||
-rw-r--r-- | src/Message.h | 14 | ||||
-rw-r--r-- | src/PacketDataStream.h | 16 | ||||
-rw-r--r-- | src/Player.cpp | 20 | ||||
-rw-r--r-- | src/Player.h | 10 | ||||
-rw-r--r-- | src/mumble/Audio.cpp | 2 | ||||
-rw-r--r-- | src/mumble/AudioConfigDialog.cpp | 2 | ||||
-rw-r--r-- | src/mumble/AudioInput.cpp | 2 | ||||
-rw-r--r-- | src/mumble/Global.cpp | 2 | ||||
-rw-r--r-- | src/mumble/Global.h | 2 | ||||
-rw-r--r-- | src/mumble/MainWindow.cpp | 82 | ||||
-rw-r--r-- | src/mumble/Overlay.cpp | 10 | ||||
-rw-r--r-- | src/mumble/Overlay.h | 2 | ||||
-rw-r--r-- | src/mumble/PlayerModel.cpp | 26 | ||||
-rw-r--r-- | src/mumble/PlayerModel.h | 2 | ||||
-rw-r--r-- | src/mumble/ServerHandler.cpp | 10 | ||||
-rw-r--r-- | src/murmur/DBus.cpp | 32 | ||||
-rw-r--r-- | src/murmur/DBus_real.h | 6 | ||||
-rw-r--r-- | src/murmur/Server.cpp | 108 | ||||
-rw-r--r-- | src/murmur/Server.h | 14 | ||||
-rw-r--r-- | src/murmur/ServerDB.cpp | 10 |
21 files changed, 213 insertions, 228 deletions
diff --git a/src/Message.cpp b/src/Message.cpp index dc1847b21..b199fd931 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -32,7 +32,7 @@ #include "PacketDataStream.h" Message::Message() { - sPlayerId = 0; + uiSession = 0; } Message::~Message() { @@ -42,7 +42,7 @@ void Message::messageToNetwork(QByteArray &qbaOut) const { char buffer[65535]; PacketDataStream qdsOut(buffer, 65535); qdsOut << messageType(); - qdsOut << sPlayerId; + qdsOut << uiSession; saveStream(qdsOut); qbaOut = QByteArray(buffer, qdsOut.size()); @@ -50,7 +50,7 @@ void Message::messageToNetwork(QByteArray &qbaOut) const { void Message::messageToNetwork(PacketDataStream &pds) const { pds << messageType(); - pds << sPlayerId; + pds << uiSession; saveStream(pds); pds.truncate(); } @@ -63,9 +63,9 @@ Message *Message::networkToMessage(QByteArray &qbaIn) { Message *Message::networkToMessage(PacketDataStream &qdsIn) { Message *mMsg = NULL; unsigned char iMessageType; - short sPlayerId; + short uiSession; qdsIn >> iMessageType; - qdsIn >> sPlayerId; + qdsIn >> uiSession; switch (iMessageType) { case Speex: mMsg = new MessageSpeex(); @@ -140,23 +140,23 @@ Message *Message::networkToMessage(PacketDataStream &qdsIn) { mMsg = new MessageTexture(); break; default: - qWarning("Message: %d[%d] is unknown type", iMessageType, sPlayerId); + qWarning("Message: %d[%d] is unknown type", iMessageType, uiSession); } if (mMsg) { - mMsg->sPlayerId=sPlayerId; + mMsg->uiSession=uiSession; mMsg->restoreStream(qdsIn); if (! qdsIn.isValid()) { delete mMsg; mMsg = NULL; - qWarning("Message: %d[%d] Corrupt or short packet", iMessageType, sPlayerId); + qWarning("Message: %d[%d] Corrupt or short packet", iMessageType, uiSession); } else if (qdsIn.left() != 0) { delete mMsg; mMsg = NULL; - qWarning("Message: %d[%d] Long packet: %d leftover bytes", iMessageType, sPlayerId, qdsIn.left()); + qWarning("Message: %d[%d] Long packet: %d leftover bytes", iMessageType, uiSession, qdsIn.left()); } else if (! mMsg->isValid()) { delete mMsg; mMsg = NULL; - qWarning("Message: %d[%d] Failed to validate", iMessageType, sPlayerId); + qWarning("Message: %d[%d] Failed to validate", iMessageType, uiSession); } } @@ -220,7 +220,6 @@ void MessageServerReject::restoreStream(PacketDataStream &qdsIn) { } MessageServerSync::MessageServerSync() { - qsWelcomeText = QString(); } void MessageServerSync::saveStream(PacketDataStream &qdsOut) const { @@ -234,8 +233,6 @@ void MessageServerSync::restoreStream(PacketDataStream &qdsIn) { } MessageServerJoin::MessageServerJoin() { - qsPlayerName = QString(); - iId = -2; } void MessageServerJoin::saveStream(PacketDataStream &qdsOut) const { @@ -263,7 +260,6 @@ void MessageServerBanList::restoreStream(PacketDataStream &qdsIn) { } MessagePermissionDenied::MessagePermissionDenied() { - qsReason = QString(); } void MessagePermissionDenied::saveStream(PacketDataStream &qdsOut) const { @@ -275,8 +271,6 @@ void MessagePermissionDenied::restoreStream(PacketDataStream &qdsIn) { } MessageSpeex::MessageSpeex() { - iSeq = 0; - qbaSpeexPacket = QByteArray(); } void MessageSpeex::saveStream(PacketDataStream &qdsOut) const { @@ -294,74 +288,68 @@ bool MessageSpeex::isValid() const { } MessagePlayerMute::MessagePlayerMute() { - bMute = false; } void MessagePlayerMute::saveStream(PacketDataStream &qdsOut) const { - qdsOut << sVictim; + qdsOut << uiVictim; qdsOut << bMute; } void MessagePlayerMute::restoreStream(PacketDataStream &qdsIn) { - qdsIn >> sVictim; + qdsIn >> uiVictim; qdsIn >> bMute; } MessagePlayerDeaf::MessagePlayerDeaf() { - bDeaf = false; } void MessagePlayerDeaf::saveStream(PacketDataStream &qdsOut) const { - qdsOut << sVictim; + qdsOut << uiVictim; qdsOut << bDeaf; } void MessagePlayerDeaf::restoreStream(PacketDataStream &qdsIn) { - qdsIn >> sVictim; + qdsIn >> uiVictim; qdsIn >> bDeaf; } MessagePlayerKick::MessagePlayerKick() { - qsReason = QString(); } void MessagePlayerKick::saveStream(PacketDataStream &qdsOut) const { - qdsOut << sVictim; + qdsOut << uiVictim; qdsOut << qsReason; } void MessagePlayerKick::restoreStream(PacketDataStream &qdsIn) { - qdsIn >> sVictim; + qdsIn >> uiVictim; qdsIn >> qsReason; } MessagePlayerBan::MessagePlayerBan() { - qsReason = QString(); } void MessagePlayerBan::saveStream(PacketDataStream &qdsOut) const { - qdsOut << sVictim; + qdsOut << uiVictim; qdsOut << qsReason; } void MessagePlayerBan::restoreStream(PacketDataStream &qdsIn) { - qdsIn >> sVictim; + qdsIn >> uiVictim; qdsIn >> qsReason; } MessagePlayerMove::MessagePlayerMove() { - sVictim = -1; - iChannelId = 0; } void MessagePlayerMove::saveStream(PacketDataStream &qdsOut) const { - qdsOut << sVictim; + qdsOut << uiVictim; qdsOut << iChannelId; } void MessagePlayerMove::restoreStream(PacketDataStream &qdsIn) { - qdsIn >> sVictim; + qdsIn >> uiVictim; qdsIn >> iChannelId; } @@ -377,8 +365,6 @@ void MessagePlayerRename::restoreStream(PacketDataStream &qdsIn) { } MessagePlayerSelfMuteDeaf::MessagePlayerSelfMuteDeaf() { - bMute = false; - bDeaf = false; } void MessagePlayerSelfMuteDeaf::saveStream(PacketDataStream &qdsOut) const { @@ -392,8 +378,6 @@ void MessagePlayerSelfMuteDeaf::restoreStream(PacketDataStream &qdsIn) { } MessageChannelAdd::MessageChannelAdd() { - iId = 0; - iParent = -1; } void MessageChannelAdd::saveStream(PacketDataStream &qdsOut) const { @@ -409,7 +393,6 @@ void MessageChannelAdd::restoreStream(PacketDataStream &qdsIn) { } MessageChannelRemove::MessageChannelRemove() { - iId = 0; } void MessageChannelRemove::saveStream(PacketDataStream &qdsOut) const { @@ -421,8 +404,6 @@ void MessageChannelRemove::restoreStream(PacketDataStream &qdsIn) { } MessageChannelLink::MessageChannelLink() { - iId = 0; - ltType = UnlinkAll; } void MessageChannelLink::saveStream(PacketDataStream &qdsOut) const { @@ -440,8 +421,6 @@ void MessageChannelLink::restoreStream(PacketDataStream &qdsIn) { } MessageChannelMove::MessageChannelMove() { - iId = 0; - iParent = 0; } void MessageChannelMove::saveStream(PacketDataStream &qdsOut) const { @@ -455,23 +434,19 @@ void MessageChannelMove::restoreStream(PacketDataStream &qdsIn) { } MessageTextMessage::MessageTextMessage() { - qsMessage = QString(); } void MessageTextMessage::saveStream(PacketDataStream &qdsOut) const { - qdsOut << sVictim; + qdsOut << uiVictim; qdsOut << qsMessage; } void MessageTextMessage::restoreStream(PacketDataStream &qdsIn) { - qdsIn >> sVictim; + qdsIn >> uiVictim; qdsIn >> qsMessage; } MessageEditACL::MessageEditACL() { - bQuery = true; - iId = 0; - bInheritACL = true; } void MessageEditACL::saveStream(PacketDataStream &qdsOut) const { diff --git a/src/Message.h b/src/Message.h index 188497990..082b6d5d1 100644 --- a/src/Message.h +++ b/src/Message.h @@ -44,7 +44,7 @@ class Message { virtual void restoreStream(PacketDataStream &); public: enum MessageType { Speex, ServerAuthenticate, ServerReject, ServerSync, ServerJoin, ServerLeave, ServerBanList, PlayerMute, PlayerDeaf, PlayerKick, PlayerRename, PlayerBan, PlayerMove, PlayerSelfMuteDeaf, ChannelAdd, ChannelRemove, ChannelMove, ChannelLink, PermissionDenied, EditACL, QueryUsers, Ping, TextMessage, PlayerTexture }; - unsigned short sPlayerId; + unsigned int uiSession; Message(); virtual ~Message(); @@ -160,7 +160,7 @@ class MessagePlayerMute : public Message { void saveStream(PacketDataStream &) const; void restoreStream(PacketDataStream &); public: - short sVictim; + unsigned int uiVictim; bool bMute; MessagePlayerMute(); Message::MessageType messageType() const { @@ -174,7 +174,7 @@ class MessagePlayerDeaf : public Message { void saveStream(PacketDataStream &) const; void restoreStream(PacketDataStream &); public: - short sVictim; + unsigned int uiVictim; bool bDeaf; MessagePlayerDeaf(); Message::MessageType messageType() const { @@ -202,7 +202,7 @@ class MessagePlayerKick : public Message { void saveStream(PacketDataStream &) const; void restoreStream(PacketDataStream &); public: - short sVictim; + unsigned int uiVictim; QString qsReason; MessagePlayerKick(); Message::MessageType messageType() const { @@ -216,7 +216,7 @@ class MessagePlayerBan : public Message { void saveStream(PacketDataStream &) const; void restoreStream(PacketDataStream &); public: - short sVictim; + unsigned int uiVictim; QString qsReason; MessagePlayerBan(); Message::MessageType messageType() const { @@ -230,7 +230,7 @@ class MessagePlayerMove : public Message { void saveStream(PacketDataStream &) const; void restoreStream(PacketDataStream &); public: - short sVictim; + unsigned int uiVictim; int iChannelId; MessagePlayerMove(); Message::MessageType messageType() const { @@ -331,7 +331,7 @@ class MessageTextMessage : public Message { void saveStream(PacketDataStream &) const; void restoreStream(PacketDataStream &); public: - short sVictim; + unsigned int uiVictim; QString qsMessage; MessageTextMessage(); Message::MessageType messageType() const { diff --git a/src/PacketDataStream.h b/src/PacketDataStream.h index 3e801dbba..8084392f9 100644 --- a/src/PacketDataStream.h +++ b/src/PacketDataStream.h @@ -138,9 +138,15 @@ class PacketDataStream { quint64 i = value; if ((i & 0x8000000000000000LL) && (~i < 0x100000000LL)) { - // Sign shortcut - append(0xF8); + // Signed number. i = ~i; + if (i <= 0x3) { + // Shortcase for -1 to -4 + append(0xFC | i); + return *this; + } else { + append(0xF8); + } } if (i < 0x80) { // Need top bit clear @@ -186,7 +192,7 @@ class PacketDataStream { quint32 v = next(); bool invert = false; if ((v & 0xF0) == 0xF0) { - switch (v) { + switch (v & 0xFC) { case 0xF0: i=next() << 24 | next() << 16 | next() << 8 | next(); return *this; @@ -197,6 +203,10 @@ class PacketDataStream { invert = true; v = next(); break; + case 0xFC: + i=v & 0x03; + i = ~i; + return *this; default: ok = false; i = 0; diff --git a/src/Player.cpp b/src/Player.cpp index 75f72fb12..a1f612bd1 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -31,12 +31,12 @@ #include "Player.h" #include "Channel.h" -QHash<short, Player *> Player::c_qmPlayers; +QHash<unsigned int, Player *> Player::c_qmPlayers; QReadWriteLock Player::c_qrwlPlayers; Player::Player(QObject *p) : QObject(p) { sState = Player::Connected; - sId = 0; + uiSession = 0; iId = -1; bMute = bDeaf = false; bSelfMute = bSelfDeaf = false; @@ -46,18 +46,18 @@ Player::Player(QObject *p) : QObject(p) { cChannel = 0; } -Player *Player::get(short sId) { +Player *Player::get(unsigned int uiSession) { QReadLocker lock(&c_qrwlPlayers); - Player *p = c_qmPlayers.value(sId); + Player *p = c_qmPlayers.value(uiSession); return p; } -Player *Player::add(short sId, QObject *po) { +Player *Player::add(unsigned int uiSession, QObject *po) { QWriteLocker lock(&c_qrwlPlayers); Player *p = new Player(po); - p->sId = sId; - c_qmPlayers[sId] = p; + p->uiSession = uiSession; + c_qmPlayers[uiSession] = p; return p; } @@ -76,15 +76,15 @@ Player *Player::match(const Player *other, bool matchname) { return NULL; } -void Player::remove(short sId) { +void Player::remove(unsigned int uiSession) { QWriteLocker lock(&c_qrwlPlayers); - Player *p = c_qmPlayers.take(sId); + Player *p = c_qmPlayers.take(uiSession); if (p && p->cChannel) p->cChannel->removePlayer(p); } void Player::remove(Player *p) { - remove(p->sId); + remove(p->uiSession); } void Player::setTalking(bool talking, bool altspeech) { diff --git a/src/Player.h b/src/Player.h index 3ffd03727..8f11c812c 100644 --- a/src/Player.h +++ b/src/Player.h @@ -40,7 +40,7 @@ class Player : public QObject { public: enum State { Connected, Authenticated }; State sState; - short sId; + unsigned int uiSession; int iId; QString qsName; bool bMute, bDeaf, bSuppressed; @@ -49,14 +49,14 @@ class Player : public QObject { bool bTalking, bAltSpeak; Channel *cChannel; - static QHash<short, Player *> c_qmPlayers; + static QHash<unsigned int, Player *> c_qmPlayers; static QReadWriteLock c_qrwlPlayers; Player(QObject *p = NULL); - static Player *get(short); - static Player *add(short, QObject *p = NULL); + static Player *get(unsigned int); + static Player *add(unsigned int, QObject *p = NULL); static Player *match(const Player *p, bool matchname = false); - static void remove(short); + static void remove(unsigned int); static void remove(Player *); public slots: void setTalking(bool talking, bool altspeech); diff --git a/src/mumble/Audio.cpp b/src/mumble/Audio.cpp index 0620fb092..918aff2cf 100644 --- a/src/mumble/Audio.cpp +++ b/src/mumble/Audio.cpp @@ -40,7 +40,7 @@ LoopPlayer LoopPlayer::lpLoopy; LoopPlayer::LoopPlayer() { qsName = QLatin1String("Loopy"); - sId = 0; + uiSession = 0; iId = 0; sState = Player::Authenticated; bMute = bDeaf = bSuppressed = false; diff --git a/src/mumble/AudioConfigDialog.cpp b/src/mumble/AudioConfigDialog.cpp index 1815383d9..6c7ec8ed2 100644 --- a/src/mumble/AudioConfigDialog.cpp +++ b/src/mumble/AudioConfigDialog.cpp @@ -511,7 +511,7 @@ void AudioConfigDialog::updateBitrate() { QPalette pal; - if ((total / 8 > g.iMaxBandwidth) && g.sId) { + if ((total / 8 > g.iMaxBandwidth) && g.uiSession) { pal.setColor(qlBitrate->foregroundRole(), Qt::red); } diff --git a/src/mumble/AudioInput.cpp b/src/mumble/AudioInput.cpp index ad2aefb16..af47571d0 100644 --- a/src/mumble/AudioInput.cpp +++ b/src/mumble/AudioInput.cpp @@ -174,7 +174,7 @@ int AudioInput::getMaxBandwidth() { void AudioInput::encodeAudioFrame() { int iArg; float fArg; - Player *p=Player::get(g.sId); + Player *p=Player::get(g.uiSession); short max; double micMax; int i; diff --git a/src/mumble/Global.cpp b/src/mumble/Global.cpp index 4a8ce9882..43cc72b2f 100644 --- a/src/mumble/Global.cpp +++ b/src/mumble/Global.cpp @@ -37,7 +37,7 @@ Global::Global() { sh = 0; db = 0; p = 0; - sId = 0; + uiSession = 0; iPushToTalk = 0; bPushToMute = false; bCenterPosition = false; diff --git a/src/mumble/Global.h b/src/mumble/Global.h index da3385826..29b2080ea 100644 --- a/src/mumble/Global.h +++ b/src/mumble/Global.h @@ -72,7 +72,7 @@ struct Global { LoopMode lmLoopMode; double dPacketLoss; double dMaxPacketDelay; - short sId; + unsigned int uiSession; int iMaxBandwidth; Global(); }; diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 5185e1165..9e62f24ea 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -393,7 +393,7 @@ void MainWindow::msgBox(QString msg) { } void MainWindow::closeEvent(QCloseEvent *e) { - g.sId = 0; + g.uiSession = 0; g.qs->setValue(QLatin1String("mwgeom"), saveGeometry()); g.qs->setValue(QLatin1String("mw"), saveState()); g.qs->setValue(QLatin1String("mwSplitter"), qsSplit->saveState()); @@ -439,7 +439,7 @@ void MainWindow::on_Players_doubleClicked(const QModelIndex &idx) { if (!c) return; MessagePlayerMove mpm; - mpm.sVictim = g.sId; + mpm.uiVictim = g.uiSession; mpm.iChannelId = c->iId; g.sh->sendMessage(&mpm); } @@ -534,7 +534,7 @@ void MainWindow::on_PlayerMute_triggered() { return; MessagePlayerMute mpmMsg; - mpmMsg.sVictim = p->sId; + mpmMsg.uiVictim = p->uiSession; mpmMsg.bMute = ! p->bMute; g.sh->sendMessage(&mpmMsg); } @@ -553,7 +553,7 @@ void MainWindow::on_PlayerDeaf_triggered() { return; MessagePlayerDeaf mpdMsg; - mpdMsg.sVictim = p->sId; + mpdMsg.uiVictim = p->uiSession; mpdMsg.bDeaf = ! p->bDeaf; g.sh->sendMessage(&mpdMsg); } @@ -563,7 +563,7 @@ void MainWindow::on_PlayerKick_triggered() { if (!p) return; - short session = p->sId; + short session = p->uiSession; bool ok; QString reason = QInputDialog::getText(this, tr("Kicking player %1").arg(p->qsName), tr("Enter reason"), QLineEdit::Normal, QString(), &ok); @@ -574,7 +574,7 @@ void MainWindow::on_PlayerKick_triggered() { if (ok) { MessagePlayerKick mpkMsg; - mpkMsg.sVictim=p->sId; + mpkMsg.uiVictim=p->uiSession; mpkMsg.qsReason = reason; g.sh->sendMessage(&mpkMsg); } @@ -585,7 +585,7 @@ void MainWindow::on_PlayerBan_triggered() { if (!p) return; - short session = p->sId; + short session = p->uiSession; bool ok; QString reason = QInputDialog::getText(this, tr("Banning player %1").arg(p->qsName), tr("Enter reason"), QLineEdit::Normal, QString(), &ok); @@ -595,7 +595,7 @@ void MainWindow::on_PlayerBan_triggered() { if (ok) { MessagePlayerBan mpbMsg; - mpbMsg.sVictim=p->sId; + mpbMsg.uiVictim=p->uiSession; mpbMsg.qsReason = reason; g.sh->sendMessage(&mpbMsg); } @@ -607,7 +607,7 @@ void MainWindow::on_PlayerTextMessage_triggered() { if (!p) return; - short session = p->sId; + short session = p->uiSession; bool ok; QString message = QInputDialog::getText(this, tr("Sending message to %1").arg(p->qsName), tr("Enter message"), QLineEdit::Normal, QString(), &ok); @@ -617,7 +617,7 @@ void MainWindow::on_PlayerTextMessage_triggered() { if (ok) { MessageTextMessage mtxt; - mtxt.sVictim = p->sId; + mtxt.uiVictim = p->uiSession; mtxt.qsMessage = message; g.l->log(Log::TextMessage, tr("To %1: %2").arg(p->qsName).arg(mtxt.qsMessage), tr("Message to %1").arg(p->qsName)); g.sh->sendMessage(&mtxt); @@ -635,12 +635,12 @@ void MainWindow::on_ChannelMenu_aboutToShow() { add = remove = acl = link = unlink = unlinkall = false; - if (g.sId != 0) { + if (g.uiSession != 0) { add = true; acl = true; Channel *c = pmModel->getChannel(idx); - Channel *home = Player::get(g.sId)->cChannel; + Channel *home = Player::get(g.uiSession)->cChannel; if (c && c->iId != 0) remove = true; @@ -721,7 +721,7 @@ void MainWindow::on_ChannelACL_triggered() { } void MainWindow::on_ChannelLink_triggered() { - Channel *c = Player::get(g.sId)->cChannel; + Channel *c = Player::get(g.uiSession)->cChannel; Channel *l = pmModel->getChannel(qtvPlayers->currentIndex()); if (! l) l = Channel::get(0); @@ -734,7 +734,7 @@ void MainWindow::on_ChannelLink_triggered() { } void MainWindow::on_ChannelUnlink_triggered() { - Channel *c = Player::get(g.sId)->cChannel; + Channel *c = Player::get(g.uiSession)->cChannel; Channel *l = pmModel->getChannel(qtvPlayers->currentIndex()); if (! l) l = Channel::get(0); @@ -747,7 +747,7 @@ void MainWindow::on_ChannelUnlink_triggered() { } void MainWindow::on_ChannelUnlinkAll_triggered() { - Channel *c = Player::get(g.sId)->cChannel; + Channel *c = Player::get(g.uiSession)->cChannel; MessageChannelLink mcl; mcl.iId = c->iId; @@ -879,12 +879,12 @@ void MainWindow::pushLink(bool down) { else g.iPushToTalk--; - if (g.sId == 0) + if (g.uiSession == 0) return; GlobalShortcut *gs = qobject_cast<GlobalShortcut *>(sender()); int idx = gs->data().toInt(); - Channel *home = Player::get(g.sId)->cChannel; + Channel *home = Player::get(g.uiSession)->cChannel; Channel *target = NULL; switch (idx) { @@ -904,7 +904,7 @@ void MainWindow::pushLink(bool down) { return; MessagePlayerMove mpm; - mpm.sVictim = g.sId; + mpm.uiVictim = g.uiSession; mpm.iChannelId = target->iId; g.sh->sendMessage(&mpm); g.l->log(Log::Information, tr("Joining %1.").arg(target->qsName)); @@ -933,7 +933,7 @@ void MainWindow::viewCertificate(bool) { } void MainWindow::serverConnected() { - g.sId = 0; + g.uiSession = 0; g.l->clearIgnore(); g.l->setIgnore(Log::PlayerJoin); g.l->setIgnore(Log::OtherSelfMute); @@ -951,7 +951,7 @@ void MainWindow::serverConnected() { } void MainWindow::serverDisconnected(QString reason) { - g.sId = 0; + g.uiSession = 0; qaServerDisconnect->setEnabled(false); qaServerInformation->setEnabled(false); qaServerBanList->setEnabled(false); @@ -1080,19 +1080,19 @@ void MainWindow::customEvent(QEvent *evt) { } void MessageServerJoin::process(Connection *) { - Player *p = g.mw->pmModel->addPlayer(sPlayerId, qsPlayerName); + Player *p = g.mw->pmModel->addPlayer(uiSession, qsPlayerName); p->iId = iId; g.l->log(Log::PlayerJoin, MainWindow::tr("Joined server: %1.").arg(p->qsName)); } #define MSG_INIT \ - Player *pSrc=Player::get(sPlayerId); \ + Player *pSrc=Player::get(uiSession); \ Q_UNUSED(pSrc); #define VICTIM_INIT \ - Player *pDst=Player::get(sVictim); \ + Player *pDst=Player::get(uiVictim); \ if (! pDst) \ - qFatal("MainWindow: Message for nonexistant victim %d.", sVictim); + qFatal("MainWindow: Message for nonexistant victim %d.", uiVictim); void MessageServerLeave::process(Connection *) { MSG_INIT; @@ -1122,9 +1122,9 @@ void MessagePlayerSelfMuteDeaf::process(Connection *) { pSrc->setSelfMuteDeaf(bMute, bDeaf); - if (sPlayerId == g.sId || ! g.sId) + if (uiSession == g.uiSession || ! g.uiSession) return; - if (pSrc->cChannel != Player::get(g.sId)->cChannel) + if (pSrc->cChannel != Player::get(g.uiSession)->cChannel) return; QString name = pSrc->qsName; @@ -1142,16 +1142,16 @@ void MessagePlayerMute::process(Connection *) { pDst->setMute(bMute); - if (!g.sId || pDst->cChannel != Player::get(g.sId)->cChannel) + if (!g.uiSession || pDst->cChannel != Player::get(g.uiSession)->cChannel) return; QString vic = pDst->qsName; QString admin = pSrc ? pSrc->qsName : MainWindow::tr("server"); - if (sVictim == g.sId) + if (uiVictim == g.uiSession) g.l->log(Log::YouMuted, bMute ? MainWindow::tr("You were muted by %1.").arg(admin) : MainWindow::tr("You were unmuted by %1.").arg(admin)); else - g.l->log((sPlayerId == g.sId) ? Log::YouMutedOther : Log::OtherMutedOther, bMute ? MainWindow::tr("%1 muted by %2.").arg(vic).arg(admin) : MainWindow::tr("%1 unmuted by %2.").arg(vic).arg(admin)); + g.l->log((uiSession == g.uiSession) ? Log::YouMutedOther : Log::OtherMutedOther, bMute ? MainWindow::tr("%1 muted by %2.").arg(vic).arg(admin) : MainWindow::tr("%1 unmuted by %2.").arg(vic).arg(admin)); } void MessagePlayerDeaf::process(Connection *) { @@ -1160,16 +1160,16 @@ void MessagePlayerDeaf::process(Connection *) { pDst->setDeaf(bDeaf); - if (!g.sId || pDst->cChannel != Player::get(g.sId)->cChannel) + if (!g.uiSession || pDst->cChannel != Player::get(g.uiSession)->cChannel) return; QString vic = pDst->qsName; QString admin = pSrc ? pSrc->qsName : MainWindow::tr("server"); - if (sVictim == g.sId) + if (uiVictim == g.uiSession) g.l->log(Log::YouMuted, bDeaf ? MainWindow::tr("You were deafened by %1.").arg(admin) : MainWindow::tr("You were undeafened by %1.").arg(admin)); else - g.l->log((sPlayerId == g.sId) ? Log::YouMutedOther : Log::OtherMutedOther, bDeaf ? MainWindow::tr("%1 deafened by %2.").arg(vic).arg(admin) : MainWindow::tr("%1 undeafened by %2.").arg(vic).arg(admin)); + g.l->log((uiSession == g.uiSession) ? Log::YouMutedOther : Log::OtherMutedOther, bDeaf ? MainWindow::tr("%1 deafened by %2.").arg(vic).arg(admin) : MainWindow::tr("%1 undeafened by %2.").arg(vic).arg(admin)); } void MessagePlayerKick::process(Connection *) { @@ -1177,24 +1177,24 @@ void MessagePlayerKick::process(Connection *) { VICTIM_INIT; QString admin = pSrc ? pSrc->qsName : QLatin1String("server"); - if (sVictim == g.sId) { + if (uiVictim == g.uiSession) { g.l->log(Log::YouKicked, MainWindow::tr("You were kicked from the server by %1: %2.").arg(admin).arg(qsReason)); g.l->setIgnore(Log::ServerDisconnected, 1); } else { g.l->setIgnore(Log::PlayerLeave, 1); - g.l->log((sPlayerId == g.sId) ? Log::YouKicked : Log::PlayerKicked, MainWindow::tr("%3 was kicked from the server by %1: %2.").arg(admin).arg(qsReason).arg(pDst->qsName)); + g.l->log((uiSession == g.uiSession) ? Log::YouKicked : Log::PlayerKicked, MainWindow::tr("%3 was kicked from the server by %1: %2.").arg(admin).arg(qsReason).arg(pDst->qsName)); } } void MessagePlayerBan::process(Connection *) { MSG_INIT; VICTIM_INIT; - if (sVictim == g.sId) { + if (uiVictim == g.uiSession) { g.l->log(Log::YouKicked, MainWindow::tr("You were kicked and banned from the server by %1: %2.").arg(pSrc->qsName).arg(qsReason)); g.l->setIgnore(Log::ServerDisconnected, 1); } else { g.l->setIgnore(Log::PlayerLeave, 1); - g.l->log((sPlayerId == g.sId) ? Log::YouKicked : Log::PlayerKicked, MainWindow::tr("%3 was kicked and banned from the server by %1: %2.").arg(pSrc->qsName).arg(qsReason).arg(pDst->qsName)); + g.l->log((uiSession == g.uiSession) ? Log::YouKicked : Log::PlayerKicked, MainWindow::tr("%3 was kicked and banned from the server by %1: %2.").arg(pSrc->qsName).arg(qsReason).arg(pDst->qsName)); } } @@ -1203,15 +1203,15 @@ void MessagePlayerMove::process(Connection *) { VICTIM_INIT; bool log = true; - if ((sVictim == g.sId) && (sPlayerId == sVictim)) + if ((uiVictim == g.uiSession) && (uiSession == uiVictim)) log = false; - if (g.sId == 0) + if (g.uiSession == 0) log = false; QString pname = pDst->qsName; QString admin = pSrc ? pSrc->qsName : QLatin1String("server"); - if (log && (pDst->cChannel == Player::get(g.sId)->cChannel)) { + if (log && (pDst->cChannel == Player::get(g.uiSession)->cChannel)) { if (pDst == pSrc || (!pSrc)) g.l->log(Log::ChannelJoin, MainWindow::tr("%1 left channel.").arg(pname)); else @@ -1220,7 +1220,7 @@ void MessagePlayerMove::process(Connection *) { g.mw->pmModel->movePlayer(pDst, iChannelId); - if (log && (pDst->cChannel == Player::get(g.sId)->cChannel)) { + if (log && (pDst->cChannel == Player::get(g.uiSession)->cChannel)) { if (pDst == pSrc || (!pSrc)) g.l->log(Log::ChannelLeave, MainWindow::tr("%1 entered channel.").arg(pname)); else @@ -1288,7 +1288,7 @@ void MessagePermissionDenied::process(Connection *) { void MessageServerSync::process(Connection *) { MSG_INIT; g.iMaxBandwidth = iMaxBandwidth; - g.sId = sPlayerId; + g.uiSession = uiSession; g.l->clearIgnore(); g.l->log(Log::Information, qsWelcomeText); g.mw->pmModel->ensureSelfVisible(); diff --git a/src/mumble/Overlay.cpp b/src/mumble/Overlay.cpp index a1a1398e1..30c382721 100644 --- a/src/mumble/Overlay.cpp +++ b/src/mumble/Overlay.cpp @@ -506,8 +506,8 @@ void Overlay::updateOverlay() { if (! isActive())
return;
- if (g.sId) {
- Channel *home = Player::get(g.sId)->cChannel;
+ if (g.uiSession) {
+ Channel *home = Player::get(g.uiSession)->cChannel;
foreach(Channel *c, home->allLinks()) {
if (home == c)
continue;
@@ -526,7 +526,7 @@ void Overlay::updateOverlay() { QList<TextLine> lines;
- if (g.sId) {
+ if (g.uiSession) {
if (g.s.bOverlayTop) {
foreach(qpChanCol cc, linkchans) {
@@ -539,8 +539,8 @@ void Overlay::updateOverlay() { }
}
- foreach(Player *p, Player::get(g.sId)->cChannel->qlPlayers) {
- if ((g.s.osOverlay == Settings::All) || p->bTalking || ((p == Player::get(g.sId)) && g.s.bOverlayAlwaysSelf)) {
+ foreach(Player *p, Player::get(g.uiSession)->cChannel->qlPlayers) {
+ if ((g.s.osOverlay == Settings::All) || p->bTalking || ((p == Player::get(g.uiSession)) && g.s.bOverlayAlwaysSelf)) {
if (g.s.bOverlayUserTextures && (p->iId >= 0) && (! qhQueried.contains(p->iId))) {
qhQueried.insert(p->iId, p->qsName);
MessageTexture mt;
diff --git a/src/mumble/Overlay.h b/src/mumble/Overlay.h index 813591b4b..d26dc6032 100644 --- a/src/mumble/Overlay.h +++ b/src/mumble/Overlay.h @@ -104,7 +104,7 @@ class Overlay : public QObject { TextLine(const QString &t, quint32 c, int p = -1, Decoration d = None) : qsText(t), iPlayer(p), uiColor(c), dDecor(d) { }; }; - typedef QPair<short, QByteArray> UserTexture; + typedef QPair<unsigned int, QByteArray> UserTexture; QByteArray qbaMuted, qbaDeafened; QList<TextLine> qlCurrentTexts; QHash<QString, unsigned char *> qhTextures; diff --git a/src/mumble/PlayerModel.cpp b/src/mumble/PlayerModel.cpp index ab8ec7897..ea35a19c3 100644 --- a/src/mumble/PlayerModel.cpp +++ b/src/mumble/PlayerModel.cpp @@ -313,7 +313,7 @@ QVariant PlayerModel::data(const QModelIndex &idx, int role) const { return (p->bTalking) ? (p->bAltSpeak ? qiTalkingAlt : qiTalkingOn) : qiTalkingOff; break; case Qt::FontRole: - if ((idx.column() == 0) && (p->sId == g.sId)) { + if ((idx.column() == 0) && (p->uiSession == g.uiSession)) { QFont f = g.mw->font(); f.setBold(true); return f; @@ -451,7 +451,7 @@ void PlayerModel::hidePlayer(Player *p) { item->qlPlayers.removeAll(p); endRemoveRows(); - if (g.sId && (p->cChannel == Player::get(g.sId)->cChannel)) + if (g.uiSession && (p->cChannel == Player::get(g.uiSession)->cChannel)) updateOverlay(); p->cChannel = NULL; @@ -471,7 +471,7 @@ void PlayerModel::showPlayer(Player *p, Channel *c) { item->insertPlayer(p); endInsertRows(); - if (g.sId && (p->cChannel == Player::get(g.sId)->cChannel)) + if (g.uiSession && (p->cChannel == Player::get(g.uiSession)->cChannel)) updateOverlay(); ensureSelfVisible(); @@ -480,9 +480,9 @@ void PlayerModel::showPlayer(Player *p, Channel *c) { void PlayerModel::ensureSelfVisible() { QStack<Channel *> chans; - if (! g.sId) + if (! g.uiSession) return; - Channel *c = Player::get(g.sId)->cChannel; + Channel *c = Player::get(g.uiSession)->cChannel; while (c) { chans.push(c); c = c->cParent; @@ -495,12 +495,12 @@ void PlayerModel::ensureSelfVisible() { } void PlayerModel::recheckLinks() { - if (! g.sId) + if (! g.uiSession) return; bool bChanged = false; - Channel *home = Player::get(g.sId)->cChannel; + Channel *home = Player::get(g.uiSession)->cChannel; QSet<Channel *> all = home->allLinks(); @@ -521,7 +521,7 @@ void PlayerModel::recheckLinks() { updateOverlay(); } -Player *PlayerModel::addPlayer(short id, QString name) { +Player *PlayerModel::addPlayer(unsigned int id, QString name) { Player *p = Player::add(id, this); p->qsName = name; @@ -703,7 +703,7 @@ void PlayerModel::playerMuteDeafChanged() { Player *p=static_cast<Player *>(sender()); QModelIndex idx = index(p, 1); emit dataChanged(idx, idx); - if (g.sId && (p->cChannel == Player::get(g.sId)->cChannel)) + if (g.uiSession && (p->cChannel == Player::get(g.uiSession)->cChannel)) updateOverlay(); } @@ -727,7 +727,7 @@ QMimeData *PlayerModel::mimeData(const QModelIndexList &idxs) const { Channel *c = getChannel(idx); if (p) { ds << false; - ds << p->sId; + ds << p->uiSession; } else if (c) { ds << true; ds << c->iId; @@ -747,13 +747,13 @@ bool PlayerModel::dropMimeData(const QMimeData *md, Qt::DropAction, int, int, co bool isChannel; int iId = -1; - short sId = -1; + short uiSession = -1; ds >> isChannel; if (isChannel) ds >> iId; else - ds >> sId; + ds >> uiSession; Channel *c; if (! p.isValid()) { @@ -764,7 +764,7 @@ bool PlayerModel::dropMimeData(const QMimeData *md, Qt::DropAction, int, int, co if (! isChannel) { MessagePlayerMove mpm; - mpm.sVictim = sId; + mpm.uiVictim = uiSession; mpm.iChannelId = c->iId; g.sh->sendMessage(&mpm); } else { diff --git a/src/mumble/PlayerModel.h b/src/mumble/PlayerModel.h index f2f8a63a8..be128cf7c 100644 --- a/src/mumble/PlayerModel.h +++ b/src/mumble/PlayerModel.h @@ -116,7 +116,7 @@ class PlayerModel : public QAbstractItemModel { QMimeData *mimeData(const QModelIndexList &idx) const; bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex & parent); - Player *addPlayer(short id, QString name); + Player *addPlayer(unsigned int id, QString name); Player *getPlayer(const QModelIndex &idx) const; Channel *addChannel(int id, Channel *p, QString name); diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp index 39107814a..42f97aaef 100644 --- a/src/mumble/ServerHandler.cpp +++ b/src/mumble/ServerHandler.cpp @@ -98,15 +98,15 @@ void ServerHandler::udpReady() { PacketDataStream pds(buffer, buflen); - quint32 msgType, sPlayerId; - pds >> msgType >> sPlayerId; + quint32 msgType, uiSession; + pds >> msgType >> uiSession; if (msgType == Message::Ping) { quint64 t; pds >> t; uiUDPPing = tTimestamp.elapsed() - t; } else if (msgType == Message::Speex) { - Player *p = Player::get(sPlayerId); + Player *p = Player::get(uiSession); AudioOutputPtr ao = g.ao; if (ao) { if (p) { @@ -126,7 +126,7 @@ void ServerHandler::udpReady() { void ServerHandler::sendMessage(Message *mMsg, bool forceTCP) { bool mayUdp = !forceTCP && ((mMsg->messageType() == Message::Speex) || (mMsg->messageType() == Message::Ping)); - mMsg->sPlayerId = g.sId; + mMsg->uiSession = g.uiSession; if (mayUdp && ! g.s.bTCPCompat) { QMutexLocker qml(&qmUdp); @@ -201,7 +201,7 @@ void ServerHandler::message(QByteArray &qbaMsg) { if (! mMsg) return; - Player *p = Player::get(mMsg->sPlayerId); + Player *p = Player::get(mMsg->uiSession); AudioOutputPtr ao = g.ao; if (mMsg->messageType() == Message::Speex) { diff --git a/src/murmur/DBus.cpp b/src/murmur/DBus.cpp index 48621340b..5219dd08d 100644 --- a/src/murmur/DBus.cpp +++ b/src/murmur/DBus.cpp @@ -241,21 +241,21 @@ void MurmurDBus::getChannels(QList<ChannelInfo> &a) { } } -void MurmurDBus::kickPlayer(short session, const QString &reason, const QDBusMessage &msg) { +void MurmurDBus::kickPlayer(unsigned int session, const QString &reason, const QDBusMessage &msg) { PLAYER_SETUP; Connection *c = g_sServer->qmConnections.value(session); if (!c) return; MessagePlayerKick mpk; - mpk.sPlayerId = 0; - mpk.sVictim = session; + mpk.uiSession = 0; + mpk.uiVictim = session; mpk.qsReason=reason; g_sServer->sendAll(&mpk); c->disconnect(); } -void MurmurDBus::getPlayerState(short session, const QDBusMessage &msg, PlayerInfo &pi) { +void MurmurDBus::getPlayerState(unsigned int session, const QDBusMessage &msg, PlayerInfo &pi) { PLAYER_SETUP; pi = PlayerInfo(pPlayer); } @@ -278,8 +278,8 @@ void MurmurDBus::setPlayerState(const PlayerInfo &npi, const QDBusMessage &msg) pPlayer->bDeaf = deaf; pPlayer->bMute = mute; MessagePlayerDeaf mpd; - mpd.sPlayerId = 0; - mpd.sVictim=pPlayer->sId; + mpd.uiSession = 0; + mpd.uiVictim=pPlayer->uiSession; mpd.bDeaf = deaf; g_sServer->sendAll(&mpd); changed = true; @@ -288,8 +288,8 @@ void MurmurDBus::setPlayerState(const PlayerInfo &npi, const QDBusMessage &msg) pPlayer->bMute = mute; MessagePlayerMute mpm; - mpm.sPlayerId = 0; - mpm.sVictim=pPlayer->sId; + mpm.uiSession = 0; + mpm.uiVictim=pPlayer->uiSession; mpm.bMute=mute; g_sServer->sendAll(&mpm); changed = true; @@ -298,8 +298,8 @@ void MurmurDBus::setPlayerState(const PlayerInfo &npi, const QDBusMessage &msg) if (cChannel->iId != pi.channel) { g_sServer->playerEnterChannel(pPlayer, cChannel); MessagePlayerMove mpm; - mpm.sPlayerId = 0; - mpm.sVictim = pPlayer->sId; + mpm.uiSession = 0; + mpm.uiVictim = pPlayer->uiSession; mpm.iChannelId = cChannel->iId; g_sServer->sendAll(&mpm); changed = true; @@ -317,7 +317,7 @@ void MurmurDBus::addChannel(const QString &name, int chanparent, const QDBusMess newid = nc->iId; MessageChannelAdd mca; - mca.sPlayerId = 0; + mca.uiSession = 0; mca.qsName = name; mca.iParent = chanparent; mca.iId = nc->iId; @@ -363,7 +363,7 @@ void MurmurDBus::setChannelState(const ChannelInfo &nci, const QDBusMessage &msg ServerDB::updateChannel(cChannel); MessageChannelMove mcm; - mcm.sPlayerId = 0; + mcm.uiSession = 0; mcm.iId = nci.id; mcm.iParent = nci.parent; g_sServer->sendAll(&mcm); @@ -381,7 +381,7 @@ void MurmurDBus::setChannelState(const ChannelInfo &nci, const QDBusMessage &msg ServerDB::removeLink(cChannel, l); MessageChannelLink mcl; - mcl.sPlayerId = 0; + mcl.uiSession = 0; mcl.iId = nci.id; mcl.qlTargets << l->iId; mcl.ltType = MessageChannelLink::Unlink; @@ -395,7 +395,7 @@ void MurmurDBus::setChannelState(const ChannelInfo &nci, const QDBusMessage &msg ServerDB::addLink(cChannel, l); MessageChannelLink mcl; - mcl.sPlayerId = 0; + mcl.uiSession = 0; mcl.iId = nci.id; mcl.qlTargets << l->iId; mcl.ltType = MessageChannelLink::Link; @@ -570,7 +570,7 @@ void MurmurDBus::setTemporaryGroups(int channel, int playerid, const QStringList } PlayerInfo::PlayerInfo(Player *p) { - session = p->sId; + session = p->uiSession; mute = p->bMute; deaf = p->bDeaf; suppressed = p->bSuppressed; @@ -583,7 +583,7 @@ PlayerInfoExtended::PlayerInfoExtended(Player *p) : PlayerInfo(p) { id = p->iId; name = p->qsName; - Connection *c = g_sServer->qmConnections[p->sId]; + Connection *c = g_sServer->qmConnections[p->uiSession]; BandwidthRecord *bw= g_sServer->qmBandwidth[c]; onlinesecs = bw->qtFirst.elapsed() / 1000000LL; diff --git a/src/murmur/DBus_real.h b/src/murmur/DBus_real.h index a8a873bcd..2f07719dd 100644 --- a/src/murmur/DBus_real.h +++ b/src/murmur/DBus_real.h @@ -39,7 +39,7 @@ #include "ACL.h" struct PlayerInfo { - short session; + unsigned int session; bool mute, deaf, suppressed; bool selfMute, selfDeaf; int channel; @@ -142,8 +142,8 @@ class MurmurDBus : public QDBusAbstractAdaptor { void getBans(QList<BanInfo> &bans); void setBans(const QList<BanInfo> &bans, const QDBusMessage &); - void kickPlayer(short session, const QString &reason, const QDBusMessage &); - void getPlayerState(short session, const QDBusMessage &, PlayerInfo &state); + void kickPlayer(unsigned int session, const QString &reason, const QDBusMessage &); + void getPlayerState(unsigned int session, const QDBusMessage &, PlayerInfo &state); void setPlayerState(const PlayerInfo &state, const QDBusMessage &); void setChannelState(const ChannelInfo &state, const QDBusMessage &); diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 693ee52e9..a396d916c 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -168,7 +168,7 @@ void UDPThread::run() { if (setsockopt(qusUdp->socketDescriptor(), SOL_IP, IP_TOS, &val, sizeof(val))) qWarning("Server: Failed to set TOS for UDP Socket"); #endif - connect(this, SIGNAL(tcpTransmit(QByteArray, short)), g_sServer, SLOT(tcpTransmit(QByteArray, short)), Qt::QueuedConnection); + connect(this, SIGNAL(tcpTransmit(QByteArray, unsigned int)), g_sServer, SLOT(tcpTransmit(QByteArray, unsigned int)), Qt::QueuedConnection); QHostAddress senderAddr; quint16 senderPort; @@ -176,7 +176,7 @@ void UDPThread::run() { char buffer[65535]; quint32 msgType; - int sPlayerId; + int uiSession; qDebug("Entering UDP event loop"); @@ -187,7 +187,7 @@ void UDPThread::run() { len=qusUdp->readDatagram(buffer, 65535, &senderAddr, &senderPort); PacketDataStream pds(buffer, len); - pds >> msgType >> sPlayerId; + pds >> msgType >> uiSession; if ((msgType != Message::Speex) && (msgType != Message::Ping)) continue; @@ -196,8 +196,8 @@ void UDPThread::run() { Peer p(senderAddr.toIPv4Address(), senderPort); - if (p != qhPeers.value(sPlayerId)) { - Connection *source = g_sServer->qmConnections.value(sPlayerId); + if (p != qhPeers.value(uiSession)) { + Connection *source = g_sServer->qmConnections.value(uiSession); if (! source || !(source->peerAddress() == senderAddr)) { continue; } @@ -205,13 +205,13 @@ void UDPThread::run() { rl.unlock(); { QWriteLocker wl(&g_sServer->qrwlConnections); - if (g_sServer->qmConnections.contains(sPlayerId)) { - qhHosts[sPlayerId] = senderAddr; - qhPeers[sPlayerId] = p; + if (g_sServer->qmConnections.contains(uiSession)) { + qhHosts[uiSession] = senderAddr; + qhPeers[uiSession] = p; } } rl.relock(); - if (! g_sServer->qmConnections.contains(sPlayerId)) { + if (! g_sServer->qmConnections.contains(uiSession)) { continue; } } @@ -219,7 +219,7 @@ void UDPThread::run() { if (msgType == Message::Ping) qusUdp->writeDatagram(buffer, len, senderAddr, senderPort); else { - processMsg(pds, g_sServer->qmConnections.value(sPlayerId)); + processMsg(pds, g_sServer->qmConnections.value(uiSession)); } } } @@ -232,15 +232,15 @@ void UDPThread::fakeUdpPacket(Message *msg, Connection *source) { pds.rewind(); quint32 msgType; - int sPlayerId; + int uiSession; - pds >> msgType >> sPlayerId; + pds >> msgType >> uiSession; QReadLocker rl(&g_sServer->qrwlConnections); processMsg(pds, source); } -void UDPThread::sendMessage(short id, const char *data, int len, QByteArray &cache) { +void UDPThread::sendMessage(unsigned int id, const char *data, int len, QByteArray &cache) { if (qhPeers.contains(id)) { qusUdp->writeDatagram(data, len, qhHosts[id], qhPeers[id].second); } else { @@ -285,13 +285,13 @@ void UDPThread::processMsg(PacketDataStream &pds, Connection *cCon) { int len = pds.left(); if (flags & MessageSpeex::LoopBack) { - sendMessage(pSrcPlayer->sId, data, len, qba); + sendMessage(pSrcPlayer->uiSession, data, len, qba); return; } foreach(p, c->qlPlayers) { if (! p->bDeaf && ! p->bSelfDeaf && (p != pSrcPlayer)) - sendMessage(p->sId, data, len, qba); + sendMessage(p->uiSession, data, len, qba); } if (! c->qhLinks.isEmpty()) { @@ -302,7 +302,7 @@ void UDPThread::processMsg(PacketDataStream &pds, Connection *cCon) { if (ChanACL::hasPermission(pSrcPlayer, l, (flags & MessageSpeex::AltSpeak) ? ChanACL::AltSpeak : ChanACL::Speak)) { foreach(p, l->qlPlayers) { if (! p->bDeaf && ! p->bSelfDeaf) - sendMessage(p->sId, data, len, qba); + sendMessage(p->uiSession, data, len, qba); } } } @@ -346,7 +346,7 @@ void Server::log(QString s, Connection *c) { int iid = -1; QString name; if (p) { - id = p->sId; + id = p->uiSession; iid = p->iId; name = p->qsName; } @@ -379,7 +379,7 @@ void Server::newClient() { Connection *cCon = new Connection(this, sock); - short id; + unsigned int id; if (qqIds.isEmpty()) { cCon->disconnect(); @@ -429,7 +429,7 @@ void Server::connectionClosed(QString reason) { if (pPlayer->sState == Player::Authenticated) { MessageServerLeave mslMsg; - mslMsg.sPlayerId=pPlayer->sId; + mslMsg.uiSession=pPlayer->uiSession; sendExcept(&mslMsg, c); ServerDB::conLoggedOff(pPlayer); @@ -438,7 +438,7 @@ void Server::connectionClosed(QString reason) { QWriteLocker wl(&qrwlConnections); - qmConnections.remove(pPlayer->sId); + qmConnections.remove(pPlayer->uiSession); qmPlayers.remove(c); BandwidthRecord *bw = qmBandwidth.take(c); @@ -446,10 +446,10 @@ void Server::connectionClosed(QString reason) { Player::remove(pPlayer); - qqIds.enqueue(pPlayer->sId); + qqIds.enqueue(pPlayer->uiSession); - udp->qhHosts.remove(pPlayer->sId); - udp->qhPeers.remove(pPlayer->sId); + udp->qhHosts.remove(pPlayer->uiSession); + udp->qhPeers.remove(pPlayer->uiSession); qhUserTextureCache.remove(pPlayer->iId); @@ -491,7 +491,7 @@ void Server::checkTimeout() { c->disconnect(); } -void Server::tcpTransmit(QByteArray a, short id) { +void Server::tcpTransmit(QByteArray a, unsigned int id) { Connection *c = qmConnections.value(id); if (c) { c->sendMessage(a); @@ -499,7 +499,7 @@ void Server::tcpTransmit(QByteArray a, short id) { } } -void Server::sendMessage(short id, Message *mMsg) { +void Server::sendMessage(unsigned int id, Message *mMsg) { Connection *c = qmConnections.value(id); sendMessage(c, mMsg); } @@ -537,8 +537,8 @@ void Server::removeChannel(Channel *chan, Player *src, Channel *dest) { chan->removePlayer(p); MessagePlayerMove mpm; - mpm.sPlayerId = 0; - mpm.sVictim = p->sId; + mpm.uiSession = 0; + mpm.uiVictim = p->uiSession; mpm.iChannelId = dest->iId; sendAll(&mpm); @@ -546,7 +546,7 @@ void Server::removeChannel(Channel *chan, Player *src, Channel *dest) { } MessageChannelRemove mcr; - mcr.sPlayerId = src ? src->sId : 0; + mcr.uiSession = src ? src->uiSession : 0; mcr.iId = chan->iId; sendAll(&mcr); @@ -586,8 +586,8 @@ void Server::playerEnterChannel(Player *p, Channel *c, bool quiet) { p->bSuppressed = ! mayspeak; MessagePlayerMute mpm; - mpm.sPlayerId = 0; - mpm.sVictim = p->sId; + mpm.uiSession = 0; + mpm.uiVictim = p->uiSession; mpm.bMute = p->bSuppressed; g_sServer->sendAll(&mpm); } @@ -614,8 +614,8 @@ void Server::checkCommands() { continue; playerEnterChannel(p, c); MessagePlayerMove mpm; - mpm.sPlayerId = 0; - mpm.sVictim = p->sId; + mpm.uiSession = 0; + mpm.uiVictim = p->uiSession; mpm.iChannelId = c->iId; sendAll(&mpm); } else if (cmdname == "rename") { @@ -625,7 +625,7 @@ void Server::checkCommands() { if (! p || name.isEmpty()) continue; MessagePlayerRename mpr; - mpr.sPlayerId = p->sId; + mpr.uiSession = p->uiSession; mpr.qsName = name; sendAll(&mpr); } else if (cmdname == "createchannel") { @@ -639,7 +639,7 @@ void Server::checkCommands() { ServerDB::updateChannel(c); MessageChannelAdd mca; - mca.sPlayerId = 0; + mca.uiSession = 0; mca.qsName = name; mca.iParent = p->iId; mca.iId = c->iId; @@ -666,14 +666,14 @@ void Server::checkCommands() { #define MSG_SETUP(st) \ Player *pSrcPlayer = g_sServer->qmPlayers[cCon]; \ MessagePermissionDenied mpd; \ - sPlayerId = pSrcPlayer->sId; \ + uiSession = pSrcPlayer->uiSession; \ if (pSrcPlayer->sState != st) \ return #define VICTIM_SETUP \ - Player *pDstPlayer = Player::get(sVictim); \ + Player *pDstPlayer = Player::get(uiVictim); \ Q_UNUSED(pDstPlayer) \ - Connection *cDst = g_sServer->qmConnections.value(sVictim); \ + Connection *cDst = g_sServer->qmConnections.value(uiVictim); \ Q_UNUSED(cDst) #define PERM_DENIED(who, where, what) \ @@ -725,7 +725,7 @@ void MessageServerAuthenticate::process(Connection *cCon) { } Player *ppOld = Player::match(pSrcPlayer, true); - Connection *cOld = ppOld ? g_sServer->qmConnections.value(ppOld->sId) : NULL; + Connection *cOld = ppOld ? g_sServer->qmConnections.value(ppOld->uiSession) : NULL; // Allow reuse of name from same IP if (ok && ppOld && (pSrcPlayer->iId == -1)) { @@ -780,7 +780,7 @@ void MessageServerAuthenticate::process(Connection *cCon) { chans.insert(c); MessageChannelAdd mca; - mca.sPlayerId = 0; + mca.uiSession = 0; mca.iId = c->iId; mca.iParent = (c->cParent) ? c->cParent->iId : -1; mca.qsName = c->qsName; @@ -806,13 +806,13 @@ void MessageServerAuthenticate::process(Connection *cCon) { MessagePlayerMove mpm; pSrcPlayer->sState = Player::Authenticated; - msjMsg.sPlayerId = pSrcPlayer->sId; + msjMsg.uiSession = pSrcPlayer->uiSession; msjMsg.iId = pSrcPlayer->iId; msjMsg.qsPlayerName = pSrcPlayer->qsName; g_sServer->sendExcept(&msjMsg, cCon); - mpm.sPlayerId = 0; - mpm.sVictim = pSrcPlayer->sId; + mpm.uiSession = 0; + mpm.uiVictim = pSrcPlayer->uiSession; mpm.iChannelId = pSrcPlayer->cChannel->iId; if (mpm.iChannelId != 0) g_sServer->sendExcept(&mpm, cCon); @@ -820,41 +820,41 @@ void MessageServerAuthenticate::process(Connection *cCon) { foreach(Player *pPlayer, g_sServer->qmPlayers) { if (pPlayer->sState != Player::Authenticated) continue; - msjMsg.sPlayerId = pPlayer->sId; + msjMsg.uiSession = pPlayer->uiSession; msjMsg.iId = pPlayer->iId; msjMsg.qsPlayerName = pPlayer->qsName; g_sServer->sendMessage(cCon, &msjMsg); if (pPlayer->bDeaf) { MessagePlayerDeaf mpdMsg; - mpdMsg.sPlayerId = 0; - mpdMsg.sVictim = pPlayer->sId; + mpdMsg.uiSession = 0; + mpdMsg.uiVictim = pPlayer->uiSession; mpdMsg.bDeaf = true; g_sServer->sendMessage(cCon, &mpdMsg); } else if (pPlayer->bMute || pPlayer->bSuppressed) { MessagePlayerMute mpmMsg; - mpmMsg.sPlayerId = 0; - mpmMsg.sVictim = pPlayer->sId; + mpmMsg.uiSession = 0; + mpmMsg.uiVictim = pPlayer->uiSession; mpmMsg.bMute = true; g_sServer->sendMessage(cCon, &mpmMsg); } if (pPlayer->bSelfDeaf || pPlayer->bSelfMute) { MessagePlayerSelfMuteDeaf mpsmdMsg; - mpsmdMsg.sPlayerId = pPlayer->sId; + mpsmdMsg.uiSession = pPlayer->uiSession; mpsmdMsg.bDeaf = pPlayer->bSelfDeaf; mpsmdMsg.bMute = pPlayer->bSelfMute; g_sServer->sendMessage(cCon, &mpsmdMsg); } - mpm.sPlayerId = 0; - mpm.sVictim = pPlayer->sId; + mpm.uiSession = 0; + mpm.uiVictim = pPlayer->uiSession; mpm.iChannelId = pPlayer->cChannel->iId; g_sServer->sendMessage(cCon, &mpm); } MessageServerSync mssMsg; - mssMsg.sPlayerId = pSrcPlayer->sId; + mssMsg.uiSession = pSrcPlayer->uiSession; mssMsg.qsWelcomeText = g_sp.qsWelcomeText; mssMsg.iMaxBandwidth = g_sp.iMaxBandwidth; g_sServer->sendMessage(cCon, &mssMsg); @@ -873,7 +873,7 @@ void MessageServerBanList::process(Connection *cCon) { } if (bQuery) { MessageServerBanList msbl; - msbl.sPlayerId = 0; + msbl.uiSession = 0; msbl.bQuery = false; msbl.qlBans = g_sServer->qlBans; g_sServer->sendMessage(cCon, &msbl); @@ -910,7 +910,7 @@ void MessagePlayerRename::process(Connection *cCon) { void MessageSpeex::process(Connection *cCon) { MSG_SETUP(Player::Authenticated); - sPlayerId = pSrcPlayer->sId; + uiSession = pSrcPlayer->uiSession; g_sServer->udp->fakeUdpPacket(this, cCon); } @@ -1224,7 +1224,7 @@ void MessageChannelLink::process(Connection *cCon) { MessageChannelLink mcl; mcl.iId = iId; - mcl.sPlayerId=sPlayerId; + mcl.uiSession=uiSession; if (newset.count() > oldset.count()) { mcl.ltType = Link; diff --git a/src/murmur/Server.h b/src/murmur/Server.h index 9a483b1ac..0d7274744 100644 --- a/src/murmur/Server.h +++ b/src/murmur/Server.h @@ -74,12 +74,12 @@ class UDPThread : public QThread { Q_OBJECT; protected: QUdpSocket *qusUdp; - QHash<short, Peer> qhPeers; - QHash<short, QHostAddress> qhHosts; + QHash<unsigned int, Peer> qhPeers; + QHash<unsigned int, QHostAddress> qhHosts; void processMsg(PacketDataStream &pds, Connection *cCon); - void sendMessage(short id, const char *data, int len, QByteArray &cache); + void sendMessage(unsigned int id, const char *data, int len, QByteArray &cache); signals: - void tcpTransmit(QByteArray, short id); + void tcpTransmit(QByteArray, unsigned int id); public: void fakeUdpPacket(Message *msg, Connection *source); void run(); @@ -109,9 +109,9 @@ class Server : public QObject { void message(QByteArray &, Connection *cCon = NULL); void checkCommands(); void checkTimeout(); - void tcpTransmit(QByteArray, short); + void tcpTransmit(QByteArray, unsigned int); public: - QHash<short, Connection *> qmConnections; + QHash<unsigned int, Connection *> qmConnections; QHash<Connection *, Player *> qmPlayers; QHash<Connection *, BandwidthRecord *> qmBandwidth; QReadWriteLock qrwlConnections; @@ -126,7 +126,7 @@ class Server : public QObject { void sendAll(Message *); void sendExcept(Message *, Connection *); - void sendMessage(short, Message *); + void sendMessage(unsigned int, Message *); void sendMessage(Connection *, Message *); void log(QString s, Connection *c = NULL); diff --git a/src/murmur/ServerDB.cpp b/src/murmur/ServerDB.cpp index 0fede8c18..6d777df6c 100644 --- a/src/murmur/ServerDB.cpp +++ b/src/murmur/ServerDB.cpp @@ -548,7 +548,7 @@ void ServerDB::setLastChannel(const Player *p) { QSqlQuery query; query.prepare("UPDATE connections SET channel_id=? WHERE con_id = ?"); query.addBindValue(p->cChannel->iId); - query.addBindValue(p->sId); + query.addBindValue(p->uiSession); query.exec(); } } @@ -580,7 +580,7 @@ void ServerDB::conLoggedOn(const Player *p, const Connection *con) { QSqlQuery query; query.prepare("INSERT INTO connections (con_id, player_id, channel_id, player_name, ip, port) VALUES (?,?,?,?,?,?)"); - query.addBindValue(p->sId); + query.addBindValue(p->uiSession); query.addBindValue(p->iId); query.addBindValue(QVariant()); query.addBindValue(p->qsName); @@ -594,7 +594,7 @@ void ServerDB::conLoggedOff(const Player *p) { QSqlQuery query; query.prepare("DELETE FROM connections WHERE con_id = ?"); - query.addBindValue(p->sId); + query.addBindValue(p->uiSession); query.exec(); } @@ -604,7 +604,7 @@ void ServerDB::conChangedChannel(const Player *p) { query.prepare("UPDATE connections SET player_name=? WHERE con_id = ?"); query.addBindValue(p->qsName); - query.addBindValue(p->sId); + query.addBindValue(p->uiSession); query.exec(); } @@ -614,7 +614,7 @@ void ServerDB::conChangedName(const Player *p) { query.prepare("UPDATE connections SET channel_id=? WHERE con_id = ?"); query.addBindValue(p->cChannel->iId); - query.addBindValue(p->sId); + query.addBindValue(p->uiSession); query.exec(); } |