diff --git a/twe/_admin2_submit.php b/twe/_admin2_submit.php index 247d2022..25e61b62 100644 --- a/twe/_admin2_submit.php +++ b/twe/_admin2_submit.php @@ -234,6 +234,7 @@ switch($btn) { } break; case "메세지 전달": + //TODO:새 갠메 시스템으로 변경 $date = date('Y-m-d H:i:s'); for($i=0; $i < sizeof($genlist); $i++) { $query = "select msgindex from general where no='$genlist[$i]'"; diff --git a/twe/_admin3_submit.php b/twe/_admin3_submit.php index 9b33a585..4b69d075 100644 --- a/twe/_admin3_submit.php +++ b/twe/_admin3_submit.php @@ -116,6 +116,7 @@ switch($btn) { } break; case "메세지 전달": + //TODO:새 갠메 시스템으로 변경 $date = date('Y-m-d H:i:s'); for($i=0; $i < sizeof($genlist); $i++) { $query = "select msgindex from general where no='$genlist[$i]'"; diff --git a/twe/_admin4_submit.php b/twe/_admin4_submit.php index 2c0d350e..0c38acb8 100644 --- a/twe/_admin4_submit.php +++ b/twe/_admin4_submit.php @@ -50,16 +50,10 @@ switch($btn) { getDB()->query('update general set turn0=0,killturn=0,turntime=%s where no IN %li',$date, $genlist); break; case "메세지 전달": + //TODO:새 갠메 시스템으로 변경 $date = date('Y-m-d H:i:s'); + $msg; for($i=0; $i < sizeof($genlist); $i++) { - $query = "select msgindex from general where no='$genlist[$i]'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $you = MYDB_fetch_array($result); - // 상대에게 발송 - $you['msgindex']++; - if($you['msgindex'] >= 10) { $you['msgindex'] = 0; } - $query = "update general set msgindex='{$you['msgindex']}',msg{$you['msgindex']}_type=10,msg{$you['msgindex']}='$msg',msg{$you['msgindex']}_who='$genlist[$i]'+10000,msg{$you['msgindex']}_when='$date',newmsg=1 where no='$genlist[$i]'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); } break; } diff --git a/twe/c_msgsubmit.php b/twe/c_msgsubmit.php deleted file mode 100644 index 9c66a494..00000000 --- a/twe/c_msgsubmit.php +++ /dev/null @@ -1,139 +0,0 @@ -= 2) { - //echo ""; exit(); - header('Content-Type: application/json'); - echo json_encode([ - 'result' => false, - 'reason' => '권한이 충분하지 않습니다.', - 'redirect' => 'index.php', - 'page_target' => 'top' - ]); - echo 'index.php';//TODO:debug all and replace - } - -$msg = str_replace("|", "", $msg); -$msg = trim($msg); - -//TODO : 몰라서 임시로 값 세팅해봄. 추후에 용도를 확인하고 수정 필요 -$s = 50; -$msg = _String::SubStrForWidth($msg, $s, 198); - -$date = date('Y-m-d H:i:s'); - -// 전체 메세지 -if($genlist == 9999 && str_replace(" ", "", $msg) != "") { - echo ''; - if($me['nation'] == 0) { - $nation['name'] = '재야'; - $nation['color'] = 'FFFFFF'; - } else { - $query = "select nation,name,color from nation where nation='{$me['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $nation = MYDB_fetch_array($result); - } - PushMsg(1, 0, $me['picture'], $me['imgsvr'], "{$me['name']}:", $nation['color'], $nation['name'], $nation['color'], $msg); -// 국가 메세지 -} elseif($genlist >= 9000 && $msg != "") { - if($me['nation'] == 0) { - $nation['name'] = '재야'; - $nation['color'] = 'FFFFFF'; - $nation['nation'] = 0; - } else { - $query = "select nation,name,color from nation where nation='{$me['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $nation = MYDB_fetch_array($result); - } - - $genlist -= 9000; - $query = "select nation,name,color from nation where nation='$genlist'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $dest = MYDB_fetch_array($result); - - //$dest가 없다는건 수신도 재야. - if(empty($dest)){ - $dest['name'] = '재야'; - $dest['color'] = 'FFFFFF'; - $dest['nation'] = 0; - } - - if($nation['nation'] == $dest['nation']) { - PushMsg(2, $nation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:", $nation['color'], $dest['name'], $dest['color'], $msg); - } else { - //타국에 보내는 경우 - PushMsg(2, $nation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$nation['name']}▶", $nation['color'], $dest['name'], $dest['color'], $msg); - // 수뇌이면 발송, 아니면 자국으로 돌림 - if($me['level'] >= 5) { - PushMsg(3, $dest['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$nation['name']}▶", $nation['color'], $dest['name'], $dest['color'], $msg); - } else { - PushMsg(2, $nation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$nation['name']}▶", $nation['color'], $dest['name'], $dest['color'], "반송"); - } - } -// 개인 메세지 -} elseif($genlist > 0 && $msg != "") { - $query = "select name,msgindex from general where no='$genlist'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $you = MYDB_fetch_array($result); - //발신, 수신인 코딩 - $who = $me['no'] * 10000 + $genlist; - - $msg = addslashes(SQ2DQ($msg)); - - $query = "select msg{$me['msgindex']}_when as priv_when from general where no='{$me['no']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $prev_msg = MYDB_fetch_array($result); - $diff_second = strtotime($date) - strtotime($prev_msg['priv_when']); - - if($diff_second < 3) { - $who = 1 * 10000 + $me['no']; // 운영자가 본인에게 - $msg = "개인메세지는 3초당 1건만 보낼 수 있습니다!"; - //자신에게 표시 - $me['msgindex']++; - if($me['msgindex'] >= 10) { $me['msgindex'] = 0; } - $query = "update general set msgindex='{$me['msgindex']}',msg{$me['msgindex']}='$msg',msg{$me['msgindex']}_type='10',msg{$me['msgindex']}_who='$who',msg{$me['msgindex']}_when='$date',newmsg=1 where no='{$me['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - } else { - //자신에게 표시 - $me['msgindex']++; - if($me['msgindex'] >= 10) { $me['msgindex'] = 0; } - $query = "update general set msgindex='{$me['msgindex']}',msg{$me['msgindex']}='$msg',msg{$me['msgindex']}_type='9',msg{$me['msgindex']}_who='$who',msg{$me['msgindex']}_when='$date' where no='{$me['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - - // 상대에게 발송 - $you['msgindex']++; - if($you['msgindex'] >= 10) { $you['msgindex'] = 0; } - $query = "update general set msgindex='{$you['msgindex']}',msg{$you['msgindex']}='$msg',msg{$you['msgindex']}_type='10',msg{$you['msgindex']}_who='$who',msg{$you['msgindex']}_when='$date',newmsg=1 where no='$genlist'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - } - - $fp = fopen("logs/_gen_msg.txt", "a"); - //로그 파일에 기록 - fwrite($fp, _String::Fill($me['name'],12," ")." > "._String::Fill($you['name'],12," ")." | {$msg}\n"); - fclose($fp); -} - -//echo ""; -echo 'msglist.php';//TODO:debug all and replace - diff --git a/twe/event_1.php b/twe/event_1.php index c696e66d..54d3ef03 100644 --- a/twe/event_1.php +++ b/twe/event_1.php @@ -199,6 +199,8 @@ $history[count($history)] = "●{$admin['year']}년 {$admin['month']}월:< $history[count($history)] = "●{$admin['year']}년 {$admin['month']}월:【이벤트】이민족의 기세는 그 누구도 막을 수 없을듯 합니다!"; pushHistory($connect, $history); +getNationStaticInfo(null, true); + echo ""; function RegGeneral3($connect,$turnterm,$gencount,$nation,$level,$name,$leader,$power,$intel,$personal,$special,$msg="") { diff --git a/twe/event_2.php b/twe/event_2.php index 00ce90b3..00b9bbf4 100644 --- a/twe/event_2.php +++ b/twe/event_2.php @@ -203,6 +203,8 @@ $history[count($history)] = "●{$admin['year']}년 {$admin['month']}월:< $history[count($history)] = "●{$admin['year']}년 {$admin['month']}월:【이벤트】그러나 중원의 영웅들이라면 막아낼 수도 있을법 해 보입니다!"; pushHistory($connect, $history); +getNationStaticInfo(null, true); + echo ""; function RegGeneral3($connect,$turnterm,$gencount,$nation,$level,$name,$leader,$power,$intel,$personal,$special,$msg="") { diff --git a/twe/func.php b/twe/func.php index f7ebb362..257a4ad1 100644 --- a/twe/func.php +++ b/twe/func.php @@ -139,6 +139,40 @@ function getGeneralName($forceExit=false) return $generalName; } +/** + * nationID를 이용하여 국가의 '어지간해선' 변경되지 않는 정보(이름, 색, 성향, 수도)를 반환해줌 + * + * @param int|null $nationID 국가 코드 + * @param bool $forceRefresh 강제 갱신 여부 + * + * @return array|null nationID에 해당하는 국가가 있을 경우 array 반환. 그외의 경우 null + */ +function getNationStaticInfo($nationID, $forceRefresh=false) +{ + static $nationList = null; + + if ($forceRefresh) { + $nationList = null; + } + + if($nationID === null || $nationID == 0){ + return null; + } + + if($nationList === null){ + $nationList = ArrayToDict( + getDB()->query("select nation, name, color, type, capital from nation"), + "nation"); + } + + if(isset($nationList[$nationID])){ + return $nationList[$nationID]; + } + return null; + + +} + function GetImageURL($imgsvr) { global $image, $image1; if($imgsvr == 0) { @@ -293,7 +327,6 @@ function getTurn($connect, $general, $type, $font=1) { $str[$i] = "【{$city['name']}】(으)로 이동"; break; case 22: //등용 - //TODO:등용장 재디자인 $double = $command[1]; $query = "select name from general where no='$double'"; @@ -3724,6 +3757,7 @@ function deleteNation($connect, $general) { MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); pushHistory($connect, $history); + getNationStaticInfo(null, false); } function nextRuler($connect, $general) { @@ -4040,21 +4074,6 @@ function getRandTurn2($term) { return $turntime; } -function ScoutMsg($connect, $genNum, $nationName, $who, $msgIndex) { - return; - //TODO: 등용장 재 디자인. - //xxx: 일단 껐음 - // 상대에게 발송 - $msgIndex++; - if($msgIndex >= 10) { $msgIndex = 0; } - - $date = date('Y-m-d H:i:s'); - //등용 서신시 장수번호/내 번호 - $me = $genNum * 10000 + $who; - $query = "update general set msgindex='$msgIndex',msg{$msgIndex}='{$nationName}(으)로 망명 권유 서신',msg{$msgIndex}_who='$me',msg{$msgIndex}_when='$date',msg{$msgIndex}_type='11' where no='$who'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); -} - function command_Single($connect, $turn, $command) { $command = EncodeCommand(0, 0, 0, $command); diff --git a/twe/func_gamerule.php b/twe/func_gamerule.php index 742f5cd7..5dd13d68 100644 --- a/twe/func_gamerule.php +++ b/twe/func_gamerule.php @@ -867,6 +867,8 @@ function checkMerge($connect) { unset($mylog); unset($youlog); unset($history); + + getNationStaticInfo(null, true); } } @@ -985,6 +987,8 @@ function checkSurrender($connect) { unset($mylog); unset($youlog); unset($history); + + getNationStaticInfo(null, true); } } diff --git a/twe/func_message.php b/twe/func_message.php index 51c3de0e..85117022 100644 --- a/twe/func_message.php +++ b/twe/func_message.php @@ -98,6 +98,13 @@ function getMessage($msgType, $limit=30, $fromTime=NULL){ function sendRawMessage($msgType, $isSender, $mailbox, $src, $dest, $msg, $date, $validUntil, $msgOption){ + if(!$isSender && $mailBox < 9000){ + //TODO:newmsg보단 lastmsg로 datetime을 넣는게 더 나아보임 + getDB()->update('general', array( + 'newmsg' => true + ), 'no=%i', $dest['id']); + } + getDB()->insert('message', array( 'address' => $dest, 'type' => $msgType, @@ -158,8 +165,37 @@ function sendMessage($msgType, $src, $dest, $msg, $date = null, $validUntil = nu sendRawMessage($msgType, true, $srcMailbox, $src, $dest, $msg, $date, $validUntil, null); } sendRawMessage($msgType, false, $destMailbox, $src, $dest, $msg, $date, $validUntil, null); + + return true; } + +function sendScoutMsg($src, $dest, $date) { + + //$msgType, $isSender, $mailbox, $src, $dest, $msg, $date, $validUntil, $msgOption + + if(!$src || !$src['id'] || !$src['nation_id'] || !$src['nation']){ + return false; + } + + if(!$dest || !$dest['id']){ + return false; + } + + $msgType = 'private'; + $option = [ + "action" => "scout" + ]; + + $msg = "{$src['nation']}(으)로 망명 권유 서신"; + $validUntil = "9999-12-31 23:59:59";//등용장의 시간 제한 없음 + + sendRawMessage('private', false, $dest['id'], $src, $dest, $msg, $date, $validUntil, $option); + + return true; +} + + function getMailboxList(){ $result = []; @@ -409,27 +445,6 @@ function DecodeMsg($connect, $msg, $type, $who, $date, $bg, $num=0) { } -function MsgMe($connect, $bg) { - $query = "select no,nation,msgindex, - msg0,msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9, - msg0_type,msg1_type,msg2_type,msg3_type,msg4_type,msg5_type,msg6_type,msg7_type,msg8_type,msg9_type, - msg0_who,msg1_who,msg2_who,msg3_who,msg4_who,msg5_who,msg6_who,msg7_who,msg8_who,msg9_who, - msg0_when,msg1_when,msg2_when,msg3_when,msg4_when,msg5_when,msg6_when,msg7_when,msg8_when,msg9_when - from general where owner='{$_SESSION['noMember']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $me = MYDB_fetch_array($result); - - $index = $me['msgindex']; - for($i=0; $i < 10; $i++) { - if($me["msg{$index}"]) { echo "\n"; DecodeMsg($connect, $me["msg{$index}"], $me["msg{$index}_type"], $me["msg{$index}_who"], $me["msg{$index}_when"], $bg, $index); } - $index--; - if($index < 0) { $index = 9; } - } -} - - - - function moveMsg($connect, $table, $msgtype, $msgnum, $msg, $type, $who, $when, $column, $value) { //TODO: moveMsg 쓰는 곳 모두 고쳐!!! $query = "update {$table} set {$msgtype}{$msgnum}='$msg',{$msgtype}{$msgnum}_type='$type',{$msgtype}{$msgnum}_who='$who',{$msgtype}{$msgnum}_when='$when' where {$column}='$value'"; @@ -452,10 +467,6 @@ function MsgDip($connect, $bg) { if($nation['dip4']) { echo "\n"; DecodeMsg($connect, $nation['dip4'], $nation['dip4_type'], $nation['dip4_who'], $nation['dip4_when'], $bg, 4); } } -function ShowMsgEx($msgType, $src, $dest, $msg, $datetime){ - new League\Plates\Engine('templates'); -} - function ShowMsg($skin, $bgcolor, $type, $picture, $imgsvr, $me, $mycolor, $you, $youcolor, $msg, $date, $num=0, $who=0, $when=0, $level=0, $note="") { if($msg == "") return; diff --git a/twe/func_npc.php b/twe/func_npc.php index 7d28b47f..be6fb3f1 100644 --- a/twe/func_npc.php +++ b/twe/func_npc.php @@ -1042,6 +1042,7 @@ function RegCity($connect, $nation, $name, $cap=0) { if($cap > 0) { @MYDB_query("update nation set capital='$city' where nation='$nation'",$connect) or Error(__LINE__.MYDB_error($connect),""); } + getNationStaticInfo(null, true); } function Promotion($connect, $nation, $level) { diff --git a/twe/func_process.php b/twe/func_process.php index dad49c83..4aeaa03a 100644 --- a/twe/func_process.php +++ b/twe/func_process.php @@ -1385,9 +1385,6 @@ function process_21($connect, &$general) { } function process_22($connect, &$general) { - return; - //TODO: 등용장 재 디자인 - //xxx: 일단 등용장 끔 $log = array(); $alllog = array(); $date = substr($general['turntime'],11,5); @@ -1400,10 +1397,6 @@ function process_22($connect, &$general) { $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $city = MYDB_fetch_array($result); - $query = "select name from nation where nation='{$general['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $nation = MYDB_fetch_array($result); - $command = DecodeCommand($general['turn0']); $who = $command[1]; @@ -1432,7 +1425,21 @@ function process_22($connect, &$general) { $exp = CharExperience($exp, $general['personal']); $ded = CharDedication($ded, $general['personal']); - ScoutMsg($connect, $general['no'], $nation['name'], $who, $you['msgindex']); + $myNation = getNationStaticInfo($general['nation']); + $youNation = getNationStaticInfo($you['nation']); + + sendScoutMsg([ + 'id' => $general['no'], + 'nation_id' => util::array_get($myNation['nation'], 0), + 'nation' => util::array_get($myNation['name'], '재야'), + 'color' => util::array_get($myNation['color'], '#ffffff') + ],[ + 'id' => $you['no'], + 'nation_id' => util::array_get($youNation['nation'], 0), + 'nation' => util::array_get($youNation['name'], '재야'), + 'color' => util::array_get($youNation['color'], '#ffffff') + ],$date); + //sendScoutMsg($connect, $general['no'], $nation['name'], $who, $you['msgindex']); $general['intel2']++; $query = "update general set resturn='SUCCESS',gold=gold-'$cost',intel2='{$general['intel2']}',dedication=dedication+'$ded',experience=experience+'$exp' where no='{$general['no']}'"; @@ -3691,6 +3698,8 @@ function process_46($connect, &$general) { $exp = 1000; $ded = 1000; + getNationStaticInfo(null, true); + // 성격 보정 $exp = CharExperience($exp, $general['personal']); $ded = CharDedication($ded, $general['personal']); @@ -3763,6 +3772,8 @@ function process_47($connect, &$general) { MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); pushHistory($connect, $history); + + getNationStaticInfo(null, true); } pushAllLog($alllog); pushGenLog($general, $log); @@ -4390,6 +4401,8 @@ function process_55($connect, &$general) { $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $nationcount = MYDB_num_rows($result); + getNationStaticInfo(null, true); + for($i=0; $i < $nationcount; $i++) { $younation = MYDB_fetch_array($result); $query = "insert into diplomacy (me, you, state, term) values ('{$nation['nation']}', '{$younation['nation']}', '2', '0')"; @@ -4446,6 +4459,8 @@ function process_56($connect, &$general) { //분쟁기록 모두 지움 DeleteConflict($connect, $general['nation']); deleteNation($connect, $general); + + getNationStaticInfo(null, true); } pushAllLog($alllog); pushGenLog($general, $log); @@ -4991,6 +5006,8 @@ function process_66($connect, &$general) { //경험치, 공헌치 $query = "update general set dedication=dedication+'$ded',experience=experience+'$exp' where no='{$general['no']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + + getNationStaticInfo(null, true); } pushHistory($connect, $history); @@ -6308,6 +6325,8 @@ function process_81($connect, &$general) { //경험치, 공헌치 $query = "update general set dedication=dedication+'$ded',experience=experience+'$exp' where no='{$general['no']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + + getNationStaticInfo(null, true); } pushHistory($connect, $history); diff --git a/twe/index.php b/twe/index.php index f0f1f1e6..a1b3881e 100644 --- a/twe/index.php +++ b/twe/index.php @@ -253,18 +253,39 @@ if($me['userlevel'] >= 5) {
-
- - - ;color:white;font-size:13px;width:100px; value='서신전달&갱신' onclick='refreshing(4,message)'> -
내용 없이 '서신전달&갱신'을 누르면 메세지창이 갱신됩니다. -
+
+ + + + +
- +
+
+
전체 메시지(최고99자)
+
+ +
+
개인 메시지(최고99자)
+
+ +
+
+
+
+ +
+
국가 메시지(최고99자)
+
+ +
+
+
diff --git a/twe/j_msgsubmit.php b/twe/j_msgsubmit.php index a74f4b84..595c2c15 100644 --- a/twe/j_msgsubmit.php +++ b/twe/j_msgsubmit.php @@ -74,13 +74,6 @@ if($con >= 2) { ]); } -//FIXME: 원래는 필요없는 값이지만 예전 코드와 꼬일 수 있어 유지함. -$msg = str_replace('|', '', $msg); - -//TODO: 몰라서 임시로 값 세팅해봄. 추후에 용도를 확인하고 수정 필요 -//$s = 50; -//$msg = _String::SubStrForWidth($msg, $s, 198); - //SubStrForWidth는 반각은 1, 전각은 2로 측정하는듯 보이나, 대부분 글자수 단위로 카운트 하고 있어 mb_substr로 처리함. $msg = mb_substr($msg, 0, 99, 'UTF-8'); $msg = trim($msg); @@ -109,7 +102,7 @@ if($src['nation_id'] != 0) { // 전체 메세지 if($destMailbox == 9999) { - sendMessage('public', $src, [], $msg, $date); + sendMessage('public', $src, null, $msg, $date); // 국가 메세지 } elseif($destMailbox >= 9000) { @@ -119,9 +112,9 @@ if($destMailbox == 9999) { else{ $real_nation = $dest - 9000; } - $nation = $db->queryFirstRow('select nation,name,color from nation where nation=%i',$real_nation); + $nation = getNationStaticInfo($real_nation); - if($nation === NULL || empty($nation)){ + if($nation === null || empty($nation)){ $dest = ['nation_id' => 0]; } else{ @@ -167,15 +160,14 @@ if($destMailbox == 9999) { 'id' => $destMailbox, 'name' => $dest_user['name'] ]; - if($dest_user['nation'] != 0){ - $nation = $db->queryFirstRow('select nation,name,color from nation where nation=%i',$dest_user['nation']); - - $color = $nation['color']; + $destNation = getNationStaticInfo($dest_user['nation']); + if($destNation){ + $color = $destNation['color']; $color = str_replace('##', '#', $color); //FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비 $dest['color'] = $color; - $dest['nation'] = $nation['name']; - $dest['nation_id'] = $nation['nation']; + $dest['nation'] = $destNation['name']; + $dest['nation_id'] = $destNation['nation']; } sendMessage('private', $src, $dest, $msg, $date); } diff --git a/twe/lib.php b/twe/lib.php index e51ab70c..a3862b3f 100644 --- a/twe/lib.php +++ b/twe/lib.php @@ -252,6 +252,17 @@ function LogText($prefix, $variable){ fclose($fp); } +function ArrayToDict($arr, $keyName){ + $result = []; + + foreach($arr as $obj){ + $key = $obj[$keyName]; + $result[$key] = $obj; + } + + return $result; +} + function dictToArray($dict, $keys){ $result = []; @@ -288,6 +299,14 @@ function isDict(&$array){ function eraseNullValue(&$dict, $depth=512){ //TODO:Test 추가 + if($dict === null){ + return null; + } + + if(is_array($dict) && empty($dict)){ + return null; + } + if($depth <= 0){ return $dict; } @@ -297,10 +316,19 @@ function eraseNullValue(&$dict, $depth=512){ unset($dict[$key]); } else if(isDict($value)){ - $dict[$key] = eraseNullKey($value, $depth - 1); + $newValue = eraseNullKey($value, $depth - 1); + if($newValue === null){ + unset($dict[$key]); + } + else{ + $dict[$key] = $newValue; + } + } } + + return $dict; } diff --git a/twe/process_war.php b/twe/process_war.php index 89a9ae7d..2d5fe0ad 100644 --- a/twe/process_war.php +++ b/twe/process_war.php @@ -1735,18 +1735,14 @@ function ConquerCity($connect, $game, $general, $city, $nation, $destnation) { $loseGeneralGold += $loseGold; $loseGeneralRice += $loseRice; - /* - //TODO:등용장 재디자인 - //xxx: 일단 끔 //모두 등용장 발부 if($nation['name'] == "강족" || $nation['name'] == "저족" || $nation['name'] == "흉노족" || $nation['name'] == "남만족" || $nation['name'] == "산월족" || $nation['name'] == "오환족" || $nation['name'] == "왜족") { //등용장 미발부 } elseif(rand() % 100 < 50) { - ScoutMsg($connect, $ruler['no'], $nation['name'], $gen['no'], $gen['msgindex']); + sendScoutMsg($connect, $ruler['no'], $nation['name'], $gen['no'], $gen['msgindex']); } - */ //NPC인 경우 10% 확률로 임관(엔장, 인재, 의병) if($gen['npc'] >= 2 && $gen['npc'] <= 4 && rand() % 100 < 10) { @@ -1864,6 +1860,8 @@ function ConquerCity($connect, $game, $general, $city, $nation, $destnation) { //장수 사기 감소 $query = "update general set atmos=atmos*0.8 where nation='{$destnation['nation']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + + getNationStaticInfo(null, true); } }