diff --git a/hwe/_119.php b/hwe/_119.php index 3f34da10..1d65c38c 100644 --- a/hwe/_119.php +++ b/hwe/_119.php @@ -25,6 +25,7 @@ if($session->userGrade < 4) { } $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select turntime,tnmt_time from game"; diff --git a/hwe/_119_b.php b/hwe/_119_b.php index fd154c62..2b957332 100644 --- a/hwe/_119_b.php +++ b/hwe/_119_b.php @@ -27,6 +27,7 @@ $minute2 = Util::getReq('minute2', 'int'); extractMissingPostToGlobals(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); switch($btn) { diff --git a/hwe/_admin1_submit.php b/hwe/_admin1_submit.php index 88b4c4ac..7423696a 100644 --- a/hwe/_admin1_submit.php +++ b/hwe/_admin1_submit.php @@ -33,6 +33,7 @@ $startyear = Util::getReq('startyear', 'int', GameConst::$defaultStartYear); extractMissingPostToGlobals(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $admin = getAdmin(); diff --git a/hwe/_admin2.php b/hwe/_admin2.php index 54ad7618..c7d363ca 100644 --- a/hwe/_admin2.php +++ b/hwe/_admin2.php @@ -26,6 +26,7 @@ if($session->userGrade < 5) { } $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select conlimit from game limit 1"; diff --git a/hwe/_admin2_submit.php b/hwe/_admin2_submit.php index f6fa480b..ac4160b3 100644 --- a/hwe/_admin2_submit.php +++ b/hwe/_admin2_submit.php @@ -22,6 +22,7 @@ if(!$generalID){ } $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $src = MessageTarget::buildQuick($session->generalID); diff --git a/hwe/_admin4.php b/hwe/_admin4.php index 4100bd4c..f95f7f0c 100644 --- a/hwe/_admin4.php +++ b/hwe/_admin4.php @@ -26,6 +26,7 @@ if($session->userGrade < 5) { } $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select conlimit from game limit 1"; diff --git a/hwe/_admin5.php b/hwe/_admin5.php index 200bfb32..214a8ac4 100644 --- a/hwe/_admin5.php +++ b/hwe/_admin5.php @@ -39,6 +39,7 @@ if($session->userGrade < 5) { } $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $sel = []; diff --git a/hwe/_simul.php b/hwe/_simul.php index 31448750..875f5448 100644 --- a/hwe/_simul.php +++ b/hwe/_simul.php @@ -74,6 +74,7 @@ $dec = 0; $rice = 0; $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("시뮬", 2); diff --git a/hwe/a_bestGeneral.php b/hwe/a_bestGeneral.php index 3f95f757..3e8945ae 100644 --- a/hwe/a_bestGeneral.php +++ b/hwe/a_bestGeneral.php @@ -13,6 +13,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("명장일람", 2); diff --git a/hwe/a_genList.php b/hwe/a_genList.php index c0748ab9..3e59a071 100644 --- a/hwe/a_genList.php +++ b/hwe/a_genList.php @@ -13,6 +13,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("장수일람", 2); diff --git a/hwe/a_history.php b/hwe/a_history.php index 50a28805..a798931e 100644 --- a/hwe/a_history.php +++ b/hwe/a_history.php @@ -13,6 +13,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("연감", 2); diff --git a/hwe/a_kingdomList.php b/hwe/a_kingdomList.php index 2beb3c1a..e83fb199 100644 --- a/hwe/a_kingdomList.php +++ b/hwe/a_kingdomList.php @@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("세력일람", 2); diff --git a/hwe/a_status.php b/hwe/a_status.php index 578bec77..1f5e3a39 100644 --- a/hwe/a_status.php +++ b/hwe/a_status.php @@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("세력도", 2); diff --git a/hwe/a_traffic.php b/hwe/a_traffic.php index 2a497157..849e3ceb 100644 --- a/hwe/a_traffic.php +++ b/hwe/a_traffic.php @@ -5,6 +5,7 @@ include "lib.php"; include "func.php"; $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("갱신정보", 2); diff --git a/hwe/a_vote.php b/hwe/a_vote.php index e4c5effa..acbfa659 100644 --- a/hwe/a_vote.php +++ b/hwe/a_vote.php @@ -7,6 +7,7 @@ include "func.php"; $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("설문조사", 1); diff --git a/hwe/b_auction.php b/hwe/b_auction.php index 2dfb908a..3bf0ba4d 100644 --- a/hwe/b_auction.php +++ b/hwe/b_auction.php @@ -14,6 +14,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("거래장", 2); diff --git a/hwe/b_battleCenter.php b/hwe/b_battleCenter.php index 0a566c00..33c784d6 100644 --- a/hwe/b_battleCenter.php +++ b/hwe/b_battleCenter.php @@ -23,6 +23,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("감찰부", 2); diff --git a/hwe/b_betting.php b/hwe/b_betting.php index 70e05852..d9bd57c9 100644 --- a/hwe/b_betting.php +++ b/hwe/b_betting.php @@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("베팅장", 1); diff --git a/hwe/b_chiefcenter.php b/hwe/b_chiefcenter.php index 59502d02..18b66cbd 100644 --- a/hwe/b_chiefcenter.php +++ b/hwe/b_chiefcenter.php @@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("사령부", 1); diff --git a/hwe/b_dipcenter.php b/hwe/b_dipcenter.php index fd982998..96b4f141 100644 --- a/hwe/b_dipcenter.php +++ b/hwe/b_dipcenter.php @@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("내무부", 1); diff --git a/hwe/b_diplomacy.php b/hwe/b_diplomacy.php index 649de4b6..5b905d06 100644 --- a/hwe/b_diplomacy.php +++ b/hwe/b_diplomacy.php @@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("중원정보", 1); diff --git a/hwe/b_genList.php b/hwe/b_genList.php index f5717fde..0610e207 100644 --- a/hwe/b_genList.php +++ b/hwe/b_genList.php @@ -16,6 +16,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("암행부", 2); diff --git a/hwe/b_myKingdomInfo.php b/hwe/b_myKingdomInfo.php index f3508d13..b2a659f5 100644 --- a/hwe/b_myKingdomInfo.php +++ b/hwe/b_myKingdomInfo.php @@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("세력정보", 1); diff --git a/hwe/b_myPage.php b/hwe/b_myPage.php index 9e5f7491..505f4bbf 100644 --- a/hwe/b_myPage.php +++ b/hwe/b_myPage.php @@ -25,6 +25,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("내정보", 1); diff --git a/hwe/b_tournament.php b/hwe/b_tournament.php index e2182692..9a5d1aa9 100644 --- a/hwe/b_tournament.php +++ b/hwe/b_tournament.php @@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("토너먼트", 1); diff --git a/hwe/c_auction.php b/hwe/c_auction.php index 1e113c18..2ebe6a81 100644 --- a/hwe/c_auction.php +++ b/hwe/c_auction.php @@ -34,6 +34,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("입찰", 1); diff --git a/hwe/c_betting.php b/hwe/c_betting.php index 6aa93e51..63333526 100644 --- a/hwe/c_betting.php +++ b/hwe/c_betting.php @@ -38,6 +38,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); increaseRefresh("베팅", 1); diff --git a/hwe/c_myBossInfo.php b/hwe/c_myBossInfo.php index f8c352bf..be5dee5e 100644 --- a/hwe/c_myBossInfo.php +++ b/hwe/c_myBossInfo.php @@ -18,6 +18,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select startyear,year,month,scenario from game limit 1"; diff --git a/hwe/c_tournament.php b/hwe/c_tournament.php index 0b5cd2ec..7ec08161 100644 --- a/hwe/c_tournament.php +++ b/hwe/c_tournament.php @@ -21,6 +21,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select tournament,phase,tnmt_type,develcost from game limit 1"; diff --git a/hwe/c_vacation.php b/hwe/c_vacation.php index e694007c..2549db77 100644 --- a/hwe/c_vacation.php +++ b/hwe/c_vacation.php @@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select killturn from game limit 1"; diff --git a/hwe/c_vote.php b/hwe/c_vote.php index c3bc137e..f15b464f 100644 --- a/hwe/c_vote.php +++ b/hwe/c_vote.php @@ -17,6 +17,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select develcost,vote,votecomment from game limit 1"; diff --git a/hwe/commandlist.php b/hwe/commandlist.php index 63785ea9..c315c8fb 100644 --- a/hwe/commandlist.php +++ b/hwe/commandlist.php @@ -67,6 +67,7 @@ myCommandList(); function myCommandList() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $userID = Session::getUserID(); diff --git a/hwe/func.php b/hwe/func.php index c674297a..36595e41 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -96,6 +96,7 @@ function checkLimit($con = null, $conlimit = null) { } $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); if($con === null){ $con = $db->queryFirstField('SELECT con FROM general WHERE `owner`=%i', Session::getUserID()); @@ -258,6 +259,7 @@ function cityInfo() { function myNationInfo() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $userID = Session::getUserID(); @@ -435,6 +437,7 @@ function commandGroup($typename, $type=0) { function commandTable() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $userID = Session::getUserID(); @@ -675,6 +678,7 @@ function commandTable() { function CoreCommandTable() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $userID = Session::getUserID(); @@ -777,6 +781,7 @@ function myInfo() { function generalInfo($no) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select show_img_level from game limit 1"; @@ -1084,6 +1089,7 @@ function generalInfo2($no) { function adminMsg() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select msg from game limit 1"; @@ -1100,6 +1106,7 @@ function getOnlineNum() { function onlinegen() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $onlinegen = ""; @@ -1119,6 +1126,7 @@ function onlinegen() { function onlineNation() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select onlinenation from game limit 1"; @@ -1268,6 +1276,7 @@ function increaseRefresh($type="", $cnt=1) { $date = date('Y-m-d H:i:s'); $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $db->update('game', [ 'refresh'=>$db->sqleval('refresh+%i', $cnt) ], true); @@ -1338,6 +1347,7 @@ function increaseRefresh($type="", $cnt=1) { function updateTraffic() { $online = getOnlineNum(); $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $game = $db->queryFirstRow('SELECT year,month,refresh,maxonline,maxrefresh from game limit 1'); //최다갱신자 @@ -1374,6 +1384,7 @@ function updateTraffic() { function CheckOverhead() { //서버정보 $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $admin = $db->queryFirstRow('SELECT turnterm, conlimit from game LIMIT 1'); $con = Util::round(pow($admin['turnterm'], 0.6) * 3) * 10; @@ -1420,6 +1431,8 @@ function unlock() { } function timeover() { + $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $admin = DB::db()->queryFirstRow( 'SELECT turnterm,TIMESTAMPDIFF(SECOND,turntime,now()) as diff from game limit 1' ); @@ -1433,6 +1446,7 @@ function timeover() { function checkDelay() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); //서버정보 @@ -1465,6 +1479,7 @@ function checkDelay() { function updateOnline() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $nationname = ["재야"]; @@ -1514,6 +1529,7 @@ function updateOnline() { function checkTurn() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $alllog = []; @@ -1743,6 +1759,7 @@ function checkTurn() { function addAge() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); //나이와 호봉 증가 @@ -1787,7 +1804,7 @@ function addAge() { function turnDate($curtime) { $db = DB::db(); - + $gameStor = KVStorage::getStorage($db, 'game'); $admin = $db->queryFirstRow('SELECT startyear,starttime,turnterm,year,month from game limit 1'); $turn = $admin['starttime']; @@ -1816,6 +1833,7 @@ function turnDate($curtime) { function triggerTournament() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select tournament,tnmt_trig from game limit 1"; @@ -1913,6 +1931,7 @@ function PreprocessCommand($no) { function updateTurntime($no) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $alllog = []; $log = []; @@ -2163,6 +2182,7 @@ function CheckHall($no) { function uniqueItem($general, $log, $vote=0) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $alllog = []; $history = []; @@ -2374,6 +2394,7 @@ function checkExperience($general, $log) { function getAdmin() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select * from game limit 1"; @@ -2430,6 +2451,7 @@ function getNation($nation) { function deleteNation($general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $history = []; @@ -2465,6 +2487,7 @@ function deleteNation($general) { function nextRuler($general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select year,month from game limit 1"; @@ -2672,6 +2695,7 @@ function CharCritical($rate, $personal) { function SabotageInjury($city, $type=0) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; diff --git a/hwe/func_auction.php b/hwe/func_auction.php index 9903b4dd..9ec3b1e1 100644 --- a/hwe/func_auction.php +++ b/hwe/func_auction.php @@ -18,6 +18,7 @@ function GetStuffName($stuff) { function registerAuction() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select startyear,year,month,turnterm from game limit 1"; @@ -142,6 +143,7 @@ function registerAuction() { function processAuction() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $trader = []; diff --git a/hwe/func_command.php b/hwe/func_command.php index 7a9a1741..961bfeda 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -457,6 +457,7 @@ function getCoreTurn($nation, $level) { function processCommand($no) { $session = Session::getInstance(); $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select npc,no,name,picture,imgsvr,nation,nations,city,troop,injury,leader,leader2,power,power2,intel,intel2,experience,dedication,level,gold,rice,crew,crewtype,train,atmos,weap,book,horse,item,turntime,makenation,makelimit,killturn,block,dedlevel,explevel,age,belong,personal,special,special2,term,turn0,dex0,dex10,dex20,dex30,dex40 from general where no='$no'"; diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 51baa14e..e809e4fe 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -341,6 +341,7 @@ function updateQuaterly() { // 벌점 감소와 건국제한-1 전턴제한-1 외교제한-1, 1달마다 실행, 병사 있는 장수의 군량 감소, 수입비율 조정 function preUpdateMonthly() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); //연감 월결산 @@ -493,6 +494,7 @@ function preUpdateMonthly() { // 외교 로그처리, 외교 상태 처리 function postUpdateMonthly() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select startyear,year,month,scenario from game limit 1"; @@ -647,6 +649,7 @@ group by A.nation function checkWander() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select year,month from game limit 1"; @@ -678,6 +681,7 @@ function checkWander() { function checkMerge() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $mylog = []; @@ -800,6 +804,7 @@ function checkMerge() { function checkSurrender() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select year,month from game limit 1"; @@ -924,6 +929,7 @@ function checkSurrender() { function updateNationState() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $history = array(); @@ -1005,6 +1011,7 @@ function updateNationState() { function checkStatistic() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select year,month from game limit 1"; @@ -1161,6 +1168,7 @@ function checkStatistic() { function checkEmperior() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select year,month,isUnited from game limit 1"; diff --git a/hwe/func_history.php b/hwe/func_history.php index d51125ad..94ec01e8 100644 --- a/hwe/func_history.php +++ b/hwe/func_history.php @@ -151,6 +151,7 @@ function pushWorldHistory(array $history, $year=null, $month=null) { return; } $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); if($year === null || $month === null){ $game = $db->queryFirstRow('SELECT year, month FROM game LIMIT 1'); $year = $game['year']; @@ -199,6 +200,7 @@ function pushGeneralPublicRecord(array $history, $year=null, $month=null) { return; } $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); if($year === null || $month === null){ $game = $db->queryFirstRow('SELECT year, month FROM game LIMIT 1'); $year = $game['year']; @@ -249,6 +251,7 @@ function LogHistory($isFirst=0) { if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', LogHistory Start'); $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $obj = $db->queryFirstRow('SELECT year, month, startyear FROM game limit 1'); //TODO: 새롭게 추가할 지도 값 받아오는 함수를 이용하여 재구성 diff --git a/hwe/func_legacy.php b/hwe/func_legacy.php index 430c21ef..5368284e 100644 --- a/hwe/func_legacy.php +++ b/hwe/func_legacy.php @@ -106,6 +106,7 @@ function printCitiesBasedOnDistance(int $cityNo, int $maxDistance=1) { function info($type=0) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select year,month,turnterm,maxgeneral from game limit 1"; diff --git a/hwe/func_map.php b/hwe/func_map.php index 73dc37e6..c3e798c6 100644 --- a/hwe/func_map.php +++ b/hwe/func_map.php @@ -54,6 +54,7 @@ function getWorldMap($req){ $userID = $session->userID; $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $game = $db->queryFirstRow('select `startyear`, `year`, `month` from `game` where `no` = 1'); $startYear = Util::toInt($game['startyear']); diff --git a/hwe/func_npc.php b/hwe/func_npc.php index 1dedf5fd..8458be65 100644 --- a/hwe/func_npc.php +++ b/hwe/func_npc.php @@ -165,6 +165,7 @@ function SetCrew($no, $personal, $gold, $leader, $genType, $tech, $region, $city function processAI($no) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select startyear,year,month,turnterm,scenario,gold_rate,rice_rate from game limit 1"; @@ -1045,6 +1046,7 @@ function processAI($no) { function Promotion($nation, $level) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $lv = getNationChiefLevel($level); diff --git a/hwe/func_process.php b/hwe/func_process.php index d4c55c40..dc71792c 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -187,6 +187,7 @@ function CriticalScore($score, $type) { function process_1(&$general, $type) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -288,6 +289,7 @@ function process_1(&$general, $type) { function process_3(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -388,6 +390,7 @@ function process_3(&$general) { function process_4(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -479,6 +482,7 @@ function process_4(&$general) { function process_5(&$general, $type) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -580,6 +584,7 @@ function process_5(&$general, $type) { function process_7(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -671,6 +676,7 @@ function process_7(&$general) { function process_8(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -770,6 +776,7 @@ function process_8(&$general) { function process_9(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -860,6 +867,7 @@ function process_9(&$general) { function process_11(&$general, $type) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1046,6 +1054,7 @@ function process_11(&$general, $type) { function process_13(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1115,6 +1124,7 @@ function process_13(&$general) { function process_14(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1177,6 +1187,7 @@ function process_14(&$general) { function process_15(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1250,6 +1261,7 @@ function process_15(&$general) { function process_16(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1343,6 +1355,7 @@ function process_16(&$general) { function process_17(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1384,6 +1397,7 @@ function process_17(&$general) { function process_21(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1445,6 +1459,7 @@ function process_21(&$general) { function process_26(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1511,6 +1526,7 @@ function process_26(&$general) { function process_28(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1577,6 +1593,7 @@ function process_28(&$general) { function process_30(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1645,6 +1662,7 @@ function process_30(&$general) { function process_31(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1786,6 +1804,7 @@ function process_31(&$general) { function process_41(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1855,6 +1874,7 @@ function process_41(&$general) { function process_42(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -2076,6 +2096,7 @@ function process_42(&$general) { function process_43(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $genlog = []; @@ -2167,6 +2188,7 @@ function process_43(&$general) { function process_44(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -2258,6 +2280,7 @@ function process_44(&$general) { function process_48(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -2366,6 +2389,7 @@ function process_48(&$general) { function process_49(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -2503,6 +2527,7 @@ function process_49(&$general) { function process_50(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -2530,6 +2555,7 @@ function process_50(&$general) { function process_99(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; diff --git a/hwe/func_process_chief.php b/hwe/func_process_chief.php index b26315a5..15483b72 100644 --- a/hwe/func_process_chief.php +++ b/hwe/func_process_chief.php @@ -3,6 +3,7 @@ namespace sammo; function process_23(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $genlog = []; @@ -105,6 +106,7 @@ function process_23(&$general) { function process_24(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $genlog = []; @@ -233,6 +235,7 @@ function process_24(&$general) { function process_27(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -310,6 +313,7 @@ function process_27(&$general) { function process_51(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $date = substr($general['turntime'],11,5); list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1'); @@ -393,6 +397,7 @@ function process_51(&$general) { function process_52(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -505,6 +510,7 @@ function process_52(&$general) { function process_53(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $date = substr($general['turntime'],11,5); list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1'); @@ -589,6 +595,7 @@ function process_53(&$general) { function process_61(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $date = substr($general['turntime'],11,5); list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1'); @@ -689,6 +696,7 @@ function process_61(&$general) { function process_62(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -809,6 +817,7 @@ function process_62(&$general) { function process_63(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $date = substr($general['turntime'],11,5); list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1'); @@ -892,6 +901,7 @@ function process_63(&$general) { function process_64(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $date = substr($general['turntime'],11,5); list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1'); @@ -975,6 +985,7 @@ function process_64(&$general) { function process_65(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1069,6 +1080,7 @@ function process_65(&$general) { function process_66(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1159,6 +1171,7 @@ function process_66(&$general) { function process_67(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1250,6 +1263,7 @@ function process_67(&$general) { function process_68(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1353,6 +1367,7 @@ function process_68(&$general) { function process_71(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1459,6 +1474,7 @@ function process_71(&$general) { function process_72(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1574,6 +1590,7 @@ function process_72(&$general) { function process_73(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1705,6 +1722,7 @@ function process_73(&$general) { function process_74(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1849,6 +1867,7 @@ function process_74(&$general) { function process_75(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -1975,6 +1994,7 @@ function process_75(&$general) { function process_76(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -2194,6 +2214,7 @@ function process_76(&$general) { function process_77(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -2322,6 +2343,7 @@ function process_77(&$general) { function process_78(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -2447,6 +2469,7 @@ function process_78(&$general) { function process_81(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; diff --git a/hwe/func_process_personnel.php b/hwe/func_process_personnel.php index 93c483b7..5392d330 100644 --- a/hwe/func_process_personnel.php +++ b/hwe/func_process_personnel.php @@ -3,6 +3,7 @@ namespace sammo; function process_22(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -60,6 +61,7 @@ function process_22(&$general) { function process_25(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -183,6 +185,7 @@ function process_25(&$general) { function process_29(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -437,6 +440,7 @@ function process_29(&$general) { function process_45(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -549,6 +553,7 @@ function process_45(&$general) { function process_46(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -637,6 +642,7 @@ function process_46(&$general) { function process_47(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -702,6 +708,7 @@ function process_47(&$general) { function process_54(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -768,6 +775,7 @@ function process_54(&$general) { function process_55(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -857,6 +865,7 @@ function process_55(&$general) { function process_56(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -910,6 +919,7 @@ function process_56(&$general) { function process_57(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; diff --git a/hwe/func_process_sabotage.php b/hwe/func_process_sabotage.php index 62c17808..36cbc368 100644 --- a/hwe/func_process_sabotage.php +++ b/hwe/func_process_sabotage.php @@ -4,6 +4,7 @@ namespace sammo; function process_32(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -129,6 +130,7 @@ function process_32(&$general) { function process_33(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -281,6 +283,7 @@ function process_33(&$general) { function process_34(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; @@ -407,6 +410,7 @@ function process_34(&$general) { function process_35(&$general) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $log = []; diff --git a/hwe/func_template.php b/hwe/func_template.php index ad13fe60..68d48702 100644 --- a/hwe/func_template.php +++ b/hwe/func_template.php @@ -66,6 +66,8 @@ function CoreTurnTable() { function allButton() { + $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $npcmode = DB::db()->queryFirstField("select npcmode from game limit 1"); if($npcmode == 1) { $site = "a_npcList.php"; diff --git a/hwe/func_time_event.php b/hwe/func_time_event.php index 8a0cf97b..e817679f 100644 --- a/hwe/func_time_event.php +++ b/hwe/func_time_event.php @@ -8,6 +8,7 @@ namespace sammo; //1월마다 실행 function processSpring() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); //인구 증가 @@ -369,6 +370,7 @@ function processFall() { function processRiceIncome() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select year,month,rice_rate from game limit 1"; @@ -570,6 +572,7 @@ function tradeRate() { function disaster() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select startyear,year,month from game limit 1"; diff --git a/hwe/func_tournament.php b/hwe/func_tournament.php index c8a72ad5..3c70329b 100644 --- a/hwe/func_tournament.php +++ b/hwe/func_tournament.php @@ -4,6 +4,7 @@ namespace sammo; function processTournament() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select tournament,phase,tnmt_type,tnmt_auto,tnmt_time,now() as now,TIMESTAMPDIFF(SECOND,tnmt_time,now()) as offset from game limit 1"; @@ -110,6 +111,7 @@ function processTournament() { function getTournamentTerm() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select tnmt_auto from game limit 1"; @@ -131,6 +133,7 @@ function getTournamentTerm() { function getTournamentTime() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select tournament,tnmt_time from game limit 1"; @@ -231,6 +234,7 @@ function printFighting($tournament, $phase) { function startTournament($auto, $type) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); eraseTnmtFightLogAll(); @@ -269,6 +273,7 @@ function startTournament($auto, $type) { function fillLowGenAll() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $general = []; @@ -376,6 +381,7 @@ function getTwo($tournament, $phase) { function qualify($tnmt_type, $tnmt, $phase) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $cand = getTwo($tnmt, $phase); @@ -416,6 +422,7 @@ function qualifyAll($tnmt_type, $tnmt, $phase) { function selection($tnmt_type, $tnmt, $phase) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); //시드1 배정 @@ -465,6 +472,7 @@ function selectionAll($tnmt_type, $tnmt, $phase) { function finallySingle($tnmt_type, $tnmt, $phase) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $cand = getTwo($tnmt, $phase); @@ -505,6 +513,7 @@ function finallyAll($tnmt_type, $tnmt, $phase) { function final16set() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); //1조1-5조2, 2조1-6조2, 3조1-7조2, 4조1-8조2, 5조1-1조2, 6조1-2조2, 7조1-3조2, 8조1-4조2 @@ -529,6 +538,7 @@ function final16set() { function finalFight($tnmt_type, $tnmt, $phase, $type) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); switch($type) { @@ -561,6 +571,7 @@ function finalFight($tnmt_type, $tnmt, $phase, $type) { function setGift($tnmt_type, $tnmt, $phase) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select year,month,develcost from game limit 1"; @@ -715,6 +726,7 @@ function setGift($tnmt_type, $tnmt, $phase) { function setRefund() { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $query = "select develcost from game limit 1"; diff --git a/hwe/index.php b/hwe/index.php index 9fee6a78..85acf8d9 100644 --- a/hwe/index.php +++ b/hwe/index.php @@ -10,6 +10,7 @@ $userID = Session::getUserID(); increaseRefresh("메인", 1); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); if (!$userID) { diff --git a/hwe/j_autoreset.php b/hwe/j_autoreset.php index a18f8588..bc35fff1 100644 --- a/hwe/j_autoreset.php +++ b/hwe/j_autoreset.php @@ -5,7 +5,7 @@ include 'lib.php'; include "func.php"; $db = DB::db(); - +$gameStor = KVStorage::getStorage($db, 'game'); $reserved = $db->queryFirstRow('SELECT `date`, options FROM reserved_open ORDER BY `date` ASC LIMIT 1'); if(!$reserved){ diff --git a/hwe/j_get_select_npc_token.php b/hwe/j_get_select_npc_token.php index 93de3b31..f59d1bef 100644 --- a/hwe/j_get_select_npc_token.php +++ b/hwe/j_get_select_npc_token.php @@ -21,6 +21,7 @@ $oNow = new \DateTimeImmutable(); $now = $oNow->format('Y-m-d H:i:s'); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $oldGeneral = $db->queryFirstField('SELECT `no` FROM general WHERE `owner`=%i', $userID); if($oldGeneral !== null){ diff --git a/hwe/j_install.php b/hwe/j_install.php index f4cc8af0..67a860a0 100644 --- a/hwe/j_install.php +++ b/hwe/j_install.php @@ -51,8 +51,8 @@ $reserve_open = Util::getReq('reserve_open'); if($reserve_open){ $reserve_open = new \DateTime($reserve_open); $db = DB::db(); - - if (!$db->queryFirstField("SHOW TABLES LIKE 'game'")) { + + if (!$db->queryFirstField("SHOW TABLES LIKE 'storage'")) { $clearResult = ResetHelper::clearDB(); if(!$clearResult['result']){ Json::die($clearResult); diff --git a/hwe/j_select_npc.php b/hwe/j_select_npc.php index ffa83201..199cbcb0 100644 --- a/hwe/j_select_npc.php +++ b/hwe/j_select_npc.php @@ -16,6 +16,7 @@ if(!$pick){ $session = Session::requireLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $rootDB = RootDB::db(); $oNow = new \DateTimeImmutable(); diff --git a/hwe/j_server_basic_info.php b/hwe/j_server_basic_info.php index 6877b4fe..88ceb33d 100644 --- a/hwe/j_server_basic_info.php +++ b/hwe/j_server_basic_info.php @@ -17,6 +17,7 @@ if(!class_exists('\\sammo\\DB')){ } $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); if(file_exists(__dir__.'/.htaccess')){ $reserved = $db->queryFirstRow( diff --git a/hwe/join.php b/hwe/join.php index d094eba7..35621580 100644 --- a/hwe/join.php +++ b/hwe/join.php @@ -23,6 +23,7 @@ if (!$member) { } $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); ?> diff --git a/hwe/join_post.php b/hwe/join_post.php index 76c155bf..45f576c2 100644 --- a/hwe/join_post.php +++ b/hwe/join_post.php @@ -66,6 +66,7 @@ if (!$member) { } $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); ########## 동일 정보 존재여부 확인. ########## $admin = $db->queryFirstRow('SELECT year,month,maxgeneral,scenario,show_img_level,turnterm,genius,npcmode from game limit 1'); diff --git a/hwe/process_war.php b/hwe/process_war.php index f47e0e9b..da36c6bd 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -6,6 +6,7 @@ function processWar($general, $city) { '@phan-var array $general'; $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $templates = new \League\Plates\Engine('templates'); @@ -1634,6 +1635,7 @@ function getRate($game, $type, $dtype) { function addConflict($city, $nationID, $mykillnum) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $nationlist = []; $killnum = [0]; diff --git a/hwe/processing.php b/hwe/processing.php index 6558b8e3..db4cb027 100644 --- a/hwe/processing.php +++ b/hwe/processing.php @@ -193,6 +193,7 @@ function command_99($turn) { function command_11($turn, $command) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $userID = Session::getUserID(); @@ -401,6 +402,7 @@ function calc(cost, formnum) { function command_12($turn, $command) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $userID = Session::getUserID(); @@ -961,6 +963,7 @@ function command_24($turn, $command) { function command_25($turn, $command) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); $userID = Session::getUserID(); @@ -1528,6 +1531,7 @@ function command_44($turn, $command) { function command_46($turn, $command) { $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); starter("건국"); diff --git a/hwe/sammo/DiplomaticMessage.php b/hwe/sammo/DiplomaticMessage.php index 10c9e4d7..67b0e627 100644 --- a/hwe/sammo/DiplomaticMessage.php +++ b/hwe/sammo/DiplomaticMessage.php @@ -225,6 +225,8 @@ class DiplomaticMessage extends Message{ $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); + $general = $db->queryFirstRow( 'SELECT `name`, `level` FROM general WHERE `no`=%i AND nation=%i', $receiverID, diff --git a/hwe/sammo/Engine/Diplomacy.php b/hwe/sammo/Engine/Diplomacy.php index ebe5508f..72652ceb 100644 --- a/hwe/sammo/Engine/Diplomacy.php +++ b/hwe/sammo/Engine/Diplomacy.php @@ -24,6 +24,7 @@ class Diplomacy{ } $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $srcNation = $db->queryFirstRow( 'SELECT nation, `name`, `power`, capital, gold, rice, surlimit, color, `level` FROM nation WHERE nation=%i', $srcNationID diff --git a/hwe/sammo/Engine/Personnel.php b/hwe/sammo/Engine/Personnel.php index d6b2965f..b63a1261 100644 --- a/hwe/sammo/Engine/Personnel.php +++ b/hwe/sammo/Engine/Personnel.php @@ -21,6 +21,7 @@ class Personnel{ public function __construct(int $nationID, int $senderID){ $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $nation = $db->queryFirstRow( 'SELECT nation, `name`, `level`, capital, scout FROM nation WHERE nation=%i', $nationID diff --git a/hwe/sammo/ResetHelper.php b/hwe/sammo/ResetHelper.php index 8480fae0..1ae40c99 100644 --- a/hwe/sammo/ResetHelper.php +++ b/hwe/sammo/ResetHelper.php @@ -89,7 +89,7 @@ class ResetHelper{ } } - + (KVStorage::getStorage($db, 'game'))->resetValues(); return [ 'result'=>true diff --git a/hwe/select_npc.php b/hwe/select_npc.php index a4b815a1..b8c03e5b 100644 --- a/hwe/select_npc.php +++ b/hwe/select_npc.php @@ -7,6 +7,7 @@ include "func.php"; $session = Session::requireLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); list($npcmode, $maxgeneral) = $db->queryFirstList('SELECT npcmode,maxgeneral FROM game LIMIT 1'); diff --git a/hwe/turn.php b/hwe/turn.php index ee762f1a..bb2ea59d 100644 --- a/hwe/turn.php +++ b/hwe/turn.php @@ -18,6 +18,7 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game'); $connect=$db->get(); increaseRefresh("턴반복", 1); diff --git a/src/sammo/KVStorage.php b/src/sammo/KVStorage.php index a15d6375..8c19face 100644 --- a/src/sammo/KVStorage.php +++ b/src/sammo/KVStorage.php @@ -2,16 +2,28 @@ namespace sammo; class KVStorage{ - private $db = null; + private $db; + private $tableName; private $storNamespace; private $cacheData = null; - public function __construct(\MeekroDB $db, string $storNamespace, bool $cacheMode=false){ + static private $storageList = []; + + static public function getStorage(\MeekroDB $db, string $storNamespace, string $tableName='storage'):self{ + $obj_id = spl_object_hash($db); + $fullKey = $obj_id.','.$storNamespace.','.$tableName; + if(key_exists($fullKey, static::$storageList)){ + return static::$storageList[$fullKey]; + } + $obj = new static($db, $storNamespace, $tableName); + static::$storageList[$fullKey] = $obj; + return $obj; + } + + public function __construct(\MeekroDB $db, string $storNamespace, string $tableName='storage'){ $this->db = $db; $this->storNamespace = $storNamespace; - if($cacheMode){ - $this->cacheData = []; - } + $this->tableName = $tableName; } public function __get($key) { @@ -26,6 +38,13 @@ class KVStorage{ $this->deleteValue($key); } + public function turnOnCache(): self{ + if($this->cacheData === null){ + $this->cacheData = []; + } + return $this; + } + public function resetCache(bool $disableCache=true):self{ if($disableCache){ $this->cacheData = null; @@ -66,17 +85,36 @@ class KVStorage{ return $this; } - public function cacheAll():self{ + public function cacheAll(bool $invalidateAll=true):self{ + if(!$invalidateAll && $this->cacheData !== null && count($this->cacheData)>0){ + return $this; + } $this->cacheData = $this->getDBAll(); return $this; } - public function cacheValues(array $keys):self{ + public function cacheValues(array $keys, bool $invalidateAll=false):self{ if($this->cacheData === null){ $this->cacheData = []; } - $values = $this->getDBValues($keys); - foreach($keys as $key){ + + if($invalidateAll){ + $notExists = $keys; + } + else{ + $notExists = []; + foreach($keys as $key){ + if(!key_exists($key, $this->cacheData)){ + $notExists[] = $key; + } + } + if(!$notExists){ + return $this; + } + } + + $values = $this->getDBValues($notExists); + foreach($notExists as $key){ if(key_exists($key, $values)){ $this->cacheData[$key] = $values[$key]; } @@ -99,6 +137,15 @@ class KVStorage{ return $result; } + public function getValuesAsArray(array $keys, bool $onlyCache=false): array{ + $dictResult = $this->getValues($keys, $onlyCache); + $result = []; + foreach($keys as $key){ + $result[] = $dictResult[$key]??null; + } + return $result; + } + public function getValues(array $keys, bool $onlyCache=false): array{ if ($this->cacheData === null) { return $this->getDBValues($keys); @@ -165,7 +212,8 @@ class KVStorage{ private function getDBAll(): array{ $result = []; foreach($this->db->queryAllLists( - 'SELECT `key`, `value` FROM storage WHERE `namespace`=%s', + 'SELECT `key`, `value` FROM %b WHERE `namespace`=%s', + $this->tableName, $this->storNamespace ) as list($key, $value)) { @@ -177,7 +225,8 @@ class KVStorage{ private function getDBValues(array $keys): array{ $result = []; foreach($this->db->queryAllLists( - 'SELECT `key`, `value` FROM storage WHERE `namespace`=%s AND `key` IN %ls', + 'SELECT `key`, `value` FROM %b WHERE `namespace`=%s AND `key` IN %ls', + $this->tableName, $this->storNamespace, $keys ) as list($key, $value)) @@ -194,7 +243,8 @@ class KVStorage{ private function getDBValue($key){ $value = $this->db->queryFirstField( - 'SELECT `value` FROM storage WHERE `namespace`=%s AND `key`=%s', + 'SELECT `value` FROM %b WHERE `namespace`=%s AND `key`=%s', + $this->tableName, $this->storNamespace, $key ); @@ -208,7 +258,7 @@ class KVStorage{ if($value === null){ return $this->deleteDBValue($key); } - $this->db->insertUpdate('storage', [ + $this->db->insertUpdate($this->tableName, [ 'namespace'=>$this->storNamespace, 'key'=>$key, 'value'=>Json::encode($value) @@ -217,7 +267,7 @@ class KVStorage{ } private function deleteDBValue($key):self{ - $this->db->delete('storage', [ + $this->db->delete($this->tableName, [ 'namespace'=>$this->storNamespace, 'key'=>$key ]); @@ -225,7 +275,7 @@ class KVStorage{ } private function resetDBNamespace():self{ - $this->db->delete('storage', [ + $this->db->delete($this->tableName, [ 'namespace'=>$this->storNamespace ]); return $this; diff --git a/src/sammo/Session.php b/src/sammo/Session.php index fdfe52f6..70aa408c 100644 --- a/src/sammo/Session.php +++ b/src/sammo/Session.php @@ -230,6 +230,7 @@ class Session } $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game'); $general = $db->queryFirstRow( 'SELECT `no`, `name`, `killturn`, `turntime` from general where `owner` = %i',