From 445e445e49352858744ff5f2f4fdac48db4dcf57 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 9 May 2019 01:28:49 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=EC=98=88=EC=95=BD=ED=84=B4=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=20=EB=A6=B4=EB=A6=AC=EC=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/commandlist.php | 4 +-- hwe/func.php | 43 +++++++++++++++++++------ hwe/func_gamerule.php | 2 +- hwe/func_process_chief.php | 4 +-- hwe/func_process_personnel.php | 4 +-- hwe/install.php | 7 ++++ hwe/j_autoreset.php | 3 +- hwe/j_install.php | 58 +++++++++++++++++++++++++--------- hwe/join_post.php | 6 ++-- hwe/js/install.js | 1 + hwe/sammo/ResetHelper.php | 5 ++- hwe/sammo/Scenario/NPC.php | 2 +- 12 files changed, 99 insertions(+), 40 deletions(-) diff --git a/hwe/commandlist.php b/hwe/commandlist.php index 233b32f0..9662029b 100644 --- a/hwe/commandlist.php +++ b/hwe/commandlist.php @@ -78,7 +78,7 @@ function myCommandList() { $date = date('Y-m-d H:i:s'); // 명령 목록 - $admin = $gameStor->getValues(['year','month','turnterm']); + $admin = $gameStor->getValues(['year','month','turnterm','turntime']); $me = $db->queryFirstRow("SELECT `no`,turntime,term,turn0,turn1,turn2,turn3,turn4,turn5,turn6,turn7,turn8,turn9,turn10,turn11,turn12,turn13,turn14,turn15,turn16,turn17,turn18,turn19,turn20,turn21,turn22,turn23 FROM general WHERE `owner`=%s", $userID); if(!$me){ @@ -97,7 +97,7 @@ function myCommandList() { $month = $admin['month']; // 실행된 턴시간이면 +1 $cutTurn = cutTurn($me['turntime'], $admin['turnterm']); - if($date <= $cutTurn) { $month++; } + if($date <= $cutTurn && $date < $admin['tuntime']) { $month++; } $totaldate = $me['turntime']; diff --git a/hwe/func.php b/hwe/func.php index b8c74338..37eb5792 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1523,6 +1523,11 @@ function checkTurn() { $alllog = []; + if(date('Y-m-d H:i:s') < $gameStor->turntime){ + //턴 시각 이전이면 아무것도 하지 않음 + return true; + } + // 잦은 갱신 금지 현재 5초당 1회 if(!timeover()) { return; } // 현재 처리중이면 접근 불가 @@ -1557,7 +1562,12 @@ function checkTurn() { $db->update('plock', ['plock'=>1], true); return; } + + $date = date('Y-m-d H:i:s'); + $gameStor->cacheAll(); + + // 1턴이상 갱신 없었으면 서버 지연 //if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', checkDelay'); checkDelay(); @@ -1569,10 +1579,11 @@ function checkTurn() { CheckOverhead(); //서버정보 - $date = date('Y-m-d H:i:s'); + // 최종 처리 월턴의 다음 월턴시간 구함 $prevTurn = cutTurn($gameStor->turntime, $gameStor->turnterm); $nextTurn = addTurn($prevTurn, $gameStor->turnterm); + $computedPrevTurn = false; // 현재 턴 이전 월턴까지 모두처리. //최종 처리 이후 다음 월턴이 현재 시간보다 전이라면 while($nextTurn <= $date) { @@ -1678,12 +1689,16 @@ function checkTurn() { // 다음달로 넘김 $prevTurn = $nextTurn; $nextTurn = addTurn($prevTurn, $gameStor->turnterm); + $computedPrevTurn = true; } //if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', '.__LINE__); // 이시각 정각 시까지 업데이트 완료했음 - $gameStor->turntime = $prevTurn; + if($computedPrevTurn){ + $gameStor->turntime = $prevTurn; + } + // 그 시각 년도,월 저장 list($gameStor->year, $gameStor->month) = turnDate($prevTurn); @@ -2915,16 +2930,24 @@ 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); + } $randtime = rand(0, 60 * $term - 1); - $turntime = date('Y-m-d H:i:s', strtotime('now') + $randtime); - - return $turntime; + return $baseDateTime->add(new \DateInterval('PT'.$randtime.'S'))->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); + } $randtime = rand(0, 60 * $term - 1); - $turntime = date('Y-m-d H:i:s', strtotime('now') - $randtime); - - return $turntime; + return $baseDateTime->sub(new \DateInterval('PT'.$randtime.'S'))->format('Y-m-d H:i:s'); } diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 03132efc..ba16fdec 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -973,7 +973,7 @@ function updateNationState() { $connect=$db->get(); $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']); $query = "select nation,name,level,gennum,tech from nation"; $nationresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); diff --git a/hwe/func_process_chief.php b/hwe/func_process_chief.php index 3e9a9bc8..04125696 100644 --- a/hwe/func_process_chief.php +++ b/hwe/func_process_chief.php @@ -1894,7 +1894,7 @@ function process_76(&$general) { $date = substr($general['turntime'],11,5); - $admin = $gameStor->getValues(['startyear','year','month','develcost','npccount','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),""); @@ -2070,7 +2070,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.php b/hwe/func_process_personnel.php index 10c6e192..0eade9c9 100644 --- a/hwe/func_process_personnel.php +++ b/hwe/func_process_personnel.php @@ -290,7 +290,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),""); @@ -490,7 +490,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/join_post.php b/hwe/join_post.php index 2452534c..89bd02cc 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)); @@ -187,7 +187,7 @@ else{ $experience *= 0.8; } -$turntime = getRandTurn($admin['turnterm']); +$turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime'])); $lastconnect = date('Y-m-d H:i:s'); 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 fd1582bc..e5e6d057 100644 --- a/hwe/sammo/ResetHelper.php +++ b/hwe/sammo/ResetHelper.php @@ -129,7 +129,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){ @@ -186,8 +187,6 @@ class ResetHelper{ true ); - - $turntime = date('Y-m-d H:i:s'); $time = substr($turntime, 11, 2); if($sync == 0) { // 현재 시간을 1월로 맞춤 diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php index c336bfd8..05f387d6 100644 --- a/hwe/sammo/Scenario/NPC.php +++ b/hwe/sammo/Scenario/NPC.php @@ -227,7 +227,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); From 2f09df75212ea55a79402909063da7434180ec06 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 9 May 2019 01:34:06 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=EA=B0=80=EC=98=A4=ED=94=88=20=EC=9D=BC?= =?UTF-8?q?=EC=9E=90=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/j_server_basic_info.php | 1 + js/entrance.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hwe/j_server_basic_info.php b/hwe/j_server_basic_info.php index 32913687..5e218964 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 ], diff --git a/js/entrance.js b/js/entrance.js index ea9a87ba..f2db3f91 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%>)\ "; From 943e2be676f5e562cfa64ce5cbd382a42998442f Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 9 May 2019 01:59:06 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=EC=BB=A4=EB=A7=A8=EB=93=9C=20=EC=B0=BD?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EA=B0=80=EC=98=A4=ED=94=88=20=EB=95=8C?= =?UTF-8?q?=EB=AC=B8=EC=97=90=20=ED=84=B4=EC=9D=B4=20=EC=9D=B4=EC=83=81?= =?UTF-8?q?=ED=95=98=EA=B2=8C=20=EB=B3=B4=EC=9D=B4=EB=8A=94=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/commandlist.php | 4 ++-- hwe/sammo/ResetHelper.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hwe/commandlist.php b/hwe/commandlist.php index 9662029b..35ec1877 100644 --- a/hwe/commandlist.php +++ b/hwe/commandlist.php @@ -78,7 +78,7 @@ function myCommandList() { $date = date('Y-m-d H:i:s'); // 명령 목록 - $admin = $gameStor->getValues(['year','month','turnterm','turntime']); + $admin = $gameStor->getValues(['year','month','turnterm','turntime','opentime']); $me = $db->queryFirstRow("SELECT `no`,turntime,term,turn0,turn1,turn2,turn3,turn4,turn5,turn6,turn7,turn8,turn9,turn10,turn11,turn12,turn13,turn14,turn15,turn16,turn17,turn18,turn19,turn20,turn21,turn22,turn23 FROM general WHERE `owner`=%s", $userID); if(!$me){ @@ -97,7 +97,7 @@ function myCommandList() { $month = $admin['month']; // 실행된 턴시간이면 +1 $cutTurn = cutTurn($me['turntime'], $admin['turnterm']); - if($date <= $cutTurn && $date < $admin['tuntime']) { $month++; } + if($date <= $cutTurn && $date >= $admin['opentime']) { $month++; } $totaldate = $me['turntime']; diff --git a/hwe/sammo/ResetHelper.php b/hwe/sammo/ResetHelper.php index e5e6d057..bf1bf6ef 100644 --- a/hwe/sammo/ResetHelper.php +++ b/hwe/sammo/ResetHelper.php @@ -228,6 +228,7 @@ class ResetHelper{ 'develcost'=>$develcost, 'turntime'=>$turntime, 'starttime'=>$starttime, + 'opentime'=>$turntime, 'turnterm'=>$turnterm, 'killturn'=>$killturn, 'genius'=>GameConst::$defaultMaxGenius, From 85e9223603a0571fd7bf81a987fa08134db0eb6f Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 9 May 2019 02:00:25 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=EC=84=9C=EB=B2=84=EC=9D=98=20=EC=98=A4?= =?UTF-8?q?=ED=94=88=20=EC=8B=9C=EA=B0=84=EC=9D=84=20=EA=B8=B0=EB=A1=9D?= =?UTF-8?q?=ED=96=88=EC=9C=BC=EB=AF=80=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/j_server_basic_info.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hwe/j_server_basic_info.php b/hwe/j_server_basic_info.php index 5e218964..75d2e9a2 100644 --- a/hwe/j_server_basic_info.php +++ b/hwe/j_server_basic_info.php @@ -64,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']);