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.");
    }