def parseNewWorm(wormID, name): global worms name = name.replace("\t", " ").strip() # Do not allow tab in names, it will screw up our ranking tab-separated text-file database exists = False try: worm = worms[wormID] exists = True except KeyError: #Worm doesn't exist. worm = Worm() worm.Name = name worm.iID = wormID worm.Ping = [] worms[wormID] = worm if io.getGameType() == "Hide and Seek": minSeekers = 1 if len(worms.values()) >= 4: minSeekers = 2 if io.getNumberWormsInTeam(1) < minSeekers: io.setWormTeam(wormID, 1) # Seeker else: io.setWormTeam(wormID, 0) # Hider else: # Balance teams teams = [0,0,0,0] for w in worms.keys(): teams[worms[w].Team] += 1 minTeam = 0 minTeamCount = teams[0] for f in range(cfg.MAX_TEAMS): if minTeamCount > teams[f]: minTeamCount = teams[f] minTeam = f io.setWormTeam(wormID, minTeam) if cfg.RANKING_AUTHENTICATION: if not name in ranking.auth: ranking.auth[name] = getWormSkin(wormID) try: f = open(io.getFullFileName("pwn0meter_auth.txt"),"r") try: portalocker.lock(f, portalocker.LOCK_EX) except: pass f.write( name + "\t" + str(ranking.auth[name][0]) + " " + ranking.auth[name][1] + "\n" ) f.close() except IOError: msg("ERROR: Unable to open pwn0meter_auth.txt") else: if ranking.auth[name] != getWormSkin(wormID): io.kickWorm(wormID, "Player with name %s already registered" % name) wormIP = io.getWormIP(wormID).split(":")[0] # io.messageLog("Curtime " + str(time.time()) + " IP " + str(wormIP) + " Kicked worms: " + str(cmds.kickedUsers), io.LOG_INFO) if wormIP in cmds.kickedUsers and cmds.kickedUsers[ wormIP ] > time.time(): io.kickWorm( wormID, "You can join in " + str(int(cmds.kickedUsers[ wormIP ] - time.time())/60 + 1) + " minutes" ) return cmds.recheckVote()
def ParseAuthInfo(): try: f = open(io.getFullFileName("pwn0meter_auth.txt"),"r") except IOError: return {} authInfo = {} l = f.readline() while l != "": l = l.strip() if not (l.count("\t") == 1): l = f.readline() continue ( worm, auth ) = l.split("\t") auth = auth.split(" ") authInfo[worm] = ( int(auth[0]), " ".join(auth[1:]).lower() ) l = f.readline() f.close() return authInfo
def ParseAuthInfo(): try: f = open(io.getFullFileName("pwn0meter_auth.txt"), "r") except IOError: return {} authInfo = {} l = f.readline() while l != "": l = l.strip() if not (l.count("\t") == 1): l = f.readline() continue (worm, auth) = l.split("\t") auth = auth.split(" ") authInfo[worm] = (int(auth[0]), " ".join(auth[1:]).lower()) l = f.readline() f.close() return authInfo
def parseNewWorm(wormID, name): global worms name = name.replace("\t", " ").strip( ) # Do not allow tab in names, it will screw up our ranking tab-separated text-file database exists = False try: worm = worms[wormID] exists = True except KeyError: #Worm doesn't exist. worm = Worm() worm.Name = name worm.iID = wormID worm.Ping = [] worms[wormID] = worm if io.getGameType() == "Hide and Seek": minSeekers = 1 if len(worms.values()) >= 4: minSeekers = 2 if io.getNumberWormsInTeam(1) < minSeekers: io.setWormTeam(wormID, 1) # Seeker else: io.setWormTeam(wormID, 0) # Hider else: # Balance teams teams = [0, 0, 0, 0] for w in worms.keys(): teams[worms[w].Team] += 1 minTeam = 0 minTeamCount = teams[0] for f in range(cfg.MAX_TEAMS): if minTeamCount > teams[f]: minTeamCount = teams[f] minTeam = f io.setWormTeam(wormID, minTeam) if cfg.RANKING_AUTHENTICATION: if not name in ranking.auth: ranking.auth[name] = getWormSkin(wormID) try: f = open(io.getFullFileName("pwn0meter_auth.txt"), "r") try: portalocker.lock(f, portalocker.LOCK_EX) except: pass f.write(name + "\t" + str(ranking.auth[name][0]) + " " + ranking.auth[name][1] + "\n") f.close() except IOError: msg("ERROR: Unable to open pwn0meter_auth.txt") else: if ranking.auth[name] != getWormSkin(wormID): io.kickWorm(wormID, "Player with name %s already registered" % name) wormIP = io.getWormIP(wormID).split(":")[0] # io.messageLog("Curtime " + str(time.time()) + " IP " + str(wormIP) + " Kicked worms: " + str(cmds.kickedUsers), io.LOG_INFO) if wormIP in cmds.kickedUsers and cmds.kickedUsers[wormIP] > time.time(): io.kickWorm( wormID, "You can join in " + str(int(cmds.kickedUsers[wormIP] - time.time()) / 60 + 1) + " minutes") return cmds.recheckVote()