Best way to storage player-data

I recommend this YouTube series to understand noSQL. In short: you structure your data that way, that you only do one query to get all your data. So if you really need other views you denormalise the data.

If you don’t want to have a hosted database (SQL or noSQL), your only way is to have an own server. - Amazon RDS is expensive and I’m not sure, that Amazon can’t read your data. My trust is to Google, because I never heard, that any data from Google was leaked (like other parties).

Guest/Facebook is great, because you can use Firebase Authentication for that. First use as guest (anonymous), and if the user connects with Facebook/Google the guest account will be linked to the other auth method. This is really straight forward (native - not tested with C++, but I believe it’s easy as well). It’s the same way I want to do it within my game. So I also need to implement it.

@mars3142
We should evaluate it.
How much storage does google provide free? 1GB? 5? 10? 20?
What is the limit? I think that if I exceed a limit, I should be start to pay.

1GB (https://firebase.google.com/pricing/), but if you have 1GB in the database you should have enough paid users. We uses Firebase for another project (incl. Firebase Storage) and we only paid 3€ in the first month. Currently the project isn’t much used, because it’s a season app.

The main contra for Firebase is, that the realtime feature is only in iOS/Android (PlayStore only, because it needs the Play Services), so if you want a desktop version (or other mobile devices: Nintendo Switch :wink: ) you have to implement it with the rest API, but if you want it just for save games, it should be a no brainer (my personal opinion).

Currently I implemented a meta data download from Firebase with the rest API, so I can update it at game start. I can also use Firebase Storage, but I want to write an edit tool in java (for Android), so I can edit the data on the go (no need to upload files, because everything is in the database).

Ok, thanks for the info :slight_smile:
If anyone have other alternatives… please tell me.

Just use sqlite3 with xxtea encryption, that will be enough.
or UserDefault with xxtea encryption.
You can find xxtea in Project_folder/cocos2d/external/xxtea

Could you paste cocos2dx code for that?. How di you retrieve access_token?

@smitpatel88 thanks for your advice. I’m evaluating an external database (client-server), however, please, tell me how can I apply xxtea with SQLite3? I added xxtea.cpp and xxtea.h to my project. What’s the next step? I saw examples but I’m not sure. Have you an example in c++ ?

The meta data is “world readable” (yet), so currently I didn’t managed to use a access token. This will be the next step, to secure every download incl. the meta data. - I will come back to you…

Just open xxtea.h file there is two methods xxtea_encrypt & xxtea_decrypt
To set : First encrypt your string then store into database.
To get : Fetch string from database, then decrypt it and use it.

See this thread if you have any problem:

You can read my SecureUserDefault which i used xxtea and User Default.

Why does everyone ignore the part from @tranthor

I would like an external database (not only for greater security, also for I can access to the information easily, as administrador of the game).

UserDefaults are only stored locally and if Android doesn’t backup them, they are lost after an uninstall. Also isn’t it possible to offer multi device support. I also wouldn’t use it for “save games”, because UserDefaults should only helpful for settings and not as a “state” storage.
I would recommend SQLite (if you want to store key/values), because it’s for such kind of data. But it has the same restrictions like UserDefaults/SharedPrefs -> only active for current device and lost after uninstall.

Are you sure about that? I have seen source code for Angular2/4 with Firebase realtime update.

I excluded the web client, because @tranthor set the topic to C++. Sure Firebase is usable with JScript code, but do you really want to build extra for Firebase a script support into your game? I don’t think so.

I thought to use a webservice for get and set data through php/mysql, with POST method. But it’s through http and I think it is unsecure.

Firebase realtime database is a very good option, but I’m not secure about the prices. If the application becomes viral I think I would pay a lot more than having my own server ($0.06 per auth, imagine in a viral app the costs of them). And another disadvantage is that I do not know the manipulation of data that Google could do without my authorization.

I think the best is host my own server. It is the most secure method (in my opinion). The problem is, what database can I use. Most people recommend noSQL instead of SQL. But if I select a NoSQL database, what is the better client for include in c++ for iOS and Android NDK apps? I like redis, but the official client not compiles in my project. If anyone have any suggestion, please tell me.

Firebase realtime database is a very good option, but I’m not secure about the prices. If the application becomes viral I think I would pay a lot more than having my own server ($0.06 per auth, imagine in a viral app the costs of them). And another disadvantage is that I do not know the manipulation of data that Google could do without my authorization.

You misread it. $0.06 is only for authentication by SMS - not for Facebook or Google login. Where did you read, that Google can manipulate your data? That would be the end of Google, if it would be public, that they change customers project data. I don’t understand your point of view - everybody is saying “Google is evil”. But they can’t, because their business is build on trust. If no one trust their services, Google will end to exists. - Firebase can create daily backups. It’s up to you to download them and compare it to the day before. This way you see every unauthorised change.

An own server can’t be so secure like Firebase/Azure/AWS. But I wish you good luck and please report, if the first DDOS or hack has happened :wink:

You are a fanatic of google, Do you work for them? Hahaha, it’s a joke.
I will repeat it, I’m not sure about the prices. I would like to know a viral app (with millons and millons of players around the world) that chose firebase realtime database instead of his own server. If you know any, tell me :slight_smile:

No, I don’t work for Google or Apple. It’s just my personal opinion about your concerns against Google.

As I said before: If your game goes viral, you will get money from your customers (by ads or post paid for the game).

I also found this regarding your question.

Ok, thanks for the info :slight_smile:

I tested the RESTful way of firebase and it’s pretty straight forward to use it with anonymous login. If someone wants to know more about it, you can find the information here and here.

PS: Eventually I create a simple demo, after the cocos2d-x 3.16 release for Android, iOS, macOS and win32. This would be nice to have for the future, if you can’t use the Firebase SDK on your platform.

Ok, months have passed since this publication and I continue with the same problem, hahaha. My problem is simple, I want to use SQL Server or MySQL. Is possible use it without a HTTP POST communication?

I want to include SQL Server API or MySQL API to my c++ code and connect with my own server. I don’t want to make a PHP code and communicate it through http to mysql.

I included MySQL Connector for c++ following this guide:

It works perfect for x86 archs. But it not works in arm archs:

ld: warning: ignoring file /usr/local/lib/libmysqlcppconn.7.1.1.9.dylib, file was built for x86_64 which is not the architecture being linked (arm64): /usr/local/lib/libmysqlcppconn.7.1.1.9.dylib
Undefined symbols for architecture arm64:
  "_get_driver_instance", referenced from:
      GameManager::addChicken() in GameManager.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

In the download page I view only link for x86 architectures:
https://dev.mysql.com/downloads/connector/cpp/

Maybe it´s only for desktop apps. Impossible for devices…