Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xor72000 committed Jul 27, 2017
2 parents ee0132b + 6e22d94 commit e14aa41
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 37 deletions.
2 changes: 1 addition & 1 deletion system/Classes/Daemon/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 15 additions & 2 deletions system/Classes/EventListener/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion system/Classes/EventListener/ProcessExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 12 additions & 8 deletions system/Modules/Athena/Manager/OrbitalBaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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
Expand All @@ -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;
}
Expand Down
45 changes: 22 additions & 23 deletions system/Modules/Athena/Repository/OrbitalBaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions system/Modules/Promethee/Manager/TechnologyQueueManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function scheduleQueues()
}
}



/**
* @param int $id
* @return TechnologyQueue
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion system/action/std/hermes/conversation/start.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion system/action/std/hermes/conversation/write.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e14aa41

Please sign in to comment.