Exemplo n.º 1
0
        //用 初始化类各成员
        public bool initOuterPost(ref LoadArchive loadAr)
        {
            float xTemp      = 0.0f;
            float yTemp      = 0.0f;
            float zTemp      = 0.0f;
            float orientTemp = 0.0f;

            if (!loadAr.ReadFloat(ref xTemp))
            {
                return(false);
            }
            this.x = xTemp;

            if (!loadAr.ReadFloat(ref yTemp))
            {
                return(false);
            }
            this.y = yTemp;

            if (!loadAr.ReadFloat(ref zTemp))
            {
                return(false);
            }
            this.z = zTemp;

            if (!loadAr.ReadFloat(ref orientTemp))
            {
                return(false);
            }
            this.orient = orientTemp;

            return(true);
        }
Exemplo n.º 2
0
        private bool InnerParsePropValue(LoadArchive loadAr, int type, ref Var key)
        {
            switch (type)
            {
            case OuterDataType.OUTER_TYPE_BYTE:
            {
                int value = 0;
                if (!loadAr.ReadInt8(ref value))
                {
                    return(false);
                }
                key.SetInt(value);
            }
            break;

            case OuterDataType.OUTER_TYPE_WORD:
            {
                int value = 0;
                if (!loadAr.ReadInt16(ref value))
                {
                    return(false);
                }
                key.SetInt(value);
            }
            break;

            case OuterDataType.OUTER_TYPE_DWORD:
            {
                int value = 0;
                if (!loadAr.ReadInt32(ref value))
                {
                    return(false);
                }
                key.SetInt(value);
            }
            break;

            case OuterDataType.OUTER_TYPE_QWORD:
            {
                long value = 0;
                if (!loadAr.ReadInt64(ref value))
                {
                    return(false);
                }
                key.SetInt64(value);
            }
            break;

            case OuterDataType.OUTER_TYPE_FLOAT:
            {
                float value = 0.0f;
                if (!loadAr.ReadFloat(ref value))
                {
                    return(false);
                }
                key.SetFloat(value);
            }
            break;

            case OuterDataType.OUTER_TYPE_DOUBLE:
            {
                double value = 0.0;
                if (!loadAr.ReadDouble(ref value))
                {
                    return(false);
                }
                key.SetDouble(value);
            }
            break;

            case OuterDataType.OUTER_TYPE_STRING:
            {
                string value = string.Empty;
                if (!loadAr.ReadString(ref value))
                {
                    return(false);
                }
                key.SetString(value);
            }
            break;

            case OuterDataType.OUTER_TYPE_WIDESTR:
            {
                string value = string.Empty;
                if (!loadAr.ReadWideStr(ref value))
                {
                    return(false);
                }
                key.SetWideStr(value);
            }
            break;

            case OuterDataType.OUTER_TYPE_OBJECT:
            {
                ObjectID value = ObjectID.zero;

                if (!loadAr.ReadObject(ref value))
                {
                    return(false);
                }
                key.SetObject(value);
            }
            break;

            default:
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        //读取数据
        public static bool ReadData(ref LoadArchive loadAr, int nDataType, ref object obj)
        {
            switch (nDataType)
            {
            case OuterDataType.OUTER_TYPE_UNKNOWN:
            {
                LogSystem.LogError("Tools::ReadData nDataType error");
                return(false);
            }

            // break;
            case OuterDataType.OUTER_TYPE_BYTE:
            {
                int value = 0;
                if (!loadAr.ReadInt8(ref value))
                {
                    LogSystem.LogError("Read OUTER_TYPE_BYTE error");
                }
            }
            break;

            case OuterDataType.OUTER_TYPE_WORD:
            {
                int value = 0;
                if (!loadAr.ReadInt16(ref value))
                {
                    LogSystem.LogError("Read OUTER_TYPE_WORD error");
                }
            }
            break;

            case OuterDataType.OUTER_TYPE_DWORD:
            {
                int value = 0;
                if (!loadAr.ReadInt32(ref value))
                {
                    LogSystem.LogError("Read OUTER_TYPE_DWORD error");
                }
            }
            break;

            case OuterDataType.OUTER_TYPE_QWORD:
            {
                long value = 0;
                if (!loadAr.ReadInt64(ref value))
                {
                    LogSystem.LogError("Read OUTER_TYPE_QWORD error");
                }
            }
            break;

            case OuterDataType.OUTER_TYPE_FLOAT:
            {
                float value = 0.0f;
                if (!loadAr.ReadFloat(ref value))
                {
                    LogSystem.LogError("Read OUTER_TYPE_FLOAT error");
                }
            }
            break;

            case OuterDataType.OUTER_TYPE_DOUBLE:
            {
                double value = 0.0f;
                if (!loadAr.ReadDouble(ref value))
                {
                    LogSystem.LogError("Read OUTER_TYPE_DOUBLE error");
                }
            }
            break;

            case OuterDataType.OUTER_TYPE_STRING:
            {
                string value = string.Empty;
                if (!loadAr.ReadString(ref value))
                {
                    LogSystem.LogError("Read OUTER_TYPE_STRING error");
                }
            }
            break;

            case OuterDataType.OUTER_TYPE_WIDESTR:
            {
                string value = string.Empty;
                if (!loadAr.ReadWideStr(ref value))
                {
                    LogSystem.LogError("Read OUTER_TYPE_WIDESTR error");
                }
            }
            break;

            case OuterDataType.OUTER_TYPE_OBJECT:
            {
                ObjectID value = ObjectID.zero;

                if (!loadAr.ReadObject(ref value))
                {
                    LogSystem.LogError("Read OUTER_TYPE_WIDESTR error");
                }
            }
            break;

            default:
                LogSystem.LogError("unkwon data type");
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        //用 初始化类各成员
        public bool initOuterDest(ref LoadArchive loadAr)
        {
            float xTemp           = 0.0f;
            float yTemp           = 0.0f;
            float zTemp           = 0.0f;
            float orientTemp      = 0.0f;
            float MoveSpeedTemp   = 0.0f;
            float RotateSpeedTemp = 0.0f;
            float JumpSpeedTemp   = 0.0f;
            // float GravityTemp = 0.0f;
            int ModeTemp = 0;

            if (!loadAr.ReadFloat(ref xTemp))
            {
                return(false);
            }
            this.x = xTemp;

            if (!loadAr.ReadFloat(ref yTemp))
            {
                return(false);
            }
            this.y = yTemp;

            if (!loadAr.ReadFloat(ref zTemp))
            {
                return(false);
            }
            this.z = zTemp;

            if (!loadAr.ReadFloat(ref orientTemp))
            {
                return(false);
            }
            this.orient = orientTemp;


            if (!loadAr.ReadFloat(ref MoveSpeedTemp))
            {
                return(false);
            }
            this.MoveSpeed = MoveSpeedTemp;

            if (!loadAr.ReadFloat(ref RotateSpeedTemp))
            {
                return(false);
            }
            this.RotateSpeed = RotateSpeedTemp;

            if (!loadAr.ReadFloat(ref JumpSpeedTemp))
            {
                return(false);
            }
            this.JumpSpeed = JumpSpeedTemp;

            if (!loadAr.ReadFloat(ref Gravity))
            {
                return(false);
            }
            this.JumpSpeed = Gravity;

            if (!loadAr.ReadInt32(ref ModeTemp))
            {
                return(false);
            }
            this.Mode = ModeTemp;

            return(true);
        }
Exemplo n.º 5
0
        public bool RecvRecordRow(ref GameRecord rec, int index,
                                  ref LoadArchive ar, int row, int count)
        {
            try
            {
                if (rec == null || ar == null)
                {
                    //Log.Trace("rec or ar is null");
                    return(false);
                }

                if (row < 0 || count < 0)
                {
                    //Log.Trace("row or count < 0");
                    return(false);
                }

                if (!mRecordTable.ContainsKey(index))
                {
                    //Log.Trace("record table doesn't contain index:" + index.ToString());
                    return(false);
                }

                int col_count = mRecordTable[index].nCols;

                Var key = new Var();
                for (int i = row; i < (row + count); i++)
                {
                    if (!rec.InsertRow(i))
                    {
                        //Log.Trace("InsertRow failed row =" + i.ToString());
                        return(false);
                    }

                    for (int c = 0; c < col_count; c++)
                    {
                        int nColType = mRecordTable[index].ColTypes[c];
                        switch (nColType)
                        {
                        case OuterDataType.OUTER_TYPE_BYTE:
                        {
                            int value = 0;
                            if (!ar.ReadInt8(ref value))
                            {
                                return(false);
                            }
                            key.SetInt(value);
                        }
                        break;

                        case OuterDataType.OUTER_TYPE_WORD:
                        {
                            int value = 0;
                            if (!ar.ReadInt16(ref value))
                            {
                                return(false);
                            }
                            key.SetInt(value);
                        }
                        break;

                        case OuterDataType.OUTER_TYPE_DWORD:
                        {
                            int value = 0;
                            if (!ar.ReadInt32(ref value))
                            {
                                return(false);
                            }
                            key.SetInt(value);
                        }
                        break;

                        case OuterDataType.OUTER_TYPE_QWORD:
                        {
                            long value = 0;
                            if (!ar.ReadInt64(ref value))
                            {
                                return(false);
                            }
                            key.SetInt64(value);
                        }
                        break;

                        case OuterDataType.OUTER_TYPE_FLOAT:
                        {
                            float value = 0.0f;
                            if (!ar.ReadFloat(ref value))
                            {
                                return(false);
                            }
                            key.SetFloat(value);
                        }
                        break;

                        case OuterDataType.OUTER_TYPE_DOUBLE:
                        {
                            double value = 0.0;
                            if (!ar.ReadDouble(ref value))
                            {
                                return(false);
                            }
                            key.SetDouble(value);
                        }
                        break;

                        case OuterDataType.OUTER_TYPE_STRING:
                        {
                            string value = "";
                            if (!ar.ReadString(ref value))
                            {
                                return(false);
                            }
                            key.SetString(value);
                        }
                        break;

                        case OuterDataType.OUTER_TYPE_WIDESTR:
                        {
                            string value = "";
                            if (!ar.ReadWideStr(ref value))
                            {
                                return(false);
                            }
                            key.SetWideStr(value);
                        }
                        break;

                        case OuterDataType.OUTER_TYPE_OBJECT:
                        {
                            ObjectID value = new ObjectID();
                            if (!ar.ReadObject(ref value))
                            {
                                return(false);
                            }
                            key.SetObject(value);
                        }
                        break;

                        default:
                            //Log.Trace("type error" + rec.GetName());
                            return(false);
                        }//end switch

                        if (!rec.SetValue(i, c, key))
                        {
                            //Log.Trace("set value failed record name :" + rec.GetName());
                            return(false);
                        }
                    } //end(int c = 0;
                }     //end for(int i = row
            }
            catch (Exception ex)
            {
                Log.TraceExcep(ref ex);
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
        public bool RecvRecordGrid(ref GameRecord rec, int isViewObj,
                                   int nIdent, int nSerial, int index, ref LoadArchive loadAr,
                                   int count)
        {
            try
            {
                Var key = new Var();
                for (int i = 0; i < count; i++)
                {
                    int row = 0;
                    int col = 0;
                    if (!loadAr.ReadInt16(ref row))
                    {
                        return(false);
                    }
                    if (!loadAr.ReadInt8(ref col))
                    {
                        return(false);
                    }

                    if (col >= mRecordTable[index].nCols)
                    {
                        //Log.Trace("col error");
                        return(false);
                    }

                    switch (mRecordTable[index].ColTypes[col])
                    {
                    case OuterDataType.OUTER_TYPE_BYTE:
                    {
                        int value = 0;
                        if (!loadAr.ReadInt8(ref value))
                        {
                            return(false);
                        }
                        key.SetInt(value);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_WORD:
                    {
                        int value = 0;
                        if (!loadAr.ReadInt16(ref value))
                        {
                            return(false);
                        }
                        key.SetInt(value);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_DWORD:
                    {
                        int value = 0;
                        if (!loadAr.ReadInt32(ref value))
                        {
                            return(false);
                        }
                        key.SetInt(value);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_QWORD:
                    {
                        long value = 0;
                        if (!loadAr.ReadInt64(ref value))
                        {
                            return(false);
                        }
                        key.SetInt64(value);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_FLOAT:
                    {
                        float value = 0.0f;
                        if (!loadAr.ReadFloat(ref value))
                        {
                            return(false);
                        }
                        key.SetFloat(value);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_DOUBLE:
                    {
                        double value = 0.0;
                        if (!loadAr.ReadDouble(ref value))
                        {
                            return(false);
                        }
                        key.SetDouble(value);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_STRING:
                    {
                        string value = "";
                        if (!loadAr.ReadString(ref value))
                        {
                            return(false);
                        }
                        key.SetString(value);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_WIDESTR:
                    {
                        string value = "";
                        if (!loadAr.ReadWideStr(ref value))
                        {
                            return(false);
                        }
                        key.SetWideStr(value);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_OBJECT:
                    {
                        ObjectID value = new ObjectID();
                        if (!loadAr.ReadObject(ref value))
                        {
                            return(false);
                        }
                        key.SetObject(value);
                    }
                    break;

                    default:
                        //Log.Trace("unknown type record name " + rec.GetName());
                        return(false);
                    }//end switch

                    if (!rec.SetValue(row, col, key))
                    {
                        //Log.Trace("set value error recname " + rec.GetName());
                        return(false);
                    }

                    if (isViewObj == 0)
                    {
                        string  ident   = nIdent.ToString() + "-" + nSerial.ToString();
                        VarList argList = new VarList();
                        argList.AddString(ident);
                        argList.AddString(rec.GetName());
                        argList.AddInt(row);
                        argList.AddInt(col);
                        if (!Excute_CallBack("on_record_single_grid", argList))
                        {
                            //Log.Trace("does not RegistCallBack on_record_single_grid");
                        }
                    }//end if (isViewObj == 0)
                    else if (isViewObj == 3)
                    {
                        string  view_ident = nIdent.ToString();
                        VarList argList    = new VarList();
                        argList.AddString(view_ident);
                        argList.AddString(rec.GetName());
                        argList.AddInt(row);
                        argList.AddInt(col);
                        if (!Excute_CallBack("on_view_record_single_grid", argList))
                        {
                            //Log.Trace("does not RegistCallBack on_view_record_single_grid");
                        }
                    }//end if (isViewObj == 3)
                    else if (isViewObj == 1)
                    {
                        string  view_ident = nIdent.ToString();
                        string  item_ident = nSerial.ToString();
                        VarList argList    = new VarList();
                        argList.AddString(view_ident);
                        argList.AddString(item_ident);
                        argList.AddString(rec.GetName());
                        argList.AddInt(row);
                        argList.AddInt(col);
                        if (!Excute_CallBack("on_viewobj_record_single_grid", argList))
                        {
                            //Log.Trace("does not RegistCallBack on_viewobj_record_single_grid");
                        }
                    }//end if (isViewObj == 1)
                    else if (isViewObj == 2)
                    {
                        VarList argList = new VarList();
                        argList.AddString(rec.GetName());
                        argList.AddInt(row);
                        argList.AddInt(col);
                        if (!Excute_CallBack("on_scene_record_single_grid", argList))
                        {
                            //Log.Trace("does not RegistCallBack on_scene_record_single_grid");
                        }
                    } //end if (isViewObj == 2)
                }     // end for (int i = 0; i < count; i ++ )
            }
            catch (System.Exception ex)
            {
                Log.TraceExcep(ref ex);
                return(false);
            }

            return(true);
        }
Exemplo n.º 7
0
        //读取数据
        public static bool ReadData(ref LoadArchive loadAr, int nDataType, ref object obj)
        {
            switch (nDataType)
            {
            case OuterDataType.OUTER_TYPE_UNKNOWN:
            {
                //Log.TraceError("Tools::ReadData nDataType error");
                return(false);
            }

            // break;
            case OuterDataType.OUTER_TYPE_BYTE:
            {
                int value = 0;
                if (!loadAr.ReadInt8(ref value))
                {
                    //Log.TraceError("Read OUTER_TYPE_BYTE error");
                }
                //				//Log.Trace("Read prop name = [" + propItem.getPropName() + "]"
                //				+ "prop value = [" + value + "]");
            }
            break;

            case OuterDataType.OUTER_TYPE_WORD:
            {
                int value = 0;
                if (!loadAr.ReadInt16(ref value))
                {
                    //Log.TraceError("Read OUTER_TYPE_WORD error");
                }
                //				//Log.Trace("Read prop name = [" + propItem.getPropName() + "]"
                //				+ "prop value = [" + value + "]");
            }
            break;

            case OuterDataType.OUTER_TYPE_DWORD:
            {
                int value = 0;
                if (!loadAr.ReadInt32(ref value))
                {
                    //Log.TraceError("Read OUTER_TYPE_DWORD error");
                }
                //				//Log.Trace("Read prop name = [" + propItem.getPropName() + "]"
                //				+ "prop value = [" + value + "]");
            }
            break;

            case OuterDataType.OUTER_TYPE_QWORD:
            {
                long value = 0;
                if (!loadAr.ReadInt64(ref value))
                {
                    //Log.TraceError("Read OUTER_TYPE_QWORD error");
                }
                //				//Log.Trace("Read prop name = [" + propItem.getPropName() + "]"
                //				+ "prop value = [" + value + "]");
            }
            break;

            case OuterDataType.OUTER_TYPE_FLOAT:
            {
                float value = 0.0f;
                if (!loadAr.ReadFloat(ref value))
                {
                    //Log.TraceError("Read OUTER_TYPE_FLOAT error");
                }
                //				//Log.Trace("Read prop name = [" + propItem.getPropName() + "]"
                //				+ "prop value = [" + value + "]");
            }
            break;

            case OuterDataType.OUTER_TYPE_DOUBLE:
            {
                double value = 0.0f;
                if (!loadAr.ReadDouble(ref value))
                {
                    //Log.TraceError("Read OUTER_TYPE_DOUBLE error");
                }
                //				//Log.Trace("Read prop name = [" + propItem.getPropName() + "]"
                //				+ "prop value = [" + value + "]");
            }
            break;

            case OuterDataType.OUTER_TYPE_STRING:
            {
                string value = "";
                if (!loadAr.ReadString(ref value))
                {
                    //Log.TraceError("Read OUTER_TYPE_STRING error");
                }
                //				//Log.Trace("Read prop name = [" + propItem.getPropName() + "]"
                //				+ "prop value = [" + value + "]");
            }
            break;

            case OuterDataType.OUTER_TYPE_WIDESTR:
            {
                string value = "";
                if (!loadAr.ReadWideStr(ref value))
                {
                    //Log.TraceError("Read OUTER_TYPE_WIDESTR error");
                }
                //				//Log.Trace("Read prop name = [" + propItem.getPropName() + "]"
                //				+ "prop value = [" + value + "]");
            }
            break;

            case OuterDataType.OUTER_TYPE_OBJECT:
            {
                ObjectID value = new ObjectID();
                if (!loadAr.ReadObject(ref value))
                {
                    //Log.TraceError("Read OUTER_TYPE_WIDESTR error");
                }
                //				//Log.Trace("Read prop name = [" + propItem.getPropName() + "]"
                //				+ "prop value = [" + objId.m_nIdent + "." + objId.m_nSerial+"]");
            }
            break;

            default:
                //Log.TraceError("unkwon data type");
                return(false);
            }
            return(true);
        }
Exemplo n.º 8
-1
        private bool InnerParsePropValue(LoadArchive loadAr, int type, ref VarList.VarData key)
        {
            switch (type)
            {
            case OuterDataType.OUTER_TYPE_BYTE:
            {
                int value = 0;
                if (!loadAr.ReadInt8(ref value))
                {
                    return(false);
                }
                key.nType = VarType.Int;
                key.Data  = value;
            }
            break;

            case OuterDataType.OUTER_TYPE_WORD:
            {
                int value = 0;
                if (!loadAr.ReadInt16(ref value))
                {
                    return(false);
                }

                key.nType = VarType.Int;
                key.Data  = value;
            }
            break;

            case OuterDataType.OUTER_TYPE_DWORD:
            {
                int value = 0;
                if (!loadAr.ReadInt32(ref value))
                {
                    return(false);
                }

                key.nType = VarType.Int;
                key.Data  = value;
            }
            break;

            case OuterDataType.OUTER_TYPE_QWORD:
            {
                long value = 0;
                if (!loadAr.ReadInt64(ref value))
                {
                    return(false);
                }
                key.nType = VarType.Int64;
                key.Data  = value;
            }
            break;

            case OuterDataType.OUTER_TYPE_FLOAT:
            {
                float value = 0.0f;
                if (!loadAr.ReadFloat(ref value))
                {
                    return(false);
                }
                key.nType = VarType.Float;
                key.Data  = value;
            }
            break;

            case OuterDataType.OUTER_TYPE_DOUBLE:
            {
                double value = 0.0;
                if (!loadAr.ReadDouble(ref value))
                {
                    return(false);
                }
                key.nType = VarType.Double;
                key.Data  = value;;
            }
            break;

            case OuterDataType.OUTER_TYPE_STRING:
            {
                string value = "";
                if (!loadAr.ReadString(ref value))
                {
                    return(false);
                }
                key.nType = VarType.String;
                key.Data  = value;
            }
            break;

            case OuterDataType.OUTER_TYPE_WIDESTR:
            {
                string value = "";
                if (!loadAr.ReadWideStr(ref value))
                {
                    return(false);
                }

                key.nType = VarType.WideStr;
                key.Data  = value;
            }
            break;

            case OuterDataType.OUTER_TYPE_OBJECT:
            {
                ObjectID value = new ObjectID();
                if (!loadAr.ReadObject(ref value))
                {
                    return(false);
                }

                key.nType = VarType.Object;
                key.Data  = value;
            }
            break;

            default:
                return(false);
            }

            return(true);
        }