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

Differentiate save files based on game type #2122

Merged

Conversation

eos428
Copy link
Contributor

@eos428 eos428 commented Oct 28, 2020

Solves #323

So far the actual saving and loading seems alright for standard and campaign maps. However, I haven't saved the extra things needed for campaign maps.

@ihhub @idshibanov Any pointers on what to save? I think it should the player's hero data so maybe one of the heroes stream operators?

@idshibanov
Copy link
Collaborator

@ihhub @idshibanov Any pointers on what to save? I think it should the player's hero data so maybe one of the heroes stream operators?

Things to keep track:

  1. Maps finished to this point
  2. Maps chosen (when there's a branch in campaign, especially switch between Good and Evil campaigns at 5th scenario)
  3. Campaign awards earned (artifacts, creatures, "dwarven alliance" in Good campaign)
  4. Current scenario bonus chosen (one of the three)
  5. Optionally (not in original, but nice to have) we can save certain heroes (experience and skills only).

You don't have to add all of them right now, but make sure it will be easy to do in the future.

@idshibanov idshibanov added this to the 0.9 milestone Oct 28, 2020
@idshibanov idshibanov added campaign Campaign related stuff improvement New feature, request or improvement labels Oct 28, 2020
@ihhub
Copy link
Owner

ihhub commented Oct 29, 2020

Hi @eos428 , it's a very good but critical change which also breaks the backward compatibility. We will definitely come back to this pull request after 0.8.3 which is just in few days.

@eos428
Copy link
Contributor Author

eos428 commented Oct 30, 2020

No problem with that, take your time 👍

There's also campaign data which I do partially for this PR so I'd imagine there'll be a lot to review here haha

@eos428
Copy link
Contributor Author

eos428 commented Oct 31, 2020

Some update on the latest state of this PR:

  • Added some initial code on campaign data (I expect a lot of refactoring once it's reviewed hehe)
  • Did campaign scenario bonus. Probably no more than this for now, to prevent the PR over-scoping and becoming too big. Still have to test the troop bonus, but I tested the other two and it looks fine.

Things left to do for this PR:

  • Implement IO on campaign data
  • Code cleanup, of course
  • Likely many variable and/or class renaming

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eos428 , great stuff! We need to polish the code right now so move forward. Could you please take a look into given comments?

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eos428 I left few more comments. Please take a look.

@eos428
Copy link
Contributor Author

eos428 commented Nov 12, 2020

Fixes done. A bit unsure if I misunderstood some of the reviews so let me know if I do!

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eos428 , I left multiple comments. Could you please take a look and see if they make sense?

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eos428 , I left multiple comments. Could you please take a look?

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eos428 I left few comments and also some of previous comments haven't been addresses.

On top of this we have to modify CURRENT_FORMAT_VERSION and LAST_FORMAT_VERSION values. Please check if ( binver > CURRENT_FORMAT_VERSION || binver < LAST_FORMAT_VERSION ) { line in game_io.cpp file for more details.

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eos428 I left multiple comments mostly regarding the architecture of your changes. Could you please take a look?

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eos428 I left multiple comments. Could you please take a look?

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eos428 I left multiple comments. Could you please take a look?

@ihhub
Copy link
Owner

ihhub commented Dec 23, 2020

Hi @eos428 ,
I think we need to make some change in order to support old saves and prevent incorrect old save loading.

In bool Game::Load( const std::string & fn ) function we have the code:

HeaderSAV header;

// read raw info
fs >> strver >> binver >> header;

where we load a header. The issue here that modified HeaderSAV will read extra information from save file which is not present in the old saves.
To avoid this issue we need to modify the code to do this first:

fs >> strver >> binver;

after this we have to rename HeaderSAV into HeaderSAVBase and inherit from it another structure with our new parameter and call it (obviously) HeaderSAV. Then at the time of save loading we could decide which structure we need to use (we can utilize std::unique_ptr<HeaderSAVBase> for this) and load needed info. Please let me know if you have better ideas or questions.

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eos428 , I left just few comments. Could you please take a look into them?

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eos428 , things we need to change:

  • pass game type to Game::LoadSAV2FileInfo function and check it with read game type. If it's different then return false
  • revert changes in dialog_selectfile.cpp related to cursor. It breaks save file interaction
  • fix loading hot head and multiplayer file types. I think we mixed them together

The rest of changes I corrected. Please take a look :)

{
fheroes2::Display & display = fheroes2::Display::instance();
Cursor & cursor = Cursor::Get();
LocalEvent & le = LocalEvent::Get();

cursor.Hide();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert back all changes related to cursor.Hide() and cursor.Show() as it breaks the behaviour of typing a name for new save.

@ihhub
Copy link
Owner

ihhub commented Dec 27, 2020

Also @eos428 could you please squash all commits into one as GitHub behaves strangely with so many commits in a branch?

@eos428 eos428 force-pushed the differentiate-save-files-based-on-game-type branch from 82619a7 to 55aa57c Compare December 27, 2020 07:16
@eos428
Copy link
Contributor Author

eos428 commented Dec 27, 2020

Hi @ihhub I have made the changes as you requested.

However, in loading multiplayer saves separately (hotseat and network) I had to make more changes to the code. Mostly copy-pasted stuff though, but I hope you don't mind with that.

Also, I have to revert cursor Show/Hide changes in Game::LoadGame() due to reverting the changes in dialog_selectfile.cpp.

@ihhub ihhub merged commit 0769184 into ihhub:master Dec 27, 2020
@ihhub
Copy link
Owner

ihhub commented Dec 27, 2020

@eos428 great thanks for your work! Well done!

ihhub added a commit that referenced this pull request Dec 28, 2020
relates to #2122
and also some code cleanup
@ihhub ihhub mentioned this pull request Dec 28, 2020
ihhub added a commit that referenced this pull request Dec 28, 2020
relates to #2122
and also some code cleanup
vincent-grosbois pushed a commit to vincent-grosbois/fheroes2 that referenced this pull request Dec 28, 2020
vincent-grosbois pushed a commit to vincent-grosbois/fheroes2 that referenced this pull request Dec 28, 2020
relates to ihhub#2122
and also some code cleanup
@eos428 eos428 deleted the differentiate-save-files-based-on-game-type branch February 20, 2021 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
campaign Campaign related stuff improvement New feature, request or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants