Browse Source

fix crc32server value

main
ghost 10 months ago
parent
commit
a62e9d4fb4
  1. 13
      src/Controller/CrontabController.php
  2. 6
      src/Controller/ServerController.php

13
src/Controller/CrontabController.php

@ -153,11 +153,6 @@ class CrontabController extends AbstractController
$players = isset($info['Players']) && $info['Players'] > 0 ? (int) $info['Players'] - $bots : 0; $players = isset($info['Players']) && $info['Players'] > 0 ? (int) $info['Players'] - $bots : 0;
$total = $players + $bots; $total = $players + $bots;
// Generate CRC32 server ID
$crc32server = crc32(
$server->host . ':' . $server->port
);
// Update server name // Update server name
if (!empty($info['HostName']) && mb_strlen($info['HostName']) < 256) if (!empty($info['HostName']) && mb_strlen($info['HostName']) < 256)
{ {
@ -183,7 +178,7 @@ class CrontabController extends AbstractController
// Get last online value // Get last online value
$online = $entityManagerInterface->getRepository(Online::class)->findOneBy( $online = $entityManagerInterface->getRepository(Online::class)->findOneBy(
[ [
'crc32server' => $crc32server 'crc32server' => $server->getCrc32server()
], ],
[ [
'id' => 'DESC' // same as online.time but faster 'id' => 'DESC' // same as online.time but faster
@ -205,7 +200,7 @@ class CrontabController extends AbstractController
$online = new Online(); $online = new Online();
$online->setCrc32server( $online->setCrc32server(
$crc32server $server->getCrc32server()
); );
$online->setTime( $online->setTime(
@ -262,7 +257,7 @@ class CrontabController extends AbstractController
$player = $entityManagerInterface->getRepository(Player::class)->findOneBy( $player = $entityManagerInterface->getRepository(Player::class)->findOneBy(
[ [
'crc32server' => $crc32server, 'crc32server' => $server->getCrc32server(),
'crc32name' => $crc32name, 'crc32name' => $crc32name,
] ]
); );
@ -292,7 +287,7 @@ class CrontabController extends AbstractController
$player = new Player(); $player = new Player();
$player->setCrc32server( $player->setCrc32server(
$crc32server $server->getCrc32server()
); );
$player->setCrc32name( $player->setCrc32name(

6
src/Controller/ServerController.php

@ -121,7 +121,7 @@ class ServerController extends AbstractController
// Get online // Get online
$online = $entityManagerInterface->getRepository(Online::class)->findBy( $online = $entityManagerInterface->getRepository(Online::class)->findBy(
[ [
'crc32server' => $server->getCrc32Server() 'crc32server' => $server->getCrc32server()
], ],
'online' == $request->get('sort') ? [$field => $order] : ['time' => 'DESC'], 'online' == $request->get('sort') ? [$field => $order] : ['time' => 'DESC'],
10 10
@ -130,7 +130,7 @@ class ServerController extends AbstractController
// Get players // Get players
$players = $entityManagerInterface->getRepository(Player::class)->findBy( $players = $entityManagerInterface->getRepository(Player::class)->findBy(
[ [
'crc32server' => $server->getCrc32Server() 'crc32server' => $server->getCrc32server()
], ],
'players' == $request->get('sort') ? [$field => $order] : ['frags' => 'DESC'], 'players' == $request->get('sort') ? [$field => $order] : ['frags' => 'DESC'],
10 10
@ -168,7 +168,7 @@ class ServerController extends AbstractController
'server' => 'server' =>
[ [
'address' => $address, 'address' => $address,
'crc32server' => $server->getCrc32Server(), 'crc32server' => $server->getCrc32server(),
'name' => $server->getName(), 'name' => $server->getName(),
'host' => $server->getHost(), 'host' => $server->getHost(),
'port' => $server->getPort(), 'port' => $server->getPort(),

Loading…
Cancel
Save