Log refactoring, table_token and table_start added, deep refactoring of garbage_manag...
[brisk.git] / web / index_wr.php
index b7cea12..2d93e22 100644 (file)
@@ -150,7 +150,9 @@ else if ($user->stat == 'room') {
          $curtime = time();
          // Create new spawned table
          $bri_sem = Briskin5::lock_data($table_idx);
-         if (($bri =& new Briskin5(&$room, $table_idx)) == FALSE)
+         $table_token = uniqid("");
+         $room->table[$table_idx]->table_token = $table_token;
+         if (($bri =& new Briskin5(&$room, $table_idx, $table_token)) == FALSE)
            log_wr($sess, "bri create: FALSE");
          else
            log_wr($sess, "bri create: ".serialize($bri));
@@ -161,21 +163,22 @@ else if ($user->stat == 'room') {
          $bri_table->game_init(&$bri->user);
          $curtime = time();
 
-         
-         // init spawned users
+         //
+         // Init spawned users.
+         //
          for ($i = 0 ; $i < $table->player_n ; $i++) {
            $bri_user_cur = &$bri->user[$i];
            $user_cur = &$room->user[$table->player[$i]];
+           
+           $bri_user_cur->stat_set('table');
+           $bri_user_cur->subst = 'asta';
+           $bri_user_cur->laccwr = $curtime;
 
            $bri_user_cur->trans_step = $user_cur->step + 1;
            $bri_user_cur->comm[$bri_user_cur->step % COMM_N] = "";
            $bri_user_cur->step_inc();
            $bri_user_cur->comm[$bri_user_cur->step % COMM_N] = show_table(&$bri,&$bri_user_cur,$bri_user_cur->step+1,TRUE, FALSE);
 
-           $bri_user_cur->stat_set('table');
-           $bri_user_cur->subst = 'asta';
-           $bri_user_cur->laccwr = $curtime;
-
            $bri_user_cur->step_inc();
 
            log_wr($bri_user_cur->sess, "TRY PRESAVE: ".$bri_user_cur->step." TRANS STEP: ".$bri_user_cur->trans_step);
@@ -183,7 +186,7 @@ else if ($user->stat == 'room') {
            log_wr($sess, "Pre if!");
            
            $ret = "";
-           $ret .= sprintf('gst.st_loc++; gst.st=%d; the_end=true; window.onunload = null ; document.location.assign("briskin5/briskin5.php?table_idx=%d");|', $user_cur->step+1, $table_idx);
+           $ret .= sprintf('gst.st_loc++; gst.st=%d; createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); the_end=true; window.onunload = null ; document.location.assign("briskin5/briskin5.php");|', $user_cur->step+1, $table_idx, $table_token);
            
            $user_cur->comm[$user_cur->step % COMM_N] = $ret;
            $user_cur->trans_step = $user_cur->step + 1;