+ if ($table_cur->player_n == PLAYERS_N) {
+ log_main("PLAYERS == N TABLE ".$table_idx);
+
+
+ $no_recovery = FALSE;
+ if (isset($this->match[$table_idx])) {
+ $bin5 = $this->match[$table_idx];
+
+ 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;
+ $bin5 = FALSE;
+ }
+
+ if ($bin5 != FALSE) {
+ //
+ // SPAWN: JOIN
+ //
+ log_main("garbage_manager: bri loaded successfully.");
+ $bin5->garbage_manager(TRUE);
+
+ $bin5_table = $bin5->table[0];
+
+ // is the end of the table
+
+ if ($bin5->the_end == TRUE) {
+ /*
+ * DESTROY OF FINISHED TABLE && MOVE PLAYER TO ROOM AGAIN
+ */
+ log_main("garbage_manager: INSIDE THE END.");
+
+ $plist = "$table_cur->table_token|$table_cur->idx|$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 < $bin5_table->player_n ; $i++) {
+ // stat must be "table" by definition
+ $user_cur = $this->user[$table_cur->player[$i]];
+ $bin5_user = $bin5->user[$i];
+
+ $user_cur->subst = $bin5_user->subst;
+ $user_cur->rd_step = $bin5_user->rd_step;
+ $user_cur->step = $bin5_user->step;
+ $user_cur->lacc = $bin5_user->lacc;
+ $user_cur->laccwr = $bin5_user->lacc;
+ $user_cur->bantime = $bin5_user->bantime;
+ $user_cur->the_end = $bin5_user->the_end;
+ if ($user_cur->the_end) {
+ $this->ghost_sess->push($curtime, $user_cur->sess, GHOST_SESS_REAS_TTOT);
+ }
+ }
+
+ log_legal($curtime, $user_cur->ip, $user_cur, "STAT:DESTROY_GAME", $plist);
+
+ $this->room_join_wakeup($user_cur, FALSE, 0);
+ $table_cur->table_token = "";
+ $table_cur->wakeup_time = $curtime + WAKEUP_TIME;
+
+ $this->match_del($table_idx);
+ }
+ else {
+ log_main("gm:: save_data");
+
+ for ($i = 0 ; $i < $bin5_table->player_n ; $i++) {
+ $this->user[$table_cur->player[$i]]->lacc = $bin5->user[$i]->lacc;
+ }
+ }
+ } // if ($bin5 == 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)."; ";
+ // MLANG <br>I dati del tavolo n° ".$user_cur->table." sono inconsistenti, verranno resettati.<br><br>Torni in piedi.<br><br>
+ $prestr = sprintf($mlang_brisk['tabincon'][$G_lang], $user_cur->table);
+ $ret .= show_notify($prestr, 2000, $mlang_brisk['btn_close'][$G_lang], 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->ip, $user_cur, "STAT:DESTROY_GAME(RECOVERY)", $plist);
+
+ $this->room_join_wakeup($user_cur, TRUE, -2);
+ $table_cur->table_token = "";
+ }
+ }
+ } // 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];
+
+ log_rd2("User: ".$user_cur->name." stat: ".$user_cur->stat." subst: ".$user_cur->subst);
+
+ if ($user_cur->is_active() == FALSE)
+ continue;
+
+ if ($user_cur->lacc + (($user_cur->ping_req ? 1.5 : 1.0) * EXPIRE_TIME_RD) < ($curtime - $delta)) {
+ // Auto logout dell'utente
+ log_rd2("AUTO LOGOUT.".($user_cur->lacc + EXPIRE_TIME_RD)." curtime - delta ".($curtime - $delta));
+
+ $this->ghost_sess->push($curtime, $user_cur->sess, GHOST_SESS_REAS_TOUT);
+ $user_cur->the_end = TRUE;
+
+ log_rd2("AUTO LOGOUT.");
+ if ($user_cur->stat == 'table' || $user_cur->stat == 'room') {
+ log_auth($user_cur->sess, "Autologout session.");
+
+ if ($user_cur->subst == 'sitdown' || $user_cur->stat == 'table')
+ $this->room_wakeup($user_cur);
+ else if ($user_cur->subst == 'standup')
+ $this->room_outstandup($user_cur);
+ else
+ log_rd2("LOGOUT FROM WHAT ???");
+ }
+ }
+
+ if ($user_cur->laccwr + EXPIRE_TIME_SMAMMA < ($curtime - $delta)) { // lo rimettiamo in piedi
+ if ($user_cur->stat == 'room' && $user_cur->subst == 'sitdown') {
+ $this->room_wakeup($user_cur);
+ $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
+ /* MLANG: <br>Sei stato inattivo per ".(EXPIRE_TIME_SMAMMA/60.0)." minuti. <br><br>Quindi ritorni tra i <b>Giocatori in piedi</b>.", "torna ai tavoli" */
+ $user_cur->comm[$user_cur->step % COMM_N] .= show_notify($mlang_brisk['tabtout_a'][$G_lang].(EXPIRE_TIME_SMAMMA/60.0).$mlang_brisk['tabtout_b'][$G_lang], 0, $mlang_brisk['btn_backstand'][$G_lang], 400, 100);
+ $user_cur->step_inc();
+ }
+ }
+ }
+ log_rd2("GARBAGE UPDATED!");
+
+ $this->garbage_timeout = $curtime + GARBAGE_TIMEOUT;
+ $ismod = TRUE;
+
+ $this->ghost_sess->garbage_manager($curtime);
+
+ $this->delay_mgr->lastcheck_set($curtime);
+ return ($ismod);