refac: lastrefresh를 general_access_log로 이전
- last_refresh에 index를 걸 것인지는 고려 필요 - 안 거는게 차라리 나을 수도 있음 - 불필요해보이는 값 확인: nation_id,
This commit is contained in:
+11
-1
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\GeneralAccessLogColumn;
|
||||||
|
use sammo\Enums\TableName;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
@@ -29,7 +32,14 @@ if ($myset > 0) {
|
|||||||
$submit = 'hidden';
|
$submit = 'hidden';
|
||||||
}
|
}
|
||||||
|
|
||||||
$targetTime = addTurn($me->getVar('lastrefresh'), $gameStor->turnterm, GameConst::$minTurnDieOnPrestart);
|
$lastRefresh = $db->queryFirstField(
|
||||||
|
'SELECT %b FROM %b WHERE %b = %i',
|
||||||
|
GeneralAccessLogColumn::lastRefresh->value,
|
||||||
|
TableName::generalAccessLog->value,
|
||||||
|
GeneralAccessLogColumn::generalID->value, $generalID
|
||||||
|
);
|
||||||
|
|
||||||
|
$targetTime = addTurn($lastRefresh, $gameStor->turnterm, GameConst::$minTurnDieOnPrestart);
|
||||||
if ($gameStor->turntime <= $gameStor->opentime) {
|
if ($gameStor->turntime <= $gameStor->opentime) {
|
||||||
//서버 가오픈시 할 수 있는 행동
|
//서버 가오픈시 할 수 있는 행동
|
||||||
if ($me->getNPCType() == 0 && $me->getNationID() == 0) {
|
if ($me->getNPCType() == 0 && $me->getNationID() == 0) {
|
||||||
|
|||||||
+17
-7
@@ -6,6 +6,7 @@ use DateTime;
|
|||||||
use Ds\Set;
|
use Ds\Set;
|
||||||
use sammo\Enums\AuctionType;
|
use sammo\Enums\AuctionType;
|
||||||
use sammo\Enums\GeneralAccessLogColumn;
|
use sammo\Enums\GeneralAccessLogColumn;
|
||||||
|
use sammo\Enums\GeneralColumn;
|
||||||
use sammo\Enums\InheritanceKey;
|
use sammo\Enums\InheritanceKey;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
|
|
||||||
@@ -1007,16 +1008,16 @@ function increaseRefresh($type = "", $cnt = 1)
|
|||||||
$isunited = $gameStor->isunited;
|
$isunited = $gameStor->isunited;
|
||||||
$opentime = $gameStor->opentime;
|
$opentime = $gameStor->opentime;
|
||||||
|
|
||||||
if($userGrade == 6){
|
if ($userGrade == 6) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($isunited == 2){
|
if ($isunited == 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!$generalID){
|
if (!$generalID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($opentime > $date){
|
if ($opentime > $date) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1039,7 +1040,7 @@ function increaseRefresh($type = "", $cnt = 1)
|
|||||||
$serverID = UniqueConst::$serverID;
|
$serverID = UniqueConst::$serverID;
|
||||||
$logPath = "{$serverPath}/logs/{$serverID}/api_log.db";
|
$logPath = "{$serverPath}/logs/{$serverID}/api_log.db";
|
||||||
|
|
||||||
$logDB = FileDB::db($logPath, $serverPath. '/../f_install/sql/api_log.sql');
|
$logDB = FileDB::db($logPath, $serverPath . '/../f_install/sql/api_log.sql');
|
||||||
|
|
||||||
$ip = $_SERVER['REMOTE_ADDR'] ?? 'local';
|
$ip = $_SERVER['REMOTE_ADDR'] ?? 'local';
|
||||||
$date = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
@@ -1214,7 +1215,16 @@ function updateOnline()
|
|||||||
|
|
||||||
//동접수
|
//동접수
|
||||||
$startTurn = cutTurn($gameStor->turntime, $gameStor->turnterm, false);
|
$startTurn = cutTurn($gameStor->turntime, $gameStor->turnterm, false);
|
||||||
$onlineUser = $db->query('SELECT no,name,nation FROM general WHERE lastrefresh >= %s AND npc < 2', $startTurn);
|
$onlineUser = $db->query(
|
||||||
|
'SELECT %b, %b, %b FROM `general_access_log` as `log` INNER JOIN `general` ON `log`.%b = `general`.%b WHERE %b >= %s',
|
||||||
|
GeneralColumn::no->value,
|
||||||
|
GeneralColumn::name->value,
|
||||||
|
GeneralColumn::nation->value,
|
||||||
|
GeneralAccessLogColumn::generalID->value,
|
||||||
|
GeneralColumn::no->value,
|
||||||
|
GeneralAccessLogColumn::lastRefresh->value,
|
||||||
|
$startTurn
|
||||||
|
);
|
||||||
$onlineNum = count($onlineUser);
|
$onlineNum = count($onlineUser);
|
||||||
$onlineNationUsers = Util::arrayGroupBy($onlineUser, 'nation');
|
$onlineNationUsers = Util::arrayGroupBy($onlineUser, 'nation');
|
||||||
|
|
||||||
@@ -1742,7 +1752,7 @@ function deleteNation(General $lord, bool $applyDB): array
|
|||||||
|
|
||||||
// 전 장수 재야로
|
// 전 장수 재야로
|
||||||
foreach ($nationGeneralList as $general) {
|
foreach ($nationGeneralList as $general) {
|
||||||
if($general->getNPCType() < 2){
|
if ($general->getNPCType() < 2) {
|
||||||
$general->setAuxVar(
|
$general->setAuxVar(
|
||||||
InheritanceKey::max_belong->value,
|
InheritanceKey::max_belong->value,
|
||||||
max(
|
max(
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class BuildNationCandidate extends \sammo\BaseAPI
|
|||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$gameStor->cacheValues(['opentime', 'turntime']);
|
$gameStor->cacheValues(['opentime', 'turntime']);
|
||||||
|
|
||||||
$general = $db->queryFirstRow('SELECT no,name,nation,owner_name,npc,lastrefresh FROM general WHERE owner=%i', $userID);
|
$general = $db->queryFirstRow('SELECT no,name,nation,owner_name,npc FROM general WHERE owner=%i', $userID);
|
||||||
|
|
||||||
if (!$general) {
|
if (!$general) {
|
||||||
return '장수가 없습니다';
|
return '장수가 없습니다';
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace sammo\API\General;
|
|||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
use sammo\DummyGeneral;
|
use sammo\DummyGeneral;
|
||||||
use sammo\Enums\APIRecoveryType;
|
use sammo\Enums\APIRecoveryType;
|
||||||
|
use sammo\Enums\GeneralAccessLogColumn;
|
||||||
use sammo\GameConst;
|
use sammo\GameConst;
|
||||||
use sammo\Session;
|
use sammo\Session;
|
||||||
use sammo\General;
|
use sammo\General;
|
||||||
@@ -37,7 +38,13 @@ class DieOnPrestart extends \sammo\BaseAPI
|
|||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$gameStor->cacheValues(['turnterm', 'opentime', 'turntime', 'year', 'month']);
|
$gameStor->cacheValues(['turnterm', 'opentime', 'turntime', 'year', 'month']);
|
||||||
|
|
||||||
$general = $db->queryFirstRow('SELECT no,name,nation,owner_name,npc,lastrefresh FROM general WHERE owner=%i AND npc = 0', $userID);
|
$general = $db->queryFirstRow('SELECT no,name,nation,owner_name,npc FROM general WHERE owner=%i AND npc = 0', $userID);
|
||||||
|
$lastRefresh = $db->queryFirstField(
|
||||||
|
'SELECT %b FROM general_access_log WHERE %b = %i',
|
||||||
|
GeneralAccessLogColumn::lastRefresh->value,
|
||||||
|
GeneralAccessLogColumn::generalID,
|
||||||
|
$general['no']
|
||||||
|
);
|
||||||
|
|
||||||
if (!$general) {
|
if (!$general) {
|
||||||
return '장수가 없습니다';
|
return '장수가 없습니다';
|
||||||
@@ -55,7 +62,7 @@ class DieOnPrestart extends \sammo\BaseAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
//서버 가오픈시 할 수 있는 행동
|
//서버 가오픈시 할 수 있는 행동
|
||||||
$targetTime = addTurn($general['lastrefresh'], $gameStor->turnterm, GameConst::$minTurnDieOnPrestart);
|
$targetTime = addTurn($lastRefresh, $gameStor->turnterm, GameConst::$minTurnDieOnPrestart);
|
||||||
if ($targetTime > TimeUtil::now()) {
|
if ($targetTime > TimeUtil::now()) {
|
||||||
$targetTimeShort = substr($targetTime, 0, 19);
|
$targetTimeShort = substr($targetTime, 0, 19);
|
||||||
return "아직 삭제할 수 없습니다. {$targetTimeShort} 부터 가능합니다.";
|
return "아직 삭제할 수 없습니다. {$targetTimeShort} 부터 가능합니다.";
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use sammo\Auction;
|
|||||||
use sammo\CityConst;
|
use sammo\CityConst;
|
||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
use sammo\Enums\APIRecoveryType;
|
use sammo\Enums\APIRecoveryType;
|
||||||
|
use sammo\Enums\GeneralAccessLogColumn;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
use sammo\GameConst;
|
use sammo\GameConst;
|
||||||
use sammo\GameUnitConst;
|
use sammo\GameUnitConst;
|
||||||
@@ -414,7 +415,6 @@ class Join extends \sammo\BaseAPI
|
|||||||
'officer_level' => 0,
|
'officer_level' => 0,
|
||||||
'turntime' => $turntime,
|
'turntime' => $turntime,
|
||||||
'killturn' => 6,
|
'killturn' => 6,
|
||||||
'lastrefresh' => $now,
|
|
||||||
'crewtype' => GameUnitConst::DEFAULT_CREWTYPE,
|
'crewtype' => GameUnitConst::DEFAULT_CREWTYPE,
|
||||||
'makelimit' => 0,
|
'makelimit' => 0,
|
||||||
'betray' => $betray,
|
'betray' => $betray,
|
||||||
@@ -427,6 +427,12 @@ class Join extends \sammo\BaseAPI
|
|||||||
'special2' => $special2
|
'special2' => $special2
|
||||||
]);
|
]);
|
||||||
$generalID = $db->insertId();
|
$generalID = $db->insertId();
|
||||||
|
$db->insert('general_access_log', [
|
||||||
|
GeneralAccessLogColumn::generalID->value => $generalID,
|
||||||
|
GeneralAccessLogColumn::userID->value => $userID,
|
||||||
|
GeneralAccessLogColumn::nationID->value => 1,
|
||||||
|
GeneralAccessLogColumn::lastRefresh->value => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
if($blockCustomGeneralName){
|
if($blockCustomGeneralName){
|
||||||
//XXX: 클래스가 이게 맞나?
|
//XXX: 클래스가 이게 맞나?
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ enum GeneralColumn: string{
|
|||||||
case recent_war = 'recent_war';
|
case recent_war = 'recent_war';
|
||||||
case makelimit = 'makelimit';
|
case makelimit = 'makelimit';
|
||||||
case killturn = 'killturn';
|
case killturn = 'killturn';
|
||||||
case lastrefresh = 'lastrefresh';
|
|
||||||
case ip = 'ip';
|
case ip = 'ip';
|
||||||
case block = 'block';
|
case block = 'block';
|
||||||
case dedlevel = 'dedlevel';
|
case dedlevel = 'dedlevel';
|
||||||
|
|||||||
@@ -1030,7 +1030,7 @@ class General implements iAction
|
|||||||
'personal', 'special', 'special2', 'defence_train', 'tnmt', 'npc', 'npc_org', 'deadyear', 'npcmsg',
|
'personal', 'special', 'special2', 'defence_train', 'tnmt', 'npc', 'npc_org', 'deadyear', 'npcmsg',
|
||||||
'dex1', 'dex2', 'dex3', 'dex4', 'dex5', 'betray',
|
'dex1', 'dex2', 'dex3', 'dex4', 'dex5', 'betray',
|
||||||
'recent_war', 'last_turn', 'myset',
|
'recent_war', 'last_turn', 'myset',
|
||||||
'specage', 'specage2', 'con', 'connect', 'aux', 'lastrefresh', 'permission', 'penalty',
|
'specage', 'specage2', 'con', 'connect', 'aux', 'permission', 'penalty',
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($reqColumns === null) {
|
if ($reqColumns === null) {
|
||||||
|
|||||||
@@ -708,7 +708,6 @@ class GeneralBuilder{
|
|||||||
'dex4'=>$this->dex4,
|
'dex4'=>$this->dex4,
|
||||||
'dex5'=>$this->dex5,
|
'dex5'=>$this->dex5,
|
||||||
'aux'=>\sammo\Json::encode($this->aux),
|
'aux'=>\sammo\Json::encode($this->aux),
|
||||||
'lastrefresh'=>TimeUtil::now(),
|
|
||||||
]);
|
]);
|
||||||
$this->generalID = $db->insertId();
|
$this->generalID = $db->insertId();
|
||||||
$turnRows = [];
|
$turnRows = [];
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ CREATE TABLE `general` (
|
|||||||
`recent_war` DATETIME(6) NULL DEFAULT NULL,
|
`recent_war` DATETIME(6) NULL DEFAULT NULL,
|
||||||
`makelimit` INT(2) NULL DEFAULT '0',
|
`makelimit` INT(2) NULL DEFAULT '0',
|
||||||
`killturn` INT(3) NULL DEFAULT NULL,
|
`killturn` INT(3) NULL DEFAULT NULL,
|
||||||
`lastrefresh` DATETIME NULL DEFAULT NULL,
|
|
||||||
`ip` VARCHAR(40) NULL DEFAULT '',
|
`ip` VARCHAR(40) NULL DEFAULT '',
|
||||||
`block` INT(1) NULL DEFAULT '0',
|
`block` INT(1) NULL DEFAULT '0',
|
||||||
`dedlevel` INT(2) NULL DEFAULT '0',
|
`dedlevel` INT(2) NULL DEFAULT '0',
|
||||||
@@ -86,7 +85,6 @@ CREATE TABLE `general` (
|
|||||||
INDEX `officer_level` (`nation`, `officer_level`),
|
INDEX `officer_level` (`nation`, `officer_level`),
|
||||||
INDEX `officer_city` (`officer_city`, `officer_level`),
|
INDEX `officer_city` (`officer_city`, `officer_level`),
|
||||||
INDEX `name` (`name`),
|
INDEX `name` (`name`),
|
||||||
INDEX `last_refresh` (`lastrefresh`),
|
|
||||||
CONSTRAINT `json1` CHECK (json_valid(`last_turn`)),
|
CONSTRAINT `json1` CHECK (json_valid(`last_turn`)),
|
||||||
CONSTRAINT `json2` CHECK (json_valid(`aux`)),
|
CONSTRAINT `json2` CHECK (json_valid(`aux`)),
|
||||||
CONSTRAINT `json3` CHECK (json_valid(`penalty`))
|
CONSTRAINT `json3` CHECK (json_valid(`penalty`))
|
||||||
|
|||||||
Reference in New Issue
Block a user