Skip to content
This repository was archived by the owner on Jul 18, 2019. It is now read-only.

Commit a0da4d9

Browse files
committed
Fix to PlayerCap config and try to fix podium empty bug
1 parent 463d9f2 commit a0da4d9

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

match.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ def getPlayersData(self):
120120
def broadPlayerUpdate(self, player, pktData):
121121
data = Buffer().writeInt16(player.id).write(pktData).toBytes()
122122
for p in self.players:
123-
if not p.loaded or p.id == player.id or p.level != player.level or p.zone != player.zone:
123+
if not p.loaded or p.id == player.id:
124+
continue
125+
if not p.win and (p.level != player.level or p.zone != player.zone):
124126
continue
125127
p.sendBin(0x12, data)
126128

player.py

+18-11
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def handlePkt(self, code, b, pktData):
108108
self.match.broadBin(0x10, Buffer().writeInt16(self.id).write(pktData).writeInt16(self.skin))
109109

110110
elif code == 0x11: # KILL_PLAYER_OBJECT
111-
if self.dead:
111+
if self.dead or self.win:
112112
return
113113

114114
self.dead = True
@@ -138,7 +138,7 @@ def handlePkt(self, code, b, pktData):
138138
self.match.broadPlayerUpdate(self, pktData)
139139

140140
elif code == 0x13: # PLAYER_OBJECT_EVENT
141-
if self.dead:
141+
if self.dead or self.win:
142142
return
143143

144144
type = b.readInt8()
@@ -168,15 +168,22 @@ def handlePkt(self, code, b, pktData):
168168
self.client.startDCTimer(120)
169169

170170
pos = self.match.getWinners()
171-
if self.server.discordWebhook is not None and pos == 1 and not self.match.private:
172-
name = self.name
173-
# We already filter players that have a squad so...
174-
if len(self.team) == 0 and self.server.checkCurse(self.name):
175-
name = "[ censored ]"
176-
embed = DiscordEmbed(description='**%s** has achieved **#1** victory royale!' % name, color=0xffff00)
177-
self.server.discordWebhook.add_embed(embed)
178-
self.server.discordWebhook.execute()
179-
self.server.discordWebhook.remove_embed(0)
171+
try:
172+
# Maybe this should be assynchronous?
173+
if self.server.discordWebhook is not None and pos == 1 and not self.match.private:
174+
name = self.name
175+
# We already filter players that have a squad so...
176+
if len(self.team) == 0 and self.server.checkCurse(self.name):
177+
name = "[ censored ]"
178+
embed = DiscordEmbed(description='**%s** has achieved **#1** victory royale!' % name, color=0xffff00)
179+
self.server.discordWebhook.add_embed(embed)
180+
self.server.discordWebhook.execute()
181+
self.server.discordWebhook.remove_embed(0)
182+
except:
183+
pass
184+
185+
# Make sure that everyone knows that the player is at the axe
186+
self.match.broadPlayerUpdate(self, self.lastUpdatePkt)
180187

181188
self.match.broadBin(0x18, Buffer().writeInt16(self.id).writeInt8(pos).writeInt8(0))
182189

server.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sys
33

4-
NUM_SKINS = 6 #temporary until shop is implemented
4+
NUM_SKINS = 22 #temporary until shop is implemented
55

66
if sys.version_info.major != 3:
77
sys.stderr.write("You need python 3.7 or later to run this script\n")
@@ -74,8 +74,8 @@ def onOpen(self):
7474
if not self.address:
7575
self.address = self.transport.getPeer().host
7676

77-
# A connection can only be alive for 30 minutes
78-
self.maxConLifeTimer = reactor.callLater(30 * 60, self.sendClose)
77+
# A connection can only be alive for 20 minutes
78+
self.maxConLifeTimer = reactor.callLater(20 * 60, self.sendClose)
7979

8080
self.startDCTimer(25)
8181
self.setState("l")
@@ -261,7 +261,7 @@ def onBinaryMessage(self):
261261
b = Buffer(self.recv[1:pktLen])
262262
del self.recv[:pktLen]
263263

264-
if not self.player.loaded or self.blocked or (not self.player.match.closed and self.player.match.playing):
264+
if self.player is None or not self.player.loaded or self.blocked or (not self.player.match.closed and self.player.match.playing):
265265
self.recv.clear()
266266
return False
267267

@@ -329,7 +329,15 @@ def readConfig(self, cfgHash):
329329
self.maxSimulIP = config.getint('Server', 'MaxSimulIP')
330330
self.discordWebhookUrl = config.get('Server', 'DiscordWebhookUrl').strip()
331331
self.playerMin = config.getint('Match', 'PlayerMin')
332-
self.playerCap = config.getint('Match', 'PlayerCap')
332+
newCap = config.getint('Match', 'PlayerCap')
333+
if newCap < self.playerCap:
334+
try:
335+
for match in self.matches:
336+
if len(match.players) >= newCap:
337+
match.start()
338+
except:
339+
print("Couldn't start matches after player cap change...")
340+
self.playerCap = newCap
333341
self.autoStartTime = config.getint('Match', 'AutoStartTime')
334342
self.startTimer = config.getint('Match', 'StartTimer')
335343
self.enableVoteStart = config.getboolean('Match', 'EnableVoteStart')

0 commit comments

Comments
 (0)