Example #1
0
        public void SendCurrentEnv()
        {
            Zone zone = ZoneIn;

            for (int i = 0; i <= 5; i++)
            {
                string col = Server.Config.GetColor(i);
                if (level.Config.GetColor(i) != "")
                {
                    col = level.Config.GetColor(i);
                }
                if (zone != null && zone.Config.GetColor(i) != "")
                {
                    col = zone.Config.GetColor(i);
                }
                Session.SendSetEnvColor((byte)i, col);
            }

            if (Supports(CpeExt.EnvMapAspect))
            {
                for (EnvProp i = 0; i < EnvProp.Max; i++)
                {
                    int value = CurrentEnvProp(i, zone);
                    Send(Packet.EnvMapProperty(i, value));
                }
            }

            int weather = CurrentEnvProp(EnvProp.Weather, zone);

            Session.SendSetWeather((byte)weather);
        }
Example #2
0
        internal static void UpdateAppearance(Predicate <Player> selector, EnvProp prop, int origValue)
        {
            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                if (!selector(pl))
                {
                    continue;
                }
                int value = origValue;

                if (prop == EnvProp.SidesBlock || prop == EnvProp.EdgeBlock)
                {
                    value = pl.ConvertBlock((BlockID)value);
                }

                if (pl.Supports(CpeExt.EnvMapAspect))
                {
                    pl.Send(Packet.EnvMapProperty(prop, value));
                }
                else
                {
                    pl.SendCurrentTextures(); // Old MapAppearance packets have a few of the map properties
                }
                if (pl.ZoneIn != null)
                {
                    pl.OnChangedZone();
                }
            }
        }
Example #3
0
        public void SendCurrentMapAppearance()
        {
            byte side = (byte)level.Config.EdgeBlock, edge = (byte)level.Config.HorizonBlock;

            if (!hasBlockDefs)
            {
                side = level.RawFallback(side);
            }
            if (!hasBlockDefs)
            {
                edge = level.RawFallback(edge);
            }

            if (Supports(CpeExt.EnvMapAspect))
            {
                string url = GetTextureUrl();
                // reset all other textures back to client default.
                if (url != lastUrl)
                {
                    Send(Packet.EnvMapUrl("", hasCP437));
                }
                Send(Packet.EnvMapUrl(url, hasCP437));

                Send(Packet.EnvMapProperty(EnvProp.SidesBlock, side));
                Send(Packet.EnvMapProperty(EnvProp.EdgeBlock, edge));
                Send(Packet.EnvMapProperty(EnvProp.EdgeLevel, level.Config.EdgeLevel));
                Send(Packet.EnvMapProperty(EnvProp.SidesOffset, level.Config.SidesOffset));
                Send(Packet.EnvMapProperty(EnvProp.CloudsLevel, level.Config.CloudsHeight));

                Send(Packet.EnvMapProperty(EnvProp.MaxFog, level.Config.MaxFogDistance));
                Send(Packet.EnvMapProperty(EnvProp.CloudsSpeed, level.Config.CloudsSpeed));
                Send(Packet.EnvMapProperty(EnvProp.WeatherSpeed, level.Config.WeatherSpeed));
                Send(Packet.EnvMapProperty(EnvProp.WeatherFade, level.Config.WeatherFade));
                Send(Packet.EnvMapProperty(EnvProp.ExpFog, level.Config.ExpFog ? 1 : 0));
                Send(Packet.EnvMapProperty(EnvProp.SkyboxHorSpeed, level.Config.SkyboxHorSpeed));
                Send(Packet.EnvMapProperty(EnvProp.SkyboxVerSpeed, level.Config.SkyboxVerSpeed));
            }
            else if (Supports(CpeExt.EnvMapAppearance, 2))
            {
                string url = GetTextureUrl();
                // reset all other textures back to client default.
                if (url != lastUrl)
                {
                    Send(Packet.MapAppearanceV2("", side, edge, level.Config.EdgeLevel,
                                                level.Config.CloudsHeight, level.Config.MaxFogDistance, hasCP437));
                }
                Send(Packet.MapAppearanceV2(url, side, edge, level.Config.EdgeLevel,
                                            level.Config.CloudsHeight, level.Config.MaxFogDistance, hasCP437));
                lastUrl = url;
            }
            else if (Supports(CpeExt.EnvMapAppearance))
            {
                string url = level.Config.Terrain.Length == 0 ? ServerConfig.DefaultTerrain : level.Config.Terrain;
                Send(Packet.MapAppearance(url, side, edge, level.Config.EdgeLevel, hasCP437));
            }
        }
Example #4
0
        public void OnChangedZone()
        {
            if (Supports(CpeExt.InstantMOTD))
            {
                SendMapMotd();
            }
            Zone zone = ZoneIn;

            for (int i = 0; i <= 4; i++)
            {
                string col = level.Config.GetColor(i);
                if (zone != null && zone.Config.GetColor(i) != "")
                {
                    col = zone.Config.GetColor(i);
                }
                if (Supports(CpeExt.EnvColors))
                {
                    SendEnvColor((byte)i, col);
                }
            }

            for (EnvProp i = 0; i < EnvProp.Max; i++)
            {
                int value = level.Config.GetEnvProp(i);
                if (i == EnvProp.SidesBlock || i == EnvProp.EdgeBlock)
                {
                    if (zone != null && zone.Config.GetEnvProp(i) != Block.Invalid)
                    {
                        value = zone.Config.GetEnvProp(i);
                    }
                    value = ConvertBlock((BlockID)value);
                }
                else
                {
                    if (zone != null && zone.Config.GetEnvProp(i) != -1)
                    {
                        value = zone.Config.GetEnvProp(i);
                    }
                }
                if (Supports(CpeExt.EnvMapAspect))
                {
                    Send(Packet.EnvMapProperty(i, value));
                }
            }

            if (Supports(CpeExt.EnvWeatherType))
            {
                int weather = level.Config.Weather;
                if (zone != null && zone.Config.Weather != -1)
                {
                    weather = zone.Config.Weather;
                }
                Send(Packet.EnvWeatherType((byte)weather));
            }
        }
Example #5
0
 static void SendCurrentMapAppearance(Level lvl, EnvProp prop, int value) {
     Player[] players = PlayerInfo.Online.Items;
     foreach (Player pl in players) {
         if (pl.level != lvl) continue;
         
         if (pl.HasCpeExt(CpeExt.EnvMapAspect)) {
             pl.Send(Packet.EnvMapProperty(prop, value));
         } else {
             pl.SendCurrentMapAppearance();
         }
     }
 }
Example #6
0
        public void SendCurrentMapAppearance()
        {
            byte side = (byte)level.EdgeBlock, edge = (byte)level.HorizonBlock;

            if (side >= Block.CpeCount && !hasBlockDefs)
            {
                side = level.GetFallback(side);
            }
            if (edge >= Block.CpeCount && !hasBlockDefs)
            {
                edge = level.GetFallback(edge);
            }

            if (HasCpeExt(CpeExt.EnvMapAspect))
            {
                string url = GetTextureUrl();
                // reset all other textures back to client default.
                if (url != lastUrl)
                {
                    Send(Packet.EnvMapUrl(""));
                }
                Send(Packet.EnvMapUrl(url));

                Send(Packet.EnvMapProperty(EnvProp.SidesBlock, side));
                Send(Packet.EnvMapProperty(EnvProp.EdgeBlock, edge));
                Send(Packet.EnvMapProperty(EnvProp.EdgeLevel, level.EdgeLevel));
                Send(Packet.EnvMapProperty(EnvProp.CloudsLevel, level.CloudsHeight));
                Send(Packet.EnvMapProperty(EnvProp.MaxFog, level.MaxFogDistance));
                Send(Packet.EnvMapProperty(EnvProp.CloudsSpeed, level.CloudsSpeed));
                Send(Packet.EnvMapProperty(EnvProp.WeatherSpeed, level.WeatherSpeed));
            }
            else if (HasCpeExt(CpeExt.EnvMapAppearance, 2))
            {
                string url = GetTextureUrl();
                // reset all other textures back to client default.
                if (url != lastUrl)
                {
                    Send(Packet.MapAppearanceV2("", side, edge, level.EdgeLevel, level.CloudsHeight, level.MaxFogDistance));
                }
                Send(Packet.MapAppearanceV2(url, side, edge, level.EdgeLevel, level.CloudsHeight, level.MaxFogDistance));
                lastUrl = url;
            }
            else if (HasCpeExt(CpeExt.EnvMapAppearance))
            {
                string url = level.terrainUrl == "" ? Server.defaultTerrainUrl : level.terrainUrl;
                Send(Packet.MapAppearance(url, side, edge, level.EdgeLevel));
            }
        }