Quindi ritorni tra i Giocatori in piedi.',
+ 'en' => ' minutes.
Then you return with the standing players.'),
+ 'tickmust' => array( 'it' => ' Per attivare il messaggio di segnalazione del tavolo occorre essere seduti.
',
+ 'en' => ' To activate the signalling message of the table it\'s necessary to be sitting
'),
+ 'tickjust' => array( 'it' => ' Il messaggio di segnalazione del tavolo è già attivato.
',
+ 'en' => 'EN Il messaggio di segnalazione del tavolo è già attivato.
'),
+ 'tickwait' => array( 'it' => ' Il messaggio di segnalazione del tavolo è disattivato ancora per %d second%s.
',
+ 'en' => 'EN The signalling message of the table will be deactivated for %d second%s.
'),
+ 'alarpass' => array( 'it' => ' La password digitata non è corretta.
',
+ 'en' => ' The entered password is not correct.
'),
+ 'alarret' => array( 'it' => '"Alarm \\"%s\\" inviato a %s."',
+ 'en' => '"Alarm \\"%s\\" sent to %s."'),
+ 'authmust' => array( 'it' => 'Per autenticare qualcuno devi a tua volta essere autenticato.',
+ 'en' => 'To authenticate someone you have to be authenticated.'), // on your turn
+ 'mesgmust' => array( 'it' => 'Per inviare un messaggio devi essere autenticato.',
+ 'en' => 'To send a message you have to be authenticated.'),
+ 'nickmust' => array( 'it' => 'Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.',
+ 'en' => 'The nickname have to contain at least one letter or one number.'),
+ 'nickdupl' => array( 'it' => 'Nickname %s già in uso.',
+ 'en' => 'The nickname %s is already in use.'),
+ 'authchan' => array( 'it' => 'Non puoi cambiare nick a un tavolo per soli autenticati o se sei in modalità isolata.',
+ 'en' => 'You can\'t change your nickname into a table for only authenticated or if you are in isolation mode.'),
+ 'nickjust' => array( 'it' => 'Il nickname \'%s\' è già registrato, se il suo proprietario si autentificherà verrai rinominato d\'ufficio come ghostN.',
+ 'en' => 'The nickname \'%s\' is already registered, if its proprietary will authenticate you will named again officially ghostN.'), // FIXME: him ???
+ 'statunkn' => array( 'it' => 'Questo stato non esiste.',
+ 'en' => 'This state don\'t exists.'),
+ 'tabincon' => array( 'it' => ' I dati del tavolo n° %d sono inconsistenti, verranno resettati.
Torni in piedi.
',
+ 'en' => 'EN I dati del tavolo n° %d sono inconsistenti, verranno resettati.
Torni in piedi.
'),
+ 'listmust' => array( 'it' => 'Per andare in isolamento non bisogna essere seduti a tavoli non riservati.',
+ 'en' => 'To go to isolation you must don\'t stay on not reserved tables'),
+
+ 'tit_onauth'=>array( 'it' => '(solo aut.)',
+ 'en' => '(only aut.)'),
+ 'tit_onisol'=>array( 'it' => '(isolam.to)',
+ 'en' => '(isolation)'),
+ 'db_failed' =>array('it' => ' Il collegamento al database è fallito. Temporaneamente tutte le autenticazioni verranno sospese, accederai a Brisk come un utente normale.
Ci scusiamo per il disagio.',
+ 'en' => 'Connection to the database failed All authentications are suspended temporarly, you login as normal user. We are about the limitation')
+
+
+);
+
+$G_lng = langtolng($G_lang);
$G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "2.1.7 - trusty";
+$G_brisk_version = "3.5.3";
/* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = Array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': menu comandi, filtro opzionale sui non autenticati e "return bug" corretto.',
- 'Se vuoi iscriverti alla Mailing List, cliccala!' );
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': terza versione di test per la nuova gestione dei dati volatili, rivista gestione del ticker.',
+ 'Se vuoi iscriverti alla Mailing List, cliccala!' ),
+ 'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NEWS: third test version for the new volatile data management, ticker management refactored.',
+ 'If you want to subscribe our Mailing List, click it!' ) );
-$G_room_help= '
+$G_room_help = array( 'it' => '
Descrizione
Questa è un\'implementazione della briscola in cinque, così come è spiegata su
@@ -110,23 +166,177 @@ Dopo che è iniziata una partita per uscirne dovete chiedere agli altri gi
/nick <nuovo_nickname> - cambio di nickname
/tav <frase di invito> - invito per gli altri giocatori al tavolo dove si è seduti
/st <stato> - cambia l\'icona associata al tuo user; stato può valere: \\"normale\\", \\"fuori\\", \\"pausa\\", \\"cibo\\", \\"cane\\", \\"lavoro\\", \\"presente\\" oppure \\"sigaretta\\"
-
/garante - se si è autenticati permette di garantire per un utente fidato
+
/authreq - se si è autenticati permette di garantire per un utente fidato
/mesgtoadm - se si è autenticati permette di lasciare un messaggio all\'amministratore del sito
/listen <all or auth> - se si è autenticati permette leggere solo i messaggi degli altri autenticati (auth) o di tutti (all)
-';
+',
+
+'en' => '
+
+EN Descrizione
+EN Questa è un\'implementazione della briscola in cinque, così come è spiegata su
+Wikipedia; in breve è la variante con l\'asta prima sulla carta e poi sui punti.
+EN Configurazione del browser.
+Occorre abilitare i cookies.
+
+Uso del sito
+Potete sedervi a un tavolo o rimanere in piedi.
+Se al vostro tavolo si raggiungono i 5 giocatori inizia automaticamente la partita.
+
+Partita
+All\'inizio vengono distribuite le carte e parte l\'asta; per partecipare all\'asta, quando sarà il vostro turno, potrete scegliere se andare avanti o passare cliccando sulle icone corrispondenti. Se si arriva ai punti, scrivete nella textbox il vostro rilancio e cliccate PUNTI.
+Chi vince l\'asta dovrà decidere il seme della carta scelta e inizierà la mano.
+Per giocare le carte dovrete trascinarle nel quadrato al centro del vostro schermo.
+Il vostro turno è sempre segnalato da una cornice verde lampeggiante intorno al quadrato al centro del vostro schermo.
+Durante la partita, se vorrete ricaricare la pagina, usate l\'apposito bottone \\"reload\\" in basso a destra.
+Dopo che è iniziata una partita per uscirne dovete chiedere agli altri giocatori di sbloccarla cliccando sul lucchetto. Se non si segue questa prassi, una volta usciti, non vi potrete sedere a nessun tavolo per '.floor(BAN_TIME/60).' minuti.
+
+
Comandi della chat
+
/nick <nuovo_nickname> - cambio di nickname
+
/tav <frase di invito> - invito per gli altri giocatori al tavolo dove si è seduti
+
/st <stato> - cambia l\'icona associata al tuo user; stato può valere: \\"normale\\", \\"fuori\\", \\"pausa\\", \\"cibo\\", \\"cane\\", \\"lavoro\\", \\"presente\\" oppure \\"sigaretta\\"
+
/authreq - se si è autenticati permette di garantire per un utente fidato
+
/mesgtoadm - se si è autenticati permette di lasciare un messaggio all\'amministratore del sito
+
/listen <all or auth> - se si è autenticati permette leggere solo i messaggi degli altri autenticati (auth) o di tutti (all)
+
+
+');
//
+$G_room_passwdhowto = array( 'it' => '
Come registrarsi su Brisk
+
+Attualmente ci sono due metodi per ottenere una password sul sito:
+
+
Facendosi garantire da un utente di Brisk che già possidede una password
+
Auto-garantendosi utilizzando uno dei seguenti sistemi di identificazione digitale:
+
+
Carta Regionale dei Servizi della Lombardia (la tessera sanitaria)
+
Carta Regionale dei Servizi del Friuli Venezia Giulia (la tessera sanitaria)
+
Smart card di InfoCamere
+
+
+Per auto-garantisi occorre possedere:
+
+
il codice PIN della propria carta
+
il lettore di smart-card per collegare la carta al PC (acquistabile di solito presso le edicole)
+
+
+Per effettuare la registrazione collegarsi al sito:
');
+
+$escinp_from = array( "\"" );
+$escinp_to = array( """ );
+
+function escinput($s)
+{
+ GLOBAL $escinp_from, $escinp_to;
+
+ return str_replace($escinp_from, $escinp_to, $s);
+}
+
+function eschtml($s)
+{
+ return htmlentities($s);
+}
+
+function esclfhtml($s)
+{
+ return str_replace("\n", " \n", htmlentities($s));
+}
+
+
+function langtolng($lang)
+{
+ GLOBAL $G_lang;
+ return ($G_lang == 'en' ? '-en' : '');
+}
+
+function csplitter($in, $sep)
+{
+ $st = 0;
+ $id = 0;
+ $out = array();
+ $out[$id] = "";
+ for ($i = 0 ; $i < strlen($in) ; $i++) {
+ $ini = substr($in, $i, 1);
+ if ($st == 0) {
+ if ($ini == '\\')
+ $st = 1;
+ else if ($ini == $sep) {
+ $id++;
+ $out[$id] = "";
+ }
+ else {
+ $out[$id] .= $ini;
+ }
+ }
+ else if ($st == 1) {
+ $out[$id] .= $ini;
+ $st = 0;
+ }
+ }
+
+ return ($out);
+}
function xcape($s)
{
@@ -153,6 +363,23 @@ function xcapemesg($s)
}
+class Vect {
+ function Vect($a)
+ {
+ $this->el = $a;
+ }
+
+ function getbyid($idx)
+ {
+ return ($this->el[$idx]);
+ }
+
+ function setbyid($idx, $v)
+ {
+ $this->el[$idx] = $v;
+ }
+}
+
class Table {
var $idx;
var $player;
@@ -173,19 +400,17 @@ class Table {
{
}
- function &create($idx)
+ function create($idx)
{
- GLOBAL $G_false;
-
- if (($thiz =& new Table()) == FALSE)
- return ($G_false);
+ if (($thiz = new Table()) == FALSE)
+ return (FALSE);
$thiz->idx = $idx;
$thiz->player = array();
$thiz->player_n = 0;
$thiz->auth_only = FALSE;
- $thiz->wag_own = NULL;
+ $thiz->wag_own = -1;
$thiz->wag_com = "";
$thiz->wag_tout = 0;
@@ -197,10 +422,8 @@ class Table {
return ($thiz);
}
- function copy(&$from)
+ function copy($from)
{
- GLOBAL $G_false;
-
$this->idx = $from->idx;
$this->player = array();
for ($i = 0 ; $i < $from->player_n ; $i++)
@@ -221,24 +444,20 @@ class Table {
$this->wakeup_time = $from->wakeup_time;
}
- function &clone(&$from)
+ function myclone($from)
{
- GLOBAL $G_false;
-
- if (($thiz =& new Table()) == FALSE)
- return ($G_false);
+ if (($thiz = new Table()) == FALSE)
+ return (FALSE);
$this->copy($from);
return ($thiz);
}
- function &spawn(&$from)
+ function spawn($from)
{
- GLOBAL $G_false;
-
- if (($thiz =& new Table()) == FALSE)
- return ($G_false);
+ if (($thiz = new Table()) == FALSE)
+ return (FALSE);
$thiz->idx = $from->idx;
$thiz->player = array();
@@ -260,11 +479,11 @@ class Table {
return ($thiz);
}
- function wag_set(&$user, $mesg)
+ function wag_set($user_idx, $mesg)
{
log_main("WAG_SET");
- $this->wag_own = &$user;
+ $this->wag_own = $user_idx;
$this->wag_com = $mesg;
$this->wag_tout = 0;
}
@@ -274,17 +493,17 @@ class Table {
log_main("WAG_RESET");
unset($this->wag_own);
- $this->wag_own = NULL;
+ $this->wag_own = -1;
$this->wag_com = "";
$this->wag_tout = $timeout;
}
- function getPlayer($idx)
+ function player_get($idx)
{
return ($this->player[$idx]);
}
- function setPlayer($idx, $player)
+ function player_set($idx, $player)
{
$this->player[$idx] = $player;
}
@@ -297,7 +516,7 @@ class Table {
return ($this->player_n - 1);
}
- function user_rem(&$room, &$user)
+ function user_rem($room, $user)
{
$tabpos = $user->table_pos;
@@ -307,7 +526,7 @@ class Table {
/* aggiorna l'array dei giocatori al tavolo. */
for ($i = $tabpos ; $i < $this->player_n-1 ; $i++) {
$this->player[$i] = $this->player[$i+1];
- $user_cur = &$room->user[$this->player[$i]];
+ $user_cur = $room->user[$this->player[$i]];
$user_cur->table_pos = $i;
}
$this->player_n--;
@@ -323,7 +542,7 @@ class Table {
// ($this->table[$i]->auth_only == FALSE ? TRUE : $user->flags & USER_FLAG_AUTH));
// function act_content($isstanding, $sitted, $table, $cur_table, $allowed)
- function act_content(&$user)
+ function act_content($user)
{
$ret = "";
$isstanding = ($user->subst == 'standup');
@@ -365,7 +584,12 @@ class Table {
// User flags
define(USER_FLAG_AUTH, 0x02);
+
+define(USER_FLAG_MAP_AUTH, 0x0c);
define(USER_FLAG_LISTAUTH, 0x04);
+define(USER_FLAG_ISOLAUTH, 0x08);
+
+define(USER_FLAG_DBFAILED, 0x10);
// user status
define(USER_FLAG_S_NORM, 0x000); // done
@@ -376,10 +600,25 @@ define(USER_FLAG_S_EAT, 0x400); // done
define(USER_FLAG_S_WRK, 0x500); // done
define(USER_FLAG_S_SMK, 0x600); // done
define(USER_FLAG_S_EYE, 0x700); // done
+define(USER_FLAG_S_RABB, 0x800); // done
+define(USER_FLAG_S_SOCC, 0x900); // done
+define(USER_FLAG_S_BABY, 0xa00); // done
+define(USER_FLAG_S_MOP, 0xb00); // done
define(USER_FLAG_S_ALL, 0xf00); // done
+/* type of user normal, supporter etc ... */
+define(USER_FLAG_TY_ALL, 0xff0000); // done
+define(USER_FLAG_TY_NORM, 0x010000); // done
+define(USER_FLAG_TY_SUPER, 0x020000); // done
+// ... other usefull status ...
+define(USER_FLAG_TY_SUSPEND, 0x400000); // done
+define(USER_FLAG_TY_DISABLE, 0x800000); // done
+
class User {
+ var $idx; // index in the users array when you are in game
+ var $idx_orig; // index in the users array when you aren't in game
+ var $code; // authentication code
var $name; // name of the user
var $sess; // session of the user
var $ip; // ip of the user
@@ -398,8 +637,8 @@ class User {
// FIXME: the table_orig field must be removed after table field verify of index management (in spawned table
// it is allways ZERO
- var $table_orig; // id of the current table (if in table state)
- var $table; // id of the current table (if in table state)
+ var $table; // id of the current table when you are in game
+ var $table_orig; // id of the current table when you aren't in game
var $table_pos; // idx on the table
var $table_token;// token that identify a game on a table
var $flags; // Bitfield with: AUTHENTICATE: 0x02
@@ -410,51 +649,55 @@ class User {
var $chat_cur; // Current chat line number
var $chat_ban; // Time for ban chat
var $chat_dlt; // Delta t for ban
+ var $shm_sz;
+
function User() {
}
- function &create($name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") {
- GLOBAL $G_false;
-
- if (($thiz =& new User()) == FALSE)
- return ($G_false);
-
- $thiz->name = $name;
- $thiz->sess = $sess;
- $thiz->ip = $ip;
- $thiz->lacc = time();
- $thiz->laccwr = time();
- $thiz->bantime = 0;
- $thiz->stat = $stat;
- $thiz->subst = $subst;
- $thiz->step = 1;
- $thiz->trans_step = -1;
- $thiz->comm = array();
- $thiz->asta_card = -2;
- $thiz->asta_pnt = -1;
- $thiz->handpt = -1;
+ function create($idx, $name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") {
+ if (($thiz = new User()) == FALSE)
+ return (FALSE);
+
+ $thiz->idx = $idx;
+ $thiz->idx_orig = $idx;
+ $thiz->code = -1;
+ $thiz->name = $name;
+ $thiz->sess = $sess;
+ $thiz->ip = $ip;
+ $thiz->lacc = time();
+ $thiz->laccwr = time();
+ $thiz->bantime = 0;
+ $thiz->stat = $stat;
+ $thiz->subst = $subst;
+ $thiz->step = 1;
+ $thiz->trans_step = -1;
+ $thiz->comm = array();
+ $thiz->asta_card = -2;
+ $thiz->asta_pnt = -1;
+ $thiz->handpt = -1;
$thiz->exitislock = TRUE;
- $thiz->flags = 0x00;
+ $thiz->flags = 0x00;
- $thiz->chattime = array_fill(0, CHAT_N, 0);
- $thiz->chat_cur = 0;
- $thiz->chat_lst = "";
- $thiz->chat_ban = 0;
- $thiz->chat_dlt = 0;
+ $thiz->chattime = array_fill(0, CHAT_N, 0);
+ $thiz->chat_cur = 0;
+ $thiz->chat_lst = "";
+ $thiz->chat_ban = 0;
+ $thiz->chat_dlt = 0;
$thiz->table_orig = $table;
$thiz->table = $table;
- $thiz->table_pos = -1;
- $thiz->table_token = "";
-
+ $thiz->table_pos = -1;
+ $thiz->table_token= "";
+ $thiz->shm_sz = SHM_DIMS_U_MIN;
return ($thiz);
}
- function copy(&$from)
+ function copy($from)
{
- GLOBAL $G_false;
-
+ $this->idx = $from->idx;
+ $this->idx_orig = $from->idx;
+ $this->code = $from->code;
$this->name = $from->name;
$this->sess = $from->sess;
$this->ip = $from->ip;
@@ -469,53 +712,54 @@ class User {
$i_start = (1 > ($from->step - COMM_N) ? 1 : ($from->step - COMM_N));
for ($i = $i_start ; $i < $from->step ; $i++) {
- $ii = $i % COMM_N;
- $this->comm[$ii] = $from->comm[$ii];
+ $ii = $i % COMM_N;
+ if (isset($from->comm[$ii])) {
+ $this->comm[$ii] = $from->comm[$ii];
+ }
}
$this->asta_card = $from->asta_card;
$this->asta_pnt = $from->asta_pnt;
$this->handpt = $from->handpt;
$this->exitislock = $from->exitislock;
- $this->flags = $from->flags;
+ $this->flags = $from->flags;
- $this->chattime = array();
+ $this->chattime = array();
for ($i = 0 ; $i < CHAT_N ; $i++)
$this->chattime[$i] = $from->chattime[$i];
- $this->chat_cur = $from->chat_cur;
- $this->chat_lst = $from->chat_lst;
- $this->chat_ban = $from->chat_ban;
- $this->chat_dlt = $from->chat_dlt;
+ $this->chat_cur = $from->chat_cur;
+ $this->chat_lst = $from->chat_lst;
+ $this->chat_ban = $from->chat_ban;
+ $this->chat_dlt = $from->chat_dlt;
$this->table_orig = $from->table_orig;
$this->table = $from->table;
$this->table_pos = $from->table_pos;
$this->table_token = $from->table_token;
$this->the_end = $from->the_end;
-
+ $this->shm_sz = $from->shm_sz;
return (TRUE);
}
- function &clone(&$from)
+ function myclone($from)
{
- GLOBAL $G_false;
-
- if (($thiz =& new User()) == FALSE)
- return ($G_false);
+ if (($thiz = new User()) == FALSE)
+ return (FALSE);
$thiz->copy($from);
return ($thiz);
}
- function &spawn(&$from, $table, $table_pos)
+ function spawn($from, $table, $table_pos)
{
- GLOBAL $G_false;
-
- if (($thiz =& new User()) == FALSE)
- return ($G_false);
+ if (($thiz = new User()) == FALSE)
+ return (FALSE);
+ $thiz->idx = $from->idx;
+ $thiz->idx_orig = $from->idx;
+ $thiz->code = $from->code;
$thiz->name = $from->name;
$thiz->sess = $from->sess;
$thiz->ip = $from->ip;
@@ -555,9 +799,18 @@ class User {
$thiz->table = 0;
$thiz->table_pos = $table_pos;
$thiz->table_token = $from->table_token;
+ $thiz->shm_sz = $from->shm_sz;
return ($thiz);
}
+
+ function idx_get() {
+ return ($this->idx);
+ }
+
+ function code_get() {
+ return ($this->code);
+ }
function stat_set($stat) {
log_main("sess: [".$this->sess. "] NEW STAT: [".$stat."]");
@@ -566,7 +819,7 @@ class User {
/*
if (validate_sess($this->sess)) {
if (file_exists(PROXY_PATH) == FALSE)
- mkdir(PROXY_PATH);
+ mkdir(PROXY_PATH, 0775, TRUE);
$fp = fopen(PROXY_PATH."/".$this->sess.".stat", 'w');
fwrite($fp, sprintf("%s\n",$this->stat));
fclose($fp);
@@ -574,39 +827,69 @@ class User {
*/
}
- function step_set($step) {
- $this->step = $step;
-
- do {
- if (validate_sess($this->sess) == FALSE)
- break;
- if (file_exists(PROXY_PATH) == FALSE)
- mkdir(PROXY_PATH);
- if (($fp = @fopen(PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE)
- break;
- fwrite($fp, pack("l",$this->step), 4);
- fclose($fp);
-
+ function step_set($step)
+ {
+ $this->step = $step & 0x7fffffff;
+
return (TRUE);
- } while (0);
-
- return (FALSE);
}
function step_inc($delta = 1) {
- $this->step += $delta;
-
- if (validate_sess($this->sess)) {
- if (file_exists(PROXY_PATH) == FALSE)
- mkdir(PROXY_PATH);
- $fp = fopen(PROXY_PATH."/".$this->sess.".step", 'w');
- fwrite($fp, pack("l",$this->step), 4);
- fclose($fp);
+ $this->step += $delta;
+ /* modularization because unpack() not manage unsigned 32bit int correctly */
+ $this->step &= 0x7fffffff;
+
+ return TRUE;
+ }
- return (TRUE);
- }
-
- return (FALSE);
+ function save_step()
+ {
+ do {
+ if (validate_sess($this->sess) == FALSE)
+ break;
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH, 0775, TRUE);
+ if (($fp = @fopen(PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE)
+ break;
+ fwrite($fp, pack("LL",$this->step, $this->idx));
+ fclose($fp);
+
+ log_main("step_set [".$this->sess. "] [".$this->step."]");
+
+ return (TRUE);
+ } while (0);
+
+ return (FALSE);
+ }
+
+ static function load_step($sess)
+ {
+ $fp = FALSE;
+ do {
+ if (validate_sess($sess) == FALSE)
+ break;
+
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH, 0775, TRUE);
+ if (($fp = @fopen(PROXY_PATH."/".$sess.".step", 'rb')) == FALSE)
+ break;
+ if (($s = fread($fp, 8)) == FALSE)
+ break;
+ if (mb_strlen($s, "ASCII") != 8)
+ break;
+ $arr = unpack('Ls/Li', $s);
+ fclose($fp);
+
+ // log_rd2("A0: ".$arr[0]." A1: ".$arr[1]);
+ return ($arr);
+ } while (0);
+
+ if ($fp != FALSE)
+ fclose($fp);
+
+ log_rd2("STEP_GET [".$sess."]: return false ");
+
+ return (FALSE);
}
function reset() {
@@ -626,42 +909,109 @@ class User {
$this->chat_dlt = 0;
$this->the_end = FALSE;
}
-} // end class User
-
-
-
-
-
-
-function step_get($sess) {
- $fp = FALSE;
- do {
- if (validate_sess($sess) == FALSE)
- break;
-
- if (file_exists(PROXY_PATH) == FALSE)
- mkdir(PROXY_PATH);
- if (($fp = @fopen(PROXY_PATH."/".$sess.".step", 'rb')) == FALSE)
- break;
- if (($s = fread($fp, 4)) == FALSE)
- break;
- if (strlen($s) != 4)
- break;
- $arr = unpack('l', $s);
- fclose($fp);
+ static function load_data($id, $sess)
+ {
+ log_main("load_data: id [".$id."] sess [".($sess == FALSE ? "FALSE" : $sess)."] ");
+
+ do {
+ if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) {
+ log_main("ftok failed");
+ break;
+ }
+
+ if (($shm_sz = sharedmem_sz($tok)) == -1) {
+ log_main("shmop_open failed");
+ }
+
+ if ($shm_sz == -1)
+ $shm_sz = SHM_DIMS_U_MIN;
+
+ if ($shm = shm_attach($tok, $shm_sz)) {
+ $user = @shm_get_var($shm, $tok);
+
+ if ($sess != FALSE && $user->sess != $sess) {
+ break;
+ }
+ log_only("user == ".($user == FALSE ? "FALSE" : "TRUE")." user === ".($user === FALSE ? "FALSE" : "TRUE")." user isset ".(isset($user) ? "TRUE" : "FALSE"));
+
+ if ($user == FALSE) {
+ log_only("INIT MAIN DATA");
+
+ // SHSPLIT FIXME: init_data for User class ??
+ $user = User::create($id, "", "");
+ if (@shm_put_var($shm, $tok, $user) == FALSE) {
+ log_only("PUT_VAR FALLITA ".strlen(serialize($user)));
+ log_only(serialize($user));
+ }
+ }
+ else {
+ if ($sess != FALSE) {
+ /*
+ * NOTE: this part is for check only, theoretically
+ * user->step anch proxy_step are set allways at the same value
+ */
+ $old_step = $user->step;
+ $arr = User::load_step($sess);
+ $user->step = $arr['s'];
+ if ($old_step != $user->step) {
+ log_crit("steps are diffetents User->step ".$user->step." Old_step: ".$old_step);
+ }
+ }
+ }
+ $user->shm_sz = $shm_sz;
+
+ shm_detach($shm);
+ }
+
+ //
+ // SHSPLIT: load users from the shared memory
+ //
+ return ($user);
+ } while (0);
+
+ return (FALSE);
+ }
+
- // log_rd2("A0: ".$arr[0]." A1: ".$arr[1]);
- return ($arr[1]);
- } while (0);
+ static function save_data($user, $id)
+ {
+ GLOBAL $sess;
+
+ $shm = FALSE;
+
+ if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) {
+ return (FALSE);
+ }
+ while ($user->shm_sz < SHM_DIMS_U_MAX) {
+ if (($shm = shm_attach($tok, $user->shm_sz)) == FALSE)
+ break;
+
+ // log_only("PUT_VAR DI ".strlen(serialize($user)));
+ if (shm_put_var($shm, $tok, $user) != FALSE) {
+ shm_detach($shm);
+ if ($user->sess != "")
+ $user->save_step();
+ log_main("User[".$id."] saved.");
+ return (TRUE);
+ }
+ if (shm_remove($shm) === FALSE) {
+ log_only("REMOVE FALLITA");
+ break;
+ }
+ shm_detach($shm);
+ $user->shm_sz += SHM_DIMS_U_DLT;
+ }
+
+ if ($shm)
+ shm_detach($shm);
+
+ return (FALSE);
+ }
- if ($fp != FALSE)
- fclose($fp);
- log_rd2("STEP_GET: return false ");
+} // end class User
- return (FALSE);
-}
function step_unproxy($sess) {
log_rd2("UNPROXY: ".PROXY_PATH."/".$sess.".step");
@@ -672,11 +1022,13 @@ function step_unproxy($sess) {
class Room {
+ static $delta_t;
+
var $user;
var $table;
var $comm; // commands for many people
var $step; // current step of the comm array
- var $garbage_timeout;
+ // externalized var $garbage_timeout;
var $shm_sz;
function Room () {
@@ -684,11 +1036,11 @@ class Room {
$this->table = array();
for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $this->user[$i] =& User::create("", "");
+ $this->user[$i] = User::create($i, "", "");
}
for ($i = 0 ; $i < TABLES_N ; $i++) {
- $this->table[$i] =& Table::create($i);
+ $this->table[$i] = Table::create($i);
/* OLD METHOD
if ($i < 12) {
$row = ( (((int)($i / 4)) % 2) == 0 );
@@ -699,40 +1051,46 @@ class Room {
$this->table[$i]->auth_only = FALSE;
}
*/
- if ($i < 12)
+ if ($i < TABLES_AUTH_N)
$this->table[$i]->auth_only = TRUE;
else
$this->table[$i]->auth_only = FALSE;
}
- $this->garbage_timeout = 0;
+ // externalized $this->garbage_timeout = 0;
+ Room::garbage_time_expire_set(0);
+ $this->shm_sz = SHM_DIMS_MIN;
}
function garbage_manager($force)
{
+ GLOBAL $G_lang, $mlang_brisk, $G_base;
+
$ismod = FALSE;
log_rd2("garbage_manager START");
/* Garbage collector degli utenti in timeout */
$curtime = time();
- if ($force || $this->garbage_timeout < $curtime) {
+
+ // externalized if ($force || $this->garbage_timeout < $curtime) {
+ if ($force || Room::garbage_time_is_expired($curtime)) {
// FIXME BRISK4: include for each kind of table
- require_once("briskin5/Obj/briskin5.phh");
+ require_once("${G_base}briskin5/Obj/briskin5.phh");
// Before all align times with table timeout
for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
- $table_cur =& $this->table[$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) {
log_main("PLAYERS == N TABLE ".$table_idx);
- if (($sem = Briskin5::lock_data($table_idx)) != FALSE) {
+ if (($sem = Bin5::lock_data($table_idx)) != FALSE) {
log_main("bin5 lock data success");
$no_recovery = FALSE;
- if (($bri = &Briskin5::load_data($table_idx)) != FALSE) {
+ if (($bri = Bin5::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);
@@ -748,11 +1106,11 @@ class Room {
log_main("garbage_manager: bri loaded successfully.");
$bri->garbage_manager(TRUE);
- $bri_table = &$bri->table[0];
+ $bri_table = $bri->table[0];
// is the end of the table
if ($bri->the_end == TRUE) {
- /*
+ /*
* DESTROY OF FINISHED TABLE && MOVE PLAYER TO ROOM AGAIN
*/
log_main("garbage_manager: INSIDE THE END.");
@@ -764,8 +1122,8 @@ class Room {
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 = $this->user[$table_cur->player[$i]];
+ $bri_user = $bri->user[$i];
$user_cur->subst = $bri_user->subst;
$user_cur->step = $bri_user->step;
@@ -776,10 +1134,10 @@ class Room {
log_legal($curtime, $user_cur, "STAT:DESTROY_GAME", $plist);
- $this->room_join_wakeup(&$user_cur, FALSE, 0);
+ $this->room_join_wakeup($user_cur, FALSE, 0);
$table_cur->table_token = "";
$table_cur->wakeup_time = $curtime + WAKEUP_TIME;
- Briskin5::destroy_data($table_idx);
+ Bin5::destroy_data($table_idx);
}
else {
log_main("gm:: save_data");
@@ -788,20 +1146,22 @@ class Room {
$this->user[$table_cur->player[$i]]->lacc = $bri->user[$i]->lacc;
}
- Briskin5::save_data(&$bri);
+ Bin5::save_data($bri);
}
- } // else if (($bri = &Briskin5::load_data($table_idx)) != FALSE) {
+ } // else if (($bri = Bin5::load_data($table_idx)) != 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 = $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)."; ";
- $ret .= show_notify(" I dati del tavolo n° ".$user_cur->table." sono inconsistenti, verranno resettati.
Torni in piedi.
", 2000, "Chiudi.", 400, 110);
+ // MLANG I dati del tavolo n° ".$user_cur->table." sono inconsistenti, verranno resettati.
Torni in piedi.
+ $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();
}
@@ -812,11 +1172,11 @@ class Room {
}
log_legal($curtime, $user_cur, "STAT:DESTROY_GAME(RECOVERY)", $plist);
- $this->room_join_wakeup(&$user_cur, TRUE, -2);
+ $this->room_join_wakeup($user_cur, TRUE, -2);
$table_cur->table_token = "";
}
- Briskin5::unlock_data($sem);
+ Bin5::unlock_data($sem);
} // bri::lock_data
} // if ($table_cur->player_n == PLAYERS_N) {
} // for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
@@ -824,7 +1184,7 @@ class Room {
log_rd2("out new loop.");
for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $user_cur = &$this->user[$i];
+ $user_cur = $this->user[$i];
log_rd2("User: ".$user_cur->name." stat: ".$user_cur->stat." subst: ".$user_cur->subst);
@@ -842,9 +1202,9 @@ class Room {
log_rd2("AUTO LOGOUT.");
if ($user_cur->subst == 'sitdown' || $user_cur->stat == 'table')
- $this->room_wakeup(&$user_cur);
+ $this->room_wakeup($user_cur);
else if ($user_cur->subst == 'standup')
- $this->room_outstandup(&$user_cur);
+ $this->room_outstandup($user_cur);
else
log_rd2("LOGOUT FROM WHAT ???");
}
@@ -852,31 +1212,36 @@ class Room {
if ($user_cur->laccwr + EXPIRE_TIME_SMAMMA < $curtime) { // lo rimettiamo in piedi
if ($user_cur->stat == 'room' && $user_cur->subst == 'sitdown') {
- $this->room_wakeup(&$user_cur);
+ $this->room_wakeup($user_cur);
$user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
/* MLANG: Sei stato inattivo per ".(EXPIRE_TIME_SMAMMA/60.0)." minuti.
Quindi ritorni tra i Giocatori in piedi.", "torna ai tavoli" */
- $user_cur->comm[$user_cur->step % COMM_N] .= show_notify(" Sei stato inattivo per ".(EXPIRE_TIME_SMAMMA/60.0)." minuti.