Commits

Peter Hosey committed 1968950

Really fix removing by separating the number of removals from the numbers of outgoing and incoming connections.

Peers' removing property is now a bool.

  • Participants
  • Parent commits 13a0728

Comments (0)

Files changed (1)

   float shue;
   int bandwidth; //Time to send exactly one Bit to one peer
   color ccolor;
-  int removing;
+  int incoming; //Number of incoming bit-streams
+  bool removing;
   int lastcheck;
   ArrayList knex;
   ArrayList actBits;
       for (int o = 0; o < peers.size(); o++)
       {
         Peer p = (Peer)peers.get(o);
-        if (p.myBits.contains(b) && !(p.removing > 0) && !(removing > 0) 
+        if (p.myBits.contains(b) && !(p.removing) && !(removing > 0) 
             && !p.knex.contains((Peer)peers.get(index)) && p.index != index && 
             !actBits.contains(b))
         {
     if (k.knex.size() < 4) {
       Connection mz = new Connection(k, (Peer)peers.get(index), j);
       k.knex.add(peers.get(index));
+      ++incoming;
       actBits.add(j);
       connections.add(mz);
     }
 
   void manageKibbles()
   {
-    if (from.removing >= 1 || to.removing >= 1 || deadkibbles > 125)
+    if (from.removing || to.removing || deadkibbles > 125)
     { 
       stream = false;  
     }
 {
   int i = 0;
   Peer toRemove = (Peer)peers.get(i);
-  toRemove.removing = 1;
+  toRemove.removing = true;
 }
 
 void keyPressed()
 
     if ( c.kibbles.isEmpty() && c.stream == false )
     {
-      if (c.to.removing >= 1)
-      { 
-        c.to.removing++;
-      }
-      if (c.from.removing >= 1)
-      { 
-        c.from.removing++;
-      }
+      c.to.incoming--;
 
       c.from.knex.remove(c.from.knex.indexOf(c.to));
       c.to.myBits.add(c.theBit);
     p.moveSelf();
     p.drawSelf();
     p.reConfigure(i);
-    if (p.removing > 1)
+    if (p.removing && p.knex.size() < 1 && p.incoming < 1)
     {
       peers.remove(i);
     } else {