new idx_orig field in User class
[brisk.git] / web / Obj / brisk.phh
index 7a608ca..8de27bd 100644 (file)
@@ -599,7 +599,8 @@ define(USER_FLAG_TY_SUSPEND, 0x400000); // done
 define(USER_FLAG_TY_DISABLE, 0x800000); // done
 
 class User {
-  var $idx;        // index in the users array
+  var $idx;        // index in the users array when you are in game
+  var $idx_orig;   // index in the users array when you aren't in game
   var $code;       // authentication code
   var $name;       // name of the user
   var $sess;       // session of the user
@@ -619,8 +620,8 @@ class User {
 
   // FIXME: the table_orig field must be removed after table field verify of index management (in spawned table
   //        it is allways ZERO
-  var $table_orig; // id of the current table (if in table state)
-  var $table;      // id of the current table (if in table state)
+  var $table;      // id of the current table when you are in game
+  var $table_orig; // id of the current table when you aren't in game
   var $table_pos;  // idx on the table
   var $table_token;// token that identify a game on a table
   var $flags;      // Bitfield with: AUTHENTICATE: 0x02 
@@ -642,36 +643,37 @@ class User {
     if (($thiz =& new User()) == FALSE)
       return (FALSE);
 
-    $thiz->idx   = $idx;
-    $thiz->code  = -1;
-    $thiz->name  = $name;
-    $thiz->sess  = $sess;
-    $thiz->ip    = $ip;
-    $thiz->lacc   = time();
-    $thiz->laccwr = time();
-    $thiz->bantime = 0;
-    $thiz->stat  = $stat;
-    $thiz->subst  = $subst;
-    $thiz->step  = 1;
-    $thiz->trans_step  = -1;
-    $thiz->comm  = array();
-    $thiz->asta_card = -2;
-    $thiz->asta_pnt  = -1;
-    $thiz->handpt = -1;
+    $thiz->idx        = $idx;
+    $thiz->idx_orig   = $idx;
+    $thiz->code       = -1;
+    $thiz->name       = $name;
+    $thiz->sess       = $sess;
+    $thiz->ip         = $ip;
+    $thiz->lacc       = time();
+    $thiz->laccwr     = time();
+    $thiz->bantime    = 0;
+    $thiz->stat       = $stat;
+    $thiz->subst      = $subst;
+    $thiz->step       = 1;
+    $thiz->trans_step = -1;
+    $thiz->comm       = array();
+    $thiz->asta_card  = -2;
+    $thiz->asta_pnt   = -1;
+    $thiz->handpt     = -1;
     $thiz->exitislock = TRUE;
 
-    $thiz->flags = 0x00;
+    $thiz->flags      = 0x00;
     
-    $thiz->chattime = array_fill(0, CHAT_N, 0);
-    $thiz->chat_cur = 0;
-    $thiz->chat_lst = "";
-    $thiz->chat_ban = 0;
-    $thiz->chat_dlt = 0;
+    $thiz->chattime   = array_fill(0, CHAT_N, 0);
+    $thiz->chat_cur   = 0;
+    $thiz->chat_lst   = "";
+    $thiz->chat_ban   = 0;
+    $thiz->chat_dlt   = 0;
 
     $thiz->table_orig = $table;
     $thiz->table      = $table;
-    $thiz->table_pos = -1;
-    $thiz->table_token = "";
+    $thiz->table_pos  = -1;
+    $thiz->table_token= "";
     $thiz->shm_sz = SHM_DIMS_U_MIN;
     return ($thiz);
   }
@@ -679,6 +681,7 @@ class User {
   function copy($from)
   {
     $this->idx        = $from->idx;
+    $this->idx_orig   = $from->idx;
     $this->code       = $from->code;
     $this->name       = $from->name;
     $this->sess       = $from->sess;
@@ -704,15 +707,15 @@ class User {
     $this->handpt     = $from->handpt;
     $this->exitislock = $from->exitislock;
 
-    $this->flags = $from->flags;
+    $this->flags      = $from->flags;
 
-    $this->chattime = array();
+    $this->chattime   = array();
     for ($i = 0 ; $i < CHAT_N ; $i++)
       $this->chattime[$i] = $from->chattime[$i];
-    $this->chat_cur = $from->chat_cur;
-    $this->chat_lst = $from->chat_lst;
-    $this->chat_ban = $from->chat_ban;
-    $this->chat_dlt = $from->chat_dlt;
+    $this->chat_cur   = $from->chat_cur;
+    $this->chat_lst   = $from->chat_lst;
+    $this->chat_ban   = $from->chat_ban;
+    $this->chat_dlt   = $from->chat_dlt;
 
     $this->table_orig = $from->table_orig;
     $this->table      = $from->table;
@@ -740,6 +743,7 @@ class User {
       return (FALSE);
     
     $thiz->idx        = $from->idx;
+    $thiz->idx_orig   = $from->idx;
     $thiz->code       = $from->code;
     $thiz->name       = $from->name;
     $thiz->sess       = $from->sess;
@@ -1073,11 +1077,11 @@ class Room {
        if ($table_cur->player_n == PLAYERS_N) {
          log_main("PLAYERS == N TABLE ".$table_idx);
          
-         if (($sem = Briskin5::lock_data($table_idx)) != FALSE) { 
+         if (($sem = Bin5::lock_data($table_idx)) != FALSE) { 
            log_main("bin5 lock data success");
            
            $no_recovery = FALSE;
-           if (($bri = &Briskin5::load_data($table_idx)) != FALSE) {
+           if (($bri = Bin5::load_data($table_idx)) != FALSE) {
              if ($table_cur->table_token != $bri->table_token) {
                log_main("ERROR: not matching table_token. Room: ".$table_cur->table_token."  Table: ".$bri->table_token);
                log_main("ERROR: not matching table_start. Room: ".$table_cur->table_start."  Table: ".$bri->table_start);
@@ -1124,7 +1128,7 @@ class Room {
                $this->room_join_wakeup(&$user_cur, FALSE, 0); 
                $table_cur->table_token = "";
                 $table_cur->wakeup_time = $curtime + WAKEUP_TIME;
-               Briskin5::destroy_data($table_idx);
+               Bin5::destroy_data($table_idx);
              }
              else {
                log_main("gm:: save_data");
@@ -1133,9 +1137,9 @@ class Room {
                  $this->user[$table_cur->player[$i]]->lacc = $bri->user[$i]->lacc;
                }
              
-               Briskin5::save_data(&$bri);
+               Bin5::save_data(&$bri);
              }
-           } // else if (($bri = &Briskin5::load_data($table_idx)) != FALSE) {
+           } // else if (($bri = &Bin5::load_data($table_idx)) != FALSE) {
            else if ($no_recovery == FALSE) {
              log_crit("ERROR: table ".$table_idx." unrecoverable join");
 
@@ -1163,7 +1167,7 @@ class Room {
              $table_cur->table_token = "";
            }
 
-           Briskin5::unlock_data($sem);
+           Bin5::unlock_data($sem);
          } // bri::lock_data
        } //  if ($table_cur->player_n == PLAYERS_N) {
       } //  for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
@@ -1936,9 +1940,9 @@ class Room {
                 $bri_user->comm[$bri_user->step % COMM_N] .= $to_tabl;
                 $bri_user->step_inc();
               }
-              Briskin5::save_data(&$bri);
+              Bin5::save_data(&$bri);
             }
-            Briskin5::unlock_data($sem);
+            Bin5::unlock_data($sem);
           } // bri::lock_data
         } //  if ($table_cur->player_n == PLAYERS_N) {
       } //  for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
@@ -2092,15 +2096,15 @@ class Room {
       if ($ghost_user->stat == "table" && $this->table[$table_idx]->player_n == PLAYERS_N) {
         // FIXME BRISK4: include for each kind of table
         require_once("${G_base}briskin5/Obj/briskin5.phh");
-        if (($brisem = Briskin5::lock_data($table_idx)) != FALSE) { 
-          if (($bri = &Briskin5::load_data($table_idx)) != FALSE) {
+        if (($brisem = Bin5::lock_data($table_idx)) != FALSE) { 
+          if (($bri = &Bin5::load_data($table_idx)) != FALSE) {
             if ($bri->the_end != TRUE) {
               $bri->user[$ghost_user->table_pos]->step_inc();
               $bri->user[$ghost_user->table_pos]->sess = $sess;
-              Briskin5::save_data(&$bri);
+              Bin5::save_data(&$bri);
             }
           }
-          Briskin5::unlock_data($brisem);
+          Bin5::unlock_data($brisem);
         }
       }