예제 #1
0
    IEnumerator SetFriendNote(string friendName, string groupName, string note, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        LogManager.General.Log(string.Format("'{0}' sets friends list note for '{1}' to '{2}'", player.name, friendName, note));

        // Find friends group
        var selectedGroup = player.friends.GetGroupByName(groupName);

        // Get account ID
        string friendAccountId = null;

        yield return(LobbyGameDB.GetAccountIdByPlayerName(friendName, data => {
            friendAccountId = data;
        }));

        // Error getting account ID?
        if (friendAccountId == null)
        {
            Lobby.RPC("SetFriendNotePlayerDoesntExistError", info.sender, friendName);
            yield break;
        }

        // Remove player from the group
        selectedGroup.friends.Find(friend => friend.accountId == friendAccountId).note = note;

        // Save friends list in database
        yield return(FriendsDB.SetFriends(
                         player.accountId,
                         player.friends,
                         null
                         ));
    }
예제 #2
0
    IEnumerator ClientArtifactEquip(int itemId, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Wait for all actions to execute
        while (player.artifactsEditingFlag)
        {
            yield return(null);
        }

        try {
            var arti = new Artifact(itemId);

            player.artifactsEditingFlag = true;
            if (player.artifactTree.AddArtifact(itemId))
            {
                player.artifactInventory.RemoveArtifact(arti);
                Lobby.RPC("ArtifactEquip", player.peer, itemId);

                // Save changes
                yield return(ArtifactsDB.SetArtifactTree(
                                 player,
                                 player.artifactTree
                                 ));

                yield return(ArtifactsDB.SetArtifactInventory(
                                 player,
                                 player.artifactInventory
                                 ));
            }
        } finally {
            player.artifactsEditingFlag = false;
        }
    }
예제 #3
0
    IEnumerator ClientArtifactDiscard(byte level, byte slotId, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Wait for all actions to execute
        while (player.artifactsEditingFlag)
        {
            yield return(null);
        }

        try {
            player.artifactsEditingFlag = true;
            player.artifactInventory.bags[level].RemoveItemSlot(slotId);
            Lobby.RPC("ArtifactDiscard", player.peer, level, slotId);

            // Save changes
            yield return(ArtifactsDB.SetArtifactTree(
                             player,
                             player.artifactTree
                             ));

            yield return(ArtifactsDB.SetArtifactInventory(
                             player,
                             player.artifactInventory
                             ));
        } finally {
            player.artifactsEditingFlag = false;
        }
    }
    IEnumerator ChangePassword(string newPassword, LobbyMessageInfo info)
    {
        // Get the account
        var player = LobbyServer.GetLobbyPlayer(info);

        // Change name
        LogManager.General.Log("Player '" + player.name + "' has requested to change its password.");
        yield return(StartCoroutine(LobbyGameDB.SetPassword(player, newPassword)));
    }
예제 #5
0
    void ClientInputSettings(string inputSettingsString, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        //LogManager.General.Log("Player '" + player.name + "' sent new input settings");
        InputSettings inputSettings = Jboy.Json.ReadObject <InputSettings>(inputSettingsString);

        SettingsDB.SetInputSettings(player, inputSettings);
    }
예제 #6
0
    void ClientArtifactTree(string jsonTree, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);
        //LogManager.General.Log(jsonTree);

        ArtifactTree tree = Jboy.Json.ReadObject <ArtifactTree>(jsonTree);

        LogManager.General.Log("Player '" + player.name + "' sent new artifact tree " + tree.ToString());
        ArtifactsDB.SetArtifactTree(player, tree);
    }
예제 #7
0
    IEnumerator GuildRepresentRequest(string guildId, bool represent, LobbyMessageInfo info)
    {
        LobbyPlayer player    = LobbyServer.GetLobbyPlayer(info);
        string      accountId = player.accountId;

        // Get guild members from database
        if (!GameDB.guildIdToGuildMembers.ContainsKey(guildId))
        {
            yield return(GuildsDB.GetGuildMembers(guildId));
        }

        var guildMembers = GameDB.guildIdToGuildMembers[guildId];
        var index        = guildMembers.FindIndex(o => o.accountId == accountId);

        if (index == -1)
        {
            Lobby.RPC("GuildRepresentError", info.sender, guildId, represent);
            yield break;
        }

        // Get guild ID list
        if (player.guildList == null)
        {
            yield return(GuildsDB.GetGuildList(accountId, data => {
                if (data == null)
                {
                    player.guildList = new GuildList();
                }
                else
                {
                    player.guildList = data;
                }
            }));
        }

        // Set/unset main guild
        if (represent)
        {
            // Start representing
            player.guildList.mainGuildId = guildId;
        }
        else
        {
            // Stop representing
            if (player.guildList.mainGuildId == guildId)
            {
                player.guildList.mainGuildId = "";
            }
        }

        // Set guild ID list
        yield return(GuildsDB.SetGuildList(accountId, player.guildList));

        Lobby.RPC("GuildRepresentSuccess", info.sender, guildId, represent);
    }
예제 #8
0
    void LeaveQueue(LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Make the player leave the queue
        if (player.LeaveQueue())
        {
            // Let the player know he left the queue
            LogManager.General.Log("'" + player.name + "' left the queue");
            Lobby.RPC("LeftQueue", player.peer);
        }
    }
예제 #9
0
    void ClientCharacterStats(CharacterStats charStats, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        if (!charStats.valid)
        {
            LogManager.General.LogWarning("Detected character stat points hack on player '" + player.name + "'");
            return;
        }

        //LogManager.General.Log("Player '" + player.name + "' sent new character stats " + charStats.ToString());
        TraitsDB.SetCharacterStats(player, charStats);
    }
예제 #10
0
    IEnumerator LeaveInstance(bool gameEnded, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        if (player.inMatch)
        {
            LogManager.General.Log("Player '" + player.name + "' returned from a match");

            if (gameEnded)
            {
                // Send him his new stats
                LobbyGameDB.GetPlayerStats(player);

                // Send him his new artifact inventory
                ArtifactsDB.GetArtifactInventory(player);

                // Update ranking list cache
                if (!player.match.updatedRankingList)
                {
                    RankingsServer.instance.StartRankingListCacheUpdate(player.match);
                    player.match.updatedRankingList = true;
                }
            }

            LeaveMatch(player);
        }
        else if (player.inFFA)
        {
            // Send him his new stats
            //StartCoroutine(lobbyGameDB.GetPlayerStats(player));

            // Update ranking list cache

            /*if(!player.match.updatedRankingList) {
             *      RankingsServer.instance.StartRankingListCacheUpdate(player.match);
             *      player.match.updatedRankingList = true;
             * }*/

            LeaveMatch(player);
        }
        else if (player.inTown || player.inWorld)
        {
            player.gameInstance = null;

            if (AccountManager.Master.IsLoggedIn(player.peer))
            {
                yield return(AccountManager.Master.LogOut(info.sender).WaitUntilDone());
            }
        }
    }
예제 #11
0
    IEnumerator AddFriend(string friendName, string groupName, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        LogManager.General.Log(string.Format("'{0}' added '{1}' to friend list group '{2}'", player.name, friendName, groupName));

        // Find friends group
        var selectedGroup = player.friends.GetGroupByName(groupName);

        // Get account ID
        string friendAccountId = null;

        yield return(LobbyGameDB.GetAccountIdByPlayerName(friendName, data => {
            friendAccountId = data;
        }));

        // Error getting account ID?
        if (friendAccountId == null)
        {
            Lobby.RPC("FriendAddPlayerDoesntExistError", info.sender, friendName);
            yield break;
        }

        // Trying to add yourself?
        if (friendAccountId == player.accountId)
        {
            Lobby.RPC("FriendAddCantAddYourselfError", info.sender, friendName);
            yield break;
        }

        // Already in friends list?
        if (!player.friends.CanAdd(friendAccountId))
        {
            Lobby.RPC("FriendAddAlreadyExistsError", info.sender, friendName);
            yield break;
        }

        // Add player to the group
        selectedGroup.friends.Add(new Friend(friendAccountId));

        // Send new friends list
        player.OnFriendsListLoaded();

        // Save friends list in database
        yield return(FriendsDB.SetFriends(
                         player.accountId,
                         player.friends,
                         null
                         ));
    }
예제 #12
0
    IEnumerator GuildKickRequest(string guildId, string accountId, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Does the player have rights to kick
        if (!Guild.CanKick(guildId, player.accountId))
        {
            Lobby.RPC("GuildKickError", info.sender, guildId, accountId);
            yield break;
        }

        // Kicking is the same as leaving
        yield return(GuildLeaveRequest(guildId, accountId, info));
    }
예제 #13
0
    IEnumerator CrystalBalanceRequest(LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        yield return(DonationsDB.GetPaymentsList(player.accountId, data => {
            if (data == null)
            {
                Lobby.RPC("ReceiveCrystalBalance", player.peer, player.accountId, 0);
            }
            else
            {
                Lobby.RPC("ReceiveCrystalBalance", player.peer, player.accountId, (int)(data.balance * 100));
            }
        }));
    }
예제 #14
0
    IEnumerator RemoveFriendsGroup(string groupName, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        LogManager.General.Log(string.Format("'{0}' removed friends group called '{1}'", player.name, groupName));

        // Remove it
        player.friends.RemoveGroup(groupName);

        // Save friends list in database
        yield return(FriendsDB.SetFriends(
                         player.accountId,
                         player.friends,
                         null
                         ));
    }
예제 #15
0
    void JoinFFARequest(byte playersPerTeam, LobbyMessageInfo info)
    {
        var player = LobbyServer.GetLobbyPlayer(info);

        // If the player is in PvP already, ignore the request
        if (!player.canEnterPvP)
        {
            return;
        }

        // Start new server if needed
        LobbyFFA ffaInstance = LobbyFFA.PickFFAInstance(player);

        // Connect the player once the instance is ready
        StartCoroutine(player.ConnectToGameInstanceDelayed(ffaInstance));
    }
예제 #16
0
    void ClientSkillBuild(SkillBuild build, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // TODO: Check the build for hacks

        SkillBuildsDB.SetSkillBuild(
            player.accountId,
            build,
            data => {
            if (data == null)
            {
                Lobby.RPC("SkillBuildSaveError", info.sender);
            }
        }
            );
    }
예제 #17
0
    void AcceptMatch(bool accept, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        if (player.instanceAwaitingAccept == null)
        {
            return;
        }

        if (accept)
        {
            player.AcceptMatch();
        }
        else
        {
            player.DenyMatch();
        }
    }
예제 #18
0
    void ClientCharacterCustomization(CharacterCustomization custom, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        LogManager.General.Log(string.Format("Account '{0}' sent character customization!", player.account.name));

        CharacterCustomizationDB.SetCharacterCustomization(
            player.accountId,
            custom,
            data => {
            if (data != null)
            {
                player.custom = data;
                Lobby.RPC("ReceiveCharacterCustomization", player.peer, player.accountId, player.custom);
            }
        }
            );
    }
예제 #19
0
    IEnumerator GuildDisbandRequest(string guildId, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Get guild members from database
        if (!GameDB.guildIdToGuildMembers.ContainsKey(guildId))
        {
            yield return(GuildsDB.GetGuildMembers(guildId));
        }

        // Does the player have rights to disband?
        if (!Guild.CanDisband(guildId, player.accountId))
        {
            Lobby.RPC("GuildDisbandError", info.sender, guildId);
            yield break;
        }

        // We checked whether the player has the right to disband the guild.
        // Now we need to do this:

        // 1.) Remove the guild from the players' guild list (AccountToGuilds).
        // 2.) Remove the member list for that guild (GuildToMembers).
        // 3.) Remove the guild entry itself (Guilds).
        // 4.) Remove the cache data about that guild (automatically done in 2 and 3).

        // 1.) Remove the guild from the players' guild list (AccountToGuilds)
        foreach (GuildMember member in GameDB.guildIdToGuildMembers[guildId])
        {
            // Update guild ID list
            StartCoroutine(RemoveGuildFromGuildList(guildId, member.accountId, info.sender));
        }

        // 2.) Remove the member list for that guild (GuildToMembers)
        yield return(GuildsDB.RemoveGuildMembers(guildId));

        // 3.) Remove the guild entry itself (Guilds)
        yield return(GuildsDB.RemoveGuild(guildId));

        // Notify the player who requested it
        Lobby.RPC("GuildDisbandSuccess", info.sender, guildId);
    }
예제 #20
0
    IEnumerator GuildInvitationsListRequest(LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Get guild invitations
        if (player.guildInvitations == null)
        {
            yield return(GuildsDB.GetGuildInvitations(player.accountId, data => {
                if (data == null)
                {
                    player.guildInvitations = new List <string>();
                }
                else
                {
                    player.guildInvitations = data;
                }
            }));
        }

        Lobby.RPC("ReceiveGuildInvitationsList", player.peer, player.guildInvitations.ToArray(), true);
    }
예제 #21
0
    void EnterQueue(byte playersPerTeam, LobbyMessageInfo info)
    {
        // Check for correct team size
        if (playersPerTeam == 0 || playersPerTeam > 5)
        {
            return;
        }

        var player = LobbyServer.GetLobbyPlayer(info);

        // Do we have ranking information?
        if (player.stats == null)
        {
            return;
        }

        if (!player.canEnterPvP)
        {
            return;
        }

        var enteredQueue = queue[playersPerTeam - 1];

        // Add the player to the queue
        if (enteredQueue.AddPlayer(player))
        {
            // Let the player know he entered the queue
            LogManager.General.Log("Added '" + player.name + "' to " + playersPerTeam + "v" + playersPerTeam + " queue");
            Lobby.RPC("EnteredQueue", player.peer, playersPerTeam);

            // Make matches as new players joined
            if (LobbyInstanceManager.uZoneNodeCount > 0)
            {
                enteredQueue.MakeMatchesBasedOnRanking();
            }
        }
    }
예제 #22
0
    IEnumerator ClientArtifactUnequip(byte level, byte slotIndex, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Wait for all actions to execute
        while (player.artifactsEditingFlag)
        {
            yield return(null);
        }

        var slot = player.artifactTree.slots[level][slotIndex];

        if (slot.artifact == null)
        {
            yield break;
        }

        try {
            player.artifactsEditingFlag = true;
            player.artifactInventory.AddArtifact(slot.artifact);
            slot.artifact = null;
            Lobby.RPC("ArtifactUnequip", player.peer, level, slotIndex);

            // Save changes
            yield return(ArtifactsDB.SetArtifactTree(
                             player,
                             player.artifactTree
                             ));

            yield return(ArtifactsDB.SetArtifactInventory(
                             player,
                             player.artifactInventory
                             ));
        } finally {
            player.artifactsEditingFlag = false;
        }
    }
예제 #23
0
    void GuildListRequest(LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        if (player.guildList == null)
        {
            GuildsDB.GetGuildList(player.accountId, data => {
                if (data == null)
                {
                    player.guildList = new GuildList();
                }
                else
                {
                    player.guildList = data;
                }

                GuildsServer.SendGuildList(player);
            });
        }
        else
        {
            GuildsServer.SendGuildList(player);
        }
    }
예제 #24
0
    IEnumerator RemoveFriend(string friendName, string groupName, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        LogManager.General.Log(string.Format("'{0}' removed '{1}' from friend list group '{2}'", player.name, friendName, groupName));

        // Find friends group
        var selectedGroup = player.friends.GetGroupByName(groupName);

        // Get account ID
        string friendAccountId = null;

        yield return(LobbyGameDB.GetAccountIdByPlayerName(friendName, data => {
            friendAccountId = data;
        }));

        // Error getting account ID?
        if (friendAccountId == null)
        {
            Lobby.RPC("FriendRemovePlayerDoesntExistError", info.sender, friendName);
            yield break;
        }

        // Remove player from the group
        selectedGroup.friends.RemoveAll(friend => friend.accountId == friendAccountId);

        // Send new friends list
        player.OnFriendsListLoaded();

        // Save friends list in database
        yield return(FriendsDB.SetFriends(
                         player.accountId,
                         player.friends,
                         null
                         ));
    }
예제 #25
0
    IEnumerator GuildInvitationRequest(string guildId, string playerName, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Check if the player has guild invitation rights
        if (!Guild.CanInvite(guildId, player.accountId))
        {
            Lobby.RPC("GuildInvitationError", info.sender, playerName);
            yield break;
        }

        List <string> guildInvitations  = null;
        string        accountIdToInvite = null;

        // Get account ID
        yield return(LobbyGameDB.GetAccountIdByPlayerName(playerName, data => {
            accountIdToInvite = data;
        }));

        if (accountIdToInvite == null)
        {
            Lobby.RPC("GuildInvitationPlayerDoesntExistError", info.sender, playerName);
            yield break;
        }

        // Get guild members
        if (!GameDB.guildIdToGuildMembers.ContainsKey(guildId))
        {
            yield return(GuildsDB.GetGuildMembers(guildId));
        }

        // Already a member?
        var guildMembers = GameDB.guildIdToGuildMembers[guildId];

        if (guildMembers.Find(m => m.accountId == accountIdToInvite) != null)
        {
            Lobby.RPC("GuildInvitationAlreadyMember", info.sender, playerName);
            yield break;
        }

        // Get guild invitations
        if (LobbyPlayer.accountIdToLobbyPlayer.ContainsKey(accountIdToInvite))
        {
            guildInvitations = LobbyPlayer.accountIdToLobbyPlayer[accountIdToInvite].guildInvitations;
        }

        if (guildInvitations == null)
        {
            yield return(GuildsDB.GetGuildInvitations(accountIdToInvite, data => {
                if (data == null)
                {
                    guildInvitations = new List <string>();
                }
                else
                {
                    guildInvitations = data;
                }
            }));
        }

        if (guildInvitations == null)
        {
            Lobby.RPC("GuildInvitationError", info.sender, playerName);
            yield break;
        }

        // Guild invitation already sent?
        if (guildInvitations.Contains(guildId))
        {
            Lobby.RPC("GuildInvitationAlreadySent", info.sender, playerName);
            yield break;
        }

        // Add guild to invitation list
        guildInvitations.Add(guildId);

        // Set guild invitations
        yield return(GuildsDB.SetGuildInvitations(accountIdToInvite, guildInvitations, data => {
            if (data == null)
            {
                Lobby.RPC("GuildInvitationError", info.sender, playerName);
            }
            else
            {
                // Notify player if he is online
                if (LobbyPlayer.accountIdToLobbyPlayer.ContainsKey(accountIdToInvite))
                {
                    var invitedPlayer = LobbyPlayer.accountIdToLobbyPlayer[accountIdToInvite];
                    invitedPlayer.guildInvitations = data;
                    Lobby.RPC("ReceiveGuildInvitationsList", invitedPlayer.peer, invitedPlayer.guildInvitations.ToArray(), true);
                }

                Lobby.RPC("GuildInvitationSuccess", info.sender, playerName);
            }
        }));
    }
예제 #26
0
    IEnumerator GuildInvitationResponse(string guildId, bool accepted, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Get guild invitations
        if (player.guildInvitations == null)
        {
            yield return(GuildsDB.GetGuildInvitations(player.accountId, data => {
                if (data == null)
                {
                    player.guildInvitations = new List <string>();
                }
                else
                {
                    player.guildInvitations = data;
                }
            }));
        }

        if (player.guildInvitations == null)
        {
            Lobby.RPC("GuildInvitationResponseError", info.sender, guildId);
            yield break;
        }

        // Were you invited?
        if (!player.guildInvitations.Contains(guildId))
        {
            Lobby.RPC("GuildInvitationResponseError", info.sender, guildId);
            yield break;
        }

        // Did the player accept the invitation?
        if (accepted)
        {
            // Get guild members from database
            if (!GameDB.guildIdToGuildMembers.ContainsKey(guildId))
            {
                yield return(GuildsDB.GetGuildMembers(guildId));
            }

            var guildMembers = GameDB.guildIdToGuildMembers[guildId];
            guildMembers.Add(new GuildMember(player.accountId, player.name, (byte)GuildMember.Rank.Default));

            // Set guild members
            yield return(GuildsDB.SetGuildMembers(guildId, guildMembers));

            // Get guild ID list
            if (player.guildList == null)
            {
                yield return(GuildsDB.GetGuildList(player.accountId, data => {
                    if (data == null)
                    {
                        player.guildList = new GuildList();
                    }
                    else
                    {
                        player.guildList = data;
                    }
                }));
            }

            // Add to guild ID list
            player.guildList.Add(guildId);

            // Set guild ID list
            yield return(GuildsDB.SetGuildList(player.accountId, player.guildList));

            // Notify all guild members
            SendGuildMemberList(guildId, guildMembers);
        }

        // Remove guild from invitation list
        player.guildInvitations.Remove(guildId);

        // Set guild invitations
        yield return(GuildsDB.SetGuildInvitations(player.accountId, player.guildInvitations, data => {
            if (data == null)
            {
                Lobby.RPC("GuildInvitationResponseError", info.sender, guildId);
            }
            else
            {
                player.guildInvitations = data;
                Lobby.RPC("GuildInvitationResponseSuccess", info.sender, guildId, accepted);
                SendGuildList(player);
            }
        }));
    }
예제 #27
0
    IEnumerator GuildCreationRequest(string name, string tag, LobbyMessageInfo info)
    {
        LobbyPlayer founder = LobbyServer.GetLobbyPlayer(info);

        // Protection against modified RPC packets
        if (!Validator.guildName.IsMatch(name))
        {
            yield break;
        }

        if (!Validator.guildTag.IsMatch(tag))
        {
            yield break;
        }

        // Check if guild name has already been registered
        bool guildNameExists = false;

        yield return(GuildsDB.GetGuildIdByGuildName(name, data => {
            if (data != null)
            {
                guildNameExists = true;
            }
        }));

        if (guildNameExists)
        {
            Lobby.RPC("GuildNameAlreadyExists", info.sender);
            yield break;
        }

        // Store new guild in database
        string guildId = null;
        var    guild   = new Guild(name, tag, founder.accountId);

        yield return(GuildsDB.PutGuild(
                         guild,
                         (key, data) => {
            if (key != null)
            {
                if (founder.guildList == null)
                {
                    founder.guildList = new GuildList();
                }

                guildId = key;
            }
        }
                         ));

        if (guildId == null)
        {
            Lobby.RPC("GuildCreationError", info.sender);
            yield break;
        }

        // Founder joins the guild automatically
        var memberList = new List <GuildMember>();        //GameDB.guildIdToGuildMembers[guildId];

        memberList.Add(new GuildMember(founder.accountId, (byte)GuildMember.Rank.Leader));
        yield return(GuildsDB.SetGuildMembers(guildId, memberList));

        founder.guildList.Add(guildId);

        // Store new guild membership in database
        yield return(GuildsDB.SetGuildList(founder.accountId, founder.guildList));

        // Let the player know that it worked
        Lobby.RPC("GuildCreationSuccess", info.sender);

        // Send him the new guild ID list
        SendGuildList(founder);

        LogManager.General.Log("Guild " + guild + " has been created.");
    }
예제 #28
0
    void InviteToParty(string invitedPlayerName, LobbyMessageInfo info)
    {
        var player = LobbyServer.GetLobbyPlayer(info);

        LogManager.General.Log(string.Format("'{0}' sent a party invitation to '{1}'", player.name, invitedPlayerName));
    }
예제 #29
0
    void ClientChat(string channelName, string msg, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Command?
        if (ProcessLobbyChatCommands(player, msg))
        {
            LogManager.Chat.Log("Lobby chat command: [" + channelName + "][" + player.name + "] '" + msg + "'");
            return;
        }

        // Add instance to channel name
        if (channelName == "Map")
        {
            if (player.canUseMapChat)
            {
                var instance = player.instance;

                if (instance == null)
                {
                    LogManager.Chat.LogError("Player instance is null on [" + channelName + "][" + player.name + "] '" + msg + "'");
                    return;
                }

                var postfix = instance.node.publicAddress + ":" + instance.port;
                channelName += "@" + postfix;
            }
            else
            {
                LogManager.Chat.LogError("Player tries to use map chat while not being in an instance [" + channelName + "][" + player.name + "] '" + msg + "'");
                LogManager.Chat.LogError(player.gameInstance.ToString());
                return;
            }
        }

        // Log all chat tries
        LogManager.Chat.Log("[" + channelName + "][" + player.name + "] '" + msg + "'");

        // Access level?
        if (channelName == "Announcement" && player.accessLevel < AccessLevel.CommunityManager)
        {
            LogManager.Chat.LogError("Player tried to chat in announcement channel without having the rights for it!");
            return;
        }

        // Does the channel exist?
        if (!LobbyChatChannel.channels.ContainsKey(channelName))
        {
            LogManager.Chat.LogError(string.Format("Channel '{0}' does not exist in the global channel list!", channelName));
            return;
        }

        var channel = LobbyChatChannel.channels[channelName];

        // Channel member?
        if (!channel.members.Contains(player))
        {
            LogManager.Chat.LogError(string.Format("Player '{0}' is not a member of chat channel '{1}'!", player.name, channelName));
            return;
        }

        // Broadcast message
        channel.BroadcastMessage(player.name, msg);
    }