X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=8136f8f5ee52f72b80e0c66add6fb737ed31cf84;hb=971fb704f6cb6091d0c597209f5f878c04336d51;hp=f0f3d750e481b52af9279fb346b564f7662243a2;hpb=a2924d2335ec5325dc322600fe373625575ac8e2;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index f0f3d75..8136f8f 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -32,7 +32,8 @@ define(COMM_N, 12); define(COMM_GEN_N, 50); define(SESS_LEN, 13); define(STREAM_TIMEOUT, 20); -define(EXPIRE_TIME_RD, 180); +// FIXME original: define(EXPIRE_TIME_RD, 180); +define(EXPIRE_TIME_RD, 60); define(EXPIRE_TIME_SMAMMA, 360); // BAN_TIME da allineare anche in commons.js define(BAN_TIME, 900); @@ -44,7 +45,7 @@ define(BRISK_DEBUG, FALSE); $G_false = FALSE; $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "0.8.2"; +$G_brisk_version = "spawn-0.0.3"; $root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': nuovo layout che permette più tavoli, più tavoli.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ); @@ -658,6 +659,7 @@ class Room { function Room () { $this->user = array(); + $this->table = array(); for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { $this->user[$i] =& User::create("", ""); @@ -670,11 +672,74 @@ class Room { function garbage_manager($force) { - + $ismod = FALSE; + /* 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) { + if (($sem = Briskin5::lock_data($table_idx)) != FALSE) { + if (($bri = &Briskin5::load_data($table_idx)) != FALSE) { + if ($bri->garbage_manager(TRUE) == TRUE) { + // if garbaged you need to save data + Briskin5::save_data(&$bri); + if ($bri->is_abandoned()) { + // FIXME recovery of room and clean of the table + /* + + # + # KILL USERS + # + + if ($user_cur->lacc + EXPIRE_TIME_RD < $curtime) { // Auto logout dell'utente + log_rd2($user_cur->sess, "AUTO LOGOUT."); + + if ($user_cur->stat == 'table' || $user_cur->stat == 'room') { + log_auth($user_cur->sess, "Autologout session."); + + $tmp_sess = $user_cur->sess; + $user_cur->sess = ""; + step_unproxy($tmp_sess); + $user_cur->name = ""; + $user_cur->step = 0; + $user_cur->the_end = FALSE; + + log_rd2($user_cur->sess, "AUTO LOGOUT."); + 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($sess, "LOGOUT FROM WHAT ???"); + } + } + + # + # destroy shared + # + + Briskin5::destroy_data($user->table); + + + */ + } + } + $table_bri = &$bri->table[0]; + for ($i = 0 ; $i < PLAYERS_N ; $i++) { + $this->user[$table_cur->player[$i]]->lacc = + $bri->user[$table_bri->player[$i]]->lacc; + } + } + Briskin5::unlock_data($sem); + } + } + } + for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { $user_cur = &$this->user[$i]; if ($user_cur->sess == "") @@ -690,6 +755,7 @@ class Room { $user_cur->sess = ""; step_unproxy($tmp_sess); $user_cur->name = ""; + $user_cur->step = 0; $user_cur->the_end = FALSE; log_rd2($user_cur->sess, "AUTO LOGOUT."); @@ -714,10 +780,10 @@ class Room { log_rd2($user_cur->sess, "GARBAGE UPDATED!"); $this->garbage_timeout = time() + GARBAGE_TIMEOUT; + $ismod = TRUE; } - // BAN_IP_CLEAN - + return ($ismod); } @@ -802,11 +868,11 @@ class Room { } } - function room_join_wakeup(&$user) + function room_join_wakeup(&$user, $update_lacc = FALSE) { $table_idx = $user->table; $table = &$this->table[$table_idx]; - + log_main($user->sess, "JOIN_WAKEUP: begin function table:".$table_idx." stat: ".$user->stat." subst: ".$user->subst); $curtime = time(); @@ -818,7 +884,9 @@ class Room { $user_cur = &$this->user[$table->player[$i]]; log_main($user->sess, "PREIMPOST INLOOP name: ".$user_cur->name); if ($user_cur->sess != "") { - $user_cur->laccwr = $curtime; + if ($update_lacc == TRUE) { + $user_cur->laccwr = $curtime; + } log_load($user->sess, "cur: ".$user_cur->name." subst: ".$user_cur->subst); if ($user_cur->subst == "shutdowned") { $user_cur->stat_set("room"); @@ -1766,6 +1834,10 @@ function show_table(&$room, &$user, $sendstep, $is_transition, $is_again) /* GENERAL STATUS */ $ret .= sprintf( 'gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;', $sendstep, $user->stat, $user->subst, $table_pos); + + log_rd($user->sess, sprintf( 'SHOW_TABLE: gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;', + $sendstep, $user->stat, $user->subst, $table_pos)); + /* BACKGROUND */ $ret .= "background_set();";