/// <summary>
        /// Check whether TDSM tile sets matches stock.
        /// </summary>
        /// <returns></returns>
        public static bool CheckTileSets(out int err)
        {
            Terraria_Server.Main.Initialize();
            using (var main = new Terraria.Main())
                main.DedServ();

            var merge = Terraria_Server.Main.tileMergeDirt.IsEqualTo(Terraria.Main.tileMergeDirt, out err);
            var tCut = Terraria_Server.Main.tileCut.IsEqualTo(Terraria.Main.tileCut, out err);
            var tAlch = Terraria_Server.Main.tileAlch.IsEqualTo(Terraria.Main.tileAlch, out err);
            var tShine = Terraria_Server.Main.tileShine.IsEqualTo(Terraria.Main.tileShine, out err);
            var wHouse = Terraria_Server.Main.wallHouse.IsEqualTo(Terraria.Main.wallHouse, out err);
            var tStone = Terraria_Server.Main.tileStone.IsEqualTo(Terraria.Main.tileStone, out err);
            var tWater = Terraria_Server.Main.tileWaterDeath.IsEqualTo(Terraria.Main.tileWaterDeath, out err);
            var tLava = Terraria_Server.Main.tileLavaDeath.IsEqualTo(Terraria.Main.tileLavaDeath, out err);
            var table = Terraria_Server.Main.tileTable.IsEqualTo(Terraria.Main.tileTable, out err);
            var bLight = Terraria_Server.Main.tileBlockLight.IsEqualTo(Terraria.Main.tileBlockLight, out err);
            var dung = Terraria_Server.Main.tileDungeon.IsEqualTo(Terraria.Main.tileDungeon, out err);
            var solTop = Terraria_Server.Main.tileSolidTop.IsEqualTo(Terraria.Main.tileSolidTop, out err);
            var tSolid = Terraria_Server.Main.tileSolid.IsEqualTo(Terraria.Main.tileSolid, out err);
            var noAtt = Terraria_Server.Main.tileNoAttach.IsEqualTo(Terraria.Main.tileNoAttach, out err);
            var noFail = Terraria_Server.Main.tileNoFail.IsEqualTo(Terraria.Main.tileNoFail, out err);
            var frameImp = Terraria_Server.Main.tileFrameImportant.IsEqualTo(Terraria.Main.tileFrameImportant, out err);

            return merge && tCut && tAlch && tShine && wHouse && tStone && tWater && tLava && table &&
                bLight && dung && solTop && tSolid && noAtt && noFail && frameImp;
        }
Ejemplo n.º 2
0
        public TerrariaTestsFixture()
        {
            _main = new Terraria.Main();

            Terraria.Localization.LanguageManager.Instance.SetLanguage("en-US");
            Terraria.Lang.InitializeLegacyLocalization();
            _main.Initialize();
        }
Ejemplo n.º 3
0
        public JistPlugin(Terraria.Main game)
            : base(game)
        {
            Order    = 1;
            Instance = new JistEngine(this);
            TShockAPI.Commands.ChatCommands.Add(new TShockAPI.Command("jist.cmd", TShockAPI_JistChatCommand, "jist"));

            ServerApi.Hooks.GameInitialize.Register(this, game_initialize);
        }
Ejemplo n.º 4
0
        public static bool DrawProj_DrawProjectile(Terraria.Main __instance, int i)
        {
            // The specially named __instance parameter is automatically filled in by Harmony to reference the Main instance that is calling this method.
            // The i parameter is automatically filled in by Harmony to be the same value as the i parameter that was passed to the original method.

            if (!PluginLoadedSuccessfully)                // If there was a problem loading things for our plugin, we will abort this stub method so we dont crash Terraria.
            {
                return(true);                             // Allow the original method to execute
            }
            if (Terraria.Main.projectile[i].type == 3001) // Only run this drawing code if the projectile that's trying to draw actually is our custom projectile
            {
                // Get our projectile from the main projectile array
                Terraria.Projectile proj = Terraria.Main.projectile[i];

                // This must be called before any projectile is drawn
                __instance.PrepareDrawnEntityDrawing(proj, Terraria.Main.GetProjectileDesiredShader(i));

                // Get how much light is at the projectile's current position (will be used for a slight color modulation effect)
                Color lightAtProjPos = Terraria.Lighting.GetColor((int)(proj.position.X + (proj.width * 0.5f)) / 16,
                                                                  (int)((proj.position.Y + (proj.height * 0.5f)) / 16));
                // Lerp at a constant 75% between the tile light and pure white to slightly modulate the projectile's color
                Color projColorMix = Color.Lerp(lightAtProjPos, Color.White, 0.75f);

                // Fade out the projectile if it's close to being removed
                if (proj.timeLeft <= 30)
                {
                    projColorMix = projColorMix * (proj.timeLeft / 30f);
                }

                // Get the projectile's texture and figure out what section contains the frame we want
                Texture2D projTex        = Terraria.GameContent.TextureAssets.Projectile[proj.type].Value;
                int       texFrameHeight = projTex.Height / Terraria.Main.projFrames[proj.type];
                int       texFrameYPos   = texFrameHeight * (proj.frame / 4); // Our code in AI() makes proj.frame go up to 4x the actual max frame so that we can divide it here for 1/4 of a 60fps framerate

                // Find the viewportspace position to draw the projectile at
                Vector2 drawPosition = proj.position
                                       + (new Vector2(projTex.Width, texFrameHeight) * 0.5f) // Use the texture's dimensions instead of proj.Width and proj.Height, since our projectile's Width & Height are undersized (for collision purposes)
                                       + (Vector2.UnitY * proj.gfxOffY)
                                       - Terraria.Main.screenPosition;

                // Draw it
                Terraria.Main.EntitySpriteDraw(projTex,
                                               drawPosition,
                                               new Rectangle(0, texFrameYPos, projTex.Width, texFrameHeight),
                                               projColorMix,
                                               proj.rotation,
                                               new Vector2(projTex.Width * 0.5f, texFrameHeight * 0.5f),
                                               1f,
                                               SpriteEffects.None,
                                               0);

                return(false); // Skip over original method
            }

            return(true); // Allow original method to run
        }
Ejemplo n.º 5
0
 private static void Main(string[] args)
 {
     using (Terraria.Main main = new Terraria.Main())
     {
         //Steam.Init();
         //if (Steam.SteamInit)
         //{
         main.Run();
         //}
     }
 }
Ejemplo n.º 6
0
 private static void Main(string[] args)
 {
     using (Terraria.Main main = new Terraria.Main())
     {
         //Steam.Init();
         //if (Steam.SteamInit)
         //{
             main.Run();
         //}
     }
 }
Ejemplo n.º 7
0
        internal static void Main(string[] args)
        {
            SetUpTerrariaLanguage();

            var log = SetUpLog();

            using var server  = SetUpServer(log);
            using var context = SetUpSynchronizationContext();

            server.Events.Raise(new ServerArgsEvent(args), log);

            using var game = new Terraria.Main();
            game.DedServ();
Ejemplo n.º 8
0
        /// <summary>
        ///     Send message in chat. Can use locale strings and write text from server to clients even if client don't have this
        ///     mod
        /// </summary>
        /// <param name="m">Text to print</param>
        /// <param name="color">text color</param>
        public static void Post(string m, Color color)
        {
            switch (Main.netMode)
            {
            case NetmodeID.SinglePlayer:
                Main.NewText(m);
                break;

            case NetmodeID.Server:
                NetMessage.BroadcastChatMessage(NetworkText.FromKey(m), color);
                break;
            }
        }
Ejemplo n.º 9
0
        private static void FixPlayerSize(Main.orig_DrawPlayer orig, Terraria.Main self, Terraria.Player drawPlayer, Vector2 Position, float rotation, Vector2 rotationOrigin, float shadow)
        {
            int playerWidth  = drawPlayer.width;
            int playerHeight = drawPlayer.height;

            drawPlayer.width  = Terraria.Player.defaultWidth;
            drawPlayer.height = Terraria.Player.defaultHeight;

            orig(self, drawPlayer, Position, rotation, new Vector2(drawPlayer.width, drawPlayer.height) * 0.5f, shadow);

            drawPlayer.width  = playerWidth;
            drawPlayer.height = playerHeight;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Acts as the main entry point of the launcher.
        /// </summary>
        /// <param name="args">The arguments supplied to the launcher.</param>
        public static void Main(string[] args)
        {
            var log = SetupLog();

            using var kernel = new OrionKernel(log);
            SetupPlugins(kernel);
            SetupLanguage();

            kernel.Raise(new ServerArgsEvent(args), log);

            using var game = new Terraria.Main();
            game.DedServ();
        }
Ejemplo n.º 11
0
        /// <summary>
        ///     Write text in to chat/console.
        ///     Mostly used for debugging and sending client only related info
        /// </summary>
        /// <param name="m">Text to print</param>
        public static void Text(string m)
        {
            switch (Main.netMode)
            {
            case NetmodeID.MultiplayerClient:
            case NetmodeID.SinglePlayer:
                Main.NewText(m);
                break;

            case NetmodeID.Server:
                Console.WriteLine(m);
                break;
            }
        }
Ejemplo n.º 12
0
            private static void ClearEvents()
            {
                if (Main.slimeRain)
                {
                    Main.StopSlimeRain(false);
                }

                if (Main.raining)
                {
                    Main.StopRain();
                }

                if (Main.windSpeedTarget >= Main._maxWind)
                {
                    Main.windSpeedTarget = Main._maxWind * 0.5f;
                }

                if (Main.windSpeedTarget <= -Main._maxWind)
                {
                    Main.windSpeedTarget = -(Main._maxWind * 0.5f);
                }
            }
Ejemplo n.º 13
0
        private static void DrawPlayerTargets(Main.orig_DrawPlayers orig, Terraria.Main self)
        {
            Terraria.Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise);

            for (int i = 0; i < playerTargets.Length; i++)
            {
                RenderTarget2D  target = playerTargets[i];
                Terraria.Player player = Terraria.Main.player[i];

                if (target == null || player == null || !player.active || player.GetModPlayer <TFPlayer>().Transporting)
                {
                    continue;
                }

                float scale = player.GetModPlayer <TFPlayer>().scale;
                float alpha = player.GetModPlayer <TFPlayer>().alpha;

                Terraria.Main.spriteBatch.Draw(target, new Vector2(Terraria.Main.screenWidth, Terraria.Main.screenHeight) * 0.5f, null, Color.White * alpha, 0f, Terraria.Utils.Size(target) * 0.5f, scale, SpriteEffects.None, 0f);
            }

            Terraria.Main.spriteBatch.End();
        }
Ejemplo n.º 14
0
 private static void Main_EnsureRenderTargetContent(Main.orig_EnsureRenderTargetContent orig, Terraria.Main self)
 {
     if (
         Terraria.Main.waterTarget == null || Terraria.Main.waterTarget.IsContentLost ||
         self.backWaterTarget == null || self.backWaterTarget.IsContentLost ||
         self.blackTarget == null || self.blackTarget.IsContentLost ||
         self.tileTarget == null || self.tileTarget.IsContentLost ||
         self.tile2Target == null || self.tile2Target.IsContentLost ||
         self.wallTarget == null || self.wallTarget.IsContentLost ||
         self.backgroundTarget == null || self.backgroundTarget.IsContentLost ||
         Terraria.Main.screenTarget == null || Terraria.Main.screenTarget.IsContentLost ||
         Terraria.Main.screenTargetSwap == null || Terraria.Main.screenTargetSwap.IsContentLost ||
         playerTargets.Any(target => target == null || target.IsContentLost))
     {
         self.InvokeMethod <object>("InitTargets");
     }
 }
Ejemplo n.º 15
0
        private static void Main(string[] args)
        {
            try
            {

                Trace.Listeners.Clear();

                TextWriterTraceListener twtl = new TextWriterTraceListener("Server.log");
                twtl.Name = "TextLogger";
                twtl.TraceOutputOptions = TraceOptions.ThreadId | TraceOptions.DateTime;

                ConsoleTraceListener ctl = new ConsoleTraceListener(false);
                ctl.TraceOutputOptions = TraceOptions.DateTime;

                Trace.Listeners.Add(twtl);
                Trace.Listeners.Add(ctl);
                Trace.AutoFlush = true;

               // Trace.WriteLine(String.Format("Endians {0}", BitConverter.IsLittleEndian));

                Game = new Terraria.Main();
                for (int i = 0; i < args.Length; i++)
                {
                    if (args[i].ToLower() == "-config")
                    {
                        i++;
                        Game.LoadDedConfig(args[i]);
                    }
                    if (args[i].ToLower() == "-port")
                    {
                        i++;
                        try
                        {
                            Netplay.serverPort = Convert.ToInt32(args[i]);
                        }
                        catch
                        {
                        }
                    }
                    if ((args[i].ToLower() == "-players") || (args[i].ToLower() == "-maxplayers"))
                    {
                        i++;
                        try
                        {
                            int mPlayers = Convert.ToInt32(args[i]);
                            Game.SetNetPlayers(mPlayers);
                        }
                        catch
                        {
                        }
                    }
                    if ((args[i].ToLower() == "-pass") || (args[i].ToLower() == "-password"))
                    {
                        i++;
                        Netplay.password = args[i];
                    }
                    if (args[i].ToLower() == "-world")
                    {
                        i++;
                        Game.SetWorld(args[i]);
                    }
                    if (args[i].ToLower() == "-worldname")
                    {
                        i++;
                        Game.SetWorldName(args[i]);
                    }
                    if (args[i].ToLower() == "-motd")
                    {
                        i++;
                        Game.NewMOTD(args[i]);
                    }
                    if (args[i].ToLower() == "-banlist")
                    {
                        i++;
                        Netplay.banFile = args[i];
                    }
                    if (args[i].ToLower() == "-autoshutdown")
                    {
                        Game.autoShut();
                    }
                    if (args[i].ToLower() == "-autocreate")
                    {
                        i++;
                        string newOpt = args[i];
                        Game.autoCreate(newOpt);
                    }
                }
                Game.DedServ();
            }
            catch (Exception exception)
            {
                try
                {
                    using (StreamWriter writer = new StreamWriter("crashlog.txt", true))
                    {
                        writer.WriteLine(DateTime.Now);
                        writer.WriteLine(exception);
                        writer.WriteLine("");
                    }
                    Trace.WriteLine("Server crash: " + DateTime.Now);
                    Trace.WriteLine(exception);
                    Trace.WriteLine("");
                    Trace.WriteLine("Please send crashlog.txt to [email protected]");
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 16
0
 public CmdAliasPlugin(Terraria.Main game)
     : base(game)
 {
     //we're absolute last in the plugin order.
     Order = int.MaxValue - 1;
 }
Ejemplo n.º 17
0
            private void SetSlimeRain()
            {
                ClearEvents();

                Main.StartSlimeRain(false);
            }
Ejemplo n.º 18
0
        public override void Load()
        {
            base.Load();

            RecentChatters = new List <string>();

#if DEBUG
            //Used for debugging
            RecentChatters.AddRange(new[]
            {
                "Nightbot",
                "KarmikKoalla",
                "Moobot",
                "SomeoneFromChat"
            });
#endif

            Instance = this;

            BossCommands = new Dictionary <string, Action>();

            EventsPool = new List <WorldEvent>();

            LastStatus.Value = $"[c/{TwitchColor}: Client not connected]";

            OldConfig = new TwitchOldConfig(Storage = new ModStorage(@"Twitch"));

            Store = new ResourceStore <byte[]>(new StorageBackedResourceStore(Storage));
            if (ModLoader.version.Major == 10)
            {
                Store.AddStore(new OnlineStore());
            }
            else
            {
                Store.AddStore(new WebStore("image/png"));
            }

            Textures = new Texture2DStore(Store);

            EmoticonHandler.store = new EmoticonsStore(Store);

            if (Storage.Exists("EmoteIDs.json"))
            {
                using (Stream p = Storage.GetStream("EmoteIDs.json"))
                    using (StreamReader s = new StreamReader(p))
                    {
                        try
                        {
                            EmoticonHandler.convertingEmotes =
                                JsonConvert.DeserializeObject <Dictionary <string, int> >(s.ReadToEnd());
                        }
                        catch (Exception e)
                        {
                            Logger.Warn($"Failed to load emotes id:\n{e}");
                        }
                    }
            }

            // Just to create file
            OldConfig.Save();


            Irc = new IrcClient(); // This client used in my twitch bot so class know all info about twitch irc server so we don't need to provide what info here

            //Start migrating to new configs
            //ShowDebug = OldConfig.Get<bool>(TwitchCfg.ShowAllIrc);
            //IgnoreCommands = OldConfig.Get<bool>(TwitchCfg.IgnoreCommands);
            //CommandPrefix = OldConfig.Get<string>(TwitchCfg.IgnoreCommandPrefix);
            Username = OldConfig.Get <string>(TwitchCfg.Username);
            Fun      = OldConfig.Get <bool>(TwitchCfg.EnableFun);
            Channel  = OldConfig.Get <string>(TwitchCfg.Channel);

            if (ShowDebug)
            {
                Razorwing.Framework.Logging.Logger.Storage =
                    Storage; //Thx tML 0.11 for adding "Mod.Logger" <3 Breaking all as all ways
            }
            if (Fun)
            {
                //Since it not work on server (Not affect clients) until i write packets for this Twitch boss is disabled for server
                if (Main.netMode == NetmodeID.Server || Main.netMode == NetmodeID.SinglePlayer)
                {
                    TwitchBoss.InitialiseDefault();
                }


                //Register inner world event invasions
                foreach (Mod mod in ModLoader.Mods)
                {
                    foreach (TypeInfo it in mod.GetType().Assembly.DefinedTypes)
                    {
                        if (!it.IsAbstract && (
                                it.BaseType != typeof(object) && it.BaseType == typeof(WorldEvent) ||
                                it.BaseType?.BaseType != typeof(object) && it.BaseType?.BaseType == typeof(WorldEvent))
                            ) //In case if WorldEvent is second parent
                        {
                            try
                            {
                                EventsPool.Add((WorldEvent)Activator.CreateInstance(it));
                            }
                            catch (Exception e)
                            {
                                Logger.Error(
                                    "Exception caught in Events register loop. Report mod author with related stacktrace: \n" +
                                    $"{e.Message}\n" +
                                    $"{e.StackTrace}\n");
                            }
                        }
                    }
                }
            }


            if (ShowDebug)
            {
                Irc.ServerMessage += (s, m) =>
                {
                    try
                    {
                        Text(m);
                    }
                    catch (Exception)
                    {
                        Logger.Warn("Failed to post message");
                    }
                }
            }
            ;

            Irc.OnConnect += (s, e) =>
            {
                LastStatus.Value = $"[c/{TwitchColor}:Connected]";

                Irc.SendRaw("CAP REQ :twitch.tv/tags");
                Thread.Sleep(500);
                Irc.SendRaw("CAP REQ :twitch.tv/commands");
                Thread.Sleep(500);
                Irc.JoinChannel(Channel);

                inRestoringState = false;
            };

            Irc.ConnectionClosed += (s, e) =>
            {
                if (!inRestoringState)
                {
                    LastStatus.Value = $"[c/{TwitchColor}:Connection lost!]";
                    inRestoringState = true;
                    Thread.Sleep(5000);
                    Irc.Connect();
                }
                else
                {
                    LastStatus.Value = $"[c/{TwitchColor}:Connection terminated! Client now offline]";
                }
            };

            Irc.ChannelMessage += (s, e) =>
            {
                if (Main.netMode != NetmodeID.Server && !Main.gameMenu)
                {
                    //If we ignore commands, we also want ignore bots messages
                    if (IgnoreCommands)
                    {
                        if (e.Message.StartsWith(CommandPrefix))
                        {
                            return;
                        }
                        //In case you self bot, we ignore your own messages
                        if (e.From == Username)
                        {
                            return;
                        }
                        //if message was send by known bot, we ignore it
                        if (KnownBots.Contains(e.From))
                        {
                            return;
                        }
                    }

                    var result = e.Message;

                    var parsed = new List <SEmote>();

                    foreach (var it in e.Badge.emotes)
                    {
                        if (it == string.Empty)
                        {
                            break;
                        }
                        string[] pair = it.Split(':');
                        string[] ind  = pair[1].Split(',');
                        parsed.AddRange(ind.Select(p =>
                        {
                            string[] ip = p.Split('-');
                            return(new SEmote(ip[0], ip[1], pair[0]));
                        }));
                    }

                    if (parsed.Count != 0)
                    {
                        var list = new Dictionary <int, string>();
                        foreach (SEmote it in parsed)
                        {
                            if (list.ContainsKey(it.Emote))
                            {
                                continue;
                            }
                            var st = e.Message.Substring(it.Start, it.End - it.Start + 1);

                            //Not perfect because if Kappa mentioned in msg KappaPride get broken,
                            //but it way faster what per glyph concat
                            result = result.Replace(st, $"[e:{it.Emote}]");

                            list.Add(it.Emote, st);
                        }

                        foreach (KeyValuePair <int, string> em in list)
                        {
                            if (!EmoticonHandler.convertingEmotes.ContainsKey(em.Value))
                            {
                                EmoticonHandler.convertingEmotes.Add(em.Value, em.Key);
                            }
                        }
                    }
                    else
                    {
                        result = e.Message;
                    }


                    var prefix = "";
                    if (e.Badge.sub)
                    {
                        prefix += $"[i:{ItemID.Star}] ";
                    }
                    if (e.Badge.mod)
                    {
                        prefix += $"[i:{ItemID.Arkhalis}]";
                    }

                    //String format
                    Main.NewText($@"{prefix} [c/{TwitchColor}:{e.Badge.DisplayName}]: {result}");

                    if (!RecentChatters.Contains(e.Badge.DisplayName))
                    {
                        RecentChatters.Add(e.Badge.DisplayName);
                    }
                }

                if ((Main.netMode == NetmodeID.Server || Main.netMode == NetmodeID.SinglePlayer) && Fun)
                {
                    if (e.Message.StartsWith(CommandPrefix))
                    {
                        return;
                    }
                    //In case you self bot, we ignore your own messages
#if !DEBUG
                    if (e.From == Username)
                    {
                        return;
                    }
#endif
                    //if message was sent by known bot, we ignore it
                    if (KnownBots.Contains(e.From))
                    {
                        return;
                    }


                    //var word = e.Message.ToLower().Split(' ').First();

                    //if (CurrentPool?.ContainsKey(word) ?? false)
                    //{
                    //    CurrentPool[word]?.Invoke(e);
                    //}
                    if (e.From == TwitchBoss.Boss && TwitchBoss.Cooldown < DateTimeOffset.Now)
                    {
                        TwitchBoss.ProcessCommand(e);
                    }
                }
            };

            if (OldConfig.Get <bool>(TwitchCfg.AutoConnect) && OldConfig.Get <string>(TwitchCfg.OAToken) !=
                "https://twitchapps.com/tmi/" &&
                OldConfig.Get <string>(TwitchCfg.Username) != "missingno")
            {
                Irc.Username  = OldConfig.Get <string>(TwitchCfg.Username);
                Irc.AuthToken = OldConfig.Get <string>(TwitchCfg.OAToken);
                Irc.Connect();
            }

            WorldGen.SpawnTownNPC += SpawnTownNpcHook;
        }
Ejemplo n.º 19
0
 public SEconomyScriptPlugin(Terraria.Main game)
     : base(game)
 {
 }
Ejemplo n.º 20
0
 public Main(Terraria.Main game) : base(game)
 {
 }
Ejemplo n.º 21
0
 public UserExists(Terraria.Main game)
     : base(game)
 {
     Order = 2;
 }
Ejemplo n.º 22
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            NetPacketType type = (NetPacketType)reader.ReadByte();

            if (type != NetPacketType.Custom)
            {
                //Currently only server can said us what we should do
                if (whoAmI != 256)
                {
                    return;
                }
            }

            if (type == NetPacketType.EventWasStarted)
            {
                var name = reader.ReadString();
                foreach (WorldEvent it in EventsPool)
                {
                    if (it.GetType().Name == name)
                    {
                        ModContent.GetInstance <EventWorld>().StartWorldEvent(it);
                        break;
                    }
                }

                if (ModContent.GetInstance <EventWorld>().CurrentEvent == null)
                {
                    Main.NewText(
                        $"WARNING! You ether or disable FunMode or you are using outdated version of mod, what haven't an {name} event! Switching to NoSync mode...");
                }

                ModContent.GetInstance <EventWorld>().CurrentEvent.TimeLeft = reader.ReadInt32();
                InvasionType invType = (InvasionType)reader.ReadByte();
                if (invType == InvasionType.Invasion)
                {
                    Main.invasionProgressWave = reader.ReadInt32();
                    Main.invasionSizeStart    = reader.ReadInt32();
                    Main.invasionSize         = reader.ReadInt32();
                    Main.invasionType         = reader.ReadInt32();
                    Main.invasionX            = reader.ReadDouble();
                    Main.invasionProgress     = reader.ReadInt32();
                }
            }
            else if (type == NetPacketType.EventWaveUpdated)
            {
                var name = reader.ReadString();
                if (ModContent.GetInstance <EventWorld>().CurrentEvent == null ||
                    ModContent.GetInstance <EventWorld>().CurrentEvent.GetType().Name != name)
                {
                    //if (ModContent.GetInstance<EventWorld>().CurrentEvent == null)
                    //    Main.NewText($"WARNING! Currently you wont have any executing event, but server send wave update for {name} event!");
                    if (ModContent.GetInstance <EventWorld>().CurrentEvent.GetType().Name != name)
                    {
                        Main.NewText(
                            $"ERROR! Currently executing event not the same what server sends! Executed event is: {ModContent.GetInstance<EventWorld>().CurrentEvent.GetType().Name}. Server has {name} event!");
                        ModContent.GetInstance <EventWorld>().CurrentEvent
                        .EventEnd(ModContent.GetInstance <EventWorld>(), this);
                        ModContent.GetInstance <EventWorld>().CurrentEvent = null;
                    }


                    foreach (WorldEvent it in EventsPool)
                    {
                        if (it.GetType().Name == name)
                        {
                            ModContent.GetInstance <EventWorld>().StartWorldEvent(it);
                            break;
                        }
                    }

                    if (ModContent.GetInstance <EventWorld>().CurrentEvent == null)
                    {
                        //Main.NewText($"WARNING! You ether or disable FunMode or you are using outdated version of mod, what haven't an {name} event!");
                    }
                }

                ModContent.GetInstance <EventWorld>().CurrentEvent.TimeLeft = reader.ReadInt32();
                InvasionType invType = (InvasionType)reader.ReadByte();
                if (invType == InvasionType.Invasion)
                {
                    Main.invasionProgressWave = reader.ReadInt32();
                    Main.invasionSizeStart    = reader.ReadInt32();
                    Main.invasionSize         = reader.ReadInt32();
                    Main.invasionType         = reader.ReadInt32();
                    Main.invasionX            = reader.ReadDouble();
                    Main.invasionProgress     = reader.ReadInt32();
                    ModContent.GetInstance <EventWorld>().CurrentEvent.OnWaveChange();
                }
            }
            else if (type == NetPacketType.EventEnded)
            {
                var name = reader.ReadString();
                if (ModContent.GetInstance <EventWorld>().CurrentEvent == null ||
                    ModContent.GetInstance <EventWorld>().CurrentEvent.GetType().Name != name)
                {
                    if (ModContent.GetInstance <EventWorld>().CurrentEvent == null)
                    {
                        Main.NewText(
                            $"WARNING! Currently you wont have any executing event, but server send event end for {name} event!");
                    }
                    if (ModContent.GetInstance <EventWorld>().CurrentEvent.GetType().Name != name)
                    {
                        Main.NewText(
                            $"ERROR! Currently executing event not the same what server sends! Executed event is: {ModContent.GetInstance<EventWorld>().CurrentEvent.GetType().Name}. Server has {name} event!");
                        ModContent.GetInstance <EventWorld>().CurrentEvent
                        .EventEnd(ModContent.GetInstance <EventWorld>(), this);
                        ModContent.GetInstance <EventWorld>().CurrentEvent = null;
                    }
                }
                else
                {
                    ModContent.GetInstance <EventWorld>().CurrentEvent
                    .EventEnd(ModContent.GetInstance <EventWorld>(), this);
                    ModContent.GetInstance <EventWorld>().CurrentEvent = null;
                }
            }
            else if (type == NetPacketType.Custom)
            {
                #region Constants

                const string lunarSky   = "LunarSkies";
                const string netSendFix = "NetSend";

                #endregion

                var eve = reader.ReadString();
                if (eve == lunarSky)
                {
                    LunarSkies t = (LunarSkies)reader.ReadByte();
                    EventPlayer.LunarSky = t;
                }
                else if (eve == netSendFix)
                {
                    var b = reader.ReadBoolean();
                    if (b)
                    {
                        ModPacket p = GetPacket();
                        p.Write((byte)NetPacketType.Custom);
                        p.Write(netSendFix);
                        p.Write(false);
                        ModContent.GetInstance <EventWorld>().WriteNetSendData(p);
                        p.Send(whoAmI);
                    }
                    else
                    {
                        ModContent.GetInstance <EventWorld>().NetReceive(reader);
                    }
                }
            }
        }
Ejemplo n.º 23
0
 public MapComponent(Game game)
     : base(game)
 {
     TerrariaGame = (Terraria.Main)game;
 }
Ejemplo n.º 24
0
        public static void LoadContent_LoadProjectileAssets(Terraria.Main __instance)
        {
            // The specially named __instance parameter is automatically filled in by Harmony to reference the Main instance that is calling this method.

            // We'll do all our setup in a try-catch so we don't crash Terraria if something goes wrong.
            try
            {
                // Load our custom projectile's texture from the embedded resource bytes we extracted in ConfigurationLoaded()
                ProjectileGraphic = HHelpers.AssetHandling.CreateTexture2DFromImageBytes(ProjectileGraphicBytes, __instance.GraphicsDevice, true, new Vector4(1f, 1f, 1f, 1f / 2.2f));
                // The PNG used in this example was written with an alpha channel gamma space that does not look good in Terraria, hence the use of the final parameter (gammaCorrection) to do some correction.
                // NOTE: Only use the gammaCorrection parameter if you know what you are doing, otherwise just skip it (or set to default value of null)

                // Just like with creating new items, we need to expand a bunch of projectile design data arrays to reach up to our projectile's ID.
                // We will fill the placeholder spaces between the last vanilla ID and our custom ID with default values.
                Helper_ExpandArray(ref Terraria.Main.projFrames, ProjectileID, 0);
                Terraria.Main.projFrames[ProjectileID] = 8;     // Our custom projectile has 8 frames of animation
                Helper_ExpandArray(ref Terraria.Main.projHook, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.Main.projHostile, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.Main.projPet, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.CanDistortWater, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.CountsAsHoming, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.DismountsPlayersOnHit, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.DontApplyParryDamageBuff, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.DontAttachHideToAlpha, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.DrawScreenCheckFluff, ProjectileID, 480);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.ExtendedCanHitCheckRange, ProjectileID, 0f);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.ExtendedCanHitCheckSearch, ProjectileID, null);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.ForcePlateDetection, ProjectileID, null);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.ImmediatelyUpdatesNPCBuffFlags, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.IsADD2Turret, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.IsAGolfBall, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.IsAMineThatDealsTripleDamageWhenStationary, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.IsARocketThatDealsDoubleDamageToPrimaryEnemy, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.IsAWhip, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.LightPet, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.MinionSacrificable, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.MinionShot, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.MinionTargettingFeature, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.NeedsUUID, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.NoLiquidDistortion, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.RocketsSkipDamageForPlayers, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.SentryShot, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.StardustDragon, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.StormTiger, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.TrailCacheLength, ProjectileID, 10);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.TrailingMode, ProjectileID, -1);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.TurretFeature, ProjectileID, false);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.WindPhysicsImmunity, ProjectileID, null);
                Terraria.ID.ProjectileID.Sets.WindPhysicsImmunity[ProjectileID] = true;     // We want our custom projectile to be immune to wind since it is an energy ball
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.YoyosLifeTimeMultiplier, ProjectileID, -1f);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.YoyosMaximumRange, ProjectileID, 200f);
                Helper_ExpandArray(ref Terraria.ID.ProjectileID.Sets.YoyosTopSpeed, ProjectileID, 10f);

                // Next we need to extend the Terraria.GameContent.TextureAssets.Projectile array to reach our Projectile's ID in size and include our Projectile's texture
                Helper_ExpandArray(ref Terraria.GameContent.TextureAssets.Projectile, ProjectileID, Terraria.GameContent.TextureAssets.Projectile[0]); // Use the first texture in the list as a default placeholder
                // Now create a ReLogic.Content.Asset<Texture2D> to hold our projectile's graphic
                Type assetType = typeof(ReLogic.Content.Asset <Texture2D>);
                ProjectileGraphicAsset = (ReLogic.Content.Asset <Texture2D>)HHelpers.ActivateInstanceUsingFirstConstructor(assetType, new object[] { "Projectile_WeaponProcessorOnAStick_ElectricBall" }); // This type has only one constructor
                // By using the ActivateInstanceUsingFirstConstructor() helper method, we avoid directly using Reflection and thus don't violate plugin Security Level 4
                HHelpers.SetPropertyValueWithReflection("Value", ProjectileGraphicAsset, ProjectileGraphic);                                                                                               // Set the Value (which is of type Texture2D)
                HHelpers.SetPropertyValueWithReflection("State", ProjectileGraphicAsset, ReLogic.Content.AssetState.Loaded);                                                                               // Set the loaded state to Loaded
                Terraria.GameContent.TextureAssets.Projectile[ProjectileID] = ProjectileGraphicAsset;                                                                                                      // Assign the newly created asset to our projectile's slot in the array
            }
            catch (Exception e)
            {
                // Something went wrong, so we will set PluginLoadedSuccessfully to false and thus disable the rest of our plugin code.
                // If you are debugging a plugin, however, you probably DONT want to do this, or you might miss thrown exceptions.
                PluginLoadedSuccessfully = false;
                return;
            }
        }
Ejemplo n.º 25
0
        public static void LoadContent_LoadWeaponAssets(Terraria.Main __instance)
        {
            // The specially named __instance parameter is automatically filled in by Harmony to reference the Main instance that is calling this method.

            // We'll do all our setup in a try-catch so we don't crash Terraria if something goes wrong.
            try
            {
                // Load our weapon's texture from the embedded resource bytes we extracted in ConfigurationLoaded()
                ItemGraphic = HHelpers.AssetHandling.CreateTexture2DFromImageBytes(ItemGraphicBytes, __instance.GraphicsDevice);
                // Using CreateTexture2DFromImageBytes() is compliant with all security levels and is the recommended way to create Texture2Ds.
                // You could use your own Streams, but using Streams (or any other type in System.IO) will make your plugin violate Security Level 3.

                // We will also modify some necessary arrays here (this method will only be called once, so this is a good time to modify these arrays).
                // There are many arrays which are indexed using the item's type (aka ID). We need to expand all those arrays to reach up to our item's ID.
                // We will fill the placeholder spaces between the last vanilla ID and our new ID with default values.
                Helper_ExpandArray(ref Terraria.Item.cachedItemSpawnsByType, WeaponItemID, -1);
                Helper_ExpandArray(ref Terraria.Item.claw, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.Item.staff, WeaponItemID, false);
                Terraria.Item.staff[WeaponItemID] = true;     // Our item is a staff, so we set this to true for our slot
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.AlsoABuildingItem, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.AnimatesAsSoul, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.BonusMeleeSpeedMultiplier, WeaponItemID, 1f);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.CanBePlacedOnWeaponRacks, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.CanBeQuickusedOnGamepad, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.CanGetPrefixes, WeaponItemID, false);
                Terraria.ID.ItemID.Sets.CanGetPrefixes[WeaponItemID] = true;     // Our item is a weapon & we want to it be able to get prefixes, so we set this to true for our slot
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.Deprecated, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.DrinkParticleColors, WeaponItemID, new Color[0]);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.ExtractinatorMode, WeaponItemID, -1);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.FoodParticleColors, WeaponItemID, new Color[0]);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.ForceConsumption, WeaponItemID, null);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.GamepadExtraRange, WeaponItemID, 0);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.GamepadSmartQuickReach, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.GamepadWholeScreenUseRange, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.gunProj, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.HasAProjectileThatHasAUsabilityCheck, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IgnoresEncumberingStone, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IsAKite, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IsAMaterial, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IsAPickup, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IsChainsaw, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IsDrill, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IsFishingCrate, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IsFishingCrateHardmode, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IsFood, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IsLavaBait, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.IsPaintScraper, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.ItemIconPulse, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.ItemNoGravity, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.ItemSpawnDecaySpeed, WeaponItemID, 1);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.ItemsThatAllowRepeatedRightClick, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.ItemsThatCountAsBombsForDemolitionistToSpawn, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.KillsToBanner, WeaponItemID, 50);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.LockOnAimAbove, WeaponItemID, 0);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.LockOnIgnoresCollision, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.NebulaPickup, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.NeverAppearsAsNewInInventory, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.NewItemSpawnPriority, WeaponItemID, 0);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.SingleUseInGamepad, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.SkipsInitialUseSound, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.SummonerWeaponThatScalesWithAttackSpeed, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.TextureCopyLoad, WeaponItemID, -1);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.ToolTipDamageMultiplier, WeaponItemID, 1f);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.Torches, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.TrapSigned, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.UsesCursedByPlanteraTooltip, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.WaterTorches, WeaponItemID, false);
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.Yoyo, WeaponItemID, false);

                // We also need to expand Terraria.Main.itemAnimations to reach up to our item's ID and include a Terraria.DataStructures.DrawAnimation for our weapon's Item
                Helper_ExpandArray(ref Terraria.Main.itemAnimations, WeaponItemID, null); // Add null DrawAnimations in the dummy slots (and in our weapon's slot as well, since the sprite has a single frame and no animations)

                // We also need to expand Terraria.ID.ItemID.Sets.TextureCopyLoad to reach up to our item's ID
                Helper_ExpandArray(ref Terraria.ID.ItemID.Sets.TextureCopyLoad, WeaponItemID, 0); // We will have all the empty placeholder spots set to 0 so that they mirror load the texture in index 0 (as opposed to crashing from trying to load an out-of-range texture index)

                // Next we need to extend the Terraria.GameContent.TextureAssets.Item array to reach our item's ID in size and include our Item's texture
                Helper_ExpandArray(ref Terraria.GameContent.TextureAssets.Item, WeaponItemID, Terraria.GameContent.TextureAssets.Item[0]); // Use the first texture in the list as a default placeholder
                // Now create a ReLogic.Content.Asset<Texture2D> to hold our item graphic
                Type assetType = typeof(ReLogic.Content.Asset <Texture2D>);
                ItemGraphicAsset = (ReLogic.Content.Asset <Texture2D>)HHelpers.ActivateInstanceUsingFirstConstructor(assetType, new object[] { "Item_WeaponProcessorOnAStick" }); // This type has only one constructor
                // By using the ActivateInstanceUsingFirstConstructor() helper method, we avoid directly using Reflection and thus don't violate plugin Security Level 4
                HHelpers.SetPropertyValueWithReflection("Value", ItemGraphicAsset, ItemGraphic);                                                                                  // Set the Value (which is of type Texture2D)
                HHelpers.SetPropertyValueWithReflection("State", ItemGraphicAsset, ReLogic.Content.AssetState.Loaded);                                                            // Set the loaded state to Loaded
                Terraria.GameContent.TextureAssets.Item[WeaponItemID] = ItemGraphicAsset;                                                                                         // Assign the newly created asset to our item's slot in the array

                // We also need to create a LocalizedText to hold our weapon Item's name
                Type localizedTextType = typeof(Terraria.Localization.LocalizedText);
                WeaponItemName = (Terraria.Localization.LocalizedText)HHelpers.ActivateInstanceUsingFirstConstructor(localizedTextType, new object[] { "", WeaponItemNameText }); // This type has only one constructor
                // By using the ActivateInstanceUsingFirstConstructor() helper method, we avoid directly using Reflection and thus don't violate plugin Security Level 4
            }
            catch (Exception e)
            {
                // Something went wrong, so we will set PluginLoadedSuccessfully to false and thus disable the rest of our plugin code.
                // If you are debugging a plugin, however, you probably DONT want to do this, or you might miss thrown exceptions.
                PluginLoadedSuccessfully = false;
                return;
            }
        }
Ejemplo n.º 26
0
 private static void Main(string[] args)
 {
     Terraria.Main main = new Terraria.Main();
     try
     {
         for (int i = 0; i < args.Length; i++)
         {
             if ((args[i].ToLower() == "-port") || (args[i].ToLower() == "-p"))
             {
                 i++;
                 try
                 {
                     Netplay.serverPort = Convert.ToInt32(args[i]);
                 }
                 catch
                 {
                 }
             }
             if ((args[i].ToLower() == "-join") || (args[i].ToLower() == "-j"))
             {
                 i++;
                 try
                 {
                     main.AutoJoin(args[i]);
                 }
                 catch
                 {
                 }
             }
             if ((args[i].ToLower() == "-pass") || (args[i].ToLower() == "-password"))
             {
                 i++;
                 Netplay.password = args[i];
                 main.AutoPass();
             }
             if (args[i].ToLower() == "-host")
             {
                 main.AutoHost();
             }
             if (args[i].ToLower() == "-loadlib")
             {
                 i++;
                 string path = args[i];
                 main.loadLib(path);
             }
         }
     #if DEBUG
         main.Run();
     #else
         Steam.Init();
         if (Steam.SteamInit)
         {
             main.Run();
         }
         else
         {
             MessageBox.Show("Please run the game with steam running also.", "Error");
         }
     #endif
     }
     catch (Exception exception)
     {
         try
         {
             using (StreamWriter writer = new StreamWriter("client-crashlog.txt", true))
             {
                 writer.WriteLine(DateTime.Now);
                 writer.WriteLine(exception);
                 writer.WriteLine("");
             }
             MessageBox.Show(exception.ToString(), "Terraria: Error");
         }
         catch
         {
         }
     }
     finally
     {
         if (main != null)
         {
     #if !DEBUG
             Steam.Kill();
     #endif
             main.Dispose();
         }
     }
 }
Ejemplo n.º 27
0
 private static void Main(string[] args)
 {
     Terraria.Main main = new Terraria.Main();
     try
     {
         for (int i = 0; i < args.Length; i++)
         {
             if ((args[i].ToLower() == "-port") || (args[i].ToLower() == "-p"))
             {
                 i++;
                 try
                 {
                     Netplay.serverPort = Convert.ToInt32(args[i]);
                 }
                 catch
                 {
                 }
             }
             if ((args[i].ToLower() == "-join") || (args[i].ToLower() == "-j"))
             {
                 i++;
                 try
                 {
                     main.AutoJoin(args[i]);
                 }
                 catch
                 {
                 }
             }
             if ((args[i].ToLower() == "-pass") || (args[i].ToLower() == "-password"))
             {
                 i++;
                 Netplay.password = args[i];
                 main.AutoPass();
             }
             if (args[i].ToLower() == "-host")
             {
                 main.AutoHost();
             }
             if (args[i].ToLower() == "-loadlib")
             {
                 i++;
                 string path = args[i];
                 main.loadLib(path);
             }
             if (args[i].ToLower() == "-nosplash") ZidoMod.nosplash();
         }
         main.Run();
     }
     catch (Exception exception)
     {
         try
         {
             using (StreamWriter writer = new StreamWriter("client-crashlog.txt", true))
             {
                 writer.WriteLine(DateTime.Now);
                 writer.WriteLine(exception);
                 writer.WriteLine("");
             }
             MessageBox.Show(exception.ToString(), "Terraria: Error");
         }
         catch
         {
         }
     }
     finally
     {
         if (main != null)
         {
             main.Dispose();
         }
     }
 }
Ejemplo n.º 28
0
 private static void Main(string[] args)
 {
     try
     {
         Game = new Terraria.Main();
         for (int i = 0; i < args.Length; i++)
         {
             if (args[i].ToLower() == "-config")
             {
                 i++;
                 Game.LoadDedConfig(args[i]);
             }
             if (args[i].ToLower() == "-port")
             {
                 i++;
                 try
                 {
                     Netplay.serverPort = Convert.ToInt32(args[i]);
                 }
                 catch
                 {
                 }
             }
             if ((args[i].ToLower() == "-players") || (args[i].ToLower() == "-maxplayers"))
             {
                 i++;
                 try
                 {
                     int mPlayers = Convert.ToInt32(args[i]);
                     Game.SetNetPlayers(mPlayers);
                 }
                 catch
                 {
                 }
             }
             if ((args[i].ToLower() == "-pass") || (args[i].ToLower() == "-password"))
             {
                 i++;
                 Netplay.password = args[i];
             }
             if (args[i].ToLower() == "-world")
             {
                 i++;
                 Game.SetWorld(args[i]);
             }
             if (args[i].ToLower() == "-worldname")
             {
                 i++;
                 Game.SetWorldName(args[i]);
             }
             if (args[i].ToLower() == "-motd")
             {
                 i++;
                 Game.NewMOTD(args[i]);
             }
             if (args[i].ToLower() == "-banlist")
             {
                 i++;
                 Netplay.banFile = args[i];
             }
             if (args[i].ToLower() == "-autoshutdown")
             {
                 Game.autoShut();
             }
             if (args[i].ToLower() == "-secure")
             {
                 Netplay.spamCheck = true;
             }
             if (args[i].ToLower() == "-autocreate")
             {
                 i++;
                 string newOpt = args[i];
                 Game.autoCreate(newOpt);
             }
             if (args[i].ToLower() == "-loadlib")
             {
                 i++;
                 string path = args[i];
                 Game.loadLib(path);
             }
         }
         Game.DedServ();
     }
     catch (Exception exception)
     {
         try
         {
             using (StreamWriter writer = new StreamWriter("crashlog.txt", true))
             {
                 writer.WriteLine(DateTime.Now);
                 writer.WriteLine(exception);
                 writer.WriteLine("");
             }
             Console.WriteLine("Server crash: " + DateTime.Now);
             Console.WriteLine(exception);
             Console.WriteLine("");
             Console.WriteLine("Please send crashlog.txt to [email protected]");
         }
         catch
         {
         }
     }
 }
Ejemplo n.º 29
0
 private static void Main(string[] args)
 {
     Terraria.Main main = new Terraria.Main();
     try
     {
         for (int i = 0; i < args.Length; i++)
         {
             if ((args[i].ToLower() == "-port") || (args[i].ToLower() == "-p"))
             {
                 i++;
                 try
                 {
                     Netplay.serverPort = Convert.ToInt32(args[i]);
                 }
                 catch
                 {
                 }
             }
             if ((args[i].ToLower() == "-join") || (args[i].ToLower() == "-j"))
             {
                 i++;
                 try
                 {
                     main.AutoJoin(args[i]);
                 }
                 catch
                 {
                 }
             }
             if ((args[i].ToLower() == "-pass") || (args[i].ToLower() == "-password"))
             {
                 i++;
                 Netplay.password = args[i];
                 main.AutoPass();
             }
             if (args[i].ToLower() == "-host")
             {
                 main.AutoHost();
             }
             if (args[i].ToLower() == "-loadlib")
             {
                 i++;
                 string path = args[i];
                 main.loadLib(path);
             }
         }
         main.Run();
     }
     catch (Exception exception)
     {
         try
         {
             using (StreamWriter writer = new StreamWriter("client-crashlog.txt", true))
             {
                 writer.WriteLine(DateTime.Now);
                 writer.WriteLine(exception);
                 writer.WriteLine("");
             }
             MessageBox.Show(exception.ToString(), "Terraria: Error");
         }
         catch
         {
         }
     }
     finally
     {
         if (main != null)
         {
             main.Dispose();
         }
     }
 }
Ejemplo n.º 30
0
 public CmdAliasPlugin(Terraria.Main game) : base(game)
 {
 }