Page MenuHomeFeedback Tracker

findDisplay 313 createDisplay "RscDisplayEmpty" crashes the game
Closed, ResolvedPublic

Description

Executing findDisplay 313 createDisplay "RscDisplayEmpty" crashes the game when previewing a mission.

On the other hand. findDisplay 46 createDisplay "RscDisplayEmpty" executed in Eden editor will return displayNull and the game won't crash.

Ideally, createDisplay should always fail silently if display cannot be created on given display for whatever reason.

Details

Severity
Crash
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Scripting

Event Timeline

R3vo created this task.Apr 20 2021, 12:17 AM
R3vo renamed this task from findDisplay 313 createDisplay "someUI" crashes the game to findDisplay 313 createDisplay "RscDisplayEmpty" crashes the game.
7erra added a subscriber: 7erra.Apr 20 2021, 12:32 PM
dedmen added a subscriber: dedmen.EditedJun 29 2021, 11:18 AM

A display can only have one child.
What you are doing is replacing the child of 313.
Which during 3DEN preview is DisplayMission, you are deleting the mission display while playing the mission.

@BIS_fnc_KK wrote a fix.
Just automatically find the last child and add the new display to that one instead of adding as child on the display that you requested.

Actually this is much more troublesome...

Currently, "parent createDisplay" is the same as "deleteDisplay child parent" followed by creating a new display.
So scripts can use that to delete displays, and as we don't know what modders might've written in their scripts, there might be scripts that intentionally do that that we would break with this change...

We can try to only do this fallback in cases where you delete the mission display as we know that will go wrong.
And there should also be a displayChild script command so that you can check for yourself if your createDisplay will be destructive.

dedmen added a comment.EditedJun 29 2021, 12:48 PM

So fix is this

parent = findDisplay 313;
wouldDeleteDisplayMission = false;
currentChild = displayChild parent;
tempParent = parent;

while (!isNull currentChild){
  if (tempParent is "DisplayMission")
    wouldDeleteDisplayMission  = true;

  tempParent = currentChild;
  currentChild = displayChild tempParent;
}
if (wouldDeleteDisplayMission)
  parent = tempParent;

parent createDisplay "RscDisplayEmpty"

I think this is the best way to handle this, while not breaking backwards compat in any way.
We know that NOONE is doing this with DisplayMission intentionally, because it crashes the game. So fixing this won't break backwards compat.

dedmen claimed this task.Jun 29 2021, 12:57 PM
dedmen changed the task status from New to Assigned.
dedmen set Ref Ticket to AIII-54390.
dedmen changed the task status from Assigned to Feedback.Jun 29 2021, 1:22 PM

rev 147826 dev-branch
Profiling branch v9 (probably this week)

R3vo closed this task as Resolved.Jul 3 2021, 9:21 AM

Works nicely.