Exemple #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);
        }
Exemple #2
0
        private bool InnerRecvProperty(GameObj obj, LoadArchive loadAr, int count, bool change)
        {
            if (obj == null)
            {
                return(false);
            }

            try
            {
                Var key = Var.zero;

                for (int i = 0; i < count; i++)
                {
                    int index = 0;
                    if (!loadAr.ReadInt16(ref index))
                    {
                        return(false);
                    }

                    if (index >= mPropertyTable.Count)
                    {
                        return(false);
                    }

                    PropData propData = GetPropDataByIndex(index);

                    propData.nCount = propData.nCount + 1;

                    if (!InnerParsePropValue(loadAr, propData.nType, ref key))
                    {
                        return(false);
                    }

                    if (!obj.UpdateProperty(ref propData.strName, key))
                    {
                        return(false);
                    }

                    if (change)
                    {
                        VarList argList = VarList.GetVarList();
                        argList.AddString(obj.GetIdent());
                        argList.AddString(propData.strName);
                        Excute_CallBack("on_object_property_change", argList);
                        argList.Collect();
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogSystem.Log("GameReceiver.InnerRecvViewProperty() Exception:", ex.ToString());
            }
            return(true);
        }
Exemple #3
0
 public bool RecvViewProperty(string strViewIdent, ref GameViewObj obj, ref LoadArchive loadAr,
                              int count, bool change)
 {
     try
     {
         return(InnerRecvViewProperty(strViewIdent, obj, loadAr, count, change));
     }
     catch (Exception ex)
     {
         LogSystem.Log("GameReceiver.RecvProperty(GameViewObj) Exception:", ex.ToString());
         return(false);
     }
 }
Exemple #4
0
 public bool RecvProperty(ref GameScene obj, ref LoadArchive loadAr,
                          int count, bool change)
 {
     try
     {
         return(InnerRecvProperty(obj, loadAr, count, change));
     }
     catch (Exception ex)
     {
         LogSystem.Log("GameReceiver.RecvProperty(GameScene) Exception:", ex.ToString());
         return(false);
     }
 }
Exemple #5
0
 public bool RecvProperty(ref GameSceneObj obj, ref LoadArchive loadAr,
                          int count, bool change)
 {
     try
     {
         return(InnerRecvProperty(obj, loadAr, count, change));
     }
     catch (Exception ex)
     {
         //Log.Trace("GameReceiver.RecvProperty Exception:" + ex.ToString());
         return(false);
     }
 }
        /// <summary>
        /// 服务器定位消息
        /// </summary>
        /// <param name="data"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        private int proc_server_location(ref Byte[] data, int len)
        {
            if (len < 16)
            {
                return(len);
            }

            LoadArchive arLoad = LoadArchive.Load(data, len);
            // Byte[] buffer = new Byte[1024];
            StoreArchive arStore = StoreArchive.Load(m_pBuffer_SP, 4096);

            uint nMsgType = 0;

            arLoad.ReadUInt8(ref nMsgType);
            arStore.WriteUInt8(nMsgType);

            ObjectID objectId = ObjectID.zero;

            arLoad.ReadObject(ref objectId);
            arStore.WriteObject(objectId);

            int x = 0;

            arLoad.ReadInt16(ref x);
            arStore.WriteFloat(x / 100.0f);

            int y = 0;

            arLoad.ReadInt16(ref y);
            arStore.WriteFloat(y / 100.0f);

            int z = 0;

            arLoad.ReadInt16(ref z);
            arStore.WriteFloat(z / 100.0f);

            int orient = 0;

            arLoad.ReadInt16(ref orient);
            arStore.WriteFloat(orient / 100.0f);

            data = arStore.GetData();
            return(arStore.GetLength());
        }
Exemple #7
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);
        }
Exemple #8
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);
        }
Exemple #9
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);
        }
Exemple #10
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);
        }
Exemple #11
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);
        }
        /// <summary>
        /// 服务器所有目标点移动
        /// </summary>
        /// <param name="data"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        private int proc_server_all_dest(ref Byte[] data, int len)
        {
            LoadArchive arLoad = LoadArchive.Load(data, len);
            // Byte[] buffer = new Byte[1024];
            StoreArchive arStore = StoreArchive.Load(m_pBuffer_SP, 4096);

            uint nMsgType = 0;

            arLoad.ReadUInt8(ref nMsgType);
            arStore.WriteUInt8(nMsgType);

            uint nCount = 0;

            arLoad.ReadUInt16(ref nCount);
            arStore.WriteUInt16(nCount);

            if (nCount > 50)
            {
                LogSystem.Log("proc_server_all_dest");
                return(len);
            }
            for (int i = 0; i < nCount; ++i)
            {
                ObjectID objectId = ObjectID.zero;
                arLoad.ReadObject(ref objectId);
                arStore.WriteObject(objectId);

                int x = 0;
                arLoad.ReadInt16(ref x);
                arStore.WriteFloat(x / 100.0f);

                int y = 0;
                arLoad.ReadInt16(ref y);
                arStore.WriteFloat(y / 100.0f);

                int z = 0;
                arLoad.ReadInt16(ref z);
                arStore.WriteFloat(z / 100.0f);

                int orient = 0;
                arLoad.ReadInt16(ref orient);
                arStore.WriteFloat(orient / 100.0f);

                int moveSpeed = 0;
                arLoad.ReadInt16(ref moveSpeed);
                arStore.WriteFloat(moveSpeed / 100.0f);

                int rotateSpeed = 0;
                arLoad.ReadInt16(ref rotateSpeed);
                arStore.WriteFloat(rotateSpeed / 100.0f);

                int jumpSpeed = 0;
                arLoad.ReadInt16(ref jumpSpeed);
                arStore.WriteFloat(jumpSpeed / 100.0f);

                int gravity = 0;
                arLoad.ReadInt16(ref gravity);
                arStore.WriteFloat(gravity / 100.0f);

                int mode = 0;
                arLoad.ReadInt32(ref mode);
                arStore.WriteInt32(mode);
            }


            data = arStore.GetData();
            return(arStore.GetLength());
        }
        /// <summary>
        /// 服务器移动消息
        /// </summary>
        /// <param name="data"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        private int proc_server_moving(ref Byte[] data, int len)
        {
            if (len < 28)
            {
                return(len);
            }

            LoadArchive arLoad = LoadArchive.Load(data, len);
            // Byte[] buffer = new Byte[1024];
            StoreArchive arStore = StoreArchive.Load(m_pBuffer_SP, 4096);

            uint nMsgType = 0;

            arLoad.ReadUInt8(ref nMsgType);
            arStore.WriteUInt8(nMsgType);

            ObjectID objectId = ObjectID.zero;

            arLoad.ReadObject(ref objectId);
            arStore.WriteObject(objectId);

            int x = 0;

            arLoad.ReadInt16(ref x);
            arStore.WriteFloat(x / 100.0f);

            int y = 0;

            arLoad.ReadInt16(ref y);
            arStore.WriteFloat(y / 100.0f);

            int z = 0;

            arLoad.ReadInt16(ref z);
            arStore.WriteFloat(z / 100.0f);

            int orient = 0;

            arLoad.ReadInt16(ref orient);
            arStore.WriteFloat(orient / 100.0f);

            int moveSpeed = 0;

            arLoad.ReadInt16(ref moveSpeed);
            arStore.WriteFloat(moveSpeed / 100.0f);

            int rotateSpeed = 0;

            arLoad.ReadInt16(ref rotateSpeed);
            arStore.WriteFloat(rotateSpeed / 100.0f);

            int jumpSpeed = 0;

            arLoad.ReadInt16(ref jumpSpeed);
            arStore.WriteFloat(jumpSpeed / 100.0f);

            int gravity = 0;

            arLoad.ReadInt16(ref gravity);
            arStore.WriteFloat(gravity / 100.0f);

            int mode = 0;

            arLoad.ReadInt32(ref mode);
            arStore.WriteInt32(mode);

            data = arStore.GetData();
            return(arStore.GetLength());
        }
Exemple #14
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);
        }
Exemple #15
0
        public void HandleMessage(byte[] data, int size)
        {
            if (data.Length == 0 || 0 == size)
            {
                Log.TraceError("Error, HandleMessage data is 0 ");
                return;
            }

            //byte[] byteTemp = new byte[size];
            //System.Array.Copy(data, 0, byteTemp, 0, size);

            //init LoadArchive
            //LoadArchive loadAr = new LoadArchive(byteTemp, 0, byteTemp.Length);

            //LoadArchive loadAr = new LoadArchive(data, 0, size);

            int protocolId = data[0];

            /*int protocolId = 0;
             * bool bRet = loadAr.ReadInt8(ref protocolId);
             * if (!bRet)
             * {
             * //Log.Trace("SocketReceiveHandle::HandleMessage parse get protocol id failed!");
             * return;
             * }*/

            //if (protocolId == GlobalServerMsg.SERVER_IDLE)
            //{
            //    //不处理
            //    return;
            //}

            /*
             * LoadArchive loadAr = new LoadArchive(data, 0, data.Length);
             * loadAr.Seek(1);
             *
             * int nArgNum = 0;
             * loadAr.ReadInt16(ref nArgNum);
             * int nType = 0;
             * loadAr.ReadInt8(ref nType);
             * int value = 0;
             * loadAr.ReadInt32(ref value);
             *
             * if (value.Equals(1401))
             * {
             *  loadAr.ReadInt8(ref nType);
             *  int type = 0;
             *  loadAr.ReadInt32(ref type);
             *  if (type.Equals(1))
             *  {
             *      Log.Trace("Receive msg id = " + value);
             *  }
             * }
             */

            ExcuteEvent(protocolId, data);

            if (protocolId.Equals(GlobalServerMsg.SERVER_CP_CUSTOM))
            {
                byte[] content = new byte[data.Length - 1];
                System.Array.Copy(data, 1, content, 0, content.Length);
                byte[] contentBytes = QuickLZ.decompress(content);

                byte[] dataTemp = new byte[contentBytes.Length + 1];
                System.Array.Copy(data, 0, dataTemp, 0, 1);                           //拷贝消息id
                System.Array.Copy(contentBytes, 0, dataTemp, 1, contentBytes.Length); //拷贝解压后消息体(除去消息头)
                data = dataTemp;
            }

            if (protocolId.Equals(GlobalServerMsg.SERVER_CUSTOM) || protocolId.Equals(GlobalServerMsg.SERVER_CP_CUSTOM))
            {
                LoadArchive loadAr = new LoadArchive(data, 0, data.Length);
                loadAr.Seek(1);
                int nArgNum = 0;
                loadAr.ReadInt16(ref nArgNum);
                int nType = 0;
                loadAr.ReadInt8(ref nType);
                loadAr.ReadInt32(ref protocolId);
            }
            CustomSystem.Instance.dispacthEvent(0, protocolId);
        }
Exemple #16
-1
        private bool InnerRecvProperty(GameObj obj, LoadArchive loadAr, int count, bool change)
        {
            VarList.VarData key = new VarList.VarData();
            for (int i = 0; i < count; i++)
            {
                int index = 0;
                if (!loadAr.ReadInt16(ref index))
                {
                    return(false);
                }

                if (index >= mPropertyTable.Count)
                {
                    return(false);
                }

                PropData propData = GetPropDataByIndex(index);
                if (propData == null)
                {
                    return(false);
                }

                propData.nCount = propData.nCount + 1;

                if (!InnerParsePropValue(loadAr, propData.nType, ref key))
                {
                    return(false);
                }

                if (!obj.UpdateProperty(ref propData.strName, key))
                {
                    return(false);
                }

                if (change)
                {
                    VarList argList = new VarList();
                    argList.AddObject(obj.GetIdent());
                    argList.AddString(propData.strName);
                    Excute_CallBack("on_object_property_change", argList);
                }
            }

            return(true);
        }
Exemple #17
-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);
        }