diff --git a/system/Classes/Daemon/Server.php b/system/Classes/Daemon/Server.php index e378b7219..0e82944b6 100644 --- a/system/Classes/Daemon/Server.php +++ b/system/Classes/Daemon/Server.php @@ -125,7 +125,7 @@ protected function treatHttpInput($input) { $client = $request = $response = null; try { - $data = fread($input, 2048); + $data = fread($input, 8192); if (empty($data)) { fclose($input); return; diff --git a/system/Classes/EventListener/ExceptionListener.php b/system/Classes/EventListener/ExceptionListener.php index 1fd579e34..96d802039 100644 --- a/system/Classes/EventListener/ExceptionListener.php +++ b/system/Classes/EventListener/ExceptionListener.php @@ -81,7 +81,20 @@ public function onCoreError(ErrorEvent $event) */ public function process($event, $message, $file, $line, $trace, $level, $flashbagLevel, $redirect = null) { - $this->logger->log("$message at $file at line $line\n$trace", $level); + $request = $event->getRequest(); + $this->logger->log(json_encode([ + 'request' => [ + 'method' => $request->getMethod(), + 'path' => $request->getPath(), + 'body' => $request->body + ], + 'session' => [ + 'player_id' => $this->sessionWrapper->get('playerId') + ], + 'message' => $message, + 'file' => $file, + 'line' => $line + ]), $level); $this->sessionWrapper->addFlashbag($message, $flashbagLevel); @@ -90,7 +103,7 @@ public function process($event, $message, $file, $line, $trace, $level, $flashba } $response = new Response(); - $redirectionData = $this->getRedirection($event->getRequest(), $redirect); + $redirectionData = $this->getRedirection($request, $redirect); if (isset($redirectionData['redirect'])) { $response->redirect($redirectionData['redirect']); } else { diff --git a/system/Classes/EventListener/ProcessExceptionListener.php b/system/Classes/EventListener/ProcessExceptionListener.php index 508fde309..852a84512 100644 --- a/system/Classes/EventListener/ProcessExceptionListener.php +++ b/system/Classes/EventListener/ProcessExceptionListener.php @@ -77,7 +77,13 @@ public function onCoreError(ProcessErrorEvent $event) */ public function process($event, $message, $file, $line, $trace, $level) { - $this->logger->log("{$this->processName} : $message at $file at line $line\n$trace", $level); + $this->logger->log(json_encode([ + 'process' => $this->processName, + 'message' => $message, + 'file' => $file, + 'line' => $line, + 'task' => $event->getTask() + ]), $level); if ($this->database->inTransaction()) { $this->database->rollBack(); diff --git a/system/Modules/Athena/Manager/OrbitalBaseManager.php b/system/Modules/Athena/Manager/OrbitalBaseManager.php index c4d3e41c5..2f85354fe 100644 --- a/system/Modules/Athena/Manager/OrbitalBaseManager.php +++ b/system/Modules/Athena/Manager/OrbitalBaseManager.php @@ -390,10 +390,9 @@ public function changeOwnerById($id, $base, $newOwner, $baseCommanders) { $this->commercialRouteManager->removeBaseRoutes($base); # suppression des technologies en cours de développement - foreach ($base->technoQueues as $queue) { - $this->entityManager->remove($queue); + foreach ($base->technoQueues as $queue) { + $this->technologyQueueManager->remove($queue); } - $this->entityManager->flush(TechnologyQueue::class); # suppression des missions de recyclages ainsi que des logs de recyclages $this->recyclingMissionManager->removeBaseMissions($base->getId()); @@ -405,11 +404,15 @@ public function changeOwnerById($id, $base, $newOwner, $baseCommanders) { # mise à jour de la date de création pour qu'elle soit dans l'ordre $base->dCreation = Utils::now(); - # ajouter/enlever la base dans le controller - if ($this->sessionWrapper->get('playerId') == $newOwner) { - $this->sessionWrapper->addBase('ob', $base->getId(), $base->getName(), $base->getSector(), $base->getSystem(), '1-' . Game::getSizeOfPlanet($base->getPlanetPopulation()), $base->typeOfBase); - } else { - $this->sessionWrapper->removeBase('ob', $base->getId()); + // If the new owner is connected, we add the base to his session + if (($session = $this->clientManager->getSessionByPlayerId($newOwner)) !== null) { + $session->addBase('ob', $base->getId(), $base->getName(), $base->getSector(), $base->getSystem(), '1-' . Game::getSizeOfPlanet($base->getPlanetPopulation()), $base->typeOfBase); + $this->sessionWrapper->save($session); + } + // If the previous owner is connected, we remove the base from his session + if (($session = $this->clientManager->getSessionByPlayerId($oldOwner)) !== null) { + $session->removeBase('ob', $base->getId()); + $this->sessionWrapper->save($session); } # rendre déserteuses les flottes en voyage @@ -418,6 +421,7 @@ public function changeOwnerById($id, $base, $newOwner, $baseCommanders) { $commander->rPlayer = $newOwner; } else if ($commander->statement == Commander::MOVING) { $commander->statement = Commander::RETIRED; + $this->realtimeActionScheduler->cancel($commander, $commander->getArrivalDate()); } else { $commander->statement = Commander::DEAD; } diff --git a/system/Modules/Athena/Repository/OrbitalBaseRepository.php b/system/Modules/Athena/Repository/OrbitalBaseRepository.php index 5824d2f9c..125c33655 100644 --- a/system/Modules/Athena/Repository/OrbitalBaseRepository.php +++ b/system/Modules/Athena/Repository/OrbitalBaseRepository.php @@ -236,34 +236,33 @@ public function update($orbitalBase) 'id' => $orbitalBase->getRPlace(), )); } - - - /** - * @param OrbitalBase $orbitalBase - */ + + /** + * @param OrbitalBase $orbitalBase + */ public function updateBuildingLevels(OrbitalBase $orbitalBase) - { - $statement = $this->connection->prepare( + { + $statement = $this->connection->prepare( 'UPDATE orbitalBase SET - levelRefinery = :levelRefinery,levelDock1 = :levelDock1, levelDock2 = :levelDock2, levelDock3 = :levelDock3, - levelTechnosphere = :levelTechnosphere, levelCommercialPlateforme = :levelCommercialPlateforme, - levelStorage = :levelStorage, levelRecycling = :levelRecycling , levelSpatioport = :levelSpatioport - WHERE rPlace = :id' + levelRefinery = :levelRefinery,levelDock1 = :levelDock1, levelDock2 = :levelDock2, levelDock3 = :levelDock3, + levelTechnosphere = :levelTechnosphere, levelCommercialPlateforme = :levelCommercialPlateforme, + levelStorage = :levelStorage, levelRecycling = :levelRecycling , levelSpatioport = :levelSpatioport + WHERE rPlace = :id' ); $statement->execute(array( - 'levelRefinery' => $orbitalBase->getLevelRefinery(), - 'levelDock1' => $orbitalBase->getlevelDock1(), - 'levelDock2' => $orbitalBase->getlevelDock2(), - 'levelDock3' => $orbitalBase->getlevelDock3(), - 'levelTechnosphere' => $orbitalBase->getlevelTechnosphere(), - 'levelCommercialPlateforme' => $orbitalBase->getlevelCommercialPlateforme(), - 'levelStorage' => $orbitalBase->getlevelStorage(), - 'levelRecycling' => $orbitalBase->getlevelRecycling(), - 'levelSpatioport' => $orbitalBase->getlevelSpatioport(), - 'id' => $orbitalBase->getRPlace(), + 'levelRefinery' => $orbitalBase->getLevelRefinery(), + 'levelDock1' => $orbitalBase->getlevelDock1(), + 'levelDock2' => $orbitalBase->getlevelDock2(), + 'levelDock3' => $orbitalBase->getlevelDock3(), + 'levelTechnosphere' => $orbitalBase->getlevelTechnosphere(), + 'levelCommercialPlateforme' => $orbitalBase->getlevelCommercialPlateforme(), + 'levelStorage' => $orbitalBase->getlevelStorage(), + 'levelRecycling' => $orbitalBase->getlevelRecycling(), + 'levelSpatioport' => $orbitalBase->getlevelSpatioport(), + 'id' => $orbitalBase->getRPlace(), )); - } - + } + /** * @param OrbitalBase $orbitalBase * @param int $resources diff --git a/system/Modules/Promethee/Manager/TechnologyQueueManager.php b/system/Modules/Promethee/Manager/TechnologyQueueManager.php index e25764314..f1e1e31aa 100644 --- a/system/Modules/Promethee/Manager/TechnologyQueueManager.php +++ b/system/Modules/Promethee/Manager/TechnologyQueueManager.php @@ -40,6 +40,8 @@ public function scheduleQueues() } } + + /** * @param int $id * @return TechnologyQueue @@ -86,4 +88,15 @@ public function add(TechnologyQueue $technologyQueue) { $this->realtimeActionScheduler->schedule('athena.orbital_base_manager', 'uTechnologyQueue', $technologyQueue, $technologyQueue->getEndedAt()); } + + /** + * @param TechnologyQueue $queue + */ + public function remove(TechnologyQueue $queue) + { + $this->realtimeActionScheduler->cancel($queue, $queue->getEndedAt()); + + $this->entityManager->remove($queue); + $this->entityManager->flush($queue); + } } \ No newline at end of file diff --git a/system/action/std/hermes/conversation/start.php b/system/action/std/hermes/conversation/start.php index 2c075a591..92d696caf 100644 --- a/system/action/std/hermes/conversation/start.php +++ b/system/action/std/hermes/conversation/start.php @@ -23,7 +23,7 @@ $content = $parser->parse($content); -if ($recipients !== FALSE AND $content !== FALSE) { +if (!empty($recipients) && !empty($content)) { if (strlen($content) < 10000) { # traitement des utilisateurs multiples $recipients = explode(',', $recipients); diff --git a/system/action/std/hermes/conversation/write.php b/system/action/std/hermes/conversation/write.php index 41a83656c..d403b6d9b 100644 --- a/system/action/std/hermes/conversation/write.php +++ b/system/action/std/hermes/conversation/write.php @@ -18,7 +18,7 @@ $content = $parser->parse($content); -if ($conversation !== FALSE AND $content !== FALSE) { +if (!empty($conversation) && !empty($content)) { if (strlen($content) < 10000) { $S_CVM = $conversationManager->getCurrentSession(); $conversationManager->newSession();