Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't migrate a deleted gun variant #72607

Closed
hexagonrecursion opened this issue Mar 25, 2024 · 1 comment · Fixed by #72717
Closed

Can't migrate a deleted gun variant #72607

hexagonrecursion opened this issue Mar 25, 2024 · 1 comment · Fixed by #72717
Labels
<Bug> This needs to be fixed Items: Variants Variants of items

Comments

@hexagonrecursion
Copy link
Contributor

Describe the bug

#72398 removed a gun variant. This caused errors when loading saves (see #72602). It looks like #50266 was supposed to allow migrating specific item variants, but this did not work when I tried it. Through trial and error I have narrowed this down: a variant can only be migrated it is has not been deleted yet.

Attach save file

N/A

Steps to reproduce

  1. Install this mod:

    [
      {
        "type": "MOD_INFO",
        "id": "variant_migrations",
        "name": "variant_migrations",
        "authors": [ "Your name here" ],
        "description": "variant_migrations",
        "category": "content",
        "dependencies": [ "dda" ]
      },
      {
        "id": "foo_bar_common",
        "type": "GUN",
        "volume": "1000 ml",
        "weight": "1000 g",
        "variant_type": "gun",
        "name": { "str": "name" },
        "description": "description",
        "symbol": "B",
        "skill": "pistol"
      },
      {
        "id": "foo",
        "type": "GUN",
        "copy-from": "foo_bar_common",
        "name": { "str": "foo" },
        "variants": [
          { "id": "v1", "name": { "str": "foo v1" }, "description": "description" },
          { "id": "v2", "name": { "str": "foo v2" }, "description": "description" },
          { "id": "v3", "name": { "str": "foo v3" }, "description": "description" }
        ]
      }
    ]
  2. Spawn all 3 variants of foo

  3. Save, quit and replace the mod with:

    [
      {
        "type": "MOD_INFO",
        "id": "variant_migrations",
        "name": "variant_migrations",
        "authors": [ "Your name here" ],
        "description": "variant_migrations",
        "category": "content",
        "dependencies": [ "dda" ]
      },
      {
        "id": "foo_bar_common",
        "type": "GUN",
        "volume": "1000 ml",
        "weight": "1000 g",
        "variant_type": "gun",
        "name": { "str": "name" },
        "description": "description",
        "symbol": "B",
        "skill": "pistol"
      },
      {
        "id": "foo",
        "type": "GUN",
        "copy-from": "foo_bar_common",
        "name": { "str": "foo" },
        "variants": [
          { "id": "v1", "name": { "str": "foo v1" }, "description": "description" },
          { "id": "v2", "name": { "str": "foo v2" }, "description": "description" }
        ]
      },
      {
        "id": "bar",
        "type": "GUN",
        "copy-from": "foo_bar_common",
        "name": { "str": "bar" },
        "variants": [
          { "id": "v2", "name": { "str": "bar v2" }, "description": "description" },
          { "id": "v3", "name": { "str": "bar v3" }, "description": "description" }
        ]
      },
      {
        "type": "MIGRATION",
        "id": "foo",
        "from_variant": "v2",
        "replace": "bar"
      },
      {
        "type": "MIGRATION",
        "id": "foo",
        "from_variant": "v3",
        "replace": "bar"
      }
    ]
  4. When loading you get an error:

    DEBUG : item 'foo' has no variant 'v3'!

    FUNCTION : void item::set_itype_variant(const string&)
    FILE : src/item.cpp
    LINE : 9336
    VERSION : cdda-experimental-2024-03-25-0528 74771e1

  5. foo v2 is correctly migrated to bar v2, but foo v3 is replaced with a different variant of foo instead of being migrated to bar v3

Expected behavior

  1. No error
  2. foo v3 is migrated to bar v3

Screenshots

No response

Versions and configuration

  • OS: Linux
    • OS Version:
  • Game Version: cdda-experimental-2024-03-25-0528 74771e1 [64-bit]
  • Graphics Version: Tiles
  • Game Language: System language []
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth],
    variant_migrations [variant_migrations]
    ]

Additional context

Pinging @anothersimulacrum because variant migrations were originally added in #50266

@hexagonrecursion hexagonrecursion added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Mar 25, 2024
@anothersimulacrum
Copy link
Member

Thank you for the excellent reproduction steps!

@anothersimulacrum anothersimulacrum added <Bug> This needs to be fixed Items: Variants Variants of items and removed (S1 - Need confirmation) Report waiting on confirmation of reproducibility labels Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bug> This needs to be fixed Items: Variants Variants of items
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants