diff --git a/hwe/commandlist.php b/hwe/commandlist.php
index 751e349e..1e7f0779 100644
--- a/hwe/commandlist.php
+++ b/hwe/commandlist.php
@@ -76,7 +76,7 @@ function myCommandList() {
$userID = Session::getUserID();
// 명령 목록
- $admin = $gameStor->getValues(['year','month','turnterm','turntime']);
+ $admin = $gameStor->getValues(['year','month','turnterm','turntime','opentime']);
$me = $db->queryFirstRow("SELECT `no`,name,city,nation,level,turntime,last_turn FROM general WHERE `owner`=%s", $userID);
if(!$me){
@@ -95,9 +95,10 @@ function myCommandList() {
$year = $admin['year'];
$month = $admin['month'];
+ $date = TimeUtil::now(true);
// 실행된 턴시간이면 +1
$cutTurn = cutTurn($me['turntime'], $admin['turnterm']);
- if($admin['turntime'] <= $cutTurn) { $month++; }
+ if($date <= $cutTurn && $date >= $admin['opentime']) { $month++; }
$totaldate = $me['turntime'];
diff --git a/hwe/func.php b/hwe/func.php
index ae93013d..e0b64d3d 100644
--- a/hwe/func.php
+++ b/hwe/func.php
@@ -2315,16 +2315,30 @@ function SabotageInjury($city, $type=0) {
return $injuryCount;
}
-function getRandTurn($term) {
+function getRandTurn($term, ?\DateTimeInterface $baseDateTime = null) {
+ if($baseDateTime === null){
+ $baseDateTime = new \DateTimeImmutable();
+ }
+ else if($baseDateTime instanceof \DateTime){
+ $baseDateTime = DateTimeImmutable::createFromMutable($baseDateTime);
+ }
+
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
$randFraction = Util::randRangeInt(0, 999999) / 1000000;//6자리 소수
- return TimeUtil::nowAddSeconds($randSecond + $randFraction, true);
+ return $baseDateTime->add(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s');
}
-function getRandTurn2($term) {
+function getRandTurn2($term, ?\DateTimeInterface $baseDateTime = null)
+{
+ if($baseDateTime === null){
+ $baseDateTime = new \DateTimeImmutable();
+ }
+ else if($baseDateTime instanceof \DateTime){
+ $baseDateTime = DateTimeImmutable::createFromMutable($baseDateTime);
+ }
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
$randFraction = Util::randRangeInt(0, 999999) / 1000000;//6자리 소수
- return TimeUtil::nowAddSeconds(- $randSecond - $randFraction, true);
-}
+ return $baseDateTime->sub(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s');
+}
\ No newline at end of file
diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php
index f46a38e6..b27c1f2d 100644
--- a/hwe/func_gamerule.php
+++ b/hwe/func_gamerule.php
@@ -882,7 +882,7 @@ function updateNationState() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$history = array();
- $admin = $gameStor->getValues(['year', 'month', 'fiction', 'startyear', 'show_img_level', 'turnterm']);
+ $admin = $gameStor->getValues(['year', 'month', 'fiction', 'startyear', 'show_img_level', 'turnterm', 'turntime']);
$assemblerCnts = [];
foreach($db->queryAllLists('SELECT nation,count(no) FROM general WHERE npc = 5 GROUP BY nation') as [$nationID, $assemblerCnt]){
diff --git a/hwe/func_process_chief.php b/hwe/func_process_chief.php
index dc2e3736..9d7fb1ec 100644
--- a/hwe/func_process_chief.php
+++ b/hwe/func_process_chief.php
@@ -1403,7 +1403,7 @@ function process_76(&$general) {
$date = substr($general['turntime'],11,5);
- $admin = $gameStor->getValues(['startyear','year','month','develcost','turnterm']);
+ $admin = $gameStor->getValues(['startyear','year','month','develcost','npccount', 'turnterm', 'turntime']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1573,7 +1573,7 @@ function process_76(&$general) {
$affinity = rand() % 150 + 1;
$name = "ⓖ의병장{$npcid}";
$picture = 'default.jpg';
- $turntime = getRandTurn($admin['turnterm']);
+ $turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime']));
$personal = rand() % 10;
$bornyear = $admin['year'];
$deadyear = $admin['year'] + 3;
diff --git a/hwe/func_process_personnel.old.php b/hwe/func_process_personnel.old.php
index ad84b547..61695f6c 100644
--- a/hwe/func_process_personnel.old.php
+++ b/hwe/func_process_personnel.old.php
@@ -284,7 +284,7 @@ function process_29(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
- $admin = $gameStor->getValues(['startyear','year','month','develcost','npccount','turnterm','scenario','maxgeneral']);
+ $admin = $gameStor->getValues(['startyear','year','month','develcost','npccount','turnterm','scenario','maxgeneral', 'turntime']);
$query = "select nation,name,level,gennum,scout from nation where nation='{$general['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -484,7 +484,7 @@ function process_29(&$general) {
$npccount = 10000 + $npcid;
$affinity = rand() % 150 + 1;
$picture = 'default.jpg';
- $turntime = getRandTurn($admin['turnterm']);
+ $turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime']));
$personal = rand() % 10;
$bornyear = $admin['year'];
$deadyear = $admin['year'] + 3;
diff --git a/hwe/install.php b/hwe/install.php
index 4fcc5d39..b4edf004 100644
--- a/hwe/install.php
+++ b/hwe/install.php
@@ -225,6 +225,13 @@ if($session->userGrade < 5 && !$allowReset){
+
+
diff --git a/hwe/j_autoreset.php b/hwe/j_autoreset.php
index 33b4f9c0..d1f3b872 100644
--- a/hwe/j_autoreset.php
+++ b/hwe/j_autoreset.php
@@ -88,7 +88,8 @@ $result = ResetHelper::buildScenario(
$options['npcmode'],
$options['show_img_level'],
$options['tournament_trig'],
- $options['join_mode']
+ $options['join_mode'],
+ $options['starttime']
);
$result['affected']=1;
diff --git a/hwe/j_install.php b/hwe/j_install.php
index c4a753d5..08e5901b 100644
--- a/hwe/j_install.php
+++ b/hwe/j_install.php
@@ -27,6 +27,20 @@ if($reserve_open && $reserve_open < date('Y-m-d H:i')){
]);
}
+$pre_reserve_open = Util::getReq('pre_reserve_open');
+if($pre_reserve_open && !$reserve_open){
+ Json::die([
+ 'result'=>false,
+ 'reason'=>'가오픈 예약을 위해선 오픈 예약을 지정해야합니다.'
+ ]);
+}
+if($pre_reserve_open && $pre_reserve_open >= $reserve_open){
+ Json::die([
+ 'result'=>false,
+ 'reason'=>'가오픈 시간이 오픈 예약 시점보다 이전이어야 합니다.'
+ ]);
+}
+
if($session->userGrade < 5 && !$allowReset){
Json::die([
'result'=>false,
@@ -114,22 +128,35 @@ if($reserve_open){
}
$scenarioObj = new Scenario($scenario, true);
+ $open_date = $reserve_open->format('Y-m-d H:i:s');
+
+ $reserveInfo = [
+ 'turnterm'=>$turnterm,
+ 'sync'=>$sync,
+ 'scenario'=>$scenario,
+ 'scenarioName'=>$scenarioObj->getTitle(),
+ 'fiction'=>$fiction,
+ 'extend'=>$extend,
+ 'npcmode'=>$npcmode,
+ 'show_img_level'=>$show_img_level,
+ 'tournament_trig'=>$tournament_trig,
+ 'gameConf'=>$scenarioObj->getGameConf(),
+ 'join_mode'=>$join_mode,
+ 'starttime'=>$open_date,
+ ];
+
+
+ if($pre_reserve_open){
+ $pre_reserve_open = new \DateTime($pre_reserve_open);
+ $open_date = $pre_reserve_open->format('Y-m-d H:i:s');
+ }
+
+
+
$db->delete('reserved_open', true);
$db->insert('reserved_open', [
- 'options'=>Json::encode([
- 'turnterm'=>$turnterm,
- 'sync'=>$sync,
- 'scenario'=>$scenario,
- 'scenarioName'=>$scenarioObj->getTitle(),
- 'fiction'=>$fiction,
- 'extend'=>$extend,
- 'npcmode'=>$npcmode,
- 'show_img_level'=>$show_img_level,
- 'tournament_trig'=>$tournament_trig,
- 'gameConf'=>$scenarioObj->getGameConf(),
- 'join_mode'=>$join_mode,
- ]),
- 'date'=>$reserve_open->format('Y-m-d H:i:s')
+ 'options'=>Json::encode($reserveInfo),
+ 'date'=>$open_date
]);
AppConf::getList()[DB::prefix()]->closeServer();
Json::die([
@@ -147,5 +174,6 @@ Json::die(ResetHelper::buildScenario(
$npcmode,
$show_img_level,
$tournament_trig,
- $join_mode
+ $join_mode,
+ TimeUtil::DatetimeNow()
));
\ No newline at end of file
diff --git a/hwe/j_server_basic_info.php b/hwe/j_server_basic_info.php
index 32913687..75d2e9a2 100644
--- a/hwe/j_server_basic_info.php
+++ b/hwe/j_server_basic_info.php
@@ -53,6 +53,7 @@ if(file_exists(__dir__.'/.htaccess')){
'fictionMode'=>($options['fiction']?'가상':'사실'),
'npcMode'=>($options['npcmode']?'가능':'불가'),
'openDatetime'=>$reserved['date'],
+ 'starttime'=>$options['starttime'],
'gameConf'=>$options['gameConf'],
'otherTextInfo'=>$otherTextInfo
],
@@ -63,12 +64,12 @@ if(file_exists(__dir__.'/.htaccess')){
//TODO: 천통시에도 예약 오픈 알림이 필요..?
-$admin = $gameStor->getValues(['isunited', 'npcmode', 'year', 'month', 'scenario', 'scenario_text', 'maxgeneral', 'turnterm', 'starttime', 'turntime']);
+$admin = $gameStor->getValues(['isunited', 'npcmode', 'year', 'month', 'scenario', 'scenario_text', 'maxgeneral', 'turnterm', 'opentime', 'turntime']);
$admin['maxUserCnt'] = $admin['maxgeneral'];
$admin['npcMode'] = $admin['npcmode'];
$admin['turnTerm'] = $admin['turnterm'];
$admin['isUnited'] = $admin['isunited'];
-$admin['starttime'] = substr($admin['starttime'], 5, 11);
+$admin['starttime'] = substr($admin['opentime'], 5, 11);
$admin['turntime'] = substr($admin['turntime'], 5, 11);
unset($admin['npcmode']);
unset($admin['maxgeneral']);
diff --git a/hwe/join_post.php b/hwe/join_post.php
index d5ec7fa9..e99782d8 100644
--- a/hwe/join_post.php
+++ b/hwe/join_post.php
@@ -68,7 +68,7 @@ if (!$member) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
-$gameStor->cacheValues(['year','month','maxgeneral','scenario','show_img_level','turnterm','genius','npcmode']);
+$gameStor->cacheValues(['year','month','maxgeneral','scenario','show_img_level','turnterm','turntime','genius','npcmode']);
########## 동일 정보 존재여부 확인. ##########
$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2');
@@ -153,7 +153,7 @@ $leader = $leader + $pleader;
$power = $power + $ppower;
$intel = $intel + $pintel;
-$admin = $gameStor->getValues(['scenario', 'turnterm', 'show_img_level', 'startyear', 'year']);
+$admin = $gameStor->getValues(['scenario', 'turnterm', 'turntime', 'show_img_level', 'startyear', 'year']);
$relYear = Util::valueFit($admin['year'] - $admin['startyear'], 0);
$age = 20 + ($pleader + $ppower + $pintel) * 2 - (mt_rand(0, 1));
@@ -196,7 +196,7 @@ else{
$experience *= 0.8;
}
-$turntime = getRandTurn($admin['turnterm']);
+$turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime']));
$lastconnect = TimeUtil::now();
if ($lastconnect >= $turntime) {
diff --git a/hwe/js/install.js b/hwe/js/install.js
index 893ff3fc..10034b89 100644
--- a/hwe/js/install.js
+++ b/hwe/js/install.js
@@ -155,6 +155,7 @@ function formSetup(){
show_img_level:$('#show_img_level input:radio:checked').val(),
tournament_trig:$('#tournament_trig input:radio:checked').val(),
reserve_open:$('#reserve_open').val(),
+ pre_reserve_open:$('#pre_reserve_open').val(),
join_mode:$('#join_mode input:radio:checked').val(),
}
}).then(function(result){
diff --git a/hwe/sammo/ResetHelper.php b/hwe/sammo/ResetHelper.php
index 8afdefd4..48db1ab9 100644
--- a/hwe/sammo/ResetHelper.php
+++ b/hwe/sammo/ResetHelper.php
@@ -130,7 +130,8 @@ class ResetHelper{
int $npcmode,
int $show_img_level,
int $tournament_trig,
- string $join_mode
+ string $join_mode,
+ string $turntime
):array{
//FIXME: 분리할 것
if(120 % $turnterm != 0){
@@ -188,8 +189,6 @@ class ResetHelper{
true
);
-
- $turntime = TimeUtil::now(true);
if($sync == 0) {
// 현재 시간을 1월로 맞춤
$starttime = cutTurn($turntime, $turnterm);
@@ -230,6 +229,7 @@ class ResetHelper{
'develcost'=>$develcost,
'turntime'=>$turntime,
'starttime'=>$starttime,
+ 'opentime'=>$turntime,
'turnterm'=>$turnterm,
'killturn'=>$killturn,
'genius'=>GameConst::$defaultMaxGenius,
diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php
index 330f3936..d8999655 100644
--- a/hwe/sammo/Scenario/NPC.php
+++ b/hwe/sammo/Scenario/NPC.php
@@ -292,7 +292,7 @@ class NPC{
$level = $nationID?1:0;
}
- $turntime = \sammo\getRandTurn($env['turnterm']);
+ $turntime = \sammo\getRandTurn($env['turnterm'], new \DateTimeImmutable($env['turntime']));
$killturn = ($this->death - $year) * 12 + mt_rand(0, 11);
diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php
index c6b0d239..5f83c5fe 100644
--- a/hwe/sammo/TurnExecutionHelper.php
+++ b/hwe/sammo/TurnExecutionHelper.php
@@ -286,6 +286,11 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
$gameStor = KVStorage::getStorage($db, 'game_env');
+ if(TimeUtil::now(true) < $gameStor->turntime){
+ //턴 시각 이전이면 아무것도 하지 않음
+ return true;
+ }
+
if(!tryLock()){
return;
}
diff --git a/js/entrance.js b/js/entrance.js
index df4109bf..e3ff5721 100644
--- a/js/entrance.js
+++ b/js/entrance.js
@@ -46,7 +46,8 @@ var serverLoginTemplate = "\
var serverReservedTemplate = "\
\
-- 오픈 일시 : <%openDatetime%> - \
+<%openDatetime==starttime?'':'- 가오픈 일시 : '+openDatetime+ '- '%>\
+- 오픈 일시 : <%starttime%> - \
<%scenarioName%> <%turnterm%>분 턴 서버 \
(상성 설정:<%fictionMode%>), (빙의 여부:<%npcMode%>), (최대 스탯:<%gameConf.defaultStatTotal%>), (기타 설정:<%otherTextInfo%>) | \
";