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);
$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.'), <b>NOVITA\'</b>: nuovo layout che permette più tavoli, più tavoli.',
'Se vuoi iscriverti alla <a target="_blank" href="http://www.milug.org/cgi-bin/mailman/listinfo/ml-briscola">Mailing List</a>, cliccala!' );
function Room () {
$this->user = array();
+ $this->table = array();
for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
$this->user[$i] =& User::create("", "");
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 == "")
$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.");
log_rd2($user_cur->sess, "GARBAGE UPDATED!");
$this->garbage_timeout = time() + GARBAGE_TIMEOUT;
+ $ismod = TRUE;
}
- // BAN_IP_CLEAN
-
+ return ($ismod);
}
}
}
- 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();
$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");
/* 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();";