.HIDE. General refactoring and documentation

This commit is contained in:
Nyo
2016-11-17 19:13:06 +01:00
parent abad698fe3
commit a2ef03c887
38 changed files with 597 additions and 449 deletions

View File

@@ -17,9 +17,8 @@ def handle(userToken, packetData):
return
# Send restricted message if needed
if not userToken.restricted:
if userUtils.isRestricted(userID):
userToken.setRestricted()
if userToken.restricted:
userToken.checkRestricted(True)
# Change action packet
packetData = clientPackets.userActionChange(packetData)

View File

@@ -18,7 +18,7 @@ def handle(userToken, packetData):
match = glob.matches.matches[matchID]
# Set slot or match mods according to modType
if match.matchModMode == matchModModes.freeMod:
if match.matchModMode == matchModModes.FREE_MOD:
# Freemod
# Host can set global DT/HT
if userID == match.hostUserID:

View File

@@ -81,11 +81,11 @@ def handle(userToken, packetData):
# Reset ready if needed
if oldMods != match.mods or oldBeatmapMD5 != match.beatmapMD5:
for i in range(0,16):
if match.slots[i].status == slotStatuses.ready:
match.slots[i].status = slotStatuses.notReady
if match.slots[i].status == slotStatuses.READY:
match.slots[i].status = slotStatuses.NOT_READY
# Reset mods if needed
if match.matchModMode == matchModModes.normal:
if match.matchModMode == matchModModes.NORMAL:
# Reset slot mods if not freeMods
for i in range(0,16):
match.slots[i].mods = 0
@@ -94,21 +94,21 @@ def handle(userToken, packetData):
match.mods = 0
# Set/reset teams
if match.matchTeamType == matchTeamTypes.teamVs or match.matchTeamType == matchTeamTypes.tagTeamVs:
if match.matchTeamType == matchTeamTypes.TEAM_VS or match.matchTeamType == matchTeamTypes.TAG_TEAM_VS:
# Set teams
c=0
for i in range(0,16):
if match.slots[i].team == matchTeams.noTeam:
match.slots[i].team = matchTeams.red if c % 2 == 0 else matchTeams.blue
if match.slots[i].team == matchTeams.NO_TEAM:
match.slots[i].team = matchTeams.RED if c % 2 == 0 else matchTeams.BLUE
c+=1
else:
# Reset teams
for i in range(0,16):
match.slots[i].team = matchTeams.noTeam
match.slots[i].team = matchTeams.NO_TEAM
# Force no freemods if tag coop
if match.matchTeamType == matchTeamTypes.tagCoop or match.matchTeamType == matchTeamTypes.tagTeamVs:
match.matchModMode = matchModModes.normal
if match.matchTeamType == matchTeamTypes.TAG_COOP or match.matchTeamType == matchTeamTypes.TAG_TEAM_VS:
match.matchModMode = matchModModes.NORMAL
# Send updated settings
match.sendUpdates()

View File

@@ -192,19 +192,20 @@ def handle(tornadoRequest):
# Get location and country from ip.zxq.co or database
if glob.localize:
# Get location and country from IP
location = locationHelper.getLocation(requestIP)
latitude, longitude = locationHelper.getLocation(requestIP)
countryLetters = locationHelper.getCountry(requestIP)
country = countryHelper.getCountryID(countryLetters)
else:
# Set location to 0,0 and get country from db
log.warning("Location skipped")
location = [0,0]
latitude = 0
longitude = 0
countryLetters = "XX"
country = countryHelper.getCountryID(userUtils.getCountry(userID))
# Set location and country
responseToken.setLocation(location)
responseToken.setCountry(country)
responseToken.setLocation(latitude, longitude)
responseToken.country = country
# Set country in db if user has no country (first bancho login)
if userUtils.getCountry(userID) == "XX":

View File

@@ -11,7 +11,7 @@ def handle(userToken, packetData):
packetData = clientPackets.setAwayMessage(packetData)
# Set token away message
userToken.setAwayMessage(packetData["awayMessage"])
userToken.awayMessage = packetData["awayMessage"]
# Send private message from fokabot
if packetData["awayMessage"] == "":