Update submitModularHandler.pyx

This commit is contained in:
Josh Smith 2019-02-13 17:13:19 -05:00
parent 37730c1bb1
commit 1090d34d38

View File

@ -111,7 +111,7 @@ class handler(requestsManager.asyncRequestHandler):
# Get restricted # Get restricted
restricted = userUtils.isRestricted(userID) restricted = userUtils.isRestricted(userID)
# Get variables for relax # Get variables for relax
used_mods = int(scoreData[13]) used_mods = int(scoreData[13])
isRelaxing = used_mods & 128 isRelaxing = used_mods & 128
@ -141,10 +141,13 @@ class handler(requestsManager.asyncRequestHandler):
# increment user playtime # increment user playtime
length = 0 length = 0
if s.passed: if s.passed:
length = userUtils.getBeatmapTime(beatmapInfo.beatmapID) try:
length = userUtils.getBeatmapTime(beatmapInfo.beatmapID)
except Exception:
log.error("Maxi's mirror must be down, as getBeatmapTime failed. L144 submitModular")
else: else:
length = math.ceil(int(self.get_argument("ft")) / 1000) length = math.ceil(int(self.get_argument("ft")) / 1000)
userUtils.incrementPlaytime(userID, s.gameMode, length) userUtils.incrementPlaytime(userID, s.gameMode, length)
# Calculate PP # Calculate PP
midPPCalcException = None midPPCalcException = None
@ -159,7 +162,7 @@ class handler(requestsManager.asyncRequestHandler):
log.error("Caught an exception in pp calculation, re-raising after saving score in db") log.error("Caught an exception in pp calculation, re-raising after saving score in db")
s.pp = 0 s.pp = 0
midPPCalcException = e midPPCalcException = e
# Restrict obvious cheaters™ # Restrict obvious cheaters™
if restricted == False: if restricted == False:
if isRelaxing: # Relax if isRelaxing: # Relax
@ -230,7 +233,6 @@ class handler(requestsManager.asyncRequestHandler):
oldPersonalBestRank = 0 oldPersonalBestRank = 0
oldPersonalBest = None oldPersonalBest = None
# Save score in db # Save score in db
s.saveScoreInDB() s.saveScoreInDB()
@ -264,7 +266,7 @@ class handler(requestsManager.asyncRequestHandler):
# Ci metto la faccia, ci metto la testa e ci metto il mio cuore # Ci metto la faccia, ci metto la testa e ci metto il mio cuore
if ((s.mods & mods.DOUBLETIME) > 0 and (s.mods & mods.HALFTIME) > 0) \ if ((s.mods & mods.DOUBLETIME) > 0 and (s.mods & mods.HALFTIME) > 0) \
or ((s.mods & mods.HARDROCK) > 0 and (s.mods & mods.EASY) > 0) \ or ((s.mods & mods.HARDROCK) > 0 and (s.mods & mods.EASY) > 0) \
or ((s.mods & mods.SUDDENDEATH) > 0 and (s.mods & mods.NOFAIL) > 0)\ or ((s.mods & mods.SUDDENDEATH) > 0 and (s.mods & mods.NOFAIL) > 0) \
or ((s.mods & mods.RELAX) > 0 and (s.mods & mods.RELAX2) > 0): or ((s.mods & mods.RELAX) > 0 and (s.mods & mods.RELAX2) > 0):
userUtils.ban(userID) userUtils.ban(userID)
userUtils.appendNotes(userID, "Impossible mod combination ({}).".format(s.mods)) userUtils.appendNotes(userID, "Impossible mod combination ({}).".format(s.mods))
@ -348,7 +350,6 @@ class handler(requestsManager.asyncRequestHandler):
oldUserData = glob.userStatsCache.get(userID, s.gameMode) oldUserData = glob.userStatsCache.get(userID, s.gameMode)
oldRank = userUtils.getGameRank(userID, s.gameMode) oldRank = userUtils.getGameRank(userID, s.gameMode)
# Always update users stats (total/ranked score, playcount, level, acc and pp) # Always update users stats (total/ranked score, playcount, level, acc and pp)
# even if not passed # even if not passed
@ -402,7 +403,6 @@ class handler(requestsManager.asyncRequestHandler):
if beatmapInfo is not None and beatmapInfo != False and s.passed: if beatmapInfo is not None and beatmapInfo != False and s.passed:
log.debug("Started building ranking panel.") log.debug("Started building ranking panel.")
if isRelaxing: # Relax if isRelaxing: # Relax
# Trigger bancho stats cache update # Trigger bancho stats cache update
glob.redis.publish("peppy:update_rxcached_stats", userID) glob.redis.publish("peppy:update_rxcached_stats", userID)
@ -498,6 +498,7 @@ class handler(requestsManager.asyncRequestHandler):
params = urlencode({"k": glob.conf.config["server"]["apikey"], "to": "#announce", "msg": annmsg}) params = urlencode({"k": glob.conf.config["server"]["apikey"], "to": "#announce", "msg": annmsg})
requests.get("{}/api/v1/fokabotMessage?{}".format(glob.conf.config["server"]["banchourl"], params)) requests.get("{}/api/v1/fokabotMessage?{}".format(glob.conf.config["server"]["banchourl"], params))
# Add the #1 to the database. Yes this is spaghetti.
scoreUtils.newFirst(s.scoreID, userID, s.fileMd5, s.gameMode, isRelaxing) scoreUtils.newFirst(s.scoreID, userID, s.fileMd5, s.gameMode, isRelaxing)
# Write message to client # Write message to client