factorized user reset (and comm array clean added)
[brisk.git] / web / Obj / brisk.phh
index bc2162c..e3dd54b 100644 (file)
@@ -30,7 +30,7 @@ define(SHM_DIMS_MIN, (50000 + 10000 * TABLES_N + 15000 * MAX_PLAYERS));
 define(SHM_DIMS_MAX, SHM_DIMS_MIN + 1048576);
 define(SHM_DIMS_DLT, 65536);
  
-define(COMM_N, 12);
+define(COMM_N, 18);
 define(COMM_GEN_N, 50);
 define(SESS_LEN, 13);
 define(STREAM_TIMEOUT, 20);
@@ -62,9 +62,9 @@ define(BRISK_SINGLE_SESS, "");
 $G_false = FALSE;
 
 $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "spawn-0.10.2";
+$G_brisk_version = "spawn-0.10.4";
 
-$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: dimensionamento dinamico dell\'area dati e ottimizzazione della stessa, versione beta.',
+$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: dimensionamento dinamico dell\'area dati e ottimizzazione della stessa, versione beta2.',
                         'Se vuoi iscriverti alla <a target="_blank" href="http://www.milug.org/cgi-bin/mailman/listinfo/ml-briscola">Mailing List</a>, cliccala!' );
 $table_wellarr = Array ( 'Benvenuto al tavolo. Se almeno tre giocatori non sbloccano l\'uscita cliccando il lucchetto, chi esce non pu&ograve; risedersi a un qualunque tavolo per '.floor(BAN_TIME/60).' minuti.');
 
@@ -643,6 +643,16 @@ class User {
     
     return (FALSE);
   }
+
+  function reset() {
+    $tmp_sess = $this->sess;
+    $this->sess = "";
+    step_unproxy($tmp_sess);
+    $this->name = "";
+    while (array_pop($this->comm) != NULL);
+    $this->step = 0;
+    $this->the_end = FALSE;
+  }
 } // end class User
 
 
@@ -818,12 +828,16 @@ class Room {
          if ($user_cur->stat == 'table' || $user_cur->stat == 'room') {
            log_auth($user_cur->sess, "Autologout session.");
            
+           $user_cur->reset();
+           /* factorized with ->reset()
            $tmp_sess = $user_cur->sess;
            $user_cur->sess = "";
            step_unproxy($tmp_sess);
            $user_cur->name = "";
+           while (array_pop($user_cur->comm) != NULL);
            $user_cur->step = 0;
            $user_cur->the_end = FALSE;
+           */
            
            log_rd2("AUTO LOGOUT.");
            if ($user_cur->subst == 'sitdown' || $user_cur->stat == 'table')
@@ -1005,8 +1019,9 @@ class Room {
        if ($tab_idx < $user_tab_n) {
          log_main("PRE show_room username: ".$user_cur->name."  STEP: ".$user_cur->step);
 
-         if ($trans_delta == 0)
-           while (array_pop($user_cur->comm) != NULL);
+//        ARRAY_POP DISABLED
+//       if ($trans_delta == 0)
+//         while (array_pop($user_cur->comm) != NULL);
 
          $user_cur->trans_step = $user_cur->step + 1 + $trans_delta;
          $user_cur->comm[$user_cur->step % COMM_N] = "";