renamed class Room to Brisk and Bin5 objects to $bin5 instead of $bri
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Tue, 21 Jan 2014 06:39:27 +0000 (07:39 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 22 Jan 2014 07:06:59 +0000 (08:06 +0100)
web/Obj/brisk.phh
web/Obj/user.phh
web/briskin5/Obj/briskin5.phh
web/briskin5/index.php
web/briskin5/index_wr.php
web/index.php
web/index_wr.php
web/spush/brisk-spush.php

index 5e75783..dbc5995 100644 (file)
@@ -623,17 +623,17 @@ class Table {
     return ($this->player_n - 1);
   }
   
-  function user_rem($room, $user)
+  function user_rem($brisk, $user)
   {
     $tabpos = $user->table_pos;
     
     /* verifico la consistenza dei dati */
-    if ($room->user[$this->player[$tabpos]] == $user) {
+    if ($brisk->user[$this->player[$tabpos]] == $user) {
       
       /* aggiorna l'array dei giocatori al tavolo. */
       for ($i = $tabpos ; $i < $this->player_n-1 ; $i++) {
        $this->player[$i] = $this->player[$i+1];
-       $user_cur = $room->user[$this->player[$i]];
+       $user_cur = $brisk->user[$this->player[$i]];
        $user_cur->table_pos = $i;
       }
       $this->player_n--;
@@ -830,7 +830,7 @@ class Client_prefs {
 }
 
 
-class Room
+class Brisk
 {
     static $delta_t;
     
@@ -845,7 +845,7 @@ class Room
     
     var $delay_mgr;
 
-    function Room($crystal_filename) {
+    function Brisk($crystal_filename) {
         $this->crystal_filename = $crystal_filename;
         $this->user  = array();
         $this->table = array();
@@ -907,27 +907,27 @@ class Room
             
             $no_recovery = FALSE;
             if (isset($this->match[$table_idx])) {
-                $bri = $this->match[$table_idx];
+                $bin5 = $this->match[$table_idx];
 
-                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);
+                if ($table_cur->table_token != $bin5->table_token) {
+                    log_main("ERROR: not matching table_token. Brisk: ".$table_cur->table_token."  Table: ".$bin5->table_token);
+                    log_main("ERROR: not matching table_start. Brisk: ".$table_cur->table_start."  Table: ".$bin5->table_start);
                     $no_recovery = TRUE;
-                    $bri = FALSE;
+                    $bin5 = FALSE;
                 }
 
-                if ($bri != FALSE) {
+                if ($bin5 != FALSE) {
                     //
                     //  SPAWN: JOIN
                     //
                     log_main("garbage_manager: bri loaded successfully.");
-                    $bri->garbage_manager(TRUE);
+                    $bin5->garbage_manager(TRUE);
                     
-                    $bri_table = $bri->table[0];
+                    $bin5_table = $bin5->table[0];
                     
                     // is the end of the table
                     
-                    if ($bri->the_end == TRUE) {
+                    if ($bin5->the_end == TRUE) {
                         /*
                          *  DESTROY OF FINISHED TABLE && MOVE PLAYER TO ROOM AGAIN
                          */
@@ -938,16 +938,16 @@ class Room
                             $plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
                         }
                         
-                        for ($i = 0 ; $i < $bri_table->player_n ; $i++) {
+                        for ($i = 0 ; $i < $bin5_table->player_n ; $i++) {
                             // stat must be "table" by definition
                             $user_cur = $this->user[$table_cur->player[$i]];
-                            $bri_user = $bri->user[$i];
+                            $bin5_user = $bin5->user[$i];
                             
-                            $user_cur->subst      = $bri_user->subst;
-                            $user_cur->step       = $bri_user->step;
-                            $user_cur->lacc       = $bri_user->lacc;
-                            $user_cur->laccwr     = $bri_user->lacc;
-                            $user_cur->bantime    = $bri_user->bantime;
+                            $user_cur->subst      = $bin5_user->subst;
+                            $user_cur->step       = $bin5_user->step;
+                            $user_cur->lacc       = $bin5_user->lacc;
+                            $user_cur->laccwr     = $bin5_user->lacc;
+                            $user_cur->bantime    = $bin5_user->bantime;
                         }
                         
                         log_legal($curtime, $user_cur->ip, $user_cur, "STAT:DESTROY_GAME", $plist);
@@ -961,11 +961,11 @@ class Room
                     else {
                         log_main("gm:: save_data");
                         
-                        for ($i = 0 ; $i < $bri_table->player_n ; $i++) {
-                            $this->user[$table_cur->player[$i]]->lacc = $bri->user[$i]->lacc;
+                        for ($i = 0 ; $i < $bin5_table->player_n ; $i++) {
+                            $this->user[$table_cur->player[$i]]->lacc = $bin5->user[$i]->lacc;
                         }
                     }
-                } // if ($bri == FALSE
+                } // if ($bin5 == FALSE
                 else if ($no_recovery == FALSE) {
                     log_crit("ERROR: table ".$table_idx." unrecoverable join");
                     
@@ -1809,19 +1809,19 @@ class Room
         // Before all align times with table timeout
         for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
             if (isset($this->match[$table_idx])) {
-                $bri = $this->match[$table_idx];
+                $bin5 = $this->match[$table_idx];
 
-                $bri_table = $bri->table[0];
-                for ($i = 0 ; $i < $bri_table->player_n ; $i++) {
+                $bin5_table = $bin5->table[0];
+                for ($i = 0 ; $i < $bin5_table->player_n ; $i++) {
                     // stat must be "table" by definition
-                    $bri_user = $bri->user[$i];
+                    $bin5_user = $bin5->user[$i];
               
-                    if ($target != "" && $bri_user->name != $target)
+                    if ($target != "" && $bin5_user->name != $target)
                         continue;
                     log_main("writa: ".$user_mesg);
-                    $bri_user->comm[$bri_user->step % COMM_N] = "gst.st = ".($bri_user->step+1)."; ";
-                    $bri_user->comm[$bri_user->step % COMM_N] .= $to_tabl;
-                    $bri_user->step_inc();
+                    $bin5_user->comm[$bin5_user->step % COMM_N] = "gst.st = ".($bin5_user->step+1)."; ";
+                    $bin5_user->comm[$bin5_user->step % COMM_N] .= $to_tabl;
+                    $bin5_user->step_inc();
                 }
             } // if (isset($this->match
         } //  for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
@@ -1866,7 +1866,7 @@ class Room
   }
 
   /*
-   * function add_user(&$room, &$sess, &$idx, $name, $pass, $ip)
+   * function add_user(&$brisk, &$sess, &$idx, $name, $pass, $ip)
    *
    * RETURN VALUE:
    *   if ($idx >  -1    && ret == FALSE)  =>  duplicated nick
@@ -1975,12 +1975,12 @@ class Room
       if ($ghost_user->stat == "table" && $this->table[$table_idx]->player_n == PLAYERS_N) {
           require_once("${G_base}briskin5/Obj/briskin5.phh");
           if (isset($this->match[$table_idx])) {
-              $bri = $this->match[$table_idx];
+              $bin5 = $this->match[$table_idx];
 
-              if ($bri->the_end != TRUE) {
-                  $bri->user[$ghost_user->table_pos]->comm[$bri->user[$ghost_user->table_pos]->step % COMM_N] = "";
-                  $bri->user[$ghost_user->table_pos]->step_inc();
-                  $bri->user[$ghost_user->table_pos]->sess = $sess;
+              if ($bin5->the_end != TRUE) {
+                  $bin5->user[$ghost_user->table_pos]->comm[$bin5->user[$ghost_user->table_pos]->step % COMM_N] = "";
+                  $bin5->user[$ghost_user->table_pos]->step_inc();
+                  $bin5->user[$ghost_user->table_pos]->sess = $sess;
               }
           }
       }
@@ -2116,17 +2116,17 @@ class Room
   // Static functions
   static function create($crystal_filename)
   {
-      if (($room_ser = @file_get_contents($crystal_filename)) == FALSE ||
-          ($room = unserialize($room_ser)) == FALSE) {
+      if (($brisk_ser = @file_get_contents($crystal_filename)) == FALSE ||
+          ($brisk = unserialize($brisk_ser)) == FALSE) {
           fprintf(STDERR, "NEW ROOM\n");
-          $room = new Room($crystal_filename);
+          $brisk = new Brisk($crystal_filename);
       }
       else {
           fprintf(STDERR, "ROOM FROM FILE\n");
           rename($crystal_filename, $crystal_filename.".old");
       }
 
-    return $room;
+    return $brisk;
   }
   
   
@@ -2148,31 +2148,31 @@ class Room
        $shm_sz = SHM_DIMS_MIN;
 
       if ($shm = shm_attach($tok, $shm_sz)) {
-          $room = @shm_get_var($shm, $tok); // CHECKED BELOW
+          $brisk = @shm_get_var($shm, $tok); // CHECKED BELOW
           
-          log_only("bri ==  ".($room == FALSE ?   "FALSE" : "TRUE")."  bri ===  ".($room === FALSE ? "FALSE" : "TRUE")."  bri isset ".(isset($room) ?   "TRUE" : "FALSE"));
-          if (isset($room)) 
-              log_only("bri count ".count($room));
+          log_only("bri ==  ".($brisk == FALSE ?   "FALSE" : "TRUE")."  bri ===  ".($brisk === FALSE ? "FALSE" : "TRUE")."  bri isset ".(isset($brisk) ?   "TRUE" : "FALSE"));
+          if (isset($brisk)) 
+              log_only("bri count ".count($brisk));
           
-          if ($room == FALSE) {
+          if ($brisk == FALSE) {
               log_only("INIT MAIN DATA");
               shm_detach($shm);
               
-              $room = Room::create();
+              $brisk = Brisk::create();
               
-              log_shme("Room::create");
+              log_shme("Brisk::create");
 
-              if (Room::save_data($room) == FALSE)
+              if (Brisk::save_data($brisk) == FALSE)
                   return FALSE;
 
-              return $room;
+              return $brisk;
           }
-          $room->shm_sz = $shm_sz;
+          $brisk->shm_sz = $shm_sz;
           
           shm_detach($shm);
 
           for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
-              if (($room->user[$i] = User::load_data($i, FALSE)) == FALSE) {
+              if (($brisk->user[$i] = User::load_data($i, FALSE)) == FALSE) {
                   log_crit("User::load_data failed");
                   break;
               }
@@ -2185,30 +2185,30 @@ class Room
       //  
       // SHSPLIT: load users from the shared memory
       //
-      return ($room);
+      return ($brisk);
     } while (0);
     
     return (FALSE);
   }
   
 
-  function save_data_orig($room
+  function save_data_orig($brisk
   {
     GLOBAL $sess;
     
     $shm =   FALSE;
     
-    // var_dump($room);
+    // var_dump($brisk);
     
     if (($tok = @ftok(FTOK_PATH."/main", "C")) == -1) 
       return (FALSE);
     
-    while ($room->shm_sz < SHM_DIMS_MAX) {
-      if (($shm = shm_attach($tok, $room->shm_sz)) == FALSE)
+    while ($brisk->shm_sz < SHM_DIMS_MAX) {
+      if (($shm = shm_attach($tok, $brisk->shm_sz)) == FALSE)
        break;
       
-      // log_only("PUT_VAR DI ".strlen(serialize($room)));
-      if (@shm_put_var($shm, $tok, $room) != FALSE) {
+      // log_only("PUT_VAR DI ".strlen(serialize($brisk)));
+      if (@shm_put_var($shm, $tok, $brisk) != FALSE) {
        shm_detach($shm);
        return (TRUE);
       }
@@ -2217,7 +2217,7 @@ class Room
        break;
       }
       shm_detach($shm);
-      $room->shm_sz += SHM_DIMS_DLT;
+      $brisk->shm_sz += SHM_DIMS_DLT;
     } 
 
     if ($shm)
@@ -2227,16 +2227,16 @@ class Room
   }
   function dump_data()
   {
-      $room_ser = serialize($this);
-      $room_ser_len = mb_strlen($room_ser, "ASCII");
-      if (file_put_contents($this->crystal_filename, $room_ser) == $room_ser_len) {
+      $brisk_ser = serialize($this);
+      $brisk_ser_len = mb_strlen($brisk_ser, "ASCII");
+      if (file_put_contents($this->crystal_filename, $brisk_ser) == $brisk_ser_len) {
           return (TRUE);
       }
       
       return (FALSE);
   }
 
-  function save_data($room
+  function save_data($brisk
   {
       GLOBAL $sess;
     
@@ -2246,21 +2246,21 @@ class Room
       if (($tok = @ftok(FTOK_PATH."/main", "C")) == -1) 
           return (FALSE);
     
-      // SHSPLIT: before save the $room you must save users, 
+      // SHSPLIT: before save the $brisk you must save users, 
       //          detach from main struct and (then) reattach
       $user_park = array();
       for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
-          $user_park[$i]  = $room->user[$i];
-          $room->user[$i] = FALSE;
+          $user_park[$i]  = $brisk->user[$i];
+          $brisk->user[$i] = FALSE;
       }
 
-      while ($room->shm_sz < SHM_DIMS_MAX) {
-          if (($shm = shm_attach($tok, $room->shm_sz)) == FALSE)
+      while ($brisk->shm_sz < SHM_DIMS_MAX) {
+          if (($shm = shm_attach($tok, $brisk->shm_sz)) == FALSE)
               break;
       
-          // log_only("PUT_VAR DI ".strlen(serialize($room)));
-          if (@shm_put_var($shm, $tok, $room) != FALSE) {
-              log_shme("Room::save_data");
+          // log_only("PUT_VAR DI ".strlen(serialize($brisk)));
+          if (@shm_put_var($shm, $tok, $brisk) != FALSE) {
+              log_shme("Brisk::save_data");
               $ret = TRUE;
               break;
           }
@@ -2269,7 +2269,7 @@ class Room
               break;
           }
           shm_detach($shm);
-          $room->shm_sz += SHM_DIMS_DLT;
+          $brisk->shm_sz += SHM_DIMS_DLT;
       } 
 
       if ($shm)
@@ -2278,7 +2278,7 @@ class Room
       // SHSPLIT: reattach users to the room class
       for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
           User::save_data($user_park[$i], $i);
-          $room->user[$i] = $user_park[$i];
+          $brisk->user[$i] = $user_park[$i];
       }
       log_load("FINISH: ".($ret == TRUE ? "TRUE" : "FALSE"));
 
@@ -2543,7 +2543,7 @@ class Room
       return NULL;
   }
 
-} // end class Room
+} // end class Brisk
 
 function make_seed()
 {
index 7fb6d16..cf857dd 100644 (file)
@@ -98,7 +98,7 @@ $mlang_user = array(
                      );
 
 class User {
-  var $room;       // reference to the room where the user is registered
+  var $brisk;      // reference to the room where the user is registered
   var $idx;        // index in the room users array when you are in game
   var $idx_orig;   // index in the room table users array when you aren't in game
   var $code;       // authentication code
@@ -154,11 +154,11 @@ class User {
   function User() {
   }
 
-  static function create(&$room, $idx, $name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") {
+  static function create(&$brisk, $idx, $name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") {
     if (($thiz = new User()) == FALSE)
       return (FALSE);
 
-    $thiz->room       = &$room;
+    $thiz->room       = &$brisk;
     $thiz->idx        = $idx;
     $thiz->idx_orig   = $idx;
     $thiz->code       = -1;
@@ -684,7 +684,7 @@ class User {
           log_rd2("NEWSTAT: ".$this->stat);
       } /* if ($this->rd_step == -1) { */
       else {
-          /* $sem = Room::lock_data(FALSE); */
+          /* $sem = Brisk::lock_data(FALSE); */
           $S_load_stat['rU_heavy']++;
           
           if ($this->rd_step < $this->step) {
@@ -692,7 +692,7 @@ class User {
                   if ($this->rd_step + COMM_N < $this->step) {
                       if (($this->rd_stat != $this->stat)) {
                           $to_stat = $this->stat;
-                          /* Room::unlock_data($sem); */
+                          /* Brisk::unlock_data($sem); */
                           log_load("RESYNC");
                           printf("xXx USER::MAINCHECK2 [%s]\n", get_class($this));
                           return ($this->page_sync($this->sess, ($to_stat == "table" ? "briskin5/index.php" : "index.php"), $this->table, $this->table_token));
@@ -739,7 +739,7 @@ class User {
               } /* if ($this->the_end == TRUE) { ... */
           } /* if ($this->rd_step < $this->step) { */
           
-          /* Room::unlock_data($sem); */
+          /* Brisk::unlock_data($sem); */
       }  /* else of if ($this->rd_step == -1) { */
       
     
index 4111281..94d0788 100644 (file)
@@ -1073,7 +1073,7 @@ class Bin5_user extends User {
           $this->rd_step  = $this->step;
       } /* if ($this->rd_step == -1) { */
       else {
-          /* $sem = Room::lock_data(FALSE); */
+          /* $sem = Brisk::lock_data(FALSE); */
           $S_load_stat['rU_heavy']++;
 
           if ($this->rd_step < $this->step) {
@@ -1081,7 +1081,7 @@ class Bin5_user extends User {
                   if ($this->rd_step + COMM_N < $this->step) {
                       if ($this->rd_stat != $this->stat) {
                           $to_stat = $this->stat;
-                          /* Room::unlock_data($sem); */
+                          /* Brisk::unlock_data($sem); */
                           log_load("RESYNC");
                           printf("xXx BIN5_USER::MAINCHECK\n");
                           return ($this->page_sync($this->sess, ($to_stat == "table" ? "index.php" : "../index.php"), $this->table, $this->table_token));
@@ -1130,7 +1130,7 @@ class Bin5_user extends User {
               } /* if ($this->the_end == TRUE) { ... */
           } /* if ($this->rd_step < $this->step) { */
 
-          /* Room::unlock_data($sem); */
+          /* Brisk::unlock_data($sem); */
       }  /* else of if ($this->rd_step == -1) { */
 
 
@@ -1167,7 +1167,7 @@ class Bin5 {
 
     var $delay_mgr;
 
-    function Bin5($room, $table_idx, $table_token, $get, $post, $cookie) {
+    function Bin5($brisk, $table_idx, $table_token, $get, $post, $cookie) {
         $this->user = array();
         $this->table = array();
 
@@ -1178,8 +1178,8 @@ class Bin5 {
             exit;
         }
 
-        $user  = $room->user;
-        $table = $room->table[$table_idx];
+        $user  = $brisk->user;
+        $table = $brisk->table[$table_idx];
 
         log_wr("Bin5 constructor");
 
@@ -1483,7 +1483,6 @@ class Bin5 {
 
         break;
         case "index_wr.php":
-            // FIXME $content can be unset
             if (isset($table_idx) && isset($table_token)) {
                 if (($bri = $s_a_p->app->match_get($table_idx, $table_token)) != FALSE) {
                     ob_start();
index e9e25d7..ac0fb12 100644 (file)
@@ -94,7 +94,7 @@ function bin5_index_main($transp_type, &$header_out, $addr, $get, $post, $cookie
 
    var gst  = new globst();
    gst.st = <?php 
-       log_load("bin5/index.php");
+   log_load("bin5/index.php");
 
    if (isset($laststate) == false) {
        $laststate = -1;
index 27e32d1..491ee9d 100644 (file)
@@ -38,7 +38,7 @@ require_once("Obj/briskin5.phh");
 /*
  *  MAIN
  */
-function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
+function bin5_index_wr_main(&$bin5, $remote_addr_full, $get, $post, $cookie)
 {
     GLOBAL $G_base, $G_dbasetype, $G_black_list;
 
@@ -50,7 +50,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
     }
 
     $curtime = time();
-    if ($bri == NULL) {
+    if ($bin5 == NULL) {
         return FALSE;
     }
 
@@ -71,7 +71,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
     log_wr(0, 'bin::index_wr.php: COMM: '.xcapemesg($mesg));
 
 
-    if (($user = &$bri->get_user($sess, &$idx)) == FALSE) {
+    if (($user = &$bin5->get_user($sess, &$idx)) == FALSE) {
         echo "Get User Error";
         log_wr("Get User Error");
         return FALSE;
@@ -97,7 +97,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
 
         log_rd2("bin5/index_wr.php: AUTO LOGOUT.");
         if ($user->stat == 'table') {
-            $bri->table_wakeup($user);
+            $bin5->table_wakeup($user);
             // to force the logout
             $user->lacc = 0;
         }
@@ -111,17 +111,17 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
      *********************/
     else if ($user->stat == 'table') {
         $user->laccwr = time();
-        $table = $bri->table[$user->table];
+        $table = $bin5->table[$user->table];
 
         if ($argz[0] == 'tableinfo') {
             log_wr("PER DI TABLEINFO");
             $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
-            $user->comm[$user->step % COMM_N] .= show_table_info(&$bri, &$table, $user->table_pos);
+            $user->comm[$user->step % COMM_N] .= show_table_info(&$bin5, &$table, $user->table_pos);
             log_wr($user->comm[$user->step % COMM_N]);
             $user->step_inc();
         }
         else if ($argz[0] == 'chatt') {
-            $bri->chatt_send(&$user,$mesg);
+            $bin5->chatt_send(&$user,$mesg);
         }
         else if ($argz[0] == 'preferences_update') {
             log_wr("PER DI PREFERENCES_UPDATE");
@@ -141,10 +141,10 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
 
             $logout_cont = TRUE;
             if ($remcalc >= 3) {
-                $lockcalc = $table->exitlock_calc(&$bri->user, $user->table_pos);
+                $lockcalc = $table->exitlock_calc(&$bin5->user, $user->table_pos);
                 if ($lockcalc < 3) {
                     $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
-                    $user->comm[$user->step % COMM_N] .= $table->exitlock_show(&$bri->user, $user->table_pos);
+                    $user->comm[$user->step % COMM_N] .= $table->exitlock_show(&$bin5->user, $user->table_pos);
                     $user->comm[$user->step % COMM_N] .=  show_notify("<br>I dati presenti sul server non erano allineati con quelli inviati dal tuo browser, adesso lo sono. Riprova ora.", 2000, "torna alla partita.", 400, 100);
 
                     log_wr($user->comm[$user->step % COMM_N]);
@@ -160,14 +160,14 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
             //      $user->bantime = $user->laccwr + BAN_TIME;
 
             if ($logout_cont == TRUE) {
-                $bri->table_wakeup(&$user);
+                $bin5->table_wakeup(&$user);
             }
         }
         else if ($argz[0] == 'exitlock') {
             if ($user->exitislock == TRUE) {
                 $user->exitislock = ($user->exitislock == TRUE ? FALSE : TRUE);
                 for ($ct = 0, $i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                    $user_cur[$i] = &$bri->user[$table->player[$i]];
+                    $user_cur[$i] = &$bin5->user[$table->player[$i]];
                     if ($user_cur[$i]->exitislock == FALSE)
                         $ct++;
                 }
@@ -207,14 +207,14 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                 /*     log_points($curtime, $user, "STAT:BRISKIN5:FINISH_GAME", $plist); */
                 /* } */
 
-                /* $table->game_init(&$bri->user); */
+                /* $table->game_init(&$bin5->user); */
 
-                if ($table->rules_engine(&$bri, $curtime, BIN5_RULES_ABANDON, $user)) {
+                if ($table->rules_engine(&$bin5, $curtime, BIN5_RULES_ABANDON, $user)) {
                     for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                        $user_cur = &$bri->user[$table->player[$i]];
+                        $user_cur = &$bin5->user[$table->player[$i]];
 
                         $ret = sprintf('gst.st = %d;', $user_cur->step+1);
-                        $ret .= show_table(&$bri,&$user_cur,$user_cur->step+1, TRUE, TRUE);
+                        $ret .= show_table(&$bin5,&$user_cur,$user_cur->step+1, TRUE, TRUE);
                         $user_cur->comm[$user_cur->step % COMM_N] = $ret;
                         $user_cur->step_inc();
                     }
@@ -269,7 +269,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                         /* next step */
                         $showst = "show_astat(";
                         for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                            $user_cur = &$bri->user[$table->player[$i]];
+                            $user_cur = &$bin5->user[$table->player[$i]];
                             $showst .= sprintf("%s%d", ($i == 0 ? "" : ", "),
                                                ($user_cur->asta_card < 9 ? $user_cur->asta_card : $user_cur->asta_pnt));
                         }
@@ -279,7 +279,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
 
                         $maxcard = -2;
                         for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                            $user_cur = &$bri->user[$table->player[$i]];
+                            $user_cur = &$bin5->user[$table->player[$i]];
                             if ($maxcard < $user_cur->asta_card)
                                 $maxcard = $user_cur->asta_card;
                         }
@@ -298,7 +298,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
 
 
                             for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                                $user_cur = &$bri->user[$table->player[$i]];
+                                $user_cur = &$bin5->user[$table->player[$i]];
                                 $ret = sprintf('gst.st = %d; %s', $user_cur->step+1, $showst);
                                 if ($user_cur->table_pos == ($table->gstart % BIN5_PLAYERS_N))
                                     $ret .= sprintf('dispose_asta(%d,%d, %s); remark_on();',
@@ -313,12 +313,12 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                         else if ($table->asta_pla_n == 0) {
                             log_wr("PASSANO TUTTI!");
 
-                            if ($table->rules_engine(&$bri, $curtime, BIN5_RULES_ALLPASS, $user)) {
+                            if ($table->rules_engine(&$bin5, $curtime, BIN5_RULES_ALLPASS, $user)) {
                                 for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                                    $user_cur = &$bri->user[$table->player[$i]];
+                                    $user_cur = &$bin5->user[$table->player[$i]];
 
                                     $ret = sprintf('gst.st = %d;', $user_cur->step+1);
-                                    $ret .= show_table(&$bri,&$user_cur,$user_cur->step+1, TRUE, TRUE);
+                                    $ret .= show_table(&$bin5,&$user_cur,$user_cur->step+1, TRUE, TRUE);
                                     $user_cur->comm[$user_cur->step % COMM_N] = $ret;
                                     $user_cur->step_inc();
                                 }
@@ -349,7 +349,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                             $table->asta_win = $chooser;
 
                             for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                                $user_cur = &$bri->user[$table->player[$i]];
+                                $user_cur = &$bin5->user[$table->player[$i]];
                                 $ret = sprintf('gst.st = %d; %s dispose_asta(%d, %d, false);', $user_cur->step+1, $showst,
                                                $table->asta_card + 1,-($table->asta_pnt));
 
@@ -383,9 +383,9 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                         log_wr("Setta la briscola a ".$a_brisco);
 
                         $chooser = $table->asta_win;
-                        $user_chooser = &$bri->user[$table->player[$chooser]];
+                        $user_chooser = &$bin5->user[$table->player[$chooser]];
                         for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                            $user_cur = &$bri->user[$table->player[$i]];
+                            $user_cur = &$bin5->user[$table->player[$i]];
                             $user_cur->subst = 'game';
                             $ret = sprintf('gst.st = %d; subst = "game";', $user_cur->step+1);
 
@@ -396,7 +396,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                             $ret .= sprintf('document.title = "Brisk - Tavolo %d";', $user->table_orig);
 
                             /* bg of caller cell */
-                            $ret .= briscola_show($bri, $table, $user_cur);
+                            $ret .= briscola_show($bin5, $table, $user_cur);
 
                             /* first gamer */
                             if ($i == ($table->gstart % BIN5_PLAYERS_N))
@@ -466,7 +466,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                         $table->gstart = $winner;
                         $turn_nex = ($table->gstart + $table->turn) % BIN5_PLAYERS_N;
 
-                        log_wr(sprintf("The winner is: [%d] [%s]", $winner, $bri->user[$table->player[$winner]]->name));
+                        log_wr(sprintf("The winner is: [%d] [%s]", $winner, $bin5->user[$table->player[$winner]]->name));
                         $card_take = sprintf("sleep(gst,2000);|cards_take(%d);|", $winner);
                         $player_cur = "remark_off();" . $card_take;
                         if ($turn_cur != $turn_nex)
@@ -480,7 +480,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
 
                     log_wr(sprintf("Turn Cur %d Turn Nex %d",$turn_cur, $turn_nex));
                     for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                        $user_cur = &$bri->user[$table->player[$i]];
+                        $user_cur = &$bin5->user[$table->player[$i]];
 
                         $ret = sprintf('gst.st = %d; ', $user_cur->step+1);
 
@@ -501,16 +501,16 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                     if ($table->turn == (BIN5_PLAYERS_N * BIN5_CARD_HAND)) { /* game finished */
                         log_wr(sprintf("GIOCO FINITO !!!"));
 
-                        if ($table->rules_engine(&$bri, $curtime, BIN5_RULES_FINISH, $user)) {
+                        if ($table->rules_engine(&$bin5, $curtime, BIN5_RULES_FINISH, $user)) {
                             for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                                $user_cur = &$bri->user[$table->player[$i]];
-                                $retar[$i] .= show_table(&$bri,&$user_cur,$user_cur->step+1,TRUE, TRUE);
+                                $user_cur = &$bin5->user[$table->player[$i]];
+                                $retar[$i] .= show_table(&$bin5,&$user_cur,$user_cur->step+1,TRUE, TRUE);
                             }
                         }
                     }
 
                     for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-                        $user_cur = &$bri->user[$table->player[$i]];
+                        $user_cur = &$bin5->user[$table->player[$i]];
 
                         $user_cur->comm[$user_cur->step % COMM_N] = $retar[$i];
                         $user_cur->step_inc();
index 09ee387..9301b37 100644 (file)
@@ -249,7 +249,7 @@ function carousel_top()
     }
 }
 
-function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $cookie)
+function index_main(&$brisk, $transp_type, &$header_out, $addr, $get, $post, $cookie)
 {
     GLOBAL $G_with_donors, $G_donors_cur, $G_donors_all;
     GLOBAL $G_with_topbanner, $G_topbanner, $G_is_local;
@@ -283,16 +283,16 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo
 
   if (isset($BRISK_SHOWHTML) == FALSE) {
       $is_table = FALSE;
-      log_main("lock Room");
+      log_main("lock Brisk");
       $curtime = time();
 
       /* Actions */
 
       if (validate_sess($sess)) {
           log_main("pre garbage_manager UNO");
-          $room->garbage_manager(TRUE);
+          $brisk->garbage_manager(TRUE);
           log_main("post garbage_manager");
-          if (($user = &$room->get_user($sess, &$idx)) != FALSE) {
+          if (($user = &$brisk->get_user($sess, &$idx)) != FALSE) {
               log_main("user stat: ".$user->stat);
               if ($user->stat == "table") {
                   $cookies = new Cookies();
@@ -313,11 +313,11 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo
               $pass_private = FALSE;
           }
 
-          $room->garbage_manager(TRUE);
+          $brisk->garbage_manager(TRUE);
           /* try login */
 
           $ipv4addr = addrtoipv4($addr);
-          if (($user = $room->add_user(&$sess, &$idx, $name, $pass_private, $ipv4addr, $cookie)) != FALSE) {
+          if (($user = $brisk->add_user(&$sess, &$idx, $name, $pass_private, $ipv4addr, $cookie)) != FALSE) {
               $ACTION = "room";
               if ($idx < 0) {
                   $idx = -$idx - 1;
@@ -337,7 +337,7 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo
               }
 
               // setcookie ("sess", "", time() + 180);      
-              $room->standup_update(&$user);
+              $brisk->standup_update(&$user);
           }
           else {
               /* Login Rendering */
index e8768ce..9360c4b 100644 (file)
@@ -84,7 +84,7 @@ define('LICMGR_CHO_ACCEPT', 0);
 define('LICMGR_CHO_REFUSE', 1);
 define('LICMGR_CHO_AFTER',  2);
 
-function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
+function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie)
 {
     GLOBAL $G_shutdown, $G_black_list, $G_lang, $G_room_help, $G_room_about, $G_room_passwdhowto, $mlang_indwr;
     GLOBAL $G_tos_vers;
@@ -122,7 +122,7 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
     $curtime = time();
     $dt = date("H:i ", $curtime);
 
-    if (($user = $room->get_user($sess, &$idx)) == FALSE) {
+    if (($user = $brisk->get_user($sess, &$idx)) == FALSE) {
         $argz = explode('|', xcapemesg($mesg));
 
         if ($argz[0] == 'getchallenge') {
@@ -195,7 +195,7 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
             return FALSE;
         }
         return TRUE;
-    }
+    } // end if (($user = $brisk->get_user($sess, ... == FALSE) {
 
     $argz = explode('|', xcapemesg($mesg));
 
@@ -233,11 +233,11 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
 
         if ($argz[1] == 'save') {
             if ($user->stat == 'room' && $user->subst == 'standup') {
-                $room->standup_update($user);
+                $brisk->standup_update($user);
             }
             else if ($user->stat == 'room' && $user->subst == 'sitdown') {
                 log_main("chatt_send pre table update");
-                $room->table_update($user);
+                $brisk->table_update($user);
                 log_main("chatt_send post table update");
             }
         }
@@ -251,9 +251,9 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
 
         log_rd2("AUTO LOGOUT.");
         if ($user->subst == 'sitdown' || $user->stat == 'table')
-            $room->room_wakeup($user);
+            $brisk->room_wakeup($user);
         else if ($user->subst == 'standup')
-            $room->room_outstandup(&$user);
+            $brisk->room_outstandup(&$user);
         else {
             log_rd2("SHUTDOWN FROM WHAT ???");
         }
@@ -545,7 +545,7 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
             
         }
         else if ($argz[0] == 'chatt') {
-            $room->chatt_send(&$user, xcapemesg($mesg));
+            $brisk->chatt_send(&$user, xcapemesg($mesg));
         }
         else if ($argz[0] == 'tosmgr') {
             // check IF is authnticated user, both terms of service versions matches
@@ -592,7 +592,7 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
                 
                 // Take parameters
                 $table_idx = (int)$argz[1];
-                $table = &$room->table[$table_idx];
+                $table = &$brisk->table[$table_idx];
     
                 $not_allowed_msg = "";
                 if ($G_shutdown) {
@@ -660,28 +660,28 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
                     //
                     
                     // Create new spawned table
-                    // $bri_sem = Bin5::lock_data(TRUE, $table_idx);
+                    // $bin5_sem = Bin5::lock_data(TRUE, $table_idx);
                     $table_token = uniqid("");
-                    $room->table[$table_idx]->table_token = $table_token;
-                    $room->table[$table_idx]->table_start = $curtime;
+                    $brisk->table[$table_idx]->table_token = $table_token;
+                    $brisk->table[$table_idx]->table_start = $curtime;
                     
                     $plist = "$table_token|$user->table|$table->player_n";
                     for ($i = 0 ; $i < $table->player_n ; $i++) {
-                        $plist .= '|'.$room->user[$table->player[$i]]->sess;
+                        $plist .= '|'.$brisk->user[$table->player[$i]]->sess;
                     }
                     log_legal($curtime, $user->ip, $user, "STAT:CREATE_GAME", $plist);
                     
                     log_wr("pre new Bin5");
-                    if (($bri = new Bin5($room, $table_idx, $table_token, $get, $post, $cookie)) == FALSE)
+                    if (($bin5 = new Bin5($brisk, $table_idx, $table_token, $get, $post, $cookie)) == FALSE)
                         log_wr("bri create: FALSE");
                     else
-                        log_wr("bri create: ".serialize($bri));
+                        log_wr("bri create: ".serialize($bin5));
                     
                     log_wr("pre init table");
                     // init table
-                    $bri_table = $bri->table[0];
-                    $bri_table->init($bri->user);
-                    $bri_table->game_init($bri->user);
+                    $bin5_table = $bin5->table[0];
+                    $bin5_table->init($bin5->user);
+                    $bin5_table->game_init($bin5->user);
                     //
                     // Init spawned users.
                     //
@@ -689,17 +689,17 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
                     //
                     log_wr("game_init after");
                     for ($i = 0 ; $i < $table->player_n ; $i++) {
-                        $bri_user_cur = $bri->user[$i];
-                        $user_cur = $room->user[$table->player[$i]];
+                        $bin5_user_cur = $bin5->user[$i];
+                        $user_cur = $brisk->user[$table->player[$i]];
                         
-                        $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->step_inc();
+                        $bin5_user_cur->laccwr = $curtime;
+                        $bin5_user_cur->trans_step = $user_cur->step + 1;
+                        $bin5_user_cur->comm[$bin5_user_cur->step % COMM_N] = "";
+                        $bin5_user_cur->step_inc();
+                        $bin5_user_cur->comm[$bin5_user_cur->step % COMM_N] = show_table(&$bin5,&$bin5_user_cur,$bin5_user_cur->step+1,TRUE, FALSE);
+                        $bin5_user_cur->step_inc();
                         
-                        log_wr("TRY PRESAVE: ".$bri_user_cur->step." TRANS STEP: ".$bri_user_cur->trans_step);
+                        log_wr("TRY PRESAVE: ".$bin5_user_cur->step." TRANS STEP: ".$bin5_user_cur->trans_step);
                         
                         log_wr("Pre if!");
                         
@@ -717,11 +717,11 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
                         $user_cur->step_inc();
                     }
                     log_wr("presave bri");
-                    $room->match_add($table_idx, $bri);
+                    $brisk->match_add($table_idx, $bin5);
                     log_wr("postsave bri");
                 }
                 // change room
-                $room->room_sitdown($user, $table_idx);
+                $brisk->room_sitdown($user, $table_idx);
                 
                 log_wr("MOP finish");
             }
@@ -739,10 +739,10 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
          **********************/
         else if ($user->subst == 'sitdown') {
             if ($argz[0] == 'wakeup') {
-                $room->room_wakeup($user);
+                $brisk->room_wakeup($user);
             }
             else if ($argz[0] == 'logout') {
-                $room->room_wakeup($user);
+                $brisk->room_wakeup($user);
                 $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
                 $user->comm[$user->step % COMM_N] .= 'postact_logout();';
                 $user->the_end = TRUE;
@@ -751,10 +751,10 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
         }
     }
     log_wr("before save data");
-    // Room::save_data($room);
+    // Brisk::save_data($brisk);
     log_wr($user->step, 'index_wr.php: after save_data()');
     
-/* Room::unlock_data($sem); */
+/* Brisk::unlock_data($sem); */
 /* exit; */
     return (FALSE);
 }
index 35c2584..7756764 100755 (executable)
@@ -43,13 +43,13 @@ function main($argv)
 {
     pid_save();
     do {
-        if (($room = Room::create(LEGAL_PATH."/brisk-crystal.data")) == FALSE) {
-            log_crit("room::create failed");
+        if (($brisk = Brisk::create(LEGAL_PATH."/brisk-crystal.data")) == FALSE) {
+            log_crit("Brisk::create failed");
             $ret = 1;
             break;
         }
 
-        if (($s_a_p = Sac_a_push::create($room, USOCK_PATH, 0, 0, $argv)) === FALSE) {
+        if (($s_a_p = Sac_a_push::create($brisk, USOCK_PATH, 0, 0, $argv)) === FALSE) {
             $ret = 2;
             break;
         }