- $this->user[$i] =& User::create("", "");
- }
-
- for ($i = 0 ; $i < TABLES_N ; $i++)
- $this->table[$i] =& Table::create();
- $this->garbage_timeout = 0;
- }
-
- function garbage_manager($force)
- {
- $ismod = FALSE;
-
- log_rd2("garbage_manager START");
-
- /* Garbage collector degli utenti in timeout */
- $curtime = time();
- if ($force || $this->garbage_timeout < $curtime) {
-
- // Before all align times with table timeout
- for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
- $table_cur =& $this->table[$table_idx];
- // if the table is complete and exists its shared mem we get the info about users lacc
-
- if ($table_cur->player_n == PLAYERS_N) {
- log_main("PLAYERS == N TABLE ".$table_idx);
-
- if (($sem = Briskin5::lock_data($table_idx)) != FALSE) {
- log_main("bin5 lock data success");
-
- $no_recovery = FALSE;
- if (($bri = &Briskin5::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);
- $no_recovery = TRUE;
- $bri = FALSE;
- }
- }
-
- if ($bri != FALSE) {
- //
- // SPAWN: JOIN
- //
- log_main("garbage_manager: bri loaded successfully.");
- $bri->garbage_manager(TRUE);
-
- $bri_table = &$bri->table[0];
-
- // is the end of the table
- if ($bri->the_end == TRUE) {
- /*
- * DESTROY OF FINISHED TABLE && MOVE PLAYER TO ROOM AGAIN
- */
- log_main("garbage_manager: INSIDE THE END.");
-
- $plist = "$table_cur->table_token|$user_cur->table|$table_cur->player_n";
- for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
- $plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
- }
-
- for ($i = 0 ; $i < $bri_table->player_n ; $i++) {
- // stat must be "table" by definition
- $user_cur =& $this->user[$table_cur->player[$i]];
- $bri_user =& $bri->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;
- }
-
- log_legal($curtime, $user_cur->sess, $user_cur->name, "STAT:DESTROY_GAME", $plist);
-
- $this->room_join_wakeup(&$user_cur, FALSE, 0);
- $table_cur->table_token = "";
- $table_cur->wakeup_time = $curtime + WAKEUP_TIME;
- Briskin5::destroy_data($table_idx);
- }
- 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;
- }
-
- Briskin5::save_data(&$bri);
- }
- } // else if (($bri = &Briskin5::load_data($table_idx)) != FALSE) {
- else if ($no_recovery == FALSE) {
- log_crit("ERROR: table ".$table_idx." unrecoverable join");
-
- for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
- $user_cur = &$this->user[$table_cur->player[$i]];
- $user_cur->subst = "shutdowner";
- $user_cur->step_inc();
-
- $ret = sprintf('stat = "%s"; subst = "%s";', $user_cur->stat, $user_cur->subst);
- $ret .= "gst.st = ".($user_cur->step+1)."; ";
- $ret .= show_notify("<br>I dati del tavolo n° ".$user_cur->table." sono inconsistenti, verranno resettati.<br><br>Torni in piedi.<br><br>", 2000, "Chiudi.", 400, 110);
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->step_inc();
- }
-
- $plist = "$table_cur->table_token|$user_cur->table|$table_cur->player_n";
- for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
- $plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
- }
- log_legal($curtime, $user_cur->sess, $user_cur->name, "STAT:DESTROY_GAME(RECOVERY)", $plist);
-
- $this->room_join_wakeup(&$user_cur, TRUE, -2);
- $table_cur->table_token = "";
- }
-
- Briskin5::unlock_data($sem);
- } // bri::lock_data
- } // if ($table_cur->player_n == PLAYERS_N) {
- } // for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
-
- log_rd2("out new loop.");
-
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $user_cur = &$this->user[$i];