def q4_make_goods(rbuf): overview = Overview(teamAname = 'Strogg', teamBname = 'Marines', teamAcolor = 0xffc37d, teamBcolor = 0x82ff8b) rules = [] rbuf = rbuf.split('\x00') if len(rbuf) % 2: rbuf.append('xxx') plusinfoitms = ('.players_strogg', '.players_marine', '.players_active', '.score_strogg', '.score_marine', '.score') plusinfo = {} for item in plusinfoitms: plusinfo[item[1:]] = [] for i in xrange(0, len(rbuf), 2): k = rbuf[i] v = rbuf[i+1] rules.append(Rule(k, v)) k = k.lower() if k == 'si_name': overview.hostname = v elif k == 'si_gametype': overview.type = v v = v.lower() if v in ('team dm', 'ctf'): overview.mode = 'team' elif v in ('tourney', 'duel'): overview.mode = '1v1' elif k == 'si_maxplayers': overview.maxplayers = int(v) elif k == 'si_map': overview.map = v elif k == 'si_version': overview.version = v elif k == 'si_usepass': overview.password = int(v) elif k == 'gamename': overview.mod = v elif k in plusinfoitms: list = Plusinfo.make_list(v) plusinfo[k[1:]] = list elif k == '.score_time': overview.time = v #q4max stores the team score as the first item in the list, followed by the player ids if plusinfo['score_strogg']: overview.teamAscore = plusinfo['score_strogg'][0] if plusinfo['score_marine']: overview.teamBscore = plusinfo['score_marine'][0] pi = Plusinfo() pi.add_map(0, plusinfo['players_strogg'], plusinfo['score_strogg'][1:]) pi.add_map(1, plusinfo['players_marine'], plusinfo['score_marine'][1:]) pi.add_map(0, plusinfo['players_active'], plusinfo['score']) return pi, rules, overview