Browse Source

fix crc32server value

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

6
src/Controller/ServerController.php

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

Loading…
Cancel
Save