merge: resume invader games after unification
This commit is contained in:
@@ -769,6 +769,7 @@ function checkEmperior()
|
|||||||
|
|
||||||
$gameStor->isunited = 2;
|
$gameStor->isunited = 2;
|
||||||
$gameStor->refreshLimit = $gameStor->refreshLimit * 100;
|
$gameStor->refreshLimit = $gameStor->refreshLimit * 100;
|
||||||
|
AutoResetProgress::record($gameStor);
|
||||||
|
|
||||||
foreach ($db->queryFirstColumn('SELECT no FROM general WHERE npc<2 AND age>=%i', GameConst::$minPushHallAge) as $hallGeneralNo) {
|
foreach ($db->queryFirstColumn('SELECT no FROM general WHERE npc<2 AND age>=%i', GameConst::$minPushHallAge) as $hallGeneralNo) {
|
||||||
CheckHall($hallGeneralNo);
|
CheckHall($hallGeneralNo);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\Event\Action;
|
namespace sammo\Event\Action;
|
||||||
|
|
||||||
use sammo\ActionLogger;
|
use sammo\ActionLogger;
|
||||||
|
use sammo\AutoResetProgress;
|
||||||
use sammo\CityConst;
|
use sammo\CityConst;
|
||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
use sammo\KVStorage;
|
use sammo\KVStorage;
|
||||||
@@ -61,6 +62,7 @@ class InvaderEnding extends \sammo\Event\Action{
|
|||||||
$logger->pushGlobalHistoryLog("<L><b>【이벤트】</b></>백성은 언젠가 영웅이 나타나길 기다립니다.");
|
$logger->pushGlobalHistoryLog("<L><b>【이벤트】</b></>백성은 언젠가 영웅이 나타나길 기다립니다.");
|
||||||
}
|
}
|
||||||
$gameStor->setValue('isunited', 3);
|
$gameStor->setValue('isunited', 3);
|
||||||
|
AutoResetProgress::record($gameStor);
|
||||||
$logger->flush();
|
$logger->flush();
|
||||||
|
|
||||||
$gameStor->refreshLimit = $gameStor->refreshLimit * 100;
|
$gameStor->refreshLimit = $gameStor->refreshLimit * 100;
|
||||||
@@ -71,4 +73,4 @@ class InvaderEnding extends \sammo\Event\Action{
|
|||||||
return [__CLASS__, 'Deleted'];
|
return [__CLASS__, 'Deleted'];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace sammo\Event\Action;
|
|||||||
|
|
||||||
use Ds\Set;
|
use Ds\Set;
|
||||||
use sammo\ActionLogger;
|
use sammo\ActionLogger;
|
||||||
|
use sammo\AutoResetProgress;
|
||||||
use sammo\CityConst;
|
use sammo\CityConst;
|
||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
use sammo\Json;
|
use sammo\Json;
|
||||||
@@ -119,6 +120,7 @@ class RaiseInvader extends \sammo\Event\Action
|
|||||||
|
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$gameStor->setValue('isunited', 1);
|
$gameStor->setValue('isunited', 1);
|
||||||
|
AutoResetProgress::record($gameStor);
|
||||||
|
|
||||||
$turnterm = $gameStor->turnterm;
|
$turnterm = $gameStor->turnterm;
|
||||||
$generalCnt = $db->queryFirstField('SELECT count(*) FROM general');
|
$generalCnt = $db->queryFirstField('SELECT count(*) FROM general');
|
||||||
|
|||||||
@@ -20,6 +20,18 @@ class TurnExecutionHelper
|
|||||||
{
|
{
|
||||||
return max($completedTick, $candidateTick);
|
return max($completedTick, $candidateTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function recordInvaderProgress(KVStorage $gameStorage, int $beforeTick): void
|
||||||
|
{
|
||||||
|
if (Util::toInt($gameStorage->isunited) !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AutoResetProgress::recordIfAdvanced(
|
||||||
|
$gameStorage,
|
||||||
|
$beforeTick,
|
||||||
|
Util::toInt($gameStorage->turntime),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
@@ -416,6 +428,8 @@ class TurnExecutionHelper
|
|||||||
$locked = true;
|
$locked = true;
|
||||||
return $gameStor->turntime;
|
return $gameStor->turntime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$completionTickBeforeRun = Util::toInt($gameStor->turntime);
|
||||||
|
|
||||||
$gameStor->cacheAll();
|
$gameStor->cacheAll();
|
||||||
// 1턴이상 갱신 없었으면 서버 지연
|
// 1턴이상 갱신 없었으면 서버 지연
|
||||||
@@ -462,6 +476,7 @@ class TurnExecutionHelper
|
|||||||
$currentTurn,
|
$currentTurn,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
self::recordInvaderProgress($gameStor, $completionTickBeforeRun);
|
||||||
unlock();
|
unlock();
|
||||||
return $gameStor->turntime;
|
return $gameStor->turntime;
|
||||||
}
|
}
|
||||||
@@ -520,6 +535,7 @@ class TurnExecutionHelper
|
|||||||
processTournament();
|
processTournament();
|
||||||
//거래 처리
|
//거래 처리
|
||||||
processAuction();
|
processAuction();
|
||||||
|
self::recordInvaderProgress($gameStor, $completionTickBeforeRun);
|
||||||
// 잠금 해제
|
// 잠금 해제
|
||||||
|
|
||||||
$turntime = $gameStor->turntime;
|
$turntime = $gameStor->turntime;
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wall-clock inactivity anchor used only by the reserved reset watchdog.
|
||||||
|
*
|
||||||
|
* GameClock ticks remain authoritative for gameplay. This timestamp records
|
||||||
|
* when a united or invader game last changed phase or actually advanced, so
|
||||||
|
* j_autoreset can distinguish a healthy running event from a stalled server.
|
||||||
|
*/
|
||||||
|
final class AutoResetProgress
|
||||||
|
{
|
||||||
|
public const STORAGE_KEY = 'autoreset_united_wall_anchor';
|
||||||
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function record(
|
||||||
|
KVStorage $gameStorage,
|
||||||
|
?\DateTimeInterface $wallTime = null,
|
||||||
|
): void {
|
||||||
|
$wallTime ??= GameClock::readWallTime();
|
||||||
|
$gameStorage->setValue(self::STORAGE_KEY, TimeUtil::format($wallTime, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function recordIfAdvanced(
|
||||||
|
KVStorage $gameStorage,
|
||||||
|
int $beforeTick,
|
||||||
|
int $afterTick,
|
||||||
|
?\DateTimeInterface $wallTime = null,
|
||||||
|
): bool {
|
||||||
|
if ($afterTick <= $beforeTick) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
self::record($gameStorage, $wallTime);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user