define(FTOK_PATH, "/var/lib/brisk");
define(LEGAL_PATH, "/tmp/legal_brisk");
define(PROXY_PATH, "/var/lib/brisk_proxy");
-define(TABLES_N, 8);
+define(TABLES_N, 12);
define(PLAYERS_N, 3);
define(MAX_POINTS, 5);
define(MAX_PLAYERS, (20 + (PLAYERS_N * TABLES_N)));
-define(SHM_DIMS, (80000 * MAX_PLAYERS));
+define(SHM_DIMS, (50000 * MAX_PLAYERS));
// define(COMM_N, 6);
define(COMM_N, 12);
define(COMM_GEN_N, 50);
$G_false = FALSE;
$G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "0.7.2";
+$G_brisk_version = "0.8.2";
-$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: ottimizzazione della CPU e chiuso il bug di mancato cambio pagina.',
+$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!' );
$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.');
$table = &$this->table[$user->table];
$user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
- $user_cur->comm[$user_cur->step % COMM_N] = sprintf('set_names(" %s", " %s", " %s", " %s", " %s"); ',
+ $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('set_names(" %s", " %s", " %s", " %s", " %s"); ',
xcape($this->user[$table->player[($user_cur->table_pos)%PLAYERS_N]]->name),
xcape($this->user[$table->player[($user_cur->table_pos+1)%PLAYERS_N]]->name),
xcape($this->user[$table->player[($user_cur->table_pos+2)%PLAYERS_N]]->name),
return (float) $sec + ((float) $usec * 100000);
}
+function log_only2($sess, $log) {
+ if (BRISK_DEBUG != TRUE)
+ return;
+
+
+ if (($fp = @fopen("/tmp/brisk_only2.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("SESS: [%s] [%s]\n", $sess, $log));
+ fclose($fp);
+ }
+}
+
function log_only($sess, $log) {
- /*
if (BRISK_DEBUG != TRUE)
return;
- */
+
if (($fp = @fopen("/tmp/brisk_only.log", 'a')) != FALSE) {
fwrite($fp, sprintf("SESS: [%s] [%s]\n", $sess, $log));
function lock_data()
{
+ GLOBAL $sess;
+
// echo "LOCK: ".FTOK_PATH."/main";
// exit;
if (($tok = ftok(FTOK_PATH."/main", "B")) == -1) {
exit;
}
if (sem_acquire($res)) {
- log_lock("XXX", "LOCK");
+ log_only($sess, "LOCK");
return ($res);
}
else
function unlock_data($res)
{
- log_lock("XXX", "UNLOCK");
+ GLOBAL $sess;
+
+ log_only($sess, "UNLOCK");
return (sem_release($res));
}
function &load_data()
{
- GLOBAL $G_false;
+ GLOBAL $G_false, $sess;
if (($tok = ftok(FTOK_PATH."/main", "B")) == -1) {
echo "FTOK FAILED";
}
if ($shm = shm_attach($tok, SHM_DIMS)) {
- if(($bri = @shm_get_var($shm, $tok)) == FALSE) {
- log_only("XXX", "INIT MAIN DATA");
-
+ $bri = @shm_get_var($shm, $tok);
+
+ log_only($sess, "bri == ".($bri == FALSE ? "FALSE" : "TRUE")." bri === ".($bri === FALSE ? "FALSE" : "TRUE")." bri isset ".(isset($bri) ? "TRUE" : "FALSE"));
+ if (isset($bri))
+ log_only($sess, "bri count ".count($bri));
+
+ if ($bri == FALSE) {
+ log_only($sess, "INIT MAIN DATA");
+
$bri = init_data();
if (shm_put_var($shm, $tok, $bri) == FALSE) {
- log_only("XX2", "PUT_VAR FALLITA ".strlen(serialize($bri)));
- log_only("XX2", serialize($bri));
+ log_only($sess, "PUT_VAR FALLITA ".strlen(serialize($bri)));
+ log_only($sess, serialize($bri));
}
}
function save_data(&$bri)
{
+ GLOBAL $sess;
+
$ret = FALSE;
$shm = FALSE;
$isacq = FALSE;
if (($shm = shm_attach($tok, SHM_DIMS)) == FALSE)
break;
+ // log_only($sess, "PUT_VAR DI ".strlen(serialize($bri)));
if (shm_put_var($shm, $tok, $bri) == FALSE) {
- log_only("XXX", "PUT_VAR FALLITA ".strlen(serialize($bri)));
- log_only("XXX", serialize($bri));
+ log_only($sess, "PUT_VAR FALLITA ".strlen(serialize($bri)));
+ log_only($sess, serialize($bri));
break;
}
// log_main("XXX", "QUI CI ARRIVA [".$bri->user[0]->name."]");