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

fix missions duplicating #44114

Merged
merged 2 commits into from
Sep 13, 2020
Merged

fix missions duplicating #44114

merged 2 commits into from
Sep 13, 2020

Conversation

akirashirosawa
Copy link
Contributor

Summary

SUMMARY: None

Purpose of change

I caught bug with duplicate mission learn_about_cattail_jelly.
After saving and loading the game, the NPC forgot about mission and duplicating it.
A similar issue is described here #38325. This PR should fix #38325 too.

Besides duplication, mission learn_about_cattail_jelly has another issue: "bag_zipper" cannot contain "cattail_jelly" because can't contain liquid. Let's fix it along the way.

Describe the solution

After a little research, I found that the duplication issue related with wrong player_id in missions. It turned out that the player_id is not loaded from the save file. Let's add it.

// void mission::deserialize( JsonIn &jsin )
jo.read( "player_id", player_id );

Fix bag_zipper:

"watertight": true,

Testing

Build and checked in the game - everything works.

@akirashirosawa
Copy link
Contributor Author

If someone's save was damaged by this bug, but you haven't talk to the NPC again, you can fix your save.

  1. Open file master.gsav.
  2. Find active_missions array.
  3. Change "player_id": -1 to "player_id": 1 in missions objects.

If you have already spoken with NPC, then in addition to written above, you need to find in the file o.0.0 (or same) this NPC (by name) and move the mission identifier from the missions array to the missions_assigned array.
For example:
"chatbin":{"first_topic":"TALK_SHELTER","mission_selected":1,"skill":"","style":"","missions":[1],"missions_assigned":[]}
->
"chatbin":{"first_topic":"TALK_SHELTER","mission_selected":1,"skill":"","style":"","missions":[0],"missions_assigned":[1]}.

You can also remove duplicate missions from "active_missions" array in *.sav file. For example, "active_missions": [1, 2, 2, 2, 1] -> "active_missions": [1, 2] to clear your mission journal.

@anothersimulacrum anothersimulacrum added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` labels Sep 11, 2020
@akirashirosawa
Copy link
Contributor Author

@jkraybill
@bouchacha
Guys, try this fix if it's still relevant for you.

@bouchacha
Copy link

Thank you for this fix! I'm a bit confused about the step involving the o.0.0 file. You mention "or same", and I see a bunch of other files similarly named (e.g. o.1.0, o.-1.0, o.1.1, etc). Is each file a designator for an NPC? Are we supposed to go through each one to update the mission array? Can we clear the active missions without doing that step?

@anothersimulacrum
Copy link
Member

Each file corresponds with an overmap, where NPCs are stored, so you should search through each to find the appropriate changes.

@akirashirosawa
Copy link
Contributor Author

akirashirosawa commented Sep 12, 2020

Yes, it is. Just search in the folder by NPC name. All these files are text (json) files. The name that is displayed in the game. In my case, the name Доннелл Рейнс (Donnell Raines in Russian) was found in the o.0.0 file. I'm not sure if Windows is able to search inside files in a folder (I use macOS). You may need to google or install an editor like VS Code or Sublime Text.

"name": "Доннелл Рейнс",
"marked_for_death": false,
"dead": false,
"patience": 0,
"myclass": "NC_TRADER",
"known_to_u": true,
// ... some other props
"chatbin": {
  "first_topic": "TALK_SHELTER",
  "skill": "",
  "style": "",
  "missions": [1], <--
  "missions_assigned": [] <---
},

Can we clear the active missions without doing that step?

In fact, yes. You just need to apply PR fix, then take the mission again (for the last time) and save the game. So the changes in step 2 will apply themselves. I wrote this for the case when there is no desire, opportunity, to take all missions again in the game. They can be returned manually as I described. But you can just take them again in the game, if it's more convenient.

But to clear the mission journal, step 3 will have to be done manually:

You can also remove duplicate missions from "active_missions" array in *.sav file. For example, "active_missions": [1, 2, 2, 2, 1] -> "active_missions": [1, 2] to clear your mission journal.

@bouchacha
Copy link

What I ended up doing was just only editing the "active_missions" array in *.sav. If the mission number showed up in finished missions, I deleted it from active_missions. The bug was fairly obvious, as the active_missions array was like [ 9, 1, 1, 24, 36, 24, 24, 18 ] etc. The main thing I cared about was clearing the mission backlog so this largely fixed the problem on my end.

@ZhilkinSerg ZhilkinSerg merged commit d59a462 into CleverRaven:master Sep 13, 2020
@akirashirosawa akirashirosawa deleted the fix-mission_learn_about_cattail_jelly branch September 13, 2020 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missions get duplicated when returning to mission-giver
4 participants