var $wakeup_time;
+ var $cache;
+
function Table()
{
}
$thiz->wakeup_time = 0;
+ $thiz->cache = NULL;
+
return ($thiz);
}
$this->table_start = $from->table_start;
$this->wakeup_time = $from->wakeup_time;
+
+ $this->cache = $from->cache;
}
function myclone($from)
$thiz->wakeup_time = $from->wakeup_time;
+ $thiz->cache = $from->cache;
+
return ($thiz);
}
for ($i = 0 ; $i < TABLES_N ; $i++) {
- $ret .= $this->table_content($user, $i);
+ $ret .= $this->table_content($user, $i, TRUE);
$ret .= $this->table[$i]->act_content($user);
if ($this->table[$i]->wag_own != -1)
return ($content);
}
- function table_content($user, $table_idx)
+ function table_content($user, $table_idx, $use_cache=FALSE)
{
$content = "";
$ret = "";
$sess = $user->sess;
$table = $this->table[$table_idx];
+ $user_at_table = FALSE;
+
if ($user->stat != 'room')
return;
$user_cur_id = $user->idx_get();
+
+ # check if user at table
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ if ($user_cur_id == $table->player[$i]) {
+ $user_at_table = TRUE;
+ break;
+ }
+ }
+
+ if ($use_cache && !$user_at_table && $table->cache != NULL) {
+ return $table->cache;
+ }
+
$content = "[ ";
for ($i = 0 ; $i < $table->player_n ; $i++) {
$user_cur = $this->user[$table->player[$i]];
$content .= ' ]';
$ret .= sprintf('j_tab_cont(%d, %s);', $table_idx, $content);
-
+ if (! $user_at_table) {
+ $table->cache = $ret;
+ }
return ($ret);
}