Esempio n. 1
0
File: GameMap.cs Progetto: Pircs/Yi
        private void LoadDataLayer(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException();
            }

            int amount;

            stream.Read(&amount, sizeof(int));

            for (var i = 0; i < amount; i++)
            {
                int mapObjType;
                stream.Read(&mapObjType, sizeof(int));

                switch (mapObjType)
                {
                case MapCover:
                {
                    //Do nothing with it...
                    var coverObj = new C2DMapCoverObj();
                    stream.Read(&coverObj, sizeof(C2DMapCoverObj));
                    var file  = new string((sbyte *)coverObj.FileName);
                    var index = new string((sbyte *)coverObj.Index);

                    //var lines = File.ReadAllLines(@"X:\Users\domi\Downloads\Client & -150 Maps\AstaCo Client\" + file);



                    //    var next=false;
                    //foreach (var line in lines)
                    //{
                    //    if (next)
                    //    {
                    //        if (!line.ToLower().Contains("frame0"))
                    //            continue;

                    //        next = false;

                    //        if (!File.Exists(@"X:\Users\domi\Downloads\Client & -150 Maps\AstaCo Client\" + line.Replace("Frame0=","")))
                    //        {
                    //            System.Diagnostics.Debugger.Break();
                    //        }
                    //        else
                    //        {
                    //            Output.WriteLine("Found: " + index);
                    //        }
                    //    }
                    //    if (line == $"[{index}]")
                    //    {
                    //        next = true;
                    //    }
                    //}

                    break;
                }

                case MapTerrain:
                {
                    var mapObj = new C2DMapTerrainObj();
                    stream.Read(mapObj.FileName, 260);
                    stream.Read(&mapObj.PosCell, sizeof(MyPos));
                    mapObj.Load(_folder);

                    //The server only need the new LayerInfo, so it will be merged
                    //and the object will be deleted
                    foreach (var part in mapObj.Parts)
                    {
                        for (var j = 0; j < part.SizeBase.Width; j++)
                        {
                            for (var k = 0; k < part.SizeBase.Height; k++)
                            {
                                var x = mapObj.PosCell.X + part.PosSceneOffset.X + j - part.SizeBase.Width;
                                var y = mapObj.PosCell.Y + part.PosSceneOffset.Y + k - part.SizeBase.Height;
                                _cells[x, y] = new Cell(part.Cells[j, k]);
                            }
                        }
                    }
                    break;
                }

                case MapSound:
                {
                    //Do nothing with it...
                    stream.Seek(sizeof(CMapSound), SeekOrigin.Current);
                    break;
                }

                case Map3Deffect:
                {
                    //Do nothing with it...
                    stream.Seek(sizeof(C3DMapEffect), SeekOrigin.Current);
                    break;
                }

                case Map3Deffectnew:
                {
                    //Do nothing with it...
                    stream.Seek(sizeof(C3DMapEffectNew), SeekOrigin.Current);
                    break;
                }
                }
            }
        }
Esempio n. 2
0
File: GameMap.cs Progetto: Pircs/Yi
        private void LoadDataLayer(FileStream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException();
            }

            int amount;

            stream.Read(&amount, sizeof(int));

            for (var i = 0; i < amount; i++)
            {
                int mapObjType;
                stream.Read(&mapObjType, sizeof(int));

                switch (mapObjType)
                {
                case MAP_COVER:
                {
                    //Do nothing with it...
                    stream.Seek(sizeof(C2DMapCoverObj), SeekOrigin.Current);
                    break;
                }

                case MAP_TERRAIN:
                {
                    var mapObj = new C2DMapTerrainObj();
                    stream.Read(mapObj.FileName, 260);
                    stream.Read(&mapObj.PosCell, sizeof(MyPos));
                    mapObj.Load(_folder);

                    //The server only need the new LayerInfo, so it will be merged
                    //and the object will be deleted
                    foreach (var part in mapObj.Parts)
                    {
                        for (var j = 0; j < part.SizeBase.Width; j++)
                        {
                            for (var k = 0; k < part.SizeBase.Height; k++)
                            {
                                var x = mapObj.PosCell.X + part.PosSceneOffset.X + j - part.SizeBase.Width;
                                var y = mapObj.PosCell.Y + part.PosSceneOffset.Y + k - part.SizeBase.Height;
                                _cells[x, y] = new Cell(part.Cells[j, k]);
                            }
                        }
                    }
                    break;
                }

                case MAP_SOUND:
                {
                    //Do nothing with it...
                    stream.Seek(sizeof(CMapSound), SeekOrigin.Current);
                    break;
                }

                case Map_3Deffect:
                {
                    //Do nothing with it...
                    stream.Seek(sizeof(C3DMapEffect), SeekOrigin.Current);
                    break;
                }

                case Map_3Deffectnew:
                {
                    //Do nothing with it...
                    stream.Seek(sizeof(C3DMapEffectNew), SeekOrigin.Current);
                    break;
                }
                }
            }
        }