This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

Game crashed when run this script

Here you can find all solved gameplay problems and bugs (beginning from Pre-Alpha 1.8.8).
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Locked
NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

Game crashed when run this script

Post by NearHuscarl » 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
0 x
Image

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 27

Post by JakSparro98 » Mon Aug 19, 2019 12:01 pm

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.
0 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Mon Aug 19, 2019 1:58 pm

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.
0 x
Gurt

Locked