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

systemTimeUTC-based save game sorting #759

Merged
merged 4 commits into from
Feb 10, 2021
Merged

systemTimeUTC-based save game sorting #759

merged 4 commits into from
Feb 10, 2021

Conversation

Br-ian
Copy link
Contributor

@Br-ian Br-ian commented Nov 23, 2020

This addresses #758 by introducing a new header to the save game called systemTimeUTC. The value of systemTimeUTC is the date/time at which the game was saved. We use systemTimeUTC not systemTime to prevent time zone and daylight saving time mumbo jumbo.

Fixes:

  • Sorting of save games in the save games UI tab
  • Loading the correct latest save when auto load is enabled (previously it was possible for the wrong/non-latest save to be loaded due to alphabetical ordering)

I only have a few hours of Arma3 scripting experience, so any feedback/code review would be welcome.

Could someone answer the following questions:

  • BIS_fnc_sortBy does not sort in place, it returns a new array, is this a performance concern for Arma?
  • Introducing a new header means old save games are not compatible, is there any way to mitigate this?
  • Is the use of private correct?

@Sparker95
Copy link
Owner

Sparker95 commented Nov 23, 2020

Hi! Thanks for this pull request. I'm leaving for a month now so I won't be able to check your PR until I return.

Introducing a new header means old save games are not compatible, is there any way to mitigate this?

Yes we absolutely need to solve this, we almost never want to make people dump their saved games, unless it's very important. But it can be done. Most likely we need to check the version of the saved game header. We can also use attributes of variables, such as ATTR_SAVE_VER, to solve this.

@Sparker95
Copy link
Owner

Sparker95 commented Feb 10, 2021

Sorry for the wait!

I've had a look at the code and it makes perfect sense, it's very nice that you could figure out our saving system and our macros in the code, given that you have a few hours of SQF programming experience :).

I've slightly changed a few things. The main one is this part:
https://github.com/Br-ian/Vindicta/blob/1e8b68a270325c3a2a3f32242853c28749b51597/src/GameManager/SaveGameHeader.sqf#L57-L69
In our saving system, we can override the deserializeFromStorage method to perform data patching in a centralized way. This way we can set a default value for systemTimeUTC and we don't need to check it in three other places :).

Also, answering your other question:
BIS_fnc_sortBy does not sort in place, it returns a new array, is this a performance concern for Arma?
It would make difference if this happened frequently, but this code only runs when we want to save the game or load the game - almost never, so it's not important.

Thanks again for your contribution!

@Sparker95 Sparker95 merged commit baf665d into Sparker95:development Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants