X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=13118f26f0dd6d11183ad99d931d6aa5676978ad;hb=4a7eb48142359ee330ba378d05b0fb20b9ab0689;hp=78a7aef8f89da3c505880193208b9649216e52f3;hpb=7c225f8f69e49965d43a4af26f5564e4d95ec4cc;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 78a7aef..13118f2 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -715,10 +715,12 @@ class Room { 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; } } @@ -737,20 +739,21 @@ class Room { /* * DESTROY OF FINISHED TABLE && MOVE PLAYER TO ROOM AGAIN */ + log_main("garbage_manager: INSIDE THE END."); + 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->trans_step = $bri_user->step; $user_cur->lacc = $bri_user->lacc; $user_cur->laccwr = $bri_user->lacc; $user_cur->bantime = $bri_user->bantime; } - $this->room_join_wakeup(&$user_cur); + $this->room_join_wakeup(&$user_cur, FALSE, 0); $table_cur->table_token = ""; Briskin5::destroy_data($table_idx); @@ -765,9 +768,26 @@ class Room { Briskin5::save_data(&$bri); } } // else if (($bri = &Briskin5::load_data($table_idx)) != FALSE) { - else { + else if ($no_recovery == FALSE) { log_main("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";', $cur_user->stat, $cur_user->subst); + $ret .= "gst.st = ".($user_cur->step+1)."; "; + $ret .= show_notify("
I dati del tavolo n° ".$user_cur->table." sono inconsistenti, verranno resettati.

Torni in piedi.

", 2000, "Chiudi.", 400, 110); + $user_cur->comm[$user_cur->step % COMM_N] = $ret; + $user_cur->step_inc(); + } + + $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++) { @@ -906,7 +926,7 @@ class Room { } } - function room_join_wakeup(&$user, $update_lacc = FALSE) + function room_join_wakeup(&$user, $update_lacc = FALSE, $trans_delta) { $table_idx = $user->table; $table = &$this->table[$table_idx]; @@ -916,6 +936,8 @@ class Room { $curtime = time(); $user_wup = array(); $user_wup_n = 0; + $user_tab = array(); + $user_tab_n = 0; log_main("JOIN WAKEUP: from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n); for ($i = 0 ; $i < $table->player_n ; $i++) { @@ -936,6 +958,7 @@ class Room { $user_cur->table = -1; $user_wup[$user_wup_n++] = &$user_cur; } + $user_tab[$user_tab_n++] = &$user_cur; } } @@ -965,33 +988,28 @@ class Room { $act_content = table_act_content(FALSE, 0, $table_idx, $user_cur->table); $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); - for ($wup_idx = 0 ; $wup_idx < $user_wup_n ; $wup_idx++) - if ($user_cur == $user_wup[$wup_idx]) + for ($tab_idx = 0 ; $tab_idx < $user_tab_n ; $tab_idx++) + if ($user_cur == $user_tab[$tab_idx]) break; // for users that wakeup the room will be reconstructed by index_rd.php - if ($user_cur == $user_wup[$wup_idx]) - continue; + if ($tab_idx < $user_tab_n) { + log_main("PRE show_room username: ".$user_cur->name." STEP: ".$user_cur->step); + $user_cur->trans_step = $user_cur->step + 1 + $trans_delta; + $user_cur->comm[$user_cur->step % COMM_N] = ""; + $user_cur->step_inc(); + $user_cur->comm[$user_cur->step % COMM_N] = show_room(&$this, ($user_cur->step + 1), &$user_cur); + $user_cur->step_inc(); + log_main("POST show_room username: ".$user_cur->name." STEP: ".$user_cur->step); + continue; + } log_main("JOIN_WAKEUP wup_idx ".$wup_idx." wup_n ".$user_wup_n); - if ($wup_idx < $user_wup_n) { - log_main("JOIN_WAKEUP less"); - // set the new status - $ret .= 'stat = "room"; subst = "standup"; '; - // clean the action buttons in other tables - for ($e = 0 ; $e < TABLES_N ; $e++) { - if ($this->table[$e]->player_n < PLAYERS_N) - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, table_act_content(TRUE, 0, $e, $user_cur->table)); - } - log_main("JOIN_WAKEUP end less"); - } - else { - log_main("JOIN_WAKEUP more"); - $act_content = table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table); - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); - log_main("JOIN_WAKEUP end more"); - } + log_main("JOIN_WAKEUP more"); + $act_content = table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table); + $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); + log_main("JOIN_WAKEUP end more"); } log_wr("ROOM_JOIN_WAKEUP: ".$ret); $user_cur->comm[$user_cur->step % COMM_N] = $ret; @@ -1253,7 +1271,8 @@ class Room { } $this->user[$idx]->name = $name_new; $this->user[$idx]->stat_set("room"); - // MOP $this->user[$idx]->step_set(0); + $this->user[$idx]->step_set(0); + while (array_pop($this->user[$idx]->comm) != NULL); $this->user[$idx]->subst = "standup"; $this->user[$idx]->lacc = $curtime; $this->user[$idx]->laccwr = $curtime; @@ -1897,9 +1916,12 @@ function table_wellcome($user) return ($ret); } -function show_room(&$room, &$user) +function show_room(&$room, $user_step, &$user) { - $ret = sprintf('gst.st = %d;', $user->step); + log_main("show_room: username: ".$user->name); + + + $ret = sprintf('gst.st = %d;', $user_step); $ret .= sprintf('stat = "%s";', $user->stat); $ret .= root_wellcome($user);