コード例 #1
0
    // 返回0成功,其他出错
    private int createAcc(string accName, GMUser user, ParamCreatePlayer param)
    {
        bool exists = user.sqlDb.keyStrExists(TableName.PLAYER_ACCOUNT_XIANXIA, "acc", accName, MySqlDbName.DB_XIANXIA);

        if (exists)
        {
            return(RetCode.RET_ACCOUNT_HAS_EXISTS);
        }

        SqlInsertGenerator gen = new SqlInsertGenerator();

        gen.addField("acc", accName, FieldType.TypeString);
        gen.addField("creator", user.m_acc, FieldType.TypeString);
        gen.addField("money", 0, FieldType.TypeNumber);
        gen.addField("moneyType", user.m_moneyType, FieldType.TypeNumber);
        gen.addField("state", PlayerState.STATE_IDLE, FieldType.TypeNumber);
        gen.addField("createTime", DateTime.Now.ToString(ConstDef.DATE_TIME24), FieldType.TypeString);
        gen.addField("createCode", user.m_createCode, FieldType.TypeString);
        gen.addField("aliasName", param.m_aliasName, FieldType.TypeString);
        gen.addField("playerWashRatio", param.m_washRatio, FieldType.TypeNumber);

        string sqlCmd = gen.getResultSql(TableName.PLAYER_ACCOUNT_XIANXIA);
        int    count  = user.sqlDb.executeOp(sqlCmd, MySqlDbName.DB_XIANXIA);

        return(count > 0 ? 0 : RetCode.RET_DB_ERROR);
    }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ParamCreatePlayer param = new ParamCreatePlayer();

            param.m_gmAccount    = Request.QueryString["gmAcc"];
            param.m_gmPwd        = Request.QueryString["gmPwd"];
            param.m_playerAcc    = Request.QueryString["playerAcc"];
            param.m_pwd          = Request.QueryString["playerPwd"];
            param.m_washRatioStr = Request.QueryString["washRatio"];
            param.m_aliasName    = Request.QueryString["aliasName"];
            param.m_sign         = Request.QueryString["sign"];

            if (!param.isParamValid())
            {
                Dictionary <string, object> data = new Dictionary <string, object>();
                data.Add("result", RetCode.RET_PARAM_NOT_VALID);
                Response.Write(Helper.genJsonStr(data));
                return;
            }

            DyOpCreatePlayer dy     = new DyOpCreatePlayer();
            string           retStr = dy.doDyop(param);

            Response.Write(retStr);
        }
コード例 #3
0
    public override string doDyop(object param)
    {
        ParamCreatePlayer p = (ParamCreatePlayer)param;
        bool cres           = createGMUser(p);

        if (!cres)
        {
            return(Helper.genJsonStr(m_retData));
        }
        if (!p.checkSign(m_gmUser))
        {
            m_retData.Add("result", RetCode.RET_SIGN_ERROR);
            return(Helper.genJsonStr(m_retData));
        }

        // 只有API号才可以创建玩家
        if (m_gmUser.m_accType != AccType.ACC_API)
        {
            m_retData.Add("result", RetCode.RET_NO_RIGHT);
            return(Helper.genJsonStr(m_retData));
        }

        // 洗码比的判断
        if (p.m_washRatio < 0 || p.m_washRatio > m_gmUser.m_washRatio)
        {
            m_retData.Add("result", RetCode.RET_PARAM_NOT_VALID);
            return(Helper.genJsonStr(m_retData));
        }

        // 玩家账号由API方拼接,这里进行判定
        // 账号里面需要有前缀
        if (p.m_playerAcc.IndexOf(m_gmUser.m_postfix) != 0)
        {
            m_retData.Add("result", RetCode.RET_ACC_PWD_FORMAT_ERROR);
            return(Helper.genJsonStr(m_retData));
        }
        //string tmpAcc = p.m_playerAcc.Remove(0, m_gmUser.m_postfix.Length);

        if (!Regex.IsMatch(p.m_playerAcc, Exp.ACCOUNT_PLAYER))
        {
            m_retData.Add("result", RetCode.RET_PARAM_NOT_VALID);
            return(Helper.genJsonStr(m_retData));
        }

        if (!Regex.IsMatch(p.m_pwd, Exp.ACCOUNT_PLAYER_PWD))
        {
            m_retData.Add("result", RetCode.RET_PARAM_NOT_VALID);
            return(Helper.genJsonStr(m_retData));
        }

        string error   = "";
        bool   res     = createAccToServer(p.m_playerAcc, p.m_pwd, ref error);
        int    retCode = RetCode.RET_OP_FAILED;

        if (res || error == "-12")
        {
            retCode = createAcc(p.m_playerAcc, m_gmUser, p);
        }
        else
        {
            /*if (error == "-12") // 该账号已存在
             * {
             *  m_retData.Add("result", RetCode.RET_ACCOUNT_HAS_EXISTS);
             * }*/
            if (error == "-11") // 数据库出错了
            {
                retCode = RetCode.RET_DB_ERROR;
                //m_retData.Add("result", RetCode.RET_DB_ERROR);
            }
            else if (error == "-14" || error == "-20") // 账号密码格式不对
            {
                retCode = RetCode.RET_ACC_PWD_FORMAT_ERROR;
                //m_retData.Add("result", RetCode.RET_ACC_PWD_FORMAT_ERROR);
            }
        }

        //if (res)
        {
            if (retCode == RetCode.RET_SUCCESS)
            {
                m_retData.Add("result", RetCode.RET_SUCCESS);
                m_retData.Add("playerAcc", p.m_playerAcc);
            }
            else
            {
                m_retData.Add("result", retCode);
            }
        }

        return(Helper.genJsonStr(m_retData));
    }