Page 1 of 1

Game crashed when run this script

Posted: Sun Aug 18, 2019 8:00 pm
by NearHuscarl

Code: Select all

        public void OnStartup()
        {
            var player = Game.CreatePlayer(Vector2.Zero);
            player.Remove();
            Events.UpdateCallback.Start((dt) =>
            {
                Log(player);
            }, 0, 1);
        }

        public static void Log(object obj)
        {
            var type = obj.GetType();
            var properties = type.GetProperties();

            foreach (var property in properties)
            {
                var propName = property.Name;
                var value = property.GetValue(obj, null).ToString();
                Game.ShowChatMessage(type.Name + "." + propName + ": " + value);
            }
        }
When running this script in the map editor, the game crash without writing any report files

EDIT: here is the error. The script above crash very quickly because it's extracted from my larger script so you wont see the error. but when my full script failed it show the error dialog briefly before crashing.

Image

Re: Game crashed when run this script

Posted: Mon Aug 19, 2019 12:01 pm
by JakSparro98
NearHuscarl wrote:
Sun Aug 18, 2019 8:00 pm

Code: Select all

        public void OnStartup()
        {
            var player = Game.CreatePlayer(Vector2.Zero);
            player.Remove();
            Events.UpdateCallback.Start((dt) =>
            {
                Log(player);
            }, 0, 1);
        }

        public static void Log(object obj)
        {
            var type = obj.GetType();
            var properties = type.GetProperties();

            foreach (var property in properties)
            {
                var propName = property.Name;
                var value = property.GetValue(obj, null).ToString();
                Game.ShowChatMessage(type.Name + "." + propName + ": " + value);
            }
        }
When running this script in the map editor, the game crash without writing any report files

EDIT: here is the error. The script above crash very quickly because it's extracted from my larger script so you wont see the error. but when my full script failed it show the error dialog briefly before crashing.

Image
That crash should be catched by the editor, but since it triggers a permission denial from the sandbox where the script is executed it crashes the entire app by calling Game.ShowChatMessage() after that exception is thrown; any suspicous call, like I/O operations and (as it seems) even introspective calls are not allowed.


In the first place, what are you trying to achieve using reflections? all the available methods, fields and such are written in the docs.

Re: Game crashed when run this script

Posted: Mon Aug 19, 2019 1:58 pm
by Gurt
Fixed game-crash after v.1.3.1b.
You will still get the exception but it will be displayed properly and not crash the game. Reflection isn't anything we plan to support to 100% and can be a limitation based on the restrictions we have in place for System.IO access in different ways.
I also fixed unresponsive code in callbacks causing SFD to freeze (for example a while(true) loop that never terminates). Looks like I missed to handle this one too!

You can opt in to the betapreview branch in Steam if you want the fixes already in the v.1.3.1b version.
Open properties for Superfighters Deluxe in Steam and select the BETA tab and there type in "balistabalista" and select the betapreview branch.