12 hours of work gone after crash- very frustrated. Any way to repair tscn file?

jbskaggsjbskaggs Posts: 647Member
edited November 2021 in General Chat

I have been saving my game scene files every half hour or so.

I was editing my scene and about to make a new copy of the whole project, when the editor crashed and overwrote my save file. Now I get an unexpected end of file error. All the data looks to be correct in the .tcsn file.

Is there anyway to repair a tscn file? I do not want to recreate 10 hours of work from memory.

EDIT: I realized I uploaded my old backfile- here is the current file that will not load. (Im sorry)

 [gd_scene load_steps=20 format=2]

[ext_resource path="res://global_sprites/quit.png" type="Texture" id=1]
[ext_resource path="res://global_sprites/tower_select.png" type="Texture" id=2]
[ext_resource path="res://global_sprites/x.png" type="Texture" id=3]
[ext_resource path="res://models/color_1650274_004.material" type="Material" id=4]
[ext_resource path="res://models/color_15277357_004.material" type="Material" id=5]
[ext_resource path="res://global_scripts/shooter.gd" type="Script" id=6]
[ext_resource path="res://global_scripts/TowerPlacement.gd" type="Script" id=7]
[ext_resource path="res://Level_00/Level_00.gd" type="Script" id=8]
[ext_resource path="res://Level_00/Sprites/2.png" type="Texture" id=9]
[ext_resource path="res://models/PathEnemy.tscn" type="PackedScene" id=10]
[ext_resource path="res://models/shooter.tscn" type="PackedScene" id=12]
[ext_resource path="res://models/pathfollow.tscn" type="PackedScene" id=13]
[ext_resource path="res://models/bullet.tscn" type="PackedScene" id=14]

[sub_resource type="CubeMesh" id=5]

[sub_resource type="BoxShape" id=4]

[sub_resource type="BoxShape" id=2]
extents = Vector3( 0.3, 1, 0.349648 )

[sub_resource type="CubeMesh" id=3]

[sub_resource type="BoxShape" id=7]
extents = Vector3( 0.325117, 0.582893, 0.333299 )

[sub_resource type="BoxShape" id=8]

[node name="level0" type="Spatial"]
script = ExtResource( 8 )
bullet = ExtResource( 14 )
node_path = NodePath("Shooter/muzzle")

[node name="PathEnemy" parent="." instance=ExtResource( 10 )]
enemy = ExtResource( 13 )

[node name="pathfollow" parent="PathEnemy" instance=ExtResource( 13 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3.17244, 0, -3.21418 )

[node name="Sprite3DBackground" type="Sprite3D" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.1, -0.1, 0.2 )
texture = ExtResource( 9 )
__meta__ = {
"_edit_lock_": true

[node name="FullMapCamera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.245358, 0.969433, 0, -0.969433, 0.245358, -0.0919414, 3.70555, 1.44883 )
current = true
size = 8.0

[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 14, 0 )
directional_shadow_mode = 0

[node name="Shooter" parent="." instance=ExtResource( 12 )]
transform = Transform( -0.999706, 0, 0.0242578, 0, 1, 0, -0.0242578, 0, -0.999706, -1.2502, -0.000375748, -1.41677 )
script = ExtResource( 6 )
node_path = NodePath("../PathEnemy/pathfollow")
bullet = ExtResource( 14 )
node_path_muzzle = NodePath("muzzle")

[node name="mesh" type="CSGMesh" parent="Shooter"]
transform = Transform( 0.5, 0, 0, 0, 1, 0, 0, 0, 0.5, 0, 0, 0 )
visible = false
mesh = SubResource( 5 )
material = ExtResource( 4 )

[node name="Area" type="Area" parent="Shooter"]

[node name="CollisionShape" type="CollisionShape" parent="Shooter/Area"]
shape = SubResource( 4 )

[node name="muzzle" type="Position3D" parent="Shooter"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.149414, -0.0700495, -1.04392 )

[node name="EndGoal" type="Area" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -2.88925, 0, 2.90441 )

[node name="CollisionShape" type="CollisionShape" parent="EndGoal"]
transform = Transform( 0.980385, -2.69815e-09, 0.197093, 2.76979e-09, 1, -8.78414e-11, -0.197093, 6.32024e-10, 0.980385, -0.100443, 0, -0.100443 )
shape = SubResource( 2 )

[node name="CSGMesh" type="CSGMesh" parent="EndGoal/CollisionShape"]
transform = Transform( 0.25, 6.76542e-16, 0, -1.36002e-15, 0.25, 1.38778e-17, 0, 9.71445e-17, 0.25, -0.0108869, 3.74785e-11, 0.083318 )
mesh = SubResource( 3 )
material = ExtResource( 5 )

[node name="BulletContainer" type="Spatial" parent="."]

[node name="TowerButton" type="TextureButton" parent="."]
margin_left = 8.0
margin_top = 510.0
margin_right = 143.0
margin_bottom = 681.0
rect_scale = Vector2( 0.5, 0.5 )
texture_normal = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false

[node name="QuitButton" type="TextureButton" parent="."]
margin_left = 8.0
margin_top = 8.0
margin_right = 279.0
margin_bottom = 94.0
rect_scale = Vector2( 0.35, 0.35 )
texture_normal = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false

[node name="CollissionMap" type="Area" parent="."]
__meta__ = {
"_edit_lock_": true

[node name="Sprite3DBackground2" type="Sprite3D" parent="CollissionMap"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.112424, -0.0796607, 0.2 )
visible = false
texture = ExtResource( 9 )

continued below...


  • Erich_LErich_L Posts: 591Member

    What exactly were you doing when the program crashed? Also, when do you get the unexpected end of file error? When you load up the project? After glimpsing over your file and one of my own one of the differences I noticed was that lines 139 to 147: many of your connections are connected to "." while none of mine are. No idea if that makes a difference tho.

  • jbskaggsjbskaggs Posts: 647Member

    I had cut a section of nodes at end of the tscn to do a save as without those nodes.

    It gives the error at start up.

    I will look at 139-147.

  • jbskaggsjbskaggs Posts: 647Member

    Nope I removed those lines and nothing changed, same error. I also went thru all dependencies and and reloaded them. Did not help.

  • jbskaggsjbskaggs Posts: 647Member

    btw I am pretty sure "." means root

  • jbskaggsjbskaggs Posts: 647Member

    continuation of code:

    [node name="CollisionPolygon" type="CollisionPolygon" parent="CollissionMap"]
    transform = Transform( 1, 0.000645772, 0, 2.82276e-11, -4.37114e-08, 1, 0.000645772, -1, -4.37114e-08, 0, 0, 0 )
    depth = 0.05
    polygon = PoolVector2Array( -3.36108, -2.49406, -2.73423, -2.16534, -2.83317, -1.74673, -3.13762, -0.795351, -3.00062, -0.0951333, -2.52873, 0.293031, -1.77524, 0.300642, -0.998909, -0.338687, -0.50419, -0.962794, 0.340638, -1.39662, 1.11697, -1.54885, 1.7535, -2.0226, 1.94657, -1.87659, 1.81583, -1.3863, 0.0666393, -0.658352, -0.702078, 0.186476, -0.816244, 0.749695, -0.374802, 1.19875, 0.957133, 1.35097, 0.401526, 1.70108, -0.580301, 1.82285, -1.71435, 1.80763, -2.81034, 1.99791, -3.32028, 2.38607, -3.43445, 2.76663, -2.77229, 2.91124, -2.17862, 2.48502, 0.0742502, 2.46979, 1.4823, 1.77719, 1.45946, 1.0313, 0.728801, 0.71925, -0.13886, 0.490919, 2.28146, -0.894295, 2.57829, -1.97507, 1.92374, -2.53828, 0.766857, -2.10445, -0.374802, -1.92179, -0.953243, -1.41185, -1.56213, -0.643129, -2.14818, -0.28541, -2.51351, -0.460464, -2.26235, -1.18351, -2.0264, -2.30995, -2.53634, -2.8275, -2.53223, -2.83805, -3.36108, -2.49406, -2.54725, -2.84557, -2.54724, -2.8606 )
    [node name="ShooterCursor" type="Spatial" parent="."]
    script = ExtResource( 7 )
    camera_path = NodePath("../FullMapCamera")
    get_tower = NodePath("../Shooter")
    [node name="Sprite3D" type="Sprite3D" parent="ShooterCursor"]
    transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0.006, 0.75, 0 )
    visible = false
    billboard = 1
    texture = ExtResource( 3 )
    [node name="shooter" parent="ShooterCursor" instance=ExtResource( 12 )]
    [node name="Area" type="Area" parent="ShooterCursor"]
    [node name="CollisionShape" type="CollisionShape" parent="ShooterCursor/Area"]
    transform = Transform( 0.35, 0, 0, 0, 0.35, 0, 0, 0, 0.35, 0, 0, 0 )
    shape = SubResource( 7 )
    [node name="AreaCursor" type="Area" parent="ShooterCursor"]
    [node name="CollisionShape" type="CollisionShape" parent="ShooterCursor/AreaCursor"]
    shape = SubResource( 8 )
    [connection signal="input_event" from="Shooter/Area" to="Shooter" method="_on_Area_input_event"]
    [connection signal="mouse_entered" from="Shooter/Area" to="Shooter" method="_on_Area_mouse_entered"]
    [connection signal="mouse_exited" from="Shooter/Area" to="Shooter" method="_on_Area_mouse_exited"]
    [connection signal="pressed" from="TowerButton" to="." method="_on_TowerButton_pressed"]
    [connection signal="pressed" from="QuitButton" to="." method="_on_TextureButton2_pressed"]
    [connection signal="area_shape_entered" from="ShooterCursor/Area" to="ShooterCursor" method="_on_Area_area_shape_entered"]
    [connection signal="area_shape_exited" from="ShooterCursor/Area" to="ShooterCursor" method="_on_Area_area_shape_exited"]
    [connection signal="input_event" from="ShooterCursor/Area" to="ShooterCursor" method="_on_Area_input_event"]
    [connection signal="input_event" from="ShooterCursor/AreaCursor" to="ShooterCursor" method="_on_AreaCursor_input_event"]
  • cyberealitycybereality Posts: 3,792Moderator

    Are you on Windows? Recuva can restore deleted or corrupted files.


    It may not be the most recent version, but you might be able to get to 1 hour back in time or something. Just keep in mind it doesn't always work, it depends on what happens with the system after the file is damaged.

  • jbskaggsjbskaggs Posts: 647Member

    hmm trying now.

  • jbskaggsjbskaggs Posts: 647Member

    Nope- the recovered file was unreadable.

  • cyberealitycybereality Posts: 3,792Moderator


  • jbskaggsjbskaggs Posts: 647Member

    I wish there was a way to see this file in godot editor and see which line is throwing error.

    I mean it's not the end of the world, but still very frustrating.

  • cyberealitycybereality Posts: 3,792Moderator
  • jbskaggsjbskaggs Posts: 647Member

    Thank you I will read those:)

  • cyberealitycybereality Posts: 3,792Moderator

    The most likely problem is that some resource got damaged and can't be loaded. The tscn file refers to resources like this:

    ExtResource( 12 )

    But you'd have to somehow figure out which id number means what, and which specific resource is the problem. How to figure that out, I don't know.

  • jbskaggsjbskaggs Posts: 647Member

    I think you have the right track there was no number 11- So I renumbered last 3 and new error:

    Parsing error.

    then in terminal:

    ERROR: res://Level_00/Level_00.tscn:33 - Parse Error: Can't load cached ext-resource #14
       at: _parse_node_tag (scene/resources/resource_format_text.cpp:255)
    ERROR: Failed to load resource 'res://Level_00/Level_00.tscn'.
       at: (core/io/resource_loader.cpp:206)
    ERROR: Failed loading resource: res://Level_00/Level_00.tscn. Make sure resources have been imported by opening the project in the editor at least once.
       at: (core/io/resource_loader.cpp:270)
    ERROR: Index p_idx = 1 is out of bounds (edited_scene.size() = 1).
       at: remove_scene (editor/editor_data.cpp:531)

    I think that's progress ??

  • xyzxyz Posts: 907Member

    @cybereality said:
    The most likely problem is that some resource got damaged and can't be loaded. The tscn file refers to resources like this:

    ExtResource( 12 )

    But you'd have to somehow figure out which id number means what, and which specific resource is the problem. How to figure that out, I don't know.

    Resource paths and their corresponding ids are listed at the beginning of the file inside ext_resource elements

    [ext_resource path="res://global_sprites/quit.png" type="Texture" id=1]

    But I'm not sure a corrupted resource would generate 'unexpected end of file' error. Unless the message pertains to the resource file itself.

    I'd first inspect all Script and PackedScene external resources (listed at the start of file) and check if any of them are visibly corrupted. Also check their external resources and so on.

  • xyzxyz Posts: 907Member

    @jbskaggs said:
    there was no number 11- So I renumbered last 3 and new error:

    Renumbering may cause additional problems. Skipped id shouldn't be a problem if nothing in the rest of the file refers to it.

  • cyberealitycybereality Posts: 3,792Moderator

    From what I can tell, the "unexpected end of file" is just the generic error when it can't load. So you won't know what the actual problem is. I was guessing that it was a resource issue, since that makes sense (something was open when it crashed and got corrupted). Some other people had the same problem too but there was no easy solution.

  • jbskaggsjbskaggs Posts: 647Member

    Thank you all!

    Here was issue: resource indexes were wrong. And one scene "shooter.tscn" was corruputed and would crash my sys everytime I tried to open it.

    Removing all references to "shooter.tscn" and fixing the index I know have 99% of my scene working! yay!

    This was a good process as it is wise to understand ths file structure.

  • cyberealitycybereality Posts: 3,792Moderator
    edited November 2021

    The missing 11 by itself is probably not the problem. That could happen maybe if there was another resource at some point and it was deleted. It would only be an issue if there was an ExtResource( 11 ) somewhere later in the file and it couldn't find that id (but it doesn't look like that's the case). It's also possible it's something else entirely, I'm not sure. Do you remember the last thing you added to the project or what exactly was open on the screen when the editor crashed? You might be able to just remove that object (you can add it back later once you get it working).

  • jbskaggsjbskaggs Posts: 647Member

    Thats what I did, thank you

  • cyberealitycybereality Posts: 3,792Moderator

    Also, if you're comfortable with it, I can take a look myself. Just upload the whole project or send me a PM if you don't want to post on the forum publicly.

  • cyberealitycybereality Posts: 3,792Moderator

    Wow! Honestly, I was guessing that was the issue but I didn't expect it to actually work.

  • jbskaggsjbskaggs Posts: 647Member

    @cybereality said:
    Wow! Honestly, I was guessing that was the issue but I didn't expect it to actually work.

    Yeah- your were right. I dont know why the shooter.tscn corrupted. I am going to just remake the shooter.tscn.

    I appreciate your offer and I can send you a private message, but I think I got this part done.

  • BimbamBimbam Posts: 219Member
    edited November 2021

    Congrats on solving your issue. :D

    May I suggest setting up Volume Shadow Copies (if Windows) which will give you automatic snapshots of your filesystem every X hours (I have mine set to ~3hrs), and additionally set up automatic incremental backups to an external drive/S3 using something like Duplicati.

    I know I've been down the rabbit hole of forgetting to commit to version control regularly, so automated backups beyond GIT have been a lifesaver to me multiple times and are worth the effort ^^.

  • jbskaggsjbskaggs Posts: 647Member

    Bimbam thank you I am setting that up. :)

  • cyberealitycybereality Posts: 3,792Moderator
    edited November 2021

    Yes, always a good time to mention Git and source control. I use Beanstalk, it is $15/month but I find the service to be good and I like their web interface.

    However, Bitbucket has a free tier and also more affordable pricing. They are also good.

    Git is very important, for keeping your code safe and also allowing you to experiment without breaking the whole thing (easy to roll back). However, it should not be considered your only backup solution. It's good to have an automatic backup, because maybe you forget to commit and the engine crashes, and also to have a fail safe.

    I use Tresorit, which is $10/month, offers 500GB of storage, is encrypted, and works on all platforms.

    This is great because I sleep comfortably knowing my projects are automatically backed up in real-time as files change, I can access from any machine or their website and easily restore if any problems happen. And I don't have to worry if I forget to submit to Git, or if my Git provider goes bust or is hacked.

    And this is not a theoretical. I used to use this service called Code Spaces for SVN source control on the DX11 engine I mentioned in another thread. The service was hacked, the hackers encrypted all the files and demanded a hefty ransom. When the company didn't pay immediately (and made attempts to regain access to their account), the hackers wiped the whole server, including all the backups. I lost about 1 year of work (though thankfully I still had the most recent version on my local machine).

    So this is not impossible and has happened. Definitely don't think just cause you have 1 backup that everything is safe. I would say you need at the very least 2 different backup solutions (for example, Git and an auto cloud backup), and maybe a local one too to be safe. However, I had trouble with syncing when having two backup applications running on the same folder (there would be merge conflicts and extra files) so I just use Tresorit now and it seems to work well.

  • jbskaggsjbskaggs Posts: 647Member

    I have to use free versions as I am on hospice and no income. I just recently learned git.

    Normally each morning I make a copy of game folder, then I edit the original and at end of day I push the files onto git.

    In this case I saved scenes- not knowing one was corrupted. So I had my morning files but the evening files had been corrpted, So autosaves with differences would be great setup.

  • cyberealitycybereality Posts: 3,792Moderator

    Makes sense. Definitely check out Bitbucket then, they are very good.

  • DaveTheCoderDaveTheCoder Posts: 666Member

    automated backups beyond GIT have been a lifesaver to me multiple times and are worth the effort


    On Linux, I use BackInTime and configured it to back up my Godot projects hourly.

Sign In or Register to comment.