OpenDreamProject / OpenDream

A project for running games made in the DM programming language
MIT License
204 stars 109 forks source link

Nebula: pAI savefiles cause strange runtimes #1750

Open out-of-phaze opened 6 months ago

out-of-phaze commented 6 months ago

Description of Issue

pAI savefiles cause strange runtimes, seemingly from the savefile being null?

Code sample

Lines 15-29 of personality.dm:

/datum/paiCandidate/proc/savefile_save(mob/user)
    if(IsGuestKey(user.key))
        return 0

    var/savefile/F = new /savefile(src.savefile_path(user))

    to_file(F["name"], src.name)
    to_file(F["description"], src.description)
    to_file(F["role"], src.role)
    to_file(F["comments"], src.comments)
    to_file(F["chassis"], src.chassis)
    to_file(F["say_verb"], src.say_verb)
    to_file(F["version"], 1)

    return 1

Logs

```js [23:59:59] Runtime in ,0: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'OpenDreamRuntime.Objects.Types.DreamObjectSavefile+SFDreamJsonValue'. Path: $ | LineNumber: 0 | BytePositionInLine: 5. Exception occurred: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'OpenDreamRuntime.Objects.Types.DreamObjectSavefile+SFDreamJsonValue'. Path: $ | LineNumber: 0 | BytePositionInLine: 5. =DM StackTrace= new /savefile /datum/paiCandidate/savefile_save code/modules/mob/living/silicon/pai/personality.dm:19 /datum/category_item/player_setup_item/player_global/pai/save_preferences code/modules/client/preference_setup/global/03_pai.dm:27 /datum/category_group/player_setup_category/save_preferences code/modules/client/preference_setup/preference_setup.dm:157 /datum/category_collection/player_setup_collection/save_preferences code/modules/client/preference_setup/preference_setup.dm:90 /datum/preferences/save_preferences code/modules/client/preferences_persist.dm:66 /datum/preferences/Topic code/modules/client/preferences.dm:308 /client/Topic Types/Client.dm:69 /client/Topic code/modules/client/client_procs.dm:108 =C# StackTrace= System.NotSupportedException: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'OpenDreamRuntime.Objects.Types.DreamObjectSavefile+SFDreamJsonValue'. Path: $ | LineNumber: 0 | BytePositionInLine: 5. ---> System.NotSupportedException: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'OpenDreamRuntime.Objects.Types.DreamObjectSavefile+SFDreamJsonValue'. --- End of inner exception stack trace --- at System.Text.Json.ThrowHelper.ThrowNotSupportedException(ReadStack& state, Utf8JsonReader& reader, NotSupportedException ex) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo) at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options) at OpenDreamRuntime.Objects.Types.DreamObjectSavefile.Initialize(DreamProcArguments args) in c:\Users\User\phaze\OpenDream\OpenDreamRuntime\Objects\Types\DreamObjectSavefile.cs:line 106 at OpenDreamRuntime.Procs.InitDreamObjectState.Resume() in c:\Users\User\phaze\OpenDream\OpenDreamRuntime\Procs\InitDreamObject.cs:line 80 at OpenDreamRuntime.DreamThread.Resume() in c:\Users\User\phaze\OpenDream\OpenDreamRuntime\DreamThread.cs:line 223 [ERRO] world.log: Exception occurred: Cannot get index "name" of null =DM StackTrace= /datum/paiCandidate/savefile_save code/modules/mob/living/silicon/pai/personality.dm:21 /datum/category_item/player_setup_item/player_global/pai/save_preferences code/modules/client/preference_setup/global/03_pai.dm:27 /datum/category_group/player_setup_category/save_preferences code/modules/client/preference_setup/preference_setup.dm:157 /datum/category_collection/player_setup_collection/save_preferences code/modules/client/preference_setup/preference_setup.dm:90 /datum/preferences/save_preferences code/modules/client/preferences_persist.dm:66 /datum/preferences/Topic code/modules/client/preferences.dm:308 /client/Topic Types/Client.dm:69 /client/Topic code/modules/client/client_procs.dm:108 =C# StackTrace= System.Exception: Cannot get index "name" of null at OpenDreamRuntime.Procs.DMProcState.ThrowCannotGetIndex(DreamValue indexing, DreamValue index) in c:\Users\User\phaze\OpenDream\OpenDreamRuntime\Procs\DMProc.cs:line 922 at OpenDreamRuntime.Procs.DMProcState.GetIndex(DreamValue indexing, DreamValue index) in c:\Users\User\phaze\OpenDream\OpenDreamRuntime\Procs\DMProc.cs:line 916 at OpenDreamRuntime.Procs.DMProcState.GetReferenceValue(DreamReference reference, Boolean peek) in c:\Users\User\phaze\OpenDream\OpenDreamRuntime\Procs\DMProc.cs:line 809 at OpenDreamRuntime.Procs.DMOpcodeHandlers.OutputReference(DMProcState state) in c:\Users\User\phaze\OpenDream\OpenDreamRuntime\Procs\DMOpcodeHandlers.cs:line 2185 at OpenDreamRuntime.Procs.DMProcState.Resume() in c:\Users\User\phaze\OpenDream\OpenDreamRuntime\Procs\DMProc.cs:line 415 at OpenDreamRuntime.DreamThread.Resume() in c:\Users\User\phaze\OpenDream\OpenDreamRuntime\DreamThread.cs:line 223 ```
amylizzle commented 5 months ago

I think this is from trying to load a savefile in a bad (ie, BYOND) format. The loading runtimes and the savefile returned is null. Could definitely use a cleaner error message there though.