CheeseLord / warts

WAcky Real Time Strategy
MIT License
1 stars 0 forks source link

Handling of multi-digit ids is (pretty badly) broken #4

Closed kronmillerg closed 8 years ago

kronmillerg commented 8 years ago

Currently, as soon as the tenth-or-later client joins, we just assert, at shared/message_infrastructure.py#83:

assert len(words) == self.count

That assert is probably invalid, because if self.count == 1 then words should just be a single word. But if you make that change:

     def encode(self, arg):
         words = self.encodeFunc(arg)
-        assert len(words) == self.count
+        if self.count == 1:
+            assert type(words) == str
+        else:
+            assert type(words) in [tuple, list]
+            assert len(words) == self.count
         return words

then you get much weirder problems. The ids start getting sent as multiple numbers, so when client number 11 joins, you start getting messages like:

which have too many arguments. Worse, somehow we aren't just crashing because the arities are wrong; instead, we read the number of arguments that we expect and ignore the extra ones. So, for example, movement is constrained to a single axis, and if another client joins then they both crash because they think both obelisks have id 1.