godot-sdk-integrations / godot-play-game-services

A Godot 4.x plugin for integration with Google Play Game Services
MIT License
138 stars 10 forks source link

Question regarding snapshot conflict #35

Closed RProduction closed 1 week ago

RProduction commented 2 weeks ago

Hello, I am currently using this plugin for my game. Is there any direction or sample code for resolving snapshot conflict? I am currently having a problem that my game save data seem not loading well after some change, or deleting application data. I need to restart the app for it to load well, but there is no way I am going to let this problem slide.

I need your help regarding this matter.

Iakobs commented 2 weeks ago

Hi! The plugin is just an interface between the Google API and Godot, so at the end of the day you should be fine following Google's documentation on it, that's what I used to develop the plugin.

For save games specifically you can take a look here, but the docs are quite scarce. This project has a demo app here that you can open and Godot. In theory, if you provide a Game Id of your own, you should be able to run the demo app in an android device and test it there, but I've only tried with my own Game Id, not others.

If you do find a problem in the plugin implementation please let me know, and I'll fix it ASAP, but as mentioned and providing that I didn't mess anything, it's just a bypass between Google and Godot! 😅

RProduction commented 2 weeks ago

Thank you for answering. What I mean is snapshot_conflict_emitted just provide the snapshot data without public function to resolve the conflict. Meanwhile android sdk of google play games give function to resolve the conflict.

Unity google game sdk also have option to resolve conflict manually or automatically.

I can't even choose what snapshot to be loaded or saved from snapshot_conflict_emitted signal.

Edit: After some thought, maybe I could use the conflict data to choose the load game data, and save data. But, I need to differentiate it is save or load function that cause the conflict.

Iakobs commented 2 weeks ago

Hi! If I understand it correctly, you need to know what action triggered the conflict_emitted signal, either the load or the save methods? I can add a field in the SnapshotConflict object coming in that signal, to indicate the original caller, something like a string with "Save" or "Load", that would be enough for you?

I remember trying to implement the manual flow for resolving conflicts, but I think there was a problem with object types conversion between Java and GDScript. I can try again, too, but if adding the origin field to the SnapshotConflict solves the problem for now, I can quickly try that. What do you think?

RProduction commented 2 weeks ago

Yeah, you can try that. For now, I can manually use some boolean to determine is it load or save. I am thinking this too complicated, that I think I need to use some conflict resolve function just like in another SDK.

Iakobs commented 2 weeks ago

Can you try this version of the plugin? I added a origin field to the SnapshotConflinct class in the SnapshotsClient autoload, so now you will know which method originated the conflict. The possible values are either LOAD or SAVE.

If this works, let me know and I will push the new version to the repo.

addons.zip

RProduction commented 2 weeks ago

Okay, I will try it

RProduction commented 2 weeks ago

Hey, it works. It give me "SAVE" and "LOAD" string for each operation in origin.

Iakobs commented 2 weeks ago

Nice! In the meantime, what's the manual flow to solve conflicts in other sdks? do you have any examples?

RProduction commented 2 weeks ago

Nevermind about conflict resolution. Unity SDK actually has built in conflict resolution strategy and manual. Manual conflict resolution just actually the same as this godot SDK does. I just actually doesn't understand how to resolve the conflict.

Load conflict resolution just choosing what snapshot will be selected by certain parameter.

Save conflict resolution? Should I call save game/save snapshot method with data inside snapshot conflict?

Iakobs commented 2 weeks ago

I don't understand either how to do conflict resolution. What I understand from Google's docs is that the designer of the game has to decide depending on every case. I guess there's no correct answer to the question.

Iakobs commented 1 week ago

Hi @RProduction I'm closing the issue for now, but please feel free to ask any other questions!