Exemple #1
0
        private void InitBuffer(ITextBuffer buffer, int id = 0)
        {
            buffer.ChangedLowPriority += BufferChangedLowPriority;

            lock (this) {
                var bufferInfo = new BufferInfo(buffer, id);
                _bufferInfo[buffer]  = bufferInfo;
                _bufferIdMapping[id] = bufferInfo;
            }

            if (_document != null)
            {
                _document.EncodingChanged -= EncodingChanged;
                _document = null;
            }
            if (buffer.Properties.TryGetProperty <ITextDocument>(typeof(ITextDocument), out _document) && _document != null)
            {
                _document.EncodingChanged += EncodingChanged;
            }
        }
        private EFEventStoreOptions GetConfig(
            ISnapshotBehaviorProvider snapshotBehaviorProvider = null,
            BufferInfo bufferInfo = null)
        {
            EFEventStoreOptions options = null;

            switch (DatabaseType)
            {
            case DatabaseType.SQLite:
                options = new EFEventStoreOptions(o => o.UseSqlite(GetConnectionString_SQLite()),
                                                  snapshotBehaviorProvider, bufferInfo);
                break;

            default:
                options = new EFEventStoreOptions(o => o.UseSqlite(GetConnectionString_SQLServer()),
                                                  snapshotBehaviorProvider, bufferInfo);
                break;
            }
            return(options);
        }
Exemple #3
0
    bool OnBuffer(BufferInfo buffer)
    {
        // 判断时间
        if (buffer.dataPO.DurationTick > 0 && buffer.duration <= 0)
        {
            return(false);
        }
        buffer.duration -= Time.deltaTime;
        // 判断触发次数
        // 如果是间隔触发,则计算
        // 否则只触发一次
        // 根据配置表中IntervalTick是否大于0来决定
        if (buffer.dataPO.IntervalTick > 0)
        {
            if (buffer.interval > 0)
            {
                buffer.interval -= Time.deltaTime;
                return(true);
            }
            else
            {
                buffer.interval = (float)buffer.dataPO.IntervalTick / 1000.0f;
            }
        }

        if (buffer.dataPO.IntervalTick == 0)
        {
            if (buffer.interval <= 0)
            {
                return(false);
            }
            else
            {
                buffer.interval -= 1.0f;
            }
        }

        OnBufferAttr(buffer);
        OnBufferBody(buffer);
        return(true);
    }
 private void ChangeBuffer()
 {
     if (SelectedServer != null && SelectedLocation != null)
     {
         BufferLock.EnterWriteLock();
         if (!BufferList.Exists(buf => buf.Server == SelectedServer && buf.Location == SelectedLocation))
         {
             BufferInfo newBuffer = new BufferInfo();
             newBuffer.Server   = SelectedServer;
             newBuffer.Location = SelectedLocation;
             BufferList.Add(newBuffer);
         }
         CurrentBuffer = string.Join(Environment.NewLine, BufferList.Find(buf => buf.Server == SelectedServer && buf.Location == SelectedLocation).Buffer);
         BufferLock.ExitWriteLock();
         Bot session = Controller.Instance.GetBot(SelectedServer);
         if (session != null)
         {
             Connected = session.Connected;
         }
     }
 }
        protected override int GetProperty()
        {
            INodeGraph graph      = base.Graph;
            BufferInfo bufferInfo = graph?.GetVariable <BufferInfo>("BufferInfo");

            if (bufferInfo != null)
            {
                if (Game.GameData.Character.ContainsKey(bufferInfo.Unit.CharacterInfoId))
                {
                    if (Game.GameData.Character[bufferInfo.Unit.CharacterInfoId].Mantra.ContainsKey(this.MantraId))
                    {
                        return(Game.GameData.Character[bufferInfo.Unit.CharacterInfoId].Mantra[this.MantraId].Level);
                    }
                }
                else if (bufferInfo.Unit.CurrentMantra.Id == this.MantraId)
                {
                    return(bufferInfo.Unit.CurrentMantra.Level);
                }
            }
            return(0);
        }
        protected override int GetProperty()
        {
            INodeGraph graph      = base.Graph;
            BufferInfo bufferInfo = graph?.GetVariable <BufferInfo>("BufferInfo");

            if (bufferInfo != null)
            {
                if (Game.GameData.Character.ContainsKey(bufferInfo.Unit.CharacterInfoId))
                {
                    if (Game.GameData.Character[bufferInfo.Unit.CharacterInfoId].Skill.ContainsKey(this.SkillId))
                    {
                        return(Game.GameData.Character[bufferInfo.Unit.CharacterInfoId].Skill[this.SkillId].Level);
                    }
                }
                else if (bufferInfo.Unit.LearnedSkills.ContainsKey(this.SkillId))
                {
                    return(bufferInfo.Unit.LearnedSkills[this.SkillId].Level);
                }
            }
            return(0);
        }
Exemple #7
0
    public void writeDebugInfo(Text debugInfo, bool renderBlocked, GameState gameState)
    {
        Vector3        pz   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        PheromoneModel near = GameState.Search <PheromoneModel> .Nearest(gameState.findPheromonesInRange(pz, 0.3f), pz);

        string pheroInfo = near == null ? " -- " : "confusion " + near.Confusion.ToString("0.00") +
                           ", homeDist " + Mathf.Min(near.HomeDistance, 99.99f).ToString("00.00") +
                           ", foodDist " + Mathf.Min(near.FoodDistance, 99.99f).ToString("00.00") +
                           "\n";

        frameTimeBuffer[frameTimeIndex] = calculateFrameInfo(renderBlocked);
        frameTimeIndex = (frameTimeIndex + 1) % BUFFER_FRAMES;
        BufferInfo info = CalculateBufferStats();

        debugInfo.text = "FPS avr " + info.AverageFramerate.ToString("00.00") +
                         ", min " + info.LowestFramerate.ToString("00.00") +
                         "	thread finished "+ (info.RenderIdleTime * 100).ToString("00.") + "%\n" +
                         "Pheromones:" + gameState.Pheromones.AsList().Count + "\n" +
                         "@" + pz.x.ToString("00.0") + "," + pz.y.ToString("00.0") +
                         ": " + pheroInfo +
                         "\n";
    }
Exemple #8
0
            public static ASVLOFFSCREEN loadImage(String filePath)
            {
                ASVLOFFSCREEN inputImg = new ASVLOFFSCREEN();

                inputImg.pi32Pitch = new int[4];
                inputImg.ppu8Plane = new IntPtr[4];
                if (bUseBGRToEngine)
                {
                    BufferInfo bufferInfo = ImageLoader.getBGRFromFile(filePath);
                    inputImg.u32PixelArrayFormat = ASVL_COLOR_FORMAT.ASVL_PAF_RGB24_B8G8R8;
                    inputImg.i32Width            = bufferInfo.width;
                    inputImg.i32Height           = bufferInfo.height;
                    inputImg.pi32Pitch[0]        = bufferInfo.stride;
                    inputImg.ppu8Plane[0]        = Marshal.AllocHGlobal(inputImg.pi32Pitch[0] * inputImg.i32Height);
                    Marshal.Copy(bufferInfo.buffer, 0, inputImg.ppu8Plane[0], inputImg.pi32Pitch[0] * inputImg.i32Height);
                    inputImg.ppu8Plane[1] = IntPtr.Zero;
                    inputImg.ppu8Plane[2] = IntPtr.Zero;
                    inputImg.ppu8Plane[3] = IntPtr.Zero;
                }
                else
                {
                    BufferInfo bufferInfo = ImageLoader.getI420FromFile(filePath);
                    inputImg.u32PixelArrayFormat = ASVL_COLOR_FORMAT.ASVL_PAF_I420;
                    inputImg.i32Width            = bufferInfo.width;
                    inputImg.i32Height           = bufferInfo.height;
                    inputImg.pi32Pitch[0]        = inputImg.i32Width;
                    inputImg.pi32Pitch[1]        = inputImg.i32Width / 2;
                    inputImg.pi32Pitch[2]        = inputImg.i32Width / 2;
                    inputImg.ppu8Plane[0]        = Marshal.AllocHGlobal(inputImg.pi32Pitch[0] * inputImg.i32Height);
                    Marshal.Copy(bufferInfo.buffer, 0, inputImg.ppu8Plane[0], inputImg.pi32Pitch[0] * inputImg.i32Height);
                    inputImg.ppu8Plane[1] = Marshal.AllocHGlobal(inputImg.pi32Pitch[1] * inputImg.i32Height / 2);
                    Marshal.Copy(bufferInfo.buffer, inputImg.pi32Pitch[0] * inputImg.i32Height, inputImg.ppu8Plane[1], inputImg.pi32Pitch[1] * inputImg.i32Height / 2);
                    inputImg.ppu8Plane[2] = Marshal.AllocHGlobal(inputImg.pi32Pitch[2] * inputImg.i32Height / 2);
                    Marshal.Copy(bufferInfo.buffer, inputImg.pi32Pitch[0] * inputImg.i32Height + inputImg.pi32Pitch[1] * inputImg.i32Height / 2, inputImg.ppu8Plane[2], inputImg.pi32Pitch[2] * inputImg.i32Height / 2);
                    inputImg.ppu8Plane[3] = IntPtr.Zero;
                }
                return(inputImg);
            }
Exemple #9
0
        public static AbstractBuffer CreateBuffer(BufferInfo info)
        {
            AbstractBuffer result = null;

            switch (info.Type)
            {
            case 11:
                result = new KickProtectBuffer(info);
                break;

            case 12:
                result = new OfferMultipleBuffer(info);
                break;

            case 13:
                result = new GPMultipleBuffer(info);
                break;

            case 15:
                result = new PropsBuffer(info);
                break;
            }
            return(result);
        }
Exemple #10
0
        //private readonly TcpClient client;
        //private long position;
        //private long length;
        //private byte[] buffer;
        //private long bufferpos;

        public RemoteStream(string ipAddress, int port, string name)
        {
            var client = new TcpClient(ipAddress, port);

            var stream = client.GetStream();

            var writer = new BinaryWriter(stream);
            var reader = new BinaryReader(stream);

            writer.Write((int)HeaderType.Size);
            writer.Write(name);

            var length = (int)reader.ReadInt64();

            this.Capacity = length;
            var buffer = new byte[bufferLength];

            var len = 0;

            while (len < length)
            {
                var bufferInfo = new BufferInfo(len, bufferLength);
                //bufferInfo.pos = pos;
                //bufferInfo.size = SocketStream.bufferLength;
                //bufferInfo.dummy = 0;

                writer.Write((int)HeaderType.Buffer);
                writer.WriteValue(bufferInfo);

                var read = reader.Read(buffer, 0, bufferLength);
                this.Write(buffer, 0, read);
                len += read;
            }
            client.Close();
            this.Position = 0;
        }
        /**
         * @param withPrefix If set to true, the decoder will be fed with NALs preceeded with 0x00000001.
         * @return How long it took to decode all the NALs
         */
        private long decode(bool withPrefix)
        {
            int  n = 0, i = 0, j = 0;
            long elapsed = 0, now = timestamp();
            int  decInputIndex = 0, decOutputIndex = 0;

            ByteBuffer[] decInputBuffers  = mDecoder.GetInputBuffers();
            ByteBuffer[] decOutputBuffers = mDecoder.GetOutputBuffers();
            BufferInfo   info             = new BufferInfo();

            while (elapsed < 3000000)
            {
                // Feeds the decoder with a NAL unit
                if (i < NB_ENCODED)
                {
                    decInputIndex = mDecoder.DequeueInputBuffer(1000000 / FRAMERATE);
                    if (decInputIndex >= 0)
                    {
                        int l1 = decInputBuffers[decInputIndex].Capacity();
                        int l2 = mVideo[i].Length;
                        decInputBuffers[decInputIndex].Clear();

                        if ((withPrefix && hasPrefix(mVideo[i])) || (!withPrefix && !hasPrefix(mVideo[i])))
                        {
                            check(l1 >= l2, "The decoder input buffer is not big enough (nal=" + l2 + ", capacity=" + l1 + ").");
                            decInputBuffers[decInputIndex].Put(mVideo[i], 0, mVideo[i].Length);
                        }
                        else if (withPrefix && !hasPrefix(mVideo[i]))
                        {
                            check(l1 >= l2 + 4, "The decoder input buffer is not big enough (nal=" + (l2 + 4) + ", capacity=" + l1 + ").");
                            decInputBuffers[decInputIndex].Put(new byte[] { 0, 0, 0, 1 });
                            decInputBuffers[decInputIndex].Put(mVideo[i], 0, mVideo[i].Length);
                        }
                        else if (!withPrefix && hasPrefix(mVideo[i]))
                        {
                            check(l1 >= l2 - 4, "The decoder input buffer is not big enough (nal=" + (l2 - 4) + ", capacity=" + l1 + ").");
                            decInputBuffers[decInputIndex].Put(mVideo[i], 4, mVideo[i].Length - 4);
                        }

                        mDecoder.QueueInputBuffer(decInputIndex, 0, l2, timestamp(), 0);
                        i++;
                    }
                    else
                    {
                        if (VERBOSE)
                        {
                            Log.d(TAG, "No buffer available !");
                        }
                    }
                }

                // Tries to get a decoded image
                decOutputIndex = mDecoder.DequeueOutputBuffer(info, 1000000 / FRAMERATE);
                if (decOutputIndex == (int)MediaCodec.InfoOutputBuffersChanged)
                {
                    decOutputBuffers = mDecoder.GetOutputBuffers();
                }
                else if (decOutputIndex == (int)MediaCodec.InfoOutputFormatChanged)
                {
                    mDecOutputFormat = mDecoder.OutputFormat;
                }
                else if (decOutputIndex >= 0)
                {
                    if (n > 2)
                    {
                        // We have successfully encoded and decoded an image !
                        int length = info.Size;
                        mDecodedVideo[j] = new byte[length];
                        decOutputBuffers[decOutputIndex].Clear();
                        decOutputBuffers[decOutputIndex].Get(mDecodedVideo[j], 0, length);
                        // Converts the decoded frame to NV21
                        convertToNV21(j);
                        if (j >= NB_DECODED - 1)
                        {
                            flushMediaCodec(mDecoder);
                            if (VERBOSE)
                            {
                                Log.v(TAG, "Decoding " + n + " frames took " + elapsed / 1000 + " ms");
                            }
                            return(elapsed);
                        }
                        j++;
                    }
                    mDecoder.ReleaseOutputBuffer(decOutputIndex, false);
                    n++;
                }
                elapsed = timestamp() - now;
            }

            throw new RuntimeException("The decoder did not decode anything.");
        }
Exemple #12
0
        public void SendAddRoom(BaseRoom room)
        {
            GSPacketIn gSPacketIn = new GSPacketIn(64);

            gSPacketIn.WriteInt(room.RoomId);
            gSPacketIn.WriteInt((int)room.GameType);
            gSPacketIn.WriteInt(room.GuildId);
            List <GamePlayer> players = room.GetPlayers();

            gSPacketIn.WriteInt(players.Count);
            foreach (GamePlayer current in players)
            {
                gSPacketIn.WriteInt(current.PlayerCharacter.ID);
                gSPacketIn.WriteString(current.PlayerCharacter.NickName);
                gSPacketIn.WriteBoolean(current.PlayerCharacter.Sex);
                gSPacketIn.WriteByte(current.PlayerCharacter.typeVIP);
                gSPacketIn.WriteInt(current.PlayerCharacter.VIPLevel);
                gSPacketIn.WriteInt(current.PlayerCharacter.Hide);
                gSPacketIn.WriteString(current.PlayerCharacter.Style);
                gSPacketIn.WriteString(current.PlayerCharacter.Colors);
                gSPacketIn.WriteString(current.PlayerCharacter.Skin);
                gSPacketIn.WriteInt(current.PlayerCharacter.Offer);
                gSPacketIn.WriteInt(current.PlayerCharacter.GP);
                gSPacketIn.WriteInt(current.PlayerCharacter.Grade);
                gSPacketIn.WriteInt(current.PlayerCharacter.Repute);
                gSPacketIn.WriteInt(current.PlayerCharacter.ConsortiaID);
                gSPacketIn.WriteString(current.PlayerCharacter.ConsortiaName);
                gSPacketIn.WriteInt(current.PlayerCharacter.ConsortiaLevel);
                gSPacketIn.WriteInt(current.PlayerCharacter.ConsortiaRepute);
                gSPacketIn.WriteInt(current.PlayerCharacter.badgeID);
                gSPacketIn.WriteString(current.PlayerCharacter.WeaklessGuildProgressStr);
                gSPacketIn.WriteInt(current.PlayerCharacter.Attack);
                gSPacketIn.WriteInt(current.PlayerCharacter.Defence);
                gSPacketIn.WriteInt(current.PlayerCharacter.Agility);
                gSPacketIn.WriteInt(current.PlayerCharacter.Luck);
                gSPacketIn.WriteInt(current.PlayerCharacter.hp);
                gSPacketIn.WriteInt(current.PlayerCharacter.FightPower);
                gSPacketIn.WriteBoolean(current.PlayerCharacter.IsMarried);
                if (current.PlayerCharacter.IsMarried)
                {
                    gSPacketIn.WriteInt(current.PlayerCharacter.SpouseID);
                    gSPacketIn.WriteString(current.PlayerCharacter.SpouseName);
                }
                gSPacketIn.WriteDouble(current.GetBaseAttack());
                gSPacketIn.WriteDouble(current.GetBaseDefence());
                gSPacketIn.WriteDouble(current.GetBaseAgility());
                gSPacketIn.WriteDouble(current.GetBaseBlood());
                gSPacketIn.WriteInt(current.MainWeapon.TemplateID);
                gSPacketIn.WriteBoolean(current.CanUseProp);
                if (current.SecondWeapon != null)
                {
                    gSPacketIn.WriteInt(current.SecondWeapon.TemplateID);
                    gSPacketIn.WriteInt(current.SecondWeapon.StrengthenLevel);
                }
                else
                {
                    gSPacketIn.WriteInt(0);
                    gSPacketIn.WriteInt(0);
                }
                gSPacketIn.WriteDouble((double)RateMgr.GetRate(eRateType.Experience_Rate) * AntiAddictionMgr.GetAntiAddictionCoefficient(current.PlayerCharacter.AntiAddiction) * ((current.GPAddPlus == 0.0) ? 1.0 : current.GPAddPlus));
                gSPacketIn.WriteDouble(AntiAddictionMgr.GetAntiAddictionCoefficient(current.PlayerCharacter.AntiAddiction) * ((current.OfferAddPlus == 0.0) ? 1.0 : current.OfferAddPlus));
                gSPacketIn.WriteDouble((double)RateMgr.GetRate(eRateType.Experience_Rate));
                gSPacketIn.WriteInt(GameServer.Instance.Configuration.ServerID);
                if (current.Pet == null)
                {
                    gSPacketIn.WriteInt(0);
                }
                else
                {
                    gSPacketIn.WriteInt(1);
                    gSPacketIn.WriteInt(current.Pet.Place);
                    gSPacketIn.WriteInt(current.Pet.TemplateID);
                    gSPacketIn.WriteInt(current.Pet.ID);
                    gSPacketIn.WriteString(current.Pet.Name);
                    gSPacketIn.WriteInt(current.Pet.UserID);
                    gSPacketIn.WriteInt(current.Pet.Level);
                    gSPacketIn.WriteString(current.Pet.Skill);
                    gSPacketIn.WriteString(current.Pet.SkillEquip);
                }
                List <AbstractBuffer> allBuffer = current.BufferList.GetAllBuffer();
                gSPacketIn.WriteInt(allBuffer.Count);
                foreach (AbstractBuffer current2 in allBuffer)
                {
                    BufferInfo info = current2.Info;
                    gSPacketIn.WriteInt(info.Type);
                    gSPacketIn.WriteBoolean(info.IsExist);
                    gSPacketIn.WriteDateTime(info.BeginDate);
                    gSPacketIn.WriteInt(info.ValidDate);
                    gSPacketIn.WriteInt(info.Value);
                    gSPacketIn.WriteInt(info.ValidCount);
                }
                gSPacketIn.WriteInt(current.EquipEffect.Count);
                foreach (ItemInfo current3 in current.EquipEffect)
                {
                    gSPacketIn.WriteInt(current3.TemplateID);
                    gSPacketIn.WriteInt(current3.Hole1);
                }
            }
            this.SendTCP(gSPacketIn);
        }
Exemple #13
0
        override public void OnOutputBufferAvailable(MediaCodec mc, int outputBufferId, BufferInfo info)
        {
            ByteBuffer  outputBuffer = mDecoder.GetOutputBuffer(outputBufferId);
            MediaFormat bufferFormat = mDecoder.GetOutputFormat(outputBufferId); // option A

            Console.WriteLine("decoded buffer format:" + bufferFormat.ToString());

            // bufferFormat is equivalent to mOutputFormat
            // outputBuffer is ready to be processed or rendered.

            Console.WriteLine("OnOutputBufferAvailable: outputBufferId = " + outputBufferId.ToString());
            byte[] decoded_data = new byte[info.Size];
            outputBuffer.Position(info.Offset);
            outputBuffer.Get(decoded_data, 0, info.Size);
            mDecoder.ReleaseOutputBuffer(outputBufferId, false);
            Console.WriteLine("call OnDecodeFrame from decoder!");

            Console.WriteLine("bufferFormat.getInteger(MediaFormat.KeyWidth)=" + bufferFormat.GetInteger(MediaFormat.KeyWidth).ToString() + " bufferFormat.getInteger(MediaFormat.KeyHeight)=" + bufferFormat.GetInteger(MediaFormat.KeyHeight).ToString());
            mCallbackObj.OnDecodeFrame(decoded_data, bufferFormat.GetInteger(MediaFormat.KeyWidth), bufferFormat.GetInteger(MediaFormat.KeyHeight), bufferFormat.GetInteger(MediaFormat.KeyColorFormat));
        }
Exemple #14
0
        public void HandleGameRoomCreate(GSPacketIn pkg)
        {
            int  totalLevel      = 0;
            int  totalFightPower = 0;
            int  roomId          = pkg.ReadInt();
            int  gameType        = pkg.ReadInt();
            int  guildId         = pkg.ReadInt();
            int  areaId          = pkg.ReadInt();
            bool IsArea          = pkg.ReadBoolean();
            int  count           = pkg.ReadInt();

            IGamePlayer[] players = new IGamePlayer[count];
            for (int i = 0; i < count; i++)
            {
                PlayerInfo      info            = new PlayerInfo();
                ProxyPlayerInfo proxyPlayerInfo = new ProxyPlayerInfo();
                proxyPlayerInfo.m_AreaID   = pkg.ReadInt();
                proxyPlayerInfo.m_AreaName = pkg.ReadString();
                info.ID              = pkg.ReadInt();
                info.NickName        = pkg.ReadString();
                info.Sex             = pkg.ReadBoolean();
                info.Hide            = pkg.ReadInt();
                info.Style           = pkg.ReadString();
                info.Colors          = pkg.ReadString();
                info.Skin            = pkg.ReadString();
                info.Offer           = pkg.ReadInt();
                info.GP              = pkg.ReadInt();
                info.Grade           = pkg.ReadInt();
                info.Repute          = pkg.ReadInt();
                info.Nimbus          = pkg.ReadInt();
                info.ConsortiaID     = pkg.ReadInt();
                info.ConsortiaName   = pkg.ReadString();
                info.ConsortiaLevel  = pkg.ReadInt();
                info.ConsortiaRepute = pkg.ReadInt();
                info.Win             = pkg.ReadInt();
                info.Total           = pkg.ReadInt();
                info.Attack          = pkg.ReadInt();
                info.Defence         = pkg.ReadInt();
                info.Agility         = pkg.ReadInt();
                info.Luck            = pkg.ReadInt();
                info.FightPower      = pkg.ReadInt();
                info.IsMarried       = pkg.ReadBoolean();
                if (info.IsMarried)
                {
                    info.SpouseID   = pkg.ReadInt();
                    info.SpouseName = pkg.ReadString();
                }
                totalFightPower                      += info.FightPower;
                proxyPlayerInfo.BaseAttack            = pkg.ReadDouble();
                proxyPlayerInfo.BaseDefence           = pkg.ReadDouble();
                proxyPlayerInfo.BaseAgility           = pkg.ReadDouble();
                proxyPlayerInfo.BaseBlood             = pkg.ReadDouble();
                proxyPlayerInfo.TemplateId            = pkg.ReadInt();
                proxyPlayerInfo.CanUserProp           = pkg.ReadBoolean();
                proxyPlayerInfo.SecondWeapon          = pkg.ReadInt();
                proxyPlayerInfo.StrengthLevel         = pkg.ReadInt();
                proxyPlayerInfo.GPAddPlus             = pkg.ReadDouble();
                proxyPlayerInfo.GMExperienceRate      = pkg.ReadFloat();
                proxyPlayerInfo.AuncherExperienceRate = pkg.ReadFloat();
                proxyPlayerInfo.OfferAddPlus          = pkg.ReadDouble();
                proxyPlayerInfo.GMOfferRate           = pkg.ReadFloat();
                proxyPlayerInfo.AuncherOfferRate      = pkg.ReadFloat();
                proxyPlayerInfo.GMRichesRate          = pkg.ReadFloat();
                proxyPlayerInfo.AuncherRichesRate     = pkg.ReadFloat();
                proxyPlayerInfo.AntiAddictionRate     = pkg.ReadDouble();
                List <BufferInfo> infos = new List <BufferInfo>();
                int buffercout          = pkg.ReadInt();
                for (int j = 0; j < buffercout; j++)
                {
                    BufferInfo buffinfo = new BufferInfo();
                    buffinfo.Type      = pkg.ReadInt();
                    buffinfo.IsExist   = pkg.ReadBoolean();
                    buffinfo.BeginDate = pkg.ReadDateTime();
                    buffinfo.ValidDate = pkg.ReadInt();
                    buffinfo.Value     = pkg.ReadInt();
                    if (info != null)
                    {
                        infos.Add(buffinfo);
                    }
                }
                players[i]            = new ProxyPlayer(this, info, proxyPlayerInfo, infos);
                players[i].CanUseProp = proxyPlayerInfo.CanUserProp;
                int ec = pkg.ReadInt();
                for (int j = 0; j < ec; j++)
                {
                    players[i].EquipEffect.Add(pkg.ReadInt());
                }
                totalLevel += info.Grade;
            }
            if (players.Length != 0)
            {
                ProxyRoom room = new ProxyRoom(ProxyRoomMgr.NextRoomId(), roomId, players, this, totalLevel, totalFightPower, IsArea);
                room.GuildId  = guildId;
                room.AreaID   = areaId;
                room.GameType = (eGameType)gameType;
                ProxyRoom oldroom = null;
                Dictionary <int, ProxyRoom> rooms;
                Monitor.Enter(rooms = this.m_rooms);
                try
                {
                    if (this.m_rooms.ContainsKey(roomId))
                    {
                        oldroom = this.m_rooms[roomId];
                        this.m_rooms.Remove(roomId);
                    }
                }
                finally
                {
                    Monitor.Exit(rooms);
                }
                if (oldroom != null)
                {
                    ProxyRoomMgr.RemoveRoom(oldroom);
                }
                Monitor.Enter(rooms = this.m_rooms);
                try
                {
                    if (!this.m_rooms.ContainsKey(roomId))
                    {
                        this.m_rooms.Add(roomId, room);
                        this.SendFightRoomID(roomId, room.RoomId);
                    }
                    else
                    {
                        room = null;
                    }
                }
                finally
                {
                    Monitor.Exit(rooms);
                }
                if (room != null)
                {
                    ProxyRoomMgr.AddRoom(room);
                }
                else
                {
                    ServerClient.log.ErrorFormat("Room already exists:{0}", roomId);
                }
            }
        }
Exemple #15
0
        private void InitBuffer(ITextBuffer buffer, int id = 0) {
            buffer.ChangedLowPriority += BufferChangedLowPriority;

            lock (this) {
                var bufferInfo = new BufferInfo(buffer, id);
                _bufferInfo[buffer] = bufferInfo;
                _bufferIdMapping[id] = bufferInfo;
            }

            if (_document != null) {
                _document.EncodingChanged -= EncodingChanged;
                _document = null;
            }
            if (buffer.Properties.TryGetProperty<ITextDocument>(typeof(ITextDocument), out _document) && _document != null) {
                _document.EncodingChanged += EncodingChanged;
            }
        }
Exemple #16
0
 public PropsBuffer(BufferInfo buffer) : base(buffer)
 {
 }
Exemple #17
0
 public OfferMultipleBuffer(BufferInfo info) : base(info)
 {
 }
        public unsafe void LoadGLTF(string filePath, ID3D12Device5 pDevice, out ID3D12Resource vertexBuffer, out uint vertexCount, out ID3D12Resource indexBuffer, out uint indexCount)
        {
            using (var stream = File.OpenRead(filePath))
            {
                if (stream == null || !stream.CanRead)
                {
                    throw new ArgumentException("Invalid parameter. Stream must be readable", "imageStream");
                }

                var model = Interface.LoadModel(stream);

                // read all buffers
                int numBuffers = model.Buffers.Length;
                var buffers    = new BufferInfo[numBuffers];

                for (int i = 0; i < numBuffers; ++i)
                {
                    var bufferBytes = model.LoadBinaryBuffer(i, filePath);
                    buffers[i] = new BufferInfo(bufferBytes);
                }

                // Read only first mesh and first primitive
                var mesh      = model.Meshes[0];
                var primitive = mesh.Primitives[0];

                // Create Vertex Buffer
                var attributes = primitive.Attributes.ToArray();

                Vector3[] positions = new Vector3[0];
                Vector3[] normals   = new Vector3[0];
                Vector2[] texcoords = new Vector2[0];
                Vector3[] tangents  = new Vector3[0];

                for (int i = 0; i < attributes.Length; i++)
                {
                    var    attributeAccessor   = model.Accessors[attributes[i].Value];
                    var    attributebufferView = model.BufferViews[attributeAccessor.BufferView.Value];
                    IntPtr attributePointer    = buffers[attributebufferView.Buffer].bufferPointer + attributebufferView.ByteOffset + attributeAccessor.ByteOffset;

                    string attributeKey = attributes[i].Key;
                    if (attributeKey.Contains("POSITION"))
                    {
                        this.AttributeCopyData(ref positions, attributeAccessor.Count * Unsafe.SizeOf <Vector3>(), attributePointer);
                    }
                    else if (attributeKey.Contains("NORMAL"))
                    {
                        this.AttributeCopyData(ref normals, attributeAccessor.Count * Unsafe.SizeOf <Vector3>(), attributePointer);
                    }
                    else if (attributeKey.Contains("TANGENT"))
                    {
                        this.AttributeCopyData(ref tangents, attributeAccessor.Count * Unsafe.SizeOf <Vector3>(), attributePointer);
                    }
                    else if (attributeKey.Contains("TEXCOORD"))
                    {
                        this.AttributeCopyData(ref texcoords, attributeAccessor.Count * Unsafe.SizeOf <Vector2>(), attributePointer);
                    }
                }

                VertexPositionNormalTangentTexture[] vertexData = new VertexPositionNormalTangentTexture[positions.Length];
                for (int i = 0; i < vertexData.Length; i++)
                {
                    Vector3 position = positions[i];
                    Vector3 normal   = (normals.Length > i) ? normals[i] : Vector3.Zero;
                    Vector2 texcoord = (texcoords.Length > i) ? texcoords[i] : Vector2.Zero;
                    Vector3 tangent  = (tangents.Length > i) ? tangents[i] : Vector3.Zero;
                    vertexData[i] = new VertexPositionNormalTangentTexture(position, normal, tangent, texcoord);
                }

                vertexCount  = (uint)vertexData.Length;
                vertexBuffer = CreateBuffer(pDevice, (uint)(Unsafe.SizeOf <VertexPositionNormalTangentTexture>() * vertexData.Length), ResourceFlags.None, ResourceStates.GenericRead, kUploadHeapProps);
                IntPtr pData = vertexBuffer.Map(0, null);
                Helpers.MemCpy(pData, vertexData, (uint)(Unsafe.SizeOf <VertexPositionNormalTangentTexture>() * vertexData.Length));
                vertexBuffer.Unmap(0, null);

                // Create Index buffer
                var    indicesAccessor   = model.Accessors[primitive.Indices.Value];
                var    indicesbufferView = model.BufferViews[indicesAccessor.BufferView.Value];
                IntPtr indicesPointer    = buffers[indicesbufferView.Buffer].bufferPointer + indicesbufferView.ByteOffset + indicesAccessor.ByteOffset;
                indexCount  = (uint)indicesAccessor.Count;
                indexBuffer = CreateBuffer(pDevice, (uint)indicesAccessor.Count * sizeof(ushort), ResourceFlags.None, ResourceStates.GenericRead, kUploadHeapProps);
                IntPtr pIB = indexBuffer.Map(0, null);
                Unsafe.CopyBlock((void *)pIB, (void *)indicesPointer, (uint)indicesAccessor.Count * sizeof(ushort));
                indexBuffer.Unmap(0, null);

                for (int i = 0; i < numBuffers; ++i)
                {
                    buffers[i].Dispose();
                }

                buffers = null;
            }
        }
        /// <summary>
        /// Update the container, buffer, and packaging panels.
        /// </summary>
        /// <param name="state">State data for the dispenser.</param>
        private void UpdatePanelInfo(ChemMasterBoundUserInterfaceState state)
        {
            var bufferModeTransfer = state.BufferModeTransfer;

            BufferTransferButton.Pressed = bufferModeTransfer;
            BufferDiscardButton.Pressed  = !bufferModeTransfer;

            ContainerInfo.Children.Clear();

            if (!state.HasBeaker)
            {
                ContainerInfo.Children.Add(new Label {
                    Text = Loc.GetString("chem-master-window-no-container-loaded-text")
                });
                return;
            }

            ContainerInfo.Children.Add(new BoxContainer // Name of the container and its fill status (Ex: 44/100u)
            {
                Orientation = LayoutOrientation.Horizontal,
                Children    =
                {
                    new Label {
                        Text = $"{state.ContainerName}: "
                    },
                    new Label
                    {
                        Text         = $"{state.BeakerCurrentVolume}/{state.BeakerMaxVolume}",
                        StyleClasses ={ StyleNano.StyleClassLabelSecondaryColor          }
                    }
                }
            });

            foreach (var reagent in state.ContainerReagents)
            {
                var name = Loc.GetString("chem-master-window-unknown-reagent-text");
                //Try to the prototype for the given reagent. This gives us it's name.
                if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype? proto))
                {
                    name = proto.Name;
                }

                if (proto != null)
                {
                    ContainerInfo.Children.Add(new BoxContainer
                    {
                        Orientation = LayoutOrientation.Horizontal,
                        Children    =
                        {
                            new Label   {
                                Text = $"{name}: "
                            },
                            new Label
                            {
                                Text         = $"{reagent.Quantity}u",
                                StyleClasses ={ StyleNano.StyleClassLabelSecondaryColor          }
                            },

                            //Padding
                            new Control {
                                HorizontalExpand = true
                            },

                            MakeChemButton("1", ReagentUnit.New(1), reagent.ReagentId, false, StyleBase.ButtonOpenRight),
                            MakeChemButton("5", ReagentUnit.New(5), reagent.ReagentId, false, StyleBase.ButtonOpenBoth),
                            MakeChemButton("10", ReagentUnit.New(10), reagent.ReagentId, false, StyleBase.ButtonOpenBoth),
                            MakeChemButton("25", ReagentUnit.New(25), reagent.ReagentId, false, StyleBase.ButtonOpenBoth),
                            MakeChemButton(Loc.GetString("chem-master-window-buffer-all-amount"), ReagentUnit.New(-1), reagent.ReagentId, false, StyleBase.ButtonOpenLeft),
                        }
                    });
                }
            }

            BufferInfo.Children.Clear();

            if (!state.BufferReagents.Any())
            {
                BufferInfo.Children.Add(new Label {
                    Text = Loc.GetString("chem-master-window-buffer-empty-text")
                });
                return;
            }

            var bufferHBox = new BoxContainer
            {
                Orientation = LayoutOrientation.Horizontal
            };

            BufferInfo.AddChild(bufferHBox);

            var bufferLabel = new Label {
                Text = $"{Loc.GetString("chem-master-window-buffer-label")} "
            };

            bufferHBox.AddChild(bufferLabel);
            var bufferVol = new Label
            {
                Text         = $"{state.BufferCurrentVolume}",
                StyleClasses = { StyleNano.StyleClassLabelSecondaryColor }
            };

            bufferHBox.AddChild(bufferVol);

            foreach (var reagent in state.BufferReagents)
            {
                var name = Loc.GetString("chem-master-window-unknown-reagent-text");
                //Try to the prototype for the given reagent. This gives us it's name.
                if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype? proto))
                {
                    name = proto.Name;
                }

                if (proto != null)
                {
                    BufferInfo.Children.Add(new BoxContainer
                    {
                        Orientation = LayoutOrientation.Horizontal,
                        //SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
                        Children =
                        {
                            new Label   {
                                Text = $"{name}: "
                            },
                            new Label
                            {
                                Text         = $"{reagent.Quantity}u",
                                StyleClasses ={ StyleNano.StyleClassLabelSecondaryColor          }
                            },

                            //Padding
                            new Control {
                                HorizontalExpand = true
                            },

                            MakeChemButton("1", ReagentUnit.New(1), reagent.ReagentId, true, StyleBase.ButtonOpenRight),
                            MakeChemButton("5", ReagentUnit.New(5), reagent.ReagentId, true, StyleBase.ButtonOpenBoth),
                            MakeChemButton("10", ReagentUnit.New(10), reagent.ReagentId, true, StyleBase.ButtonOpenBoth),
                            MakeChemButton("25", ReagentUnit.New(25), reagent.ReagentId, true, StyleBase.ButtonOpenBoth),
                            MakeChemButton(Loc.GetString("chem-master-window-buffer-all-amount"), ReagentUnit.New(-1), reagent.ReagentId, true, StyleBase.ButtonOpenLeft),
                        }
                    });
                }
            }
        }
        public void SendAddRoom(Game.Server.Rooms.BaseRoom room)
        {
            GSPacketIn pkg = new GSPacketIn((int)eFightPackageType.ROOM_CREATE);

            pkg.WriteInt(room.RoomId);
            pkg.WriteInt((int)room.GameType);
            pkg.WriteInt(room.GuildId);

            List <GamePlayer> players = room.GetPlayers();

            pkg.WriteInt(players.Count);
            foreach (GamePlayer p in players)
            {
                pkg.WriteInt(p.PlayerCharacter.ID);//改为唯一ID
                pkg.WriteString(p.PlayerCharacter.NickName);
                pkg.WriteBoolean(p.PlayerCharacter.Sex);

                pkg.WriteInt(p.PlayerCharacter.Hide);
                pkg.WriteString(p.PlayerCharacter.Style);
                pkg.WriteString(p.PlayerCharacter.Colors);
                pkg.WriteString(p.PlayerCharacter.Skin);
                pkg.WriteInt(p.PlayerCharacter.Offer);
                pkg.WriteInt(p.PlayerCharacter.GP);
                pkg.WriteInt(p.PlayerCharacter.Grade);
                pkg.WriteInt(p.PlayerCharacter.Repute);
                pkg.WriteInt(p.PlayerCharacter.ConsortiaID);
                pkg.WriteString(p.PlayerCharacter.ConsortiaName);
                pkg.WriteInt(p.PlayerCharacter.ConsortiaLevel);
                pkg.WriteInt(p.PlayerCharacter.ConsortiaRepute);

                pkg.WriteInt(p.PlayerCharacter.Attack);
                pkg.WriteInt(p.PlayerCharacter.Defence);
                pkg.WriteInt(p.PlayerCharacter.Agility);
                pkg.WriteInt(p.PlayerCharacter.Luck);
                pkg.WriteDouble(p.GetBaseAttack());
                pkg.WriteDouble(p.GetBaseDefence());
                pkg.WriteDouble(p.GetBaseAgility());
                pkg.WriteDouble(p.GetBaseBlood());
                pkg.WriteInt(p.MainWeapon.TemplateID);
                pkg.WriteBoolean(p.CanUseProp);
                if (p.SecondWeapon != null)
                {
                    pkg.WriteInt(p.SecondWeapon.TemplateID);
                    pkg.WriteInt(p.SecondWeapon.StrengthenLevel);
                }
                else
                {
                    pkg.WriteInt(0);
                    pkg.WriteInt(0);
                }
                pkg.WriteDouble(RateMgr.GetRate(eRateType.Experience_Rate) * AntiAddictionMgr.GetAntiAddictionCoefficient(p.PlayerCharacter.AntiAddiction) * (p.GPAddPlus == 0 ? 1 : p.GPAddPlus));
                pkg.WriteDouble(AntiAddictionMgr.GetAntiAddictionCoefficient(p.PlayerCharacter.AntiAddiction) * (p.OfferAddPlus == 0 ? 1 : p.OfferAddPlus));
                pkg.WriteDouble(RateMgr.GetRate(eRateType.Experience_Rate));
                pkg.WriteInt(GameServer.Instance.Configuration.ServerID);


                List <AbstractBuffer> infos = p.BufferList.GetAllBuffer();
                pkg.WriteInt(infos.Count);
                foreach (AbstractBuffer bufferInfo in infos)
                {
                    BufferInfo info = bufferInfo.Info;
                    pkg.WriteInt(info.Type);
                    pkg.WriteBoolean(info.IsExist);
                    pkg.WriteDateTime(info.BeginDate);
                    pkg.WriteInt(info.ValidDate);
                    pkg.WriteInt(info.Value);
                }

                pkg.WriteInt(p.EquipEffect.Count);
                foreach (int i in p.EquipEffect)
                {
                    pkg.WriteInt(i);
                }
            }
            SendTCP(pkg);
        }
Exemple #21
0
        BufferInfo BuildTerrainPart(TerrainMap map, int x1, int y1, int width, int length)
        {
            TileDrawInfo drawInfo = new TileDrawInfo();
            BufferInfo   info     = new BufferInfo();
            int          vboId    = GLUtils.GenBuffer();

            int lengthX = map.Width;
            int lengthY = map.Length;

            Vector3[] vertices = new Vector3[width * length * 6];
            int       index    = 0;

            int   x2   = x1 + width;
            int   y2   = y1 + length;
            float zMax = 0;

            for (int x = x1; x < x2; x++)
            {
                for (int y = y1; y < y2; y++)
                {
                    Tile tile = map[x, y];
                    if (tile.Height > zMax)
                    {
                        zMax = tile.Height;
                    }
                    drawInfo.CurrentTile = tile;
                    bool leftExists   = x > 0;
                    bool behindExists = y > 0;
                    bool rightExists  = x < lengthX - 1;
                    bool frontExists  = y < lengthY - 1;

                    if (leftExists && behindExists)
                    {
                        drawInfo.LeftBehind = map[x - 1, y - 1];
                    }
                    if (leftExists && frontExists)
                    {
                        drawInfo.LeftFront = map[x - 1, y + 1];
                    }
                    if (rightExists && behindExists)
                    {
                        drawInfo.RightBehind = map[x + 1, y - 1];
                    }
                    if (rightExists && frontExists)
                    {
                        drawInfo.RightFront = map[x + 1, y + 1];
                    }

                    if (leftExists)
                    {
                        drawInfo.Left = map[x - 1, y];
                    }
                    if (behindExists)
                    {
                        drawInfo.Behind = map[x, y - 1];
                    }
                    if (rightExists)
                    {
                        drawInfo.Right = map[x + 1, y];
                    }
                    if (frontExists)
                    {
                        drawInfo.Front = map[x, y + 1];
                    }

                    drawInfo.MapX = x;
                    drawInfo.MapY = y;
                    RenderTile(drawInfo, vertices, index);
                    index += 6;
                }
            }             // end for

            int size = vertices.Length * 12;

            GL.Arb.BindBuffer(BufferTargetArb.ArrayBuffer, vboId);
            GL.Arb.BufferData(BufferTargetArb.ArrayBuffer, new IntPtr(size), vertices, BufferUsageArb.StaticDraw);
            GL.Arb.BindBuffer(BufferTargetArb.ArrayBuffer, 0);
            info.Centre        = new Vector3(x1 + width / 2f, zMax / 2f, y1 + length / 2f);
            info.Radius        = length;
            info.VboId         = vboId;
            info.VerticesCount = drawInfo.TotalTriangles * 3;

            return(info);
        }
Exemple #22
0
        public override void RenderTiles(TerrainMap map, ref int totalTriangles)
        {
            if (chunks == null)
            {
                var sw    = Stopwatch.StartNew();
                int sizeX = map.Width / chunkSize + (map.Width % chunkSize != 0 ? 1 : 0);
                int sizeY = map.Length / chunkSize + (map.Length % chunkSize != 0 ? 1 : 0);
                chunks = new BufferInfo[sizeX * sizeY];

                int width = map.Width;
                int index = 0;
                for (int x = 0; x < sizeX; x++)
                {
                    int length = map.Length;
                    for (int y = 0; y < sizeY; y++)
                    {
                        int chunkWidth  = Math.Min(width, chunkSize);
                        int chunkLength = Math.Min(length, chunkSize);
                        chunks[index] = BuildTerrainPart(map, x * chunkSize, y * chunkSize, chunkWidth, chunkLength);
                        index++;
                        length -= chunkSize;
                        if (length < 0)
                        {
                            length = 0;
                        }
                    }
                    width -= chunkSize;
                    if (width < 0)
                    {
                        width = 0;
                    }
                }
                long elapsed = sw.ElapsedMilliseconds;
                sw.Stop();
                Console.WriteLine("Took " + elapsed + " ms to generate the map.");
            }
            totalTriangles = 0;

            GL.EnableClientState(ArrayCap.VertexArray);
            //int skip = 0;
            for (int i = 0; i < chunks.Length; i++)
            {
                BufferInfo bi     = chunks[i];
                Vector3    centre = bi.Centre;
                bool       render = map.Culling.SphereInFrustum(centre.X, centre.Y, centre.Z, bi.Radius);
                if (!render)
                {
                    //skip++;
                    continue;
                }

                GL.Arb.BindBuffer(BufferTargetArb.ArrayBuffer, bi.VboId);
                GL.VertexPointer(3, VertexPointerType.Float, 12, new IntPtr(0));
                GL.DrawArrays(BeginMode.Triangles, 0, bi.VerticesCount);
                totalTriangles += bi.VerticesCount / 3;
            }
            GL.Arb.BindBuffer(BufferTargetArb.ArrayBuffer, 0);
            GL.DisableClientState(ArrayCap.VertexArray);

            //if( skip > 0 )
            //Console.WriteLine( skip );
        }
Exemple #23
0
        /// <summary>
        /// if both inputPath string and inputUri are not null, this
        /// method will use the Uri.  Else, set one or the other
        ///
        /// They cannot both be null
        /// </summary>
        /// <param name="startMs">the start ms for trimming</param>
        /// <param name="endMs">the final ms for trimming</param>
        /// <param name="inputPath">optional input path string</param>
        /// <param name="muxer">the muxer to use for writing bytes</param>
        /// <param name="trackIndexOverride">the track index for muxer read/write to</param>
        /// <param name="bufferInfo">an input bufferinfo to get properties from</param>
        /// <param name="outputPath">the output path for method to check after finished encoding</param>
        /// <param name="ptOffset">the presentation time offset for audio, used in syncing audio and video</param>
        /// <param name="inputUri">optional inputUri to read from</param>
        /// <returns></returns>
        public async Task <string> HybridMuxingTrimmer(int startMs, int endMs, string inputPath, MediaMuxer muxer, int trackIndexOverride = -1, BufferInfo bufferInfo = null, string outputPath = null, long ptOffset = 0, Android.Net.Uri inputUri = null)
        {
            var tio = trackIndexOverride;
            await Task.Run(() =>
            {
                if (outputPath == null)
                {
                    outputPath = FileToMp4.LatestOutputPath;
                }
                MediaExtractor ext = new MediaExtractor();
                if (inputUri != null)
                {
                    ext.SetDataSource(Android.App.Application.Context, inputUri, null);
                }
                else
                {
                    ext.SetDataSource(inputPath);
                }
                int trackCount = ext.TrackCount;
                Dictionary <int, int> indexDict = new Dictionary <int, int>(trackCount);
                int bufferSize = -1;
                for (int i = 0; i < trackCount; i++)
                {
                    MediaFormat format      = ext.GetTrackFormat(i);
                    string mime             = format.GetString(MediaFormat.KeyMime);
                    bool selectCurrentTrack = false;
                    if (mime.StartsWith("audio/"))
                    {
                        selectCurrentTrack = true;
                    }
                    else if (mime.StartsWith("video/"))
                    {
                        selectCurrentTrack = false;
                    }                                                                   /*rerouted to gl video encoder*/
                    if (selectCurrentTrack)
                    {
                        ext.SelectTrack(i);
                        if (tio != -1)
                        {
                            indexDict.Add(i, i);
                        }
                        if (format.ContainsKey(MediaFormat.KeyMaxInputSize))
                        {
                            int newSize = format.GetInteger(MediaFormat.KeyMaxInputSize);
                            bufferSize  = newSize > bufferSize ? newSize : bufferSize;
                        }
                    }
                }
                MediaMetadataRetriever retrieverSrc = new MediaMetadataRetriever();
                if (!System.String.IsNullOrWhiteSpace(inputPath))
                {
                    retrieverSrc.SetDataSource(inputPath);
                }
                else
                {
                    retrieverSrc.SetDataSource(Android.App.Application.Context, inputUri);
                }
                string degreesString = retrieverSrc.ExtractMetadata(MetadataKey.VideoRotation);
                if (degreesString != null) // unused ATM but will be useful for stabilized videoview in streaming
                {
                    int degrees = int.Parse(degreesString);
                    if (degrees >= 0) /* muxer.SetOrientationHint(degrees); */ } {
                    //muxer won't accept this param once started
            }
                           if (startMs > 0)
                {
                    ext.SeekTo(startMs * 1000, MediaExtractorSeekTo.ClosestSync);
                }
                           int offset = 0;
                           if (bufferInfo == null)
                {
                    bufferInfo = new MediaCodec.BufferInfo();
                }
                           ByteBuffer dstBuf = ByteBuffer.Allocate(bufferSize);
                           long us           = endMs * 1000;
                           long uo           = us + ptOffset;
                           int cf            = 0;
                           try
                {
                    FileToMp4.AudioEncodingInProgress = true;
                    while (true)
                    {
                        bufferInfo.Offset = offset;
                        bufferInfo.Size   = ext.ReadSampleData(dstBuf, offset);
                        if (bufferInfo.Size < 0)
                        {
                            bufferInfo.Size = 0; break;
                        }
                        else
                        {
                            cf++;
                            bufferInfo.PresentationTimeUs = ext.SampleTime + ptOffset;
                            if (ext.SampleTime >= us)
                            {
                                break;
                            }                                    //out of while
                            else
                            {
                                bufferInfo.Flags = MFlags2MCodecBuff(ext.SampleFlags);
                                if (tio == -1)
                                {
                                    muxer.WriteSampleData(FileToMp4.LatestAudioTrackIndex, dstBuf, bufferInfo);
                                }
                                else
                                {
                                    muxer.WriteSampleData(tio, dstBuf, bufferInfo);
                                }
                                if (cf >= 240) //only send the muxer eventargs once every x frames to reduce CPU load
                                {
                                    Notify(ext.SampleTime, us);
                                    cf = 0;
                                }
                            }
                            ext.Advance();
                        }
                    }
                }
                           catch (Java.Lang.IllegalStateException e)
                {
                    this.Progress.Invoke(new MuxerEventArgs(ext.SampleTime, us, null, true, true));
                    Console.WriteLine("The source video file is malformed");
                }
                           catch (Java.Lang.Exception ex)
                {
                    this.Progress.Invoke(new MuxerEventArgs(ext.SampleTime, us, null, true, true));
                    Console.WriteLine(ex.Message);
                }
                           if (AppSettings.Logging.SendToConsole)
                {
                    System.Console.WriteLine($"DrainEncoder audio finished @ {bufferInfo.PresentationTimeUs}");
                }
});

            FileToMp4.AudioEncodingInProgress = false;
            try
            {
                if (!FileToMp4.VideoEncodingInProgress)
                {
                    muxer.Stop();
                    muxer.Release();
                    muxer = null;
                }
            }
            catch (Java.Lang.Exception ex) { Log.Debug("MuxingEncoder", ex.Message); }
            if (outputPath != null)
            {
                var success = System.IO.File.Exists(outputPath);
                if (success)
                {
                    this.Progress.Invoke(new MuxerEventArgs(endMs * 1000, endMs, outputPath, true));
                    return(outputPath);
                }
            }

            return(null); //nothing to look for
        }
Exemple #24
0
        private async Task ParseBuffers(ITextSnapshot[] snapshots, BufferInfo[] bufferInfos) {
            var indentationSeverity = _parser.PyService.GeneralOptions.IndentationInconsistencySeverity;
            AnalysisEntry entry = AnalysisEntry;

            List<AP.FileUpdate> updates = new List<AP.FileUpdate>();
            lock (this) {
                for (int i = 0; i < snapshots.Length; i++) {
                    var snapshot = snapshots[i];
                    var bufferInfo = bufferInfos[i];

                    if (snapshot.TextBuffer.Properties.ContainsProperty(DoNotParse) ||
                        snapshot.IsReplBufferWithCommand()) {
                        continue;
                    }

                    var lastSent = GetLastSentSnapshot(bufferInfo.Buffer);
                    if (lastSent == null || lastSent.TextBuffer != snapshot.TextBuffer) {
                        // First time parsing from a live buffer, send the entire
                        // file and set our initial snapshot.  We'll roll forward
                        // to new snapshots when we receive the errors event.  This
                        // just makes sure that the content is in sync.
                        updates.Add(
                            new AP.FileUpdate() {
                                content = snapshot.GetText(),
                                version = snapshot.Version.VersionNumber,
                                bufferId = bufferInfo.Id,
                                kind = AP.FileUpdateKind.reset
                            }
                        );
                    } else {
                        if (lastSent.Version == snapshot.Version) {
                            // this snapshot is up to date...
                            continue;
                        }

                        List<AP.VersionChanges> versions = new List<AnalysisProtocol.VersionChanges>();
                        for (var curVersion = lastSent.Version;
                            curVersion != snapshot.Version;
                            curVersion = curVersion.Next) {
                            versions.Add(
                                new AP.VersionChanges() {
                                    changes = GetChanges(curVersion)
                                }
                            );
                        }

                        updates.Add(
                            new AP.FileUpdate() {
                                versions = versions.ToArray(),
                                version = snapshot.Version.VersionNumber,
                                bufferId = bufferInfo.Id,
                                kind = AP.FileUpdateKind.changes
                            }
                        );
                    }

                    Debug.WriteLine("Added parse request {0}", snapshot.Version.VersionNumber);
                    entry.AnalysisCookie = new SnapshotCookie(snapshot);  // TODO: What about multiple snapshots?
                    SetLastSentSnapshot(snapshot);
                }
            }

            if (updates.Count != 0) {
                _parser._analysisComplete = false;
                Interlocked.Increment(ref _parser._parsePending);

                var res = await _parser.SendRequestAsync(
                    new AP.FileUpdateRequest() {
                        fileId = entry.FileId,
                        updates = updates.ToArray()
                    }
                );

                if (res != null) {
                    _parser.OnAnalysisStarted();
#if DEBUG
                    for (int i = 0; i < bufferInfos.Length; i++) {
                        var snapshot = snapshots[i];
                        var buffer = bufferInfos[i];

                        string newCode;
                        if (res.newCode.TryGetValue(buffer.Id, out newCode)) {
                            Debug.Assert(newCode == snapshot.GetText());
                        }
                    }
#endif
                } else {
                    Interlocked.Decrement(ref _parser._parsePending);
                }
            }
        }
Exemple #25
0
 public EncodedforMux(int Trackindex, byte[] Data, BufferInfo Buffinfo)
 {
     trackindex = Trackindex;
     data       = Data;
     bufferinfo = Buffinfo;
 }
        public void SendAddRoom(BaseRoom room)
        {
            GSPacketIn pkg = new GSPacketIn(64);

            pkg.WriteInt(room.RoomId);
            pkg.WriteInt((int)room.GameType);
            pkg.WriteInt(room.GuildId);
            pkg.WriteInt(GameServer.Instance.Config.AreaID);
            pkg.WriteBoolean(room.IsArea);
            List <GamePlayer> players = room.GetPlayers();

            pkg.WriteInt(players.Count);
            foreach (GamePlayer p in players)
            {
                pkg.WriteInt(p.AreaID);
                pkg.WriteString(p.AreaName);
                pkg.WriteInt(p.PlayerCharacter.ID);
                pkg.WriteString(p.PlayerCharacter.NickName);
                pkg.WriteBoolean(p.PlayerCharacter.Sex);
                pkg.WriteInt(p.PlayerCharacter.Hide);
                pkg.WriteString(p.PlayerCharacter.Style);
                pkg.WriteString(p.PlayerCharacter.Colors);
                pkg.WriteString(p.PlayerCharacter.Skin);
                pkg.WriteInt(p.PlayerCharacter.Offer);
                pkg.WriteInt(p.PlayerCharacter.GP);
                pkg.WriteInt(p.PlayerCharacter.Grade);
                pkg.WriteInt(p.PlayerCharacter.Repute);
                pkg.WriteInt(p.PlayerCharacter.Nimbus);
                pkg.WriteInt(p.PlayerCharacter.ConsortiaID);
                pkg.WriteString(p.PlayerCharacter.ConsortiaName);
                pkg.WriteInt(p.PlayerCharacter.ConsortiaLevel);
                pkg.WriteInt(p.PlayerCharacter.ConsortiaRepute);
                pkg.WriteInt(p.PlayerCharacter.Win);
                pkg.WriteInt(p.PlayerCharacter.Total);
                pkg.WriteInt(p.PlayerCharacter.Attack);
                pkg.WriteInt(p.PlayerCharacter.Defence);
                pkg.WriteInt(p.PlayerCharacter.Agility);
                pkg.WriteInt(p.PlayerCharacter.Luck);
                pkg.WriteInt(p.PlayerCharacter.FightPower);
                pkg.WriteBoolean(p.PlayerCharacter.IsMarried);
                if (p.PlayerCharacter.IsMarried)
                {
                    pkg.WriteInt(p.PlayerCharacter.SpouseID);
                    pkg.WriteString(p.PlayerCharacter.SpouseName);
                }
                pkg.WriteDouble(p.GetBaseAttack());
                pkg.WriteDouble(p.GetBaseDefence());
                pkg.WriteDouble(p.GetBaseAgility());
                pkg.WriteDouble(p.GetBaseBlood());
                if (p.MainWeapon != null)
                {
                    pkg.WriteInt(p.MainWeapon.TemplateID);
                }
                else
                {
                    pkg.WriteInt(0);
                }
                pkg.WriteBoolean(p.CanUseProp);
                if (p.SecondWeapon != null)
                {
                    pkg.WriteInt(p.SecondWeapon.TemplateID);
                    pkg.WriteInt(p.SecondWeapon.StrengthenLevel);
                }
                else
                {
                    pkg.WriteInt(0);
                    pkg.WriteInt(0);
                }
                pkg.WriteDouble(p.GPAddPlus);
                pkg.WriteFloat(p.GMExperienceRate);
                pkg.WriteFloat(p.AuncherExperienceRate);
                pkg.WriteDouble(p.OfferAddPlus);
                pkg.WriteFloat(p.GMOfferRate);
                pkg.WriteFloat(p.AuncherOfferRate);
                pkg.WriteFloat(p.GMRichesRate);
                pkg.WriteFloat(p.AuncherRichesRate);
                pkg.WriteDouble(p.AntiAddictionRate);
                List <AbstractBuffer> infos = p.BufferList.GetAllBuffer();
                pkg.WriteInt(infos.Count);
                foreach (AbstractBuffer bufferInfo in infos)
                {
                    BufferInfo info = bufferInfo.Info;
                    pkg.WriteInt(info.Type);
                    pkg.WriteBoolean(info.IsExist);
                    pkg.WriteDateTime(info.BeginDate);
                    pkg.WriteInt(info.ValidDate);
                    pkg.WriteInt(info.Value);
                }
                pkg.WriteInt(p.EquipEffect.Count);
                foreach (int i in p.EquipEffect)
                {
                    pkg.WriteInt(i);
                }
            }
            this.SendTCP(pkg);
        }
Exemple #27
0
        public void HandleGameRoomCreate(GSPacketIn pkg)
        {
            int roomId   = pkg.ReadInt();
            int gameType = pkg.ReadInt();
            int guildId  = pkg.ReadInt();

            int count      = pkg.ReadInt();
            int totalLevel = 0;

            IGamePlayer[] players = new IGamePlayer[count];
            for (int i = 0; i < count; i++)
            {
                PlayerInfo info = new PlayerInfo();
                info.ID              = pkg.ReadInt();
                info.NickName        = pkg.ReadString();
                info.Sex             = pkg.ReadBoolean();
                info.Hide            = pkg.ReadInt();
                info.Style           = pkg.ReadString();
                info.Colors          = pkg.ReadString();
                info.Skin            = pkg.ReadString();
                info.Offer           = pkg.ReadInt();
                info.GP              = pkg.ReadInt();
                info.Grade           = pkg.ReadInt();
                info.Repute          = pkg.ReadInt();
                info.ConsortiaID     = pkg.ReadInt();
                info.ConsortiaName   = pkg.ReadString();
                info.ConsortiaLevel  = pkg.ReadInt();
                info.ConsortiaRepute = pkg.ReadInt();

                info.Attack  = pkg.ReadInt();
                info.Defence = pkg.ReadInt();
                info.Agility = pkg.ReadInt();
                info.Luck    = pkg.ReadInt();

                double baseAttack    = pkg.ReadDouble();
                double baseDefence   = pkg.ReadDouble();
                double baseAgility   = pkg.ReadDouble();
                double baseBlood     = pkg.ReadDouble();
                int    templateId    = pkg.ReadInt();
                bool   canUserProp   = pkg.ReadBoolean();
                int    secondWeapon  = pkg.ReadInt();
                int    strengthLevel = pkg.ReadInt();


                double gprate    = pkg.ReadDouble();
                double offerrate = pkg.ReadDouble();
                double rate      = pkg.ReadDouble();
                int    serverid  = pkg.ReadInt();

                ItemTemplateInfo itemTemplate = ItemMgr.FindItemTemplate(templateId);
                ItemInfo         item         = null;
                if (secondWeapon != 0)
                {
                    ItemTemplateInfo secondWeaponTemp = ItemMgr.FindItemTemplate(secondWeapon);
                    item = ItemInfo.CreateFromTemplate(secondWeaponTemp, 1, 1);
                    item.StrengthenLevel = strengthLevel;
                }

                List <BufferInfo> infos = new List <BufferInfo>();

                int buffercout = pkg.ReadInt();
                for (int j = 0; j < buffercout; j++)
                {
                    BufferInfo buffinfo = new BufferInfo();
                    buffinfo.Type      = pkg.ReadInt();
                    buffinfo.IsExist   = pkg.ReadBoolean();
                    buffinfo.BeginDate = pkg.ReadDateTime();
                    buffinfo.ValidDate = pkg.ReadInt();
                    buffinfo.Value     = pkg.ReadInt();
                    if (info != null)
                    {
                        infos.Add(buffinfo);
                    }
                }

                players[i]            = new ProxyPlayer(this, info, itemTemplate, item, baseAttack, baseDefence, baseAgility, baseBlood, gprate, offerrate, rate, infos, serverid);
                players[i].CanUseProp = canUserProp;

                int ec = pkg.ReadInt();
                for (int j = 0; j < ec; j++)
                {
                    players[i].EquipEffect.Add(pkg.ReadInt());
                }
                totalLevel += info.Grade;
            }

            ProxyRoom room = new ProxyRoom(ProxyRoomMgr.NextRoomId(), roomId, players, this);

            room.GuildId  = guildId;
            room.GameType = (eGameType)gameType;

            lock (m_rooms)
            {
                if (!m_rooms.ContainsKey(roomId))
                {
                    m_rooms.Add(roomId, room);
                }
                else
                {
                    room = null;
                }
            }

            if (room != null)
            {
                ProxyRoomMgr.AddRoom(room);
            }
            else
            {
                log.ErrorFormat("Room already exists:{0}", roomId);
            }
        }
Exemple #28
0
        internal void ReparseWorker(object unused) {
            ITextSnapshot[] snapshots;
            BufferInfo[] bufferInfos;
            lock (this) {
                if (_parsing) {
                    return;
                }

                _parsing = true;
                var buffers = Buffers;
                snapshots = new ITextSnapshot[buffers.Length];
                bufferInfos = new BufferInfo[buffers.Length];
                for (int i = 0; i < buffers.Length; i++) {
                    snapshots[i] = buffers[i].CurrentSnapshot;
                    bufferInfos[i] = _bufferInfo[buffers[i]];
                }
            }

            ParseBuffers(snapshots, bufferInfos).WaitAndHandleAllExceptions(_parser._serviceProvider);

            lock (this) {
                _parsing = false;
                if (_requeue) {
                    RequeueWorker();
                }
                _requeue = false;
            }
        }
 public AbstractBuffer(BufferInfo info)
 {
     this.m_info = info;
 }
Exemple #30
0
 public SoundPlayingInfo(string fileName, int volume, BufferInfo bufferInfo)
 {
     FileName   = fileName;
     Volume     = volume;
     BufferInfo = bufferInfo;
 }
Exemple #31
0
 void OnBufferBody(BufferInfo buffer)
 {
 }
Exemple #32
0
 public KickProtectBuffer(BufferInfo info) : base(info)
 {
 }
Exemple #33
0
        public void HandleGameRoomCreate(GSPacketIn pkg)
        {
            int num      = pkg.ReadInt();
            int gameType = pkg.ReadInt();
            int guildId  = pkg.ReadInt();
            int num2     = pkg.ReadInt();
            int num3     = 0;

            IGamePlayer[] array = new IGamePlayer[num2];
            for (int i = 0; i < num2; i++)
            {
                PlayerInfo playerInfo = new PlayerInfo();
                playerInfo.ID                    = pkg.ReadInt();
                playerInfo.NickName              = pkg.ReadString();
                playerInfo.Sex                   = pkg.ReadBoolean();
                playerInfo.typeVIP               = pkg.ReadByte();
                playerInfo.VIPLevel              = pkg.ReadInt();
                playerInfo.Hide                  = pkg.ReadInt();
                playerInfo.Style                 = pkg.ReadString();
                playerInfo.Colors                = pkg.ReadString();
                playerInfo.Skin                  = pkg.ReadString();
                playerInfo.Offer                 = pkg.ReadInt();
                playerInfo.GP                    = pkg.ReadInt();
                playerInfo.Grade                 = pkg.ReadInt();
                playerInfo.Repute                = pkg.ReadInt();
                playerInfo.ConsortiaID           = pkg.ReadInt();
                playerInfo.ConsortiaName         = pkg.ReadString();
                playerInfo.ConsortiaLevel        = pkg.ReadInt();
                playerInfo.ConsortiaRepute       = pkg.ReadInt();
                playerInfo.badgeID               = pkg.ReadInt();
                playerInfo.weaklessGuildProgress = Base64.decodeToByteArray(pkg.ReadString());
                playerInfo.Attack                = pkg.ReadInt();
                playerInfo.Defence               = pkg.ReadInt();
                playerInfo.Agility               = pkg.ReadInt();
                playerInfo.Luck                  = pkg.ReadInt();
                playerInfo.hp                    = pkg.ReadInt();
                playerInfo.FightPower            = pkg.ReadInt();
                playerInfo.IsMarried             = pkg.ReadBoolean();
                if (playerInfo.IsMarried)
                {
                    playerInfo.SpouseID   = pkg.ReadInt();
                    playerInfo.SpouseName = pkg.ReadString();
                }
                ProxyPlayerInfo proxyPlayerInfo = new ProxyPlayerInfo();
                proxyPlayerInfo.BaseAttack        = pkg.ReadDouble();
                proxyPlayerInfo.BaseDefence       = pkg.ReadDouble();
                proxyPlayerInfo.BaseAgility       = pkg.ReadDouble();
                proxyPlayerInfo.BaseBlood         = pkg.ReadDouble();
                proxyPlayerInfo.TemplateId        = pkg.ReadInt();
                proxyPlayerInfo.CanUserProp       = pkg.ReadBoolean();
                proxyPlayerInfo.SecondWeapon      = pkg.ReadInt();
                proxyPlayerInfo.StrengthLevel     = pkg.ReadInt();
                proxyPlayerInfo.GPAddPlus         = pkg.ReadDouble();
                proxyPlayerInfo.OfferAddPlus      = pkg.ReadDouble();
                proxyPlayerInfo.AntiAddictionRate = pkg.ReadDouble();
                proxyPlayerInfo.ServerId          = pkg.ReadInt();
                UsersPetinfo usersPetinfo = new UsersPetinfo();
                int          num4         = pkg.ReadInt();
                if (num4 == 1)
                {
                    usersPetinfo.Place      = pkg.ReadInt();
                    usersPetinfo.TemplateID = pkg.ReadInt();
                    usersPetinfo.ID         = pkg.ReadInt();
                    usersPetinfo.Name       = pkg.ReadString();
                    usersPetinfo.UserID     = pkg.ReadInt();
                    usersPetinfo.Level      = pkg.ReadInt();
                    usersPetinfo.Skill      = pkg.ReadString();
                    usersPetinfo.SkillEquip = pkg.ReadString();
                }
                else
                {
                    usersPetinfo = null;
                }
                List <BufferInfo> list = new List <BufferInfo>();
                int num5 = pkg.ReadInt();
                for (int j = 0; j < num5; j++)
                {
                    BufferInfo bufferInfo = new BufferInfo();
                    bufferInfo.Type       = pkg.ReadInt();
                    bufferInfo.IsExist    = pkg.ReadBoolean();
                    bufferInfo.BeginDate  = pkg.ReadDateTime();
                    bufferInfo.ValidDate  = pkg.ReadInt();
                    bufferInfo.Value      = pkg.ReadInt();
                    bufferInfo.ValidCount = pkg.ReadInt();
                    if (playerInfo != null)
                    {
                        list.Add(bufferInfo);
                    }
                }
                List <ItemInfo> list2 = new List <ItemInfo>();
                int             num6  = pkg.ReadInt();
                for (int k = 0; k < num6; k++)
                {
                    int      templateId = pkg.ReadInt();
                    int      hole       = pkg.ReadInt();
                    ItemInfo itemInfo   = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(templateId), 1, 1);
                    itemInfo.Hole1 = hole;
                    list2.Add(itemInfo);
                }
                array[i]            = new ProxyPlayer(this, playerInfo, proxyPlayerInfo, usersPetinfo, list, list2);
                array[i].CanUseProp = proxyPlayerInfo.CanUserProp;
                num3 += playerInfo.Grade;
            }
            ProxyRoom proxyRoom = new ProxyRoom(ProxyRoomMgr.NextRoomId(), num, array, this);

            proxyRoom.GuildId  = guildId;
            proxyRoom.GameType = (eGameType)gameType;
            Dictionary <int, ProxyRoom> rooms;

            Monitor.Enter(rooms = this.m_rooms);
            try
            {
                if (!this.m_rooms.ContainsKey(num))
                {
                    this.m_rooms.Add(num, proxyRoom);
                }
                else
                {
                    proxyRoom = null;
                }
            }
            finally
            {
                Monitor.Exit(rooms);
            }
            if (proxyRoom != null)
            {
                ProxyRoomMgr.AddRoom(proxyRoom);
                return;
            }
            ServerClient.log.ErrorFormat("Room already exists:{0}", num);
        }