unproxy functions refactored
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 18 May 2011 21:21:21 +0000 (23:21 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 18 May 2011 21:21:21 +0000 (23:21 +0200)
web/Obj/brisk.phh
web/briskin5/Obj/briskin5.phh

index 38bc1cf..4abdd86 100644 (file)
@@ -893,13 +893,20 @@ class User {
       return (FALSE);
   }
 
+  static function unproxy_step($sess) {
+      log_rd2("UNPROXY: ".PROXY_PATH."/".$sess.".step");
+      if (file_exists(PROXY_PATH) == FALSE)
+          return;
+      @unlink(PROXY_PATH."/".$sess.".step");
+  }
+
   function reset() {
     $curtime = time();
     log_legal($curtime, $this, "STAT:LOGOUT", '');
 
     $tmp_sess = $this->sess;
     $this->sess = "";
-    step_unproxy($tmp_sess);
+    self::unproxy_step($tmp_sess);
     $this->name = "";  // OK here
     while (array_pop($this->comm) != NULL);
     $this->step = 0;
@@ -1019,13 +1026,6 @@ class User {
 } // end class User
 
 
-function step_unproxy($sess) {
-  log_rd2("UNPROXY: ".PROXY_PATH."/".$sess.".step");
-  if (file_exists(PROXY_PATH) == FALSE)
-    mkdir(PROXY_PATH);
-  @unlink(PROXY_PATH."/".$sess.".step");
-}
-
 
 class Room {
     static $delta_t;
index ce2bdb8..7b26f01 100644 (file)
@@ -570,6 +570,14 @@ class Bin5_user extends User {
         return (FALSE);
     }
     
+    static function unproxy_step($tab_id, $sess)
+    {
+        log_rd2("UNPROXY: ".BIN5_PROXY_PATH."/table".$tab_id."/".$sess.".step");
+        if (file_exists(BIN5_PROXY_PATH."/table".$tab_id) == FALSE)
+            return;
+
+        @unlink(BIN5_PROXY_PATH."/table".$tab_id."/".$sess.".step");
+    }
     
     static function load_data($tab_id, $id, $sess) 
     {
@@ -779,7 +787,7 @@ class Bin5 {
 
            $tmp_sess = $user_cur->sess;
            $user_cur->sess = "";
-           step_unproxy($tmp_sess);
+           Bin5_user::step_unproxy($tmp_sess);
            $user_cur->name = "";
            $user_cur->the_end = FALSE;
            
@@ -925,9 +933,12 @@ class Bin5 {
     log_main("DESTROY BRISKIN5 DATA");
     
     do {
-      log_main("DESTROY2 BRISKIN5 DATA");
-
-      if (($tok = @ftok(FTOK_PATH."/bin5/table".$table_idx."/table", "B")) == -1) 
+      log_main("DESTROY2 BRISKIN5 DATA [".$this->table_idx."]");
+      for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
+          $this->user[$i]->destroy_data($this->table_idx);
+          Bin5_user::unproxy_step($this->table_idx, $this->user[$i]->sess);
+      }
+      if (($tok = @ftok(FTOK_PATH."/bin5/table".$this->table_idx."/table", "B")) == -1) 
        break;
 
       if (($shm = @shmop_open($tok, 'a', 0, 0)) == FALSE)