From: Matteo Nastasi (mop) Date: Sun, 18 Feb 2007 17:53:34 +0000 (+0000) Subject: finita gestione di exit concordato X-Git-Tag: 3.0.0~302 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=c0343793fa79c053f3498a5b5eee1ef6ccb05d5e;p=brisk.git finita gestione di exit concordato --- diff --git a/web/brisk.phh b/web/brisk.phh index 868c538..2394625 100644 --- a/web/brisk.phh +++ b/web/brisk.phh @@ -30,17 +30,19 @@ define(SESS_LEN, 13); define(STREAM_TIMEOUT, 20); define(EXPIRE_TIME_RD, 180); define(EXPIRE_TIME_SMAMMA, 360); +// BAN_TIME da allineare anche in commons.js +define(BAN_TIME, 900); define(GARBAGE_TIMEOUT, 10); define(NICKSERV, "SERVER"); define(BRISK_DEBUG, FALSE); // define(DEBUGGING, "local"); $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "0.4.6"; +$G_brisk_version = "0.5.0"; $root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.').', 'Se vuoi iscriverti alla Mailing List, cliccala!' ); -$table_wellarr = Array ( 'Benvenuto al tavolo.'); +$table_wellarr = Array ( 'Benvenuto al tavolo. Se almeno tre giocatori non sbloccano l\'uscita cliccando il lucchetto, chi esce non può risedersi a un qualunque tavolo per '.floor(BAN_TIME/60).' minuti.'); $G_room_help= ' @@ -343,6 +345,7 @@ class User { var $sess; // session of the user var $lacc; // last access (for the cleanup) var $laccwr; // last access (for the cleanup) + var $bantime; // timeout to temporary ban var $stat; // status (outdoor, room, table, game, ...) var $subst; // substatus for each status var $step; // step of the current status @@ -360,6 +363,7 @@ class User { $this->sess = $sess; $this->lacc = time(); $this->laccwr = time(); + $this->bantime = 0; $this->stat = $stat; $this->subst = $subst; $this->step = 1; @@ -416,8 +420,7 @@ class brisco { log_rd2($user_cur->sess, "AUTO LOGOUT."); if ($user_cur->subst == 'sitdown' || $user_cur->stat == 'table') - $this->room_wakeu -p(&$user_cur); + $this->room_wakeup(&$user_cur); else if ($user_cur->subst == 'standup') $this->room_outstandup(&$user_cur); else @@ -453,11 +456,6 @@ p(&$user_cur); $from_table = ($user->stat == "table"); if ($from_table) { log_main("WAKEUP", "from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n); - $lockcalc = $table->exitlock_calc(&$this->user, $table_pos); - if ($lockcalc < 3) { - // BAN TEMP! -asdasdasdas - } for ($i = 0 ; $i < $table->player_n ; $i++) { $user_cur = &$this->user[$table->player[$i]]; @@ -1581,4 +1579,17 @@ function playsound($filename) return (sprintf('playsound("flasou", "%s");', $filename)); } +function secstoword($secs) +{ + $mins = floor($secs / 60); + $secs = $secs % 60; + if ($mins > 0) + $ret = sprintf("%d minut%s%s", $mins, ($mins > 1 ? "i" : "o"), ($secs > 0 ? " e " : "")); + + if ($secs > 0) + $ret .= sprintf("%d second%s", $secs, ($secs > 1 ? "i" : "o")); + + return ($ret); +} + ?> diff --git a/web/index_wr.php b/web/index_wr.php index 8a59ec5..1dcb06e 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -94,10 +94,20 @@ else if ($user->stat == 'room') { exit; } + if ($user->bantime > $user->laccwr) { + $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; + $user->comm[$user->step % COMM_N] .= show_notify("
Ti sei alzato da un tavolo senza il consenso degli altri giocatori. Dovrai aspettare ancora ".secstoword($user->bantime - $user->laccwr)." prima di poterti sedere nuovamente.", 2000, "Torna in piedi.", 400, 100); + + $user->step++; + save_data($bri); + unlock_data($sem); + exit; + } + // Take parameters $table_idx = $argz[1]; $table = &$bri->table[$table_idx]; - + if ($table->player_n == PLAYERS_N) { log_wr($sess, "Warning ! unreachable, table full."); unlock_data($sem); @@ -174,7 +184,32 @@ else if ($user->stat == 'table') { $bri->chatt_send(&$user,$mesg); } else if ($argz[0] == 'logout') { - $bri->room_wakeup(&$user); + $remcalc = $argz[1]; + + if ($user->exitislock == TRUE) { + $remcalc++; + $user->exitislock = FALSE; + } + + $logout_cont = TRUE; + if ($remcalc >= 3) { + $lockcalc = $table->exitlock_calc(&$bri->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(); + $user->comm[$user->step % COMM_N] .= show_notify("
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($sess, $user->comm[$user->step % COMM_N]); + $user->step++; + $logout_cont = FALSE; + } + } + else + $user->bantime = $user->laccwr + BAN_TIME; + + if ($logout_cont == TRUE) { + $bri->room_wakeup(&$user); + } } else if ($argz[0] == 'exitlock') { $user->exitislock = ($user->exitislock == TRUE ? FALSE : TRUE);