@@ -81,6 +81,8 @@ void Database::connect_to_db() {
8181 " id TEXT NOT NULL, "
8282 " peer_id TEXT NOT NULL, "
8383 " name TEXT NOT NULL, "
84+ " platform_id TEXT NOT NULL, "
85+ " platform TEXT NOT NULL, "
8486 " game_id TEXT NOT NULL, "
8587 " timestamp TIMESTAMPTZ DEFAULT NOW(), "
8688 " PRIMARY KEY (id, game_id),"
@@ -155,11 +157,6 @@ void Database::set_user_data(const std::string& game_id, const std::string& peer
155157 }
156158 }
157159
158- if (name.empty ()) {
159- std::cerr << " Name is required for user data" << std::endl;
160- return ;
161- }
162-
163160 pqxx::work txn (*connection);
164161
165162 // Only update existing row
@@ -225,7 +222,9 @@ std::tuple<int64_t, int, std::string, std::string> Database::leaderboard_get_use
225222 return {score, rank, timestamp, name};
226223}
227224std::string Database::get_peer_or_insert (const std::string& reconnection_token,
228- const std::string& game_id, const std::string& peer_id) {
225+ const std::string& game_id, const std::string& peer_id,
226+ const std::string platform_id,
227+ const std::string& platform) {
229228 ensure_connection ();
230229 pqxx::work txn (*connection);
231230
@@ -241,8 +240,9 @@ std::string Database::get_peer_or_insert(const std::string& reconnection_token,
241240 }
242241
243242 // Not found, insert new peer
244- txn.exec (pqxx::zview (" INSERT INTO peers (id, peer_id, name, game_id) VALUES ($1, $2, $3, $4);" ),
245- pqxx::params (reconnection_token, peer_id, " " , game_id));
243+ txn.exec (pqxx::zview (" INSERT INTO peers (id, peer_id, name, game_id, platform_id, platform) "
244+ " VALUES ($1, $2, $3, $4, $5, $6);" ),
245+ pqxx::params (reconnection_token, peer_id, " " , game_id, platform_id, platform));
246246 txn.commit ();
247247 return peer_id;
248248}
0 commit comments