+ }
+
+
+ /* this part I suppose is read only on $this->room structure */
+ if ($this->rd_step == -1) {
+ log_rd2("PRE-NEWSTAT");
+
+ /***************
+ * *
+ * TABLE *
+ * *
+ ***************/
+ if ($this->stat == 'table') {
+ log_load("RESYNC");
+ /* NOTE: $this->room is associated with the current $bri object */
+ // printf("xXx CLASS NAME [%s]\n", get_class($this->room));
+ $ret = show_table($this->room, $this, $this->step, FALSE, FALSE);
+ }
+ log_rd2("NEWSTAT: ".$this->stat);
+
+ $this->rd_stat = $this->stat;
+ $this->rd_subst = $this->subst;
+ $this->rd_step = $this->step;
+ } /* if ($this->rd_step == -1) { */
+ else {
+ $S_load_stat['rU_heavy']++;
+
+ if ($this->rd_step < $this->step) {
+ do {
+ if ($this->rd_step + COMM_N < $this->step) {
+ if ($this->rd_stat != $this->stat) {
+ $to_stat = $this->stat;
+ 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));
+ }
+ log_rd2("lost history, refresh from scratch");
+ // printf("xXx LOST HISTORY!\n");
+ $this->rd_step = -1;
+ break;
+ }
+ for ($i = $this->rd_step ; $i < $this->step ; $i++) {
+ $ii = $i % COMM_N;
+ if ($this->comm[$ii] == "") {
+ if ($i == $this->rd_step)
+ continue;
+ else
+ break;
+ }
+ log_rd2("ADDED TO THE STREAM: ".$this->comm[$ii]);
+ $ret .= $this->comm[$ii];
+ }
+ $this->rd_stat = $this->stat;
+ $this->rd_subst = $this->subst;
+ $this->rd_step = $this->step;
+ } while (0);
+
+ log_rd2($this->step, 'index_rd.php: after ret set');
+
+ // if ($this->the_end == TRUE) { management is moved
+ // in the spush scope
+ } /* if ($this->rd_step < $this->step) { */
+ } /* else of if ($this->rd_step == -1) { */
+
+
+ return ($ret);
+ } // function maincheck(...
+
+ function continue_set($match_code)
+ {
+ $this->continue = $match_code;
+ }
+
+ function continue_get() {
+ return ($this->continue);
+ }
+
+ function rules_set($rules_id)
+ {
+ $this->rules = $rules_id;
+ }
+
+ function rules_get() {
+ return ($this->rules);
+ }
+
+} // end class Bin5_user
+
+
+class Bin5 {
+ static $delta_t = array();
+ var $brisk;// room object reference
+
+ var $user;
+ var $table;
+ var $comm; // commands for many people
+ var $step; // current step of the comm array
+ var $garbage_timeout;
+ var $shm_sz;
+
+ var $table_idx;
+ var $table_token;
+
+ var $the_end;
+ var $tok;
+
+ var $delay_mgr;
+
+ function Bin5($brisk, $table_idx, $table_token, $get, $post, $cookie) {
+ $this->user = array();
+ $this->table = array();
+
+ $this->the_end = FALSE;
+ $this->shm_sz = BIN5_SHM_MIN;
+ if (($this->tok = @ftok(FTOK_PATH."/bin5/table".$table_idx."/table", "B")) == -1) {
+ echo "FTOK FAILED";
+ exit;
+ }
+
+ $this->brisk = $brisk;
+ $user = $brisk->user;
+ $table = $brisk->table[$table_idx];
+ log_wr("Bin5 constructor");
+
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $user[$table->player[$i]]->table_token = $table_token;
+ $this->user[$i] = Bin5_user::spawn($user[$table->player[$i]], $this, $table_idx, $i, $get, $post, $cookie);
+ }
+ $this->table[0] = Bin5_table::spawn($table);
+
+ log_main("TABLE_OLD_WIN - Bin5:".$this->table[0]->old_asta_win);
+
+ $this->table_idx = $table_idx;
+ $this->table_token = $table_token;
+ $this->garbage_timeout = 0;
+
+ $this->delay_mgr = new Delay_Manager((GARBAGE_TIMEOUT *3.0) / 2.0);
+
+ log_wr("Bin5 constructor end");
+ }
+
+
+ function get_user($sess, &$idx)
+ {
+ GLOBAL $PHP_SELF;
+
+ if (validate_sess($sess)) {
+ for ($i = 0 ; $i < BIN5_MAX_PLAYERS ; $i++) {
+ if ($this->user[$i]->is_empty())
+ continue;
+ if (strcmp($sess, $this->user[$i]->sess) == 0) {
+ // find it
+ $idx = $i;
+ $ret = &$this->user[$i];
+ return ($ret);
+ }
+ }
+ log_main(sprintf("get_user: Wrong sess from page [%s]",$PHP_SELF));
+ // for ($i = 0 ; $i < BIN5_MAX_PLAYERS ; $i++)
+ // log_main(sprintf("get_user: Wrong sess compared with [%s]",$this->user[$i]->sess));
+ }
+ else {
+ log_main(sprintf("get_user: Wrong strlen [%s]",$sess));