Commits

Andrew Godwin committed b8ec120

Stop bug where people can start a hill, then switch worlds.

  • Participants
  • Parent commits 048ff69

Comments (0)

Files changed (3)

File myne/plugins/blb.py

             
             # Draw all the blocks on, I guess
             # We use a generator so we can slowly release the blocks
+            # We also keep world as a local so they can't change worlds and affect the new one
+            world = self.client.world
             def generate_changes():
                 for i in range(x, x2+1):
                     for j in range(y, y2+1):
                         for k in range(z, z2+1):
                             try:
-                                self.client.world[i, j, k] = block
+                                world[i, j, k] = block
                             except AssertionError:
                                 self.client.sendServerMessage("Out of bounds blb error.")
                                 return
-                            self.client.queueTask(TASK_BLOCKSET, (i, j, k, block))
+                            self.client.queueTask(TASK_BLOCKSET, (i, j, k, block), world=world)
                             self.client.sendBlock(i, j, k, block)
                             yield
             

File myne/plugins/hill.py

         
         # Draw all the blocks on, I guess
         # We use a generator so we can slowly release the blocks
+        # We also keep world as a local so they can't change worlds and affect the new one
+        world = self.client.world
         def generate_changes():
             for i in range(x, x2+1):
                 for k in range(z, z2+1):
                     for j in range(y, y+dy+1):
                         block = BLOCK_GRASS if j == y+dy else BLOCK_DIRT
                         try:
-                            self.client.world[i, j, k] = chr(block)
+                            world[i, j, k] = chr(block)
                         except AssertionError:
                             pass
-                        self.client.queueTask(TASK_BLOCKSET, (i, j, k, block))
+                        self.client.queueTask(TASK_BLOCKSET, (i, j, k, block), world=world)
                         self.client.sendBlock(i, j, k, block)
                         yield
         

File myne/protocol.py

                 return result
         return None
     
-    def queueTask(self, task, data=[]):
+    def queueTask(self, task, data=[], world=None):
         "Adds the given task to the factory's queue."
-        self.factory.queue.put((
-            self,
-            task,
-            data,
-        ))
+        # If they've overridden the world, use that as the client.
+        if world:
+            self.factory.queue.put((
+                world,
+                task,
+                data,
+            ))
+        else:
+            self.factory.queue.put((
+                self,
+                task,
+                data,
+            ))
     
     def sendWorldMessage(self, message):
         "Sends a message to everyone in the current world."