Ejemplo n.º 1
1
        public bool GetValue(int row, int col, ref VarList.VarData result)
        {
            if (row < 0 || col < 0 || row >= GetRowCount() || col >= GetColcount())
            {
                //Log.Trace("Error,GameRecord.GetValue row or col out of range:");
                return(false);
            }

            try
            {
                VarList rowItem = rowSet[row];
                if (rowItem == null)
                {
                    return(false);
                }

                if (rowItem.GetCount() != GetColcount())
                {
                    //Log.Trace("Error,GameRecord.GetValue Col Error:");
                    return(false);
                }

                switch (colTypes[col])
                {
                case VarType.Bool:
                {
                    bool value = rowItem.GetBool(col);
                    result.Data = value;
                }

                break;

                case VarType.Int:
                {
                    int value = rowItem.GetInt(col);
                    result.Data = value;
                }
                break;

                case VarType.Int64:
                {
                    long value = rowItem.GetInt64(col);
                    result.Data = value;
                }
                break;

                case VarType.Float:
                {
                    float value = rowItem.GetFloat(col);
                    result.Data = value;
                }
                break;

                case VarType.Double:
                {
                    double value = rowItem.GetDouble(col);
                    result.Data = value;
                }
                break;

                case VarType.String:
                {
                    string value = rowItem.GetString(col);
                    result.Data = value;
                }
                break;

                case VarType.WideStr:
                {
                    string value = rowItem.GetWideStr(col);
                    result.Data = value;
                }
                break;

                case VarType.Object:
                {
                    ObjectID value = rowItem.GetObject(col);
                    if (value.IsNull())
                    {
                        //Log.Trace("Error,GameRecord.GetValue objid is null:");
                        return(false);
                    }
                    result.Data = value;
                }
                break;

                default:
                    //Log.Trace("Error,GameRecord.GetValue type error:");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                //Log.Trace("Error,GameRecord.GetValue Exception:" + ex.ToString());
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
1
        public int FindRow(int col, VarList.VarData key, int begRow, bool ignoreCase)
        {
            if (col >= GetColcount())
            {
                return(-1);
            }

            if (null == key)
            {
                return(-1);
            }

            int row_num = GetRowCount();

            if (begRow > row_num)
            {
                return(-1);
            }

            int nColType = GetColType(col);

            if (0 == nColType)
            {
                return(-1);
            }

            for (int i = begRow; i < row_num; i++)
            {
                VarList rowValueItem = rowSet[i];
                if (null == rowValueItem || 0 == rowValueItem.GetCount())
                {
                    return(-1);
                }

                switch (nColType)
                {
                case VarType.Bool:
                    if (rowValueItem.GetBool(col) == (bool)key.Data)
                    {
                        return(i);
                    }
                    break;

                case VarType.Int:
                    if (rowValueItem.GetInt(col) == (int)key.Data)
                    {
                        return(i);
                    }
                    break;

                case VarType.Int64:
                    if (rowValueItem.GetInt64(col) == (long)key.Data)
                    {
                        return(i);
                    }
                    break;

                case VarType.Float:
                    if (Tools.FloatEqual(rowValueItem.GetFloat(col), (float)key.Data))
                    {
                        return(i);
                    }
                    break;

                case VarType.Double:
                    if (Tools.DoubleEqual(rowValueItem.GetDouble(col), (double)key.Data))
                    {
                        return(i);
                    }
                    break;

                case VarType.String:
                    if (0 == String.Compare(rowValueItem.GetString(col), key.Data as string, ignoreCase))
                    {
                        return(i);
                    }
                    break;

                case VarType.WideStr:
                    if (0 == String.Compare(rowValueItem.GetWideStr(col), key.Data as string, ignoreCase))
                    {
                        return(i);
                    }
                    break;

                case VarType.Object:
                    if (rowValueItem.GetObject(col).Equals(key.Data as ObjectID))
                    {
                        return(i);
                    }
                    break;

                default:
                    break;
                }
            }
            return(-1);
        }
Ejemplo n.º 3
0
        public bool GetDouble(int row, int col, ref double dValue)
        {
            if (row < 0 || col < 0 || row >= GetRowCount() || col >= GetColcount())
            {
                LogSystem.Log("Error,GameRecord.GetValue row or col out of range:");
                return(false);
            }

            try
            {
                VarList rowItem = rowSet[row];

                if (colTypes[col] == VarType.Int)
                {
                    dValue = rowItem.GetDouble(col);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LogSystem.LogError(ex.ToString());
                return(false);
            }

            return(false);
        }
Ejemplo n.º 4
0
    /// <summary>
    /// 自动根据类型读取index位置的数据 返回值为string
    /// </summary>
    /// <param name="args"></param>
    /// <param name="index"></param>
    /// <returns></returns>
    public static string GetVarList(VarList args, int index)
    {
        int type = args.GetType(index);

        switch (type)
        {
        case VarType.Bool:
            return(args.GetBool(index) ? "true" : "false");

        case VarType.Int:
            return(args.GetInt(index).ToString());

        case VarType.String:
            return(args.GetString(index));

        case VarType.WideStr:
            return(args.GetWideStr(index));

        case VarType.Object:
            return(args.GetObject(index).ToString());

        case VarType.Float:
            return(args.GetFloat(index).ToString());

        case VarType.Double:
            return(args.GetDouble(index).ToString());

        case VarType.Int64:
            return(args.GetInt64(index).ToString());

        default:
            return("null");
        }
    }
Ejemplo n.º 5
0
        public bool AddMsgVarList(StoreArchive ar, VarList args, int beg, int end)
        {
            try
            {
                for (int i = beg; i < end; ++i)
                {
                    switch (args.GetType(i))
                    {
                    case VarType.Int:
                        ar.WriteInt8(VarType.Int);
                        ar.WriteInt32(args.GetInt(i));
                        break;

                    case VarType.Int64:
                        ar.WriteInt8(VarType.Int64);
                        ar.WriteInt64(args.GetInt64(i));
                        break;

                    case VarType.Float:
                        ar.WriteInt8(VarType.Float);
                        ar.WriteFloat(args.GetFloat(i));
                        break;

                    case VarType.Double:
                        ar.WriteInt8(VarType.Double);
                        ar.WriteDouble(args.GetDouble(i));
                        break;

                    case VarType.String:
                        ar.WriteInt8(VarType.String);
                        ar.WriteString(args.GetString(i));
                        break;

                    case VarType.WideStr:
                        ar.WriteInt8(VarType.WideStr);
                        ar.WriteWideStr(args.GetWideStr(i));
                        break;

                    case VarType.Object:
                        ar.WriteInt8(VarType.Object);
                        ar.WriteObject(args.GetObject(i));
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                LogSystem.LogError(ex.ToString());
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
        public double QueryDouble(int row, int col)
        {
            if (row >= GetRows() || col >= GetColCount())
            {
                return(0.0);
            }

            VarList row_value = (VarList)rowSet[row];

            if (row_value.GetType(col) != VarType.Double)
            {
                return(0.0);
            }
            return(row_value.GetDouble(col));
        }
Ejemplo n.º 7
0
    /// <summary>
    /// 赋值VarList
    /// </summary>
    /// <param name="args"></param>
    /// <param name="index"></param>
    /// <param name="newList"></param>
    public static void CopyVarList(ref VarList args, ref VarList newList, int start, int count)
    {
        int index = start;

        for (; index < args.GetCount() && count > 0; index++, count--)
        {
            int type = args.GetType(index);

            switch (type)
            {
            case VarType.Bool:
                newList.AddBool(args.GetBool(index));
                break;

            case VarType.Int:
                newList.AddInt(args.GetInt(index));
                break;

            case VarType.String:
                newList.AddString(args.GetString(index));
                break;

            case VarType.WideStr:
                newList.AddWideStr(args.GetWideStr(index));
                break;

            case VarType.Object:
                newList.AddObject(args.GetObject(index));
                break;

            case VarType.Float:
                newList.AddFloat(args.GetFloat(index));
                break;

            case VarType.Double:
                newList.AddDouble(args.GetDouble(index));
                break;

            case VarType.Int64:
                newList.AddInt64(args.GetInt64(index));
                break;
            }
        }
    }
Ejemplo n.º 8
0
        public int FindDouble(int col, double key, int begRow = 0, bool ignoreCase = true)
        {
            if (col >= GetColcount())
            {
                return(-1);
            }

            int row_num = GetRowCount();

            if (begRow > row_num)
            {
                return(-1);
            }

            int nColType = GetColType(col);

            if (VarType.Double != nColType)
            {
                return(-1);
            }

            for (int i = begRow; i < row_num; i++)
            {
                VarList rowValueItem = rowSet[i];
                if (null == rowValueItem || 0 == rowValueItem.GetCount())
                {
                    return(-1);
                }
                if (rowValueItem.GetDouble(col) == key)
                {
                    return(i);
                }
            }

            return(-1);
        }
Ejemplo n.º 9
0
        public void GetRoleInfo(ref VarList args, ref VarList ret)
        {
            try
            {
                if (mRoles == null || mRoles.Count == 0)
                {
                    return;
                }

                if (args == null || ret == null)
                {
                    return;
                }

                if (args.GetCount() == 0)
                {
                    return;
                }

                if (args.GetType(0) != VarType.Int)
                {
                    return;
                }

                int nIndex = args.GetInt(0);
                if (nIndex >= mRoles.Count)
                {
                    return;
                }

                VarList paraList = mRoles[nIndex].paraList;
                for (int i = 0; i < paraList.GetCount(); i++)
                {
                    switch (paraList.GetType(i))
                    {
                    case VarType.Bool:
                    {
                        ret.AddBool(paraList.GetBool(i));
                    }
                    break;

                    case VarType.Int:
                    {
                        ret.AddInt(paraList.GetInt(i));
                    }
                    break;

                    case VarType.Int64:
                    {
                        ret.AddInt64(paraList.GetInt64(i));
                    }
                    break;

                    case VarType.Float:
                    {
                        ret.AddFloat(paraList.GetFloat(i));
                    }
                    break;

                    case VarType.Double:
                    {
                        ret.AddDouble(paraList.GetDouble(i));
                    }
                    break;

                    case VarType.String:
                    {
                        ret.AddString(paraList.GetString(i));
                    }
                    break;

                    case VarType.WideStr:
                    {
                        ret.AddWideStr(paraList.GetWideStr(i));
                    }
                    break;

                    case VarType.Object:
                    {
                        ret.AddObject(paraList.GetObject(i));
                    }
                    break;

                    default:
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                //Log.Trace("GameReceiver.GetRoleInfo Exception:" + ex.ToString());
            }
            return;
        }
Ejemplo n.º 10
0
        bool AddMsgVarList(ref byte[] data, ref int index, ref VarList args,
                           int beg, int end)
        {
            try
            {
                for (int i = beg; i < end; i++)
                {
                    switch (args.GetType(i))
                    {
                    case VarType.Int:
                    {
                        WriteInt8(ref data, ref index, VarType.Int);
                        WriteInt32(ref data, ref index, (uint)args.GetInt(i));
                    }
                    break;

                    case VarType.Int64:
                    {
                        WriteInt8(ref data, ref index, VarType.Int64);
                        WriteInt64(ref data, ref index, args.GetInt64(i));
                    }
                    break;

                    case VarType.Float:
                    {
                        WriteInt8(ref data, ref index, VarType.Float);
                        WriteFloat(ref data, ref index, args.GetFloat(i));
                    }
                    break;

                    case VarType.Double:
                    {
                        WriteInt8(ref data, ref index, VarType.Double);
                        WriteDouble(ref data, ref index, args.GetDouble(i));
                    }
                    break;

                    case VarType.String:
                    {
                        WriteInt8(ref data, ref index, VarType.String);
                        WriteString(ref data, ref index, args.GetString(i));
                    }
                    break;

                    case VarType.WideStr:
                    {
                        WriteInt8(ref data, ref index, VarType.WideStr);
                        WriteWideStr(ref data, ref index, args.GetWideStr(i));
                    }
                    break;

                    case VarType.Object:
                    {
                        WriteInt8(ref data, ref index, VarType.Object);
                        WriteObject(ref data, ref index, args.GetObject(i));
                    }
                    break;

                    default:
                        //Log.Trace("unkown data type");
                        break;
                    } //end switch
                }     //end for
            }
            catch (Exception ex)
            {
                //Log.Trace("Exception:" + ex.ToString());
                return(false);
            }//end try catch
            return(true);
        }
Ejemplo n.º 11
0
        //增加一行数据到客户端
        public int AddRowValue(int row, VarList rowValue)
        {
            int newRow = AddRow(row);

            for (int i = 0; i < colTypes.Count; i++)
            {
                int nColType = colTypes[i];
                switch (nColType)
                {
                case VarType.Bool:
                {
                    SetValue(newRow, i, rowValue.GetBool(i));
                }
                break;

                case VarType.Int:
                {
                    SetValue(newRow, i, rowValue.GetInt(i));
                }
                break;

                case VarType.Int64:
                {
                    SetValue(newRow, i, rowValue.GetInt64(i));
                }
                break;

                case VarType.Float:
                {
                    SetValue(newRow, i, rowValue.GetFloat(i));
                }
                break;

                case VarType.Double:
                {
                    SetValue(newRow, i, rowValue.GetDouble(i));
                }
                break;

                case VarType.String:
                {
                    SetValue(newRow, i, rowValue.GetString(i));
                }
                break;

                case VarType.WideStr:
                {
                    SetValue(newRow, i, rowValue.GetWideStr(i));
                }
                break;

                case VarType.Object:
                {
                    SetValue(newRow, i, rowValue.GetObject(i));
                }
                break;

                default:
                    break;
                }
            }
            return(newRow);
        }
Ejemplo n.º 12
0
        public bool GetValue(int row, int col, ref Var result)
        {
            if (row < 0 || col < 0 || row >= GetRowCount() || col >= GetColcount())
            {
                return(false);
            }

            try
            {
                VarList rowItem = rowSet[row];


                if (rowItem.GetCount() != GetColcount())
                {
                    LogSystem.Log("Error,GameRecord.GetValue Col Error:");
                    return(false);
                }

                switch (colTypes[col])
                {
                case VarType.Bool:
                {
                    bool value = rowItem.GetBool(col);
                    result.SetBool(value);
                }

                break;

                case VarType.Int:
                {
                    int value = rowItem.GetInt(col);
                    result.SetInt(value);
                }
                break;

                case VarType.Int64:
                {
                    long value = rowItem.GetInt64(col);
                    result.SetInt64(value);
                }
                break;

                case VarType.Float:
                {
                    float value = rowItem.GetFloat(col);
                    result.SetFloat(value);
                }
                break;

                case VarType.Double:
                {
                    double value = rowItem.GetDouble(col);
                    result.SetDouble(value);
                }
                break;

                case VarType.String:
                {
                    string value = rowItem.GetString(col);
                    result.SetString(value);
                }
                break;

                case VarType.WideStr:
                {
                    string value = rowItem.GetWideStr(col);
                    result.SetWideStr(value);
                }
                break;

                case VarType.Object:
                {
                    ObjectID objId = rowItem.GetObject(col);
                    if (objId == null || objId.IsNull())
                    {
                        LogSystem.Log("Error,GameRecord.GetValue objid is null:");
                        return(false);
                    }
                    result.SetObject(objId);
                }
                break;

                default:
                    LogSystem.Log("Error,GameRecord.GetValue type error:");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LogSystem.Log("Error,GameRecord.GetValue Exception:", ex.ToString());
                return(false);
            }

            return(true);
        }
Ejemplo n.º 13
0
        bool AddMsgVarList(ref StoreArchive storeAr, ref VarList args,
                           int beg, int end)
        {
            try
            {
                for (int i = beg; i < end; i++)
                {
                    switch (args.GetType(i))
                    {
                    case VarType.Int:
                    {
                        storeAr.WriteInt8(VarType.Int);
                        storeAr.WriteInt32(args.GetInt(i));
                    }
                    break;

                    case VarType.Int64:
                    {
                        storeAr.WriteInt8(VarType.Int64);
                        storeAr.WriteInt64(args.GetInt64(i));
                    }
                    break;

                    case VarType.Float:
                    {
                        storeAr.WriteInt8(VarType.Float);
                        storeAr.WriteFloat(args.GetFloat(i));
                    }
                    break;

                    case VarType.Double:
                    {
                        storeAr.WriteInt8(VarType.Double);
                        storeAr.WriteDouble(args.GetDouble(i));
                    }
                    break;

                    case VarType.String:
                    {
                        storeAr.WriteInt8(VarType.String);
                        storeAr.WriteString(args.GetString(i));
                    }
                    break;

                    case VarType.WideStr:
                    {
                        storeAr.WriteInt8(VarType.WideStr);
                        storeAr.WriteWideStr(args.GetWideStr(i));
                    }
                    break;

                    case VarType.Object:
                    {
                        storeAr.WriteInt8(VarType.Object);
                        storeAr.WriteObject(args.GetObject(i));
                    }
                    break;

                    default:
                        LogSystem.Log("unkown data type");
                        break;
                    } //end switch
                }     //end for
            }
            catch (Exception ex)
            {
                LogSystem.Log("Exception:", ex.ToString());
                return(false);
            }//end try catch
            return(true);
        }