File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ use crate::{
2727use chrono:: { DateTime , Utc } ;
2828use log:: { debug, warn} ;
2929use parking_lot:: RwLock ;
30+ use rand:: RngCore ;
3031use std:: sync:: { Arc , Weak } ;
3132use store:: Games ;
3233use tdf:: { ObjectId , TdfMap , TdfSerializer } ;
@@ -94,6 +95,10 @@ pub struct Game {
9495 pub created_at : DateTime < Utc > ,
9596 /// Players currently in the game
9697 pub players : Vec < GamePlayer > ,
98+ /// ID used when reporting game results
99+ pub reporting_id : u64 ,
100+ /// Randomness seed used by players
101+ pub seed : u32 ,
97102
98103 /// Services access
99104 pub games_store : Arc < Games > ,
@@ -230,13 +235,18 @@ impl Game {
230235 games_store : Arc < Games > ,
231236 tunnel_service : Arc < TunnelService > ,
232237 ) -> Game {
238+ let mut rng = rand:: rng ( ) ;
239+ let seed = rng. next_u32 ( ) ;
240+
233241 Game {
234242 id,
235243 attributes,
236244 settings,
237245 state : Default :: default ( ) ,
238246 players : Default :: default ( ) ,
239247 created_at : Utc :: now ( ) ,
248+ reporting_id : 18014398695176361 ,
249+ seed,
240250 games_store,
241251 tunnel_service,
242252 }
Original file line number Diff line number Diff line change @@ -798,7 +798,7 @@ impl TdfSerialize for GameSetupResponse<'_> {
798798 // Game settings
799799 w. tag_owned ( b"GSET" , game. settings . bits ( ) ) ;
800800 // Game Reporting ID
801- w. tag_u64 ( b"GSID" , 0x4000000a76b645 ) ;
801+ w. tag_u64 ( b"GSID" , game . reporting_id ) ;
802802 // Game state
803803 w. tag_ref ( b"GSTA" , & game. state ) ;
804804 // Game Type used for game reporting as passed up in the request.
@@ -883,8 +883,7 @@ impl TdfSerialize for GameSetupResponse<'_> {
883883 // Queue capacity
884884 w. tag_zero ( b"QCAP" ) ;
885885 // Shared game randomness seed? (a 32 bit number shared between clients)
886- // TODO: Randomly generate this when creating a game?
887- w. tag_u32 ( b"SEED" , 0x4cbc8585 ) ;
886+ w. tag_u32 ( b"SEED" , game. seed ) ;
888887 // Team capacity
889888 w. tag_zero ( b"TCAP" ) ;
890889
You can’t perform that action at this time.
0 commit comments