mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-24 15:43:54 -07:00
more work on buddy&ignore
This commit is contained in:
parent
4149f78001
commit
0afdbc7222
9 changed files with 28 additions and 21 deletions
|
|
@ -266,6 +266,7 @@ void ProtocolResponse::initializeHash()
|
|||
responseHash.insert("spectators_not_allowed", RespSpectatorsNotAllowed);
|
||||
responseHash.insert("only_buddies", RespOnlyBuddies);
|
||||
responseHash.insert("user_level_too_low", RespUserLevelTooLow);
|
||||
responseHash.insert("on_ignore_list", RespOnIgnoreList);
|
||||
}
|
||||
|
||||
Response_JoinRoom::Response_JoinRoom(int _cmdId, ResponseCode _responseCode, ServerInfo_Room *_roomInfo)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
class DeckList;
|
||||
|
||||
enum ResponseCode { RespNothing, RespOk, RespInternalError, RespInvalidCommand, RespInvalidData, RespNameNotFound, RespLoginNeeded, RespFunctionNotAllowed, RespGameNotStarted, RespGameFull, RespContextError, RespWrongPassword, RespSpectatorsNotAllowed, RespOnlyBuddies, RespUserLevelTooLow };
|
||||
enum ResponseCode { RespNothing, RespOk, RespInternalError, RespInvalidCommand, RespInvalidData, RespNameNotFound, RespLoginNeeded, RespFunctionNotAllowed, RespGameNotStarted, RespGameFull, RespContextError, RespWrongPassword, RespSpectatorsNotAllowed, RespOnlyBuddies, RespUserLevelTooLow, RespOnIgnoreList };
|
||||
|
||||
// PrivateZone: Contents of the zone are always visible to the owner,
|
||||
// but not to anyone else.
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ public:
|
|||
virtual int getMaxGameInactivityTime() const = 0;
|
||||
virtual int getMaxPlayerInactivityTime() const = 0;
|
||||
|
||||
virtual QList<ServerInfo_User *> getBuddyList(const QString &name) = 0;
|
||||
virtual QList<ServerInfo_User *> getIgnoreList(const QString &name) = 0;
|
||||
virtual QMap<QString, ServerInfo_User *> getBuddyList(const QString &name) = 0;
|
||||
virtual QMap<QString, ServerInfo_User *> getIgnoreList(const QString &name) = 0;
|
||||
protected:
|
||||
QMap<int, Server_Game *> games;
|
||||
QList<Server_ProtocolHandler *> clients;
|
||||
|
|
|
|||
|
|
@ -179,6 +179,11 @@ ResponseCode Server_Game::checkJoin(ServerInfo_User *user, const QString &_passw
|
|||
return RespWrongPassword;
|
||||
if (!(user->getUserLevel() & ServerInfo_User::IsRegistered) && onlyRegistered)
|
||||
return RespUserLevelTooLow;
|
||||
if (onlyBuddies)
|
||||
if (!static_cast<Server_Room *>(parent())->getServer()->getBuddyList(creatorInfo->getName()).contains(user->getName()))
|
||||
return RespOnlyBuddies;
|
||||
if (static_cast<Server_Room *>(parent())->getServer()->getIgnoreList(creatorInfo->getName()).contains(user->getName()))
|
||||
return RespOnIgnoreList;
|
||||
if (spectator) {
|
||||
if (!spectatorsAllowed)
|
||||
return RespSpectatorsNotAllowed;
|
||||
|
|
|
|||
|
|
@ -241,12 +241,8 @@ ResponseCode Server_ProtocolHandler::cmdLogin(Command_Login *cmd, CommandContain
|
|||
enqueueProtocolItem(new Event_ServerMessage(server->getLoginMessage()));
|
||||
|
||||
if (authState == PasswordRight) {
|
||||
QList<ServerInfo_User *> _buddyList = server->getBuddyList(userInfo->getName());
|
||||
for (int i = 0; i < _buddyList.size(); ++i)
|
||||
buddyList.insert(_buddyList[i]->getName(), _buddyList[i]);
|
||||
QList<ServerInfo_User *> _ignoreList = server->getIgnoreList(userInfo->getName());
|
||||
for (int i = 0; i < _ignoreList.size(); ++i)
|
||||
ignoreList.insert(_ignoreList[i]->getName(), _ignoreList[i]);
|
||||
buddyList = server->getBuddyList(userInfo->getName());
|
||||
ignoreList = server->getIgnoreList(userInfo->getName());
|
||||
|
||||
// This might not scale very well. Use an extra QMap if it becomes a problem.
|
||||
const QList<Server_Game *> &serverGames = server->getGames();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue