Skip to content

Commit

Permalink
Fix player slots (current, max) usage
Browse files Browse the repository at this point in the history
  • Loading branch information
cemathey committed May 21, 2024
1 parent d1efa04 commit b3b707c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
6 changes: 3 additions & 3 deletions rcon/rcon.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,13 +1020,13 @@ def get_slots(self) -> tuple[int, int]:
@ttl_cache(ttl=5, cache_falsy=False)
def get_status(self) -> StatusType:
config = RconServerSettingsUserConfig.load_from_db()
slots = self.get_slots()
current_players, max_players = self.get_slots()
return {
"name": self.get_name(),
"map": self.current_map.model_dump(),
"nb_players": slots,
"current_players": current_players,
"max_players": max_players,
"short_name": config.short_name,
"player_count": slots.split("/")[0],
"server_number": int(get_server_number()),
}

Expand Down
5 changes: 2 additions & 3 deletions rcon/stats_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def snapshot(self, rcon):
slots = rcon.get_slots()
nb, _ = slots.split("/")
current_players, max_players = rcon.get_slots()

self.client.ts().add(self.NAME, "*", float(nb))
self.client.ts().add(self.NAME, "*", float(current_players))


def run():
Expand Down
4 changes: 2 additions & 2 deletions rcon/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ class AdminType(TypedDict):
class StatusType(TypedDict):
name: str
map: "LayerType"
nb_players: str
current_players: int
max_players: int
short_name: str
player_count: str
server_number: int


Expand Down
19 changes: 12 additions & 7 deletions rcongui/src/components/Header/serverStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { fromJS, List } from "immutable";
const Status = ({
classes,
name,
nbPlayers,
numCurrentPlayers,
maxPlayers,
map,
serverList,
timeRemaining,
Expand Down Expand Up @@ -73,8 +74,8 @@ const Status = ({
})}
</Menu>
<small style={{ display: "block" }}>
{nbPlayers} ({balance}) - {map.pretty_name} - {timeRemaining} -{" "}
{score}
{numCurrentPlayers}/{maxPlayers} ({balance}) - {map.pretty_name} -{" "}
{timeRemaining} - {score}
</small>
</Grid>
</Grid>
Expand All @@ -88,7 +89,8 @@ class ServerStatus extends React.Component {

this.state = {
name: "",
nbPlayers: "",
numCurrentPlayers: 0,
maxPlayers: 0,
map: new Map(),
serverList: List(),
refreshIntervalSec: 10,
Expand Down Expand Up @@ -149,7 +151,8 @@ class ServerStatus extends React.Component {
this.setState({
name: data?.result.name,
map: data?.result.map,
nbPlayers: data.result.nb_players,
numCurrentPlayers: data.result.current_players,
maxPlayers: data.result.max_players,
});
document.title = `(${data?.result.player_count}) ${data?.result.short_name}`;
})
Expand Down Expand Up @@ -189,7 +192,8 @@ class ServerStatus extends React.Component {
const {
map,
name,
nbPlayers,
numCurrentPlayers,
maxPlayers,
serverList,
rawTimeRemaining,
axisScore,
Expand All @@ -203,7 +207,8 @@ class ServerStatus extends React.Component {
<Status
classes={classes}
name={name}
nbPlayers={nbPlayers}
numCurrentPlayers={numCurrentPlayers}
maxPlayers={maxPlayers}
map={map}
serverList={serverList}
timeRemaining={rawTimeRemaining}
Expand Down

0 comments on commit b3b707c

Please sign in to comment.