From 8cd1d39fe726904208e1a125e947270a994788f7 Mon Sep 17 00:00:00 2001 From: Stefan Hacker Date: Mon, 27 Dec 2010 19:20:53 +0100 Subject: [PATCH] Add some legacy hacks for Ice 3.2 to bf2.py. It seems like it will never get the whole context stuff since it seems to truncate it at the first \0 it finds. --- modules/bf2.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/bf2.py b/modules/bf2.py index 92ebcfb..5a5a756 100644 --- a/modules/bf2.py +++ b/modules/bf2.py @@ -256,6 +256,8 @@ class bf2(MumoModule): state.context != self.sessions[sid][state.session].context: # identity or context changed => update update = True + else: + state.is_linked = self.sessions[sid][state.session].is_linked else: if state.identity or state.context: # New user with engaged plugin => update @@ -271,7 +273,10 @@ class bf2(MumoModule): splitcontext = state.context.split('\0', 1) if splitcontext[0] == "Battlefield 2": state.is_linked = True - + if state.identity and len(splitcontext) == 1: + #LEGACY: Assume broken Ice 3.2 which doesn't transmit context after \0 + splitcontext.append('{"ipport":""}') # Obviously this doesn't give full functionality but it doesn't crash either ;-) + if state.is_linked and len(splitcontext) == 2 and state.identity: try: context = json.loads(splitcontext[1]) @@ -306,6 +311,8 @@ class bf2(MumoModule): verify(identity, "team", basestring) if identity["team"] != "opfor" and identity["team"] != "blufor": raise ValueError("Invalid team identified") + #LEGACY: Ice 3.2 cannot handle unicode strings + identity["team"] = str(identity["team"]) state.parsedidentity = identity