merge: resume invader games after unification

This commit is contained in:
2026-08-12 15:42:22 +00:00
5 changed files with 62 additions and 1 deletions
+1
View File
@@ -769,6 +769,7 @@ function checkEmperior()
$gameStor->isunited = 2;
$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) {
CheckHall($hallGeneralNo);
+3 -1
View File
@@ -2,6 +2,7 @@
namespace sammo\Event\Action;
use sammo\ActionLogger;
use sammo\AutoResetProgress;
use sammo\CityConst;
use sammo\DB;
use sammo\KVStorage;
@@ -61,6 +62,7 @@ class InvaderEnding extends \sammo\Event\Action{
$logger->pushGlobalHistoryLog("<L><b>【이벤트】</b></>백성은 언젠가 영웅이 나타나길 기다립니다.");
}
$gameStor->setValue('isunited', 3);
AutoResetProgress::record($gameStor);
$logger->flush();
$gameStor->refreshLimit = $gameStor->refreshLimit * 100;
@@ -71,4 +73,4 @@ class InvaderEnding extends \sammo\Event\Action{
return [__CLASS__, 'Deleted'];
}
}
}
+2
View File
@@ -4,6 +4,7 @@ namespace sammo\Event\Action;
use Ds\Set;
use sammo\ActionLogger;
use sammo\AutoResetProgress;
use sammo\CityConst;
use sammo\DB;
use sammo\Json;
@@ -119,6 +120,7 @@ class RaiseInvader extends \sammo\Event\Action
$gameStor = KVStorage::getStorage($db, 'game_env');
$gameStor->setValue('isunited', 1);
AutoResetProgress::record($gameStor);
$turnterm = $gameStor->turnterm;
$generalCnt = $db->queryFirstField('SELECT count(*) FROM general');
+16
View File
@@ -20,6 +20,18 @@ class TurnExecutionHelper
{
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()
{
@@ -416,6 +428,8 @@ class TurnExecutionHelper
$locked = true;
return $gameStor->turntime;
}
$completionTickBeforeRun = Util::toInt($gameStor->turntime);
$gameStor->cacheAll();
// 1턴이상 갱신 없었으면 서버 지연
@@ -462,6 +476,7 @@ class TurnExecutionHelper
$currentTurn,
);
}
self::recordInvaderProgress($gameStor, $completionTickBeforeRun);
unlock();
return $gameStor->turntime;
}
@@ -520,6 +535,7 @@ class TurnExecutionHelper
processTournament();
//거래 처리
processAuction();
self::recordInvaderProgress($gameStor, $completionTickBeforeRun);
// 잠금 해제
$turntime = $gameStor->turntime;
+40
View File
@@ -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;
}
}