Reset redis population record at boot

This commit is contained in:
Ben 2019-10-09 01:12:31 +01:00
parent 82be5e3021
commit 2e25f27f1f
3 changed files with 4 additions and 4 deletions

View File

@ -38,7 +38,7 @@ async def get_server_presence(p, pid):
for server_name, server_config in config.servers.items(): for server_name, server_config in config.servers.items():
if server_config['World']: if server_config['World']:
server_population = await p.server.redis.hget('population', server_config['Id']) server_population = await p.server.redis.hget('houdini.population', server_config['Id'])
server_population = (7 if int(server_population) == server_config['Capacity'] server_population = (7 if int(server_population) == server_config['Capacity']
else int(server_population) // (server_config['Capacity'] // 6)) \ else int(server_population) // (server_config['Capacity'] // 6)) \
if server_population else 0 if server_population else 0

View File

@ -59,7 +59,7 @@ async def handle_join_server(p, penguin_id: int, login_key: str):
server_key = f'houdini.players.{p.server.server_config["Id"]}' server_key = f'houdini.players.{p.server.server_config["Id"]}'
await p.server.redis.sadd(server_key, p.data.id) await p.server.redis.sadd(server_key, p.data.id)
await p.server.redis.hincrby('population', p.server.server_config['Id'], 1) await p.server.redis.hincrby('houdini.population', p.server.server_config['Id'], 1)
@handlers.handler(XTPacket('j', 'jr')) @handlers.handler(XTPacket('j', 'jr'))
@ -92,4 +92,4 @@ async def handle_disconnect_room(p):
server_key = f'houdini.players.{p.server.server_config["Id"]}' server_key = f'houdini.players.{p.server.server_config["Id"]}'
await p.server.redis.srem(server_key, p.data.id) await p.server.redis.srem(server_key, p.data.id)
await p.server.redis.hincrby('population', p.server.server_config['Id'], -1) await p.server.redis.hincrby('houdini.population', p.server.server_config['Id'], -1)

View File

@ -159,7 +159,7 @@ class Houdini:
if self.server_config['World']: if self.server_config['World']:
await self.redis.delete(f'houdini.players.{self.server_config["Id"]}') await self.redis.delete(f'houdini.players.{self.server_config["Id"]}')
await self.redis.delete('{}.population'.format(self.server_name)) await self.redis.hdel(f'houdini.population', self.server_config["Id"])
caches.set_config({ caches.set_config({
'default': { 'default': {