diff --git a/hwe/func.php b/hwe/func.php index f44b711f..54a58e22 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -399,7 +399,7 @@ function myNationInfo() { "; } -function checkSecretPermission($me){ +function checkSecretPermission($me, $checkSecretLimit=true){ if(!key_exists('penalty', $me) || !key_exists('permission', $me)){ trigger_error ('canAccessSecret() 함수에 필요한 인자가 부족'); } @@ -413,15 +413,14 @@ function checkSecretPermission($me){ if($me['level'] == 0){ return -1; } - - $secretLimit = $db->queryFirstField('SELECT secretlimit FROM nation WHERE nation = %i', $me['nation']); + if($pernalty['noSecret']??false){ return 0; } $secretMin = 0; - $secretMax = 3; + $secretMax = 4; if($penalty['noTopSecret']??false){ $secretMax = 1; } @@ -447,8 +446,12 @@ function checkSecretPermission($me){ else if($me['level'] > 1){ $secretMin = 1; } - else if($me['belong'] >= $secretLimit){ - $secretMin = 1; + else if($checkSecretLimit){ + $db = DB::db(); + $secretLimit = $db->queryFirstField('SELECT secretlimit FROM nation WHERE nation = %i', $me['nation']); + if ($me['belong'] >= $secretLimit) { + $secretMin = 1; + } } return min($secretMin, $secretMax); diff --git a/hwe/func_message.php b/hwe/func_message.php index f00def43..fdca8ea9 100644 --- a/hwe/func_message.php +++ b/hwe/func_message.php @@ -5,14 +5,15 @@ function getMailboxList(){ $generalNations = []; - foreach(DB::db()->queryAllLists('select `no`, `name`, `nation`, `level`, `npc` from `general` where `npc` < 2') as $general) + foreach(DB::db()->query('select `no`, `name`, `nation`, `level`, `npc`, `permission`, `penalty` from `general` where `npc` < 2') as $general) { - list($generalID, $generalName, $nationID, $level, $npc) = $general; + [$generalID, $generalName, $nationID, $level, $npc] = [$general['no'], $general['name'], $general['nation'], $general['level'], $general['npc']]; if(!isset($generalNations[$nationID])){ $generalNations[$nationID] = []; } $obj = [$generalID, $generalName, 0]; + $permission = checkSecretPermission($general, false); if($level == 12){ $obj[2] |= 1; @@ -22,6 +23,10 @@ function getMailboxList(){ $obj[2] |= 2; } + if($permission == 4){ + $obj[2] |= 4; + } + $generalNations[$nationID][] = $obj; } @@ -37,7 +42,7 @@ function getMailboxList(){ "mailbox"=>$mailbox, "name"=>$nationName, "color"=>$color, - "general"=>$generals + "general"=>$generals, ]; }, array_merge([getNationStaticInfo(0)], getAllNationStaticInfo())); diff --git a/hwe/j_msg_submit.php b/hwe/j_msg_submit.php index 5a099d80..51bd87b9 100644 --- a/hwe/j_msg_submit.php +++ b/hwe/j_msg_submit.php @@ -150,8 +150,8 @@ if($mailbox > 0) { $session->lastMsg = $now->format('Y-m-d H:i:s'); - $destUser = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`con`,`picture`,`imgsvr` FROM general WHERE `no`=%i',$mailbox); - + $destUser = $db->queryFirstRow('SELECT `no`,`name`,`nation`,`level`,`con`,`picture`,`imgsvr`,permission,penalty FROM general WHERE `no`=%i',$mailbox); + if(!$destUser){ Json::die([ 'result' => false, @@ -160,6 +160,15 @@ if($mailbox > 0) { ]); } + $destPermission = checkSecretPermission($destUser, false); + if($permission == 4 && $destPermission == 4){ + Json::die([ + 'result' => false, + 'reason' => '외교권자끼리는 메시지를 보낼 수 없습니다.', + 'msgID' => null + ]); + } + $destNation = getNationStaticInfo($destUser['nation']); $dest = new MessageTarget( diff --git a/hwe/js/msg.js b/hwe/js/msg.js index 99a6f288..cdf1c456 100644 --- a/hwe/js/msg.js +++ b/hwe/js/msg.js @@ -376,6 +376,7 @@ function refreshMailboxList(obj){ var generalName = this[1]; var isNPC = !!(this[2] & 0x2); var isRuler = !!(this[2] & 0x1); + var isAmbassador = !!(this[2] & 0x4); @@ -387,6 +388,9 @@ function refreshMailboxList(obj){ if(isRuler){ textName = '*{0}*'.format(textName); } + else if(isAmbassador){ + textName = '#{0}#'.format(textName); + } generalList[generalID] = { id:generalID, @@ -398,6 +402,10 @@ function refreshMailboxList(obj){ }; var $item = $(''.format(generalID, textName)); + + if(permissionLevel == 4 && isAmbassador){ + $item.prop('disabled', true); + } $optgroup.append($item); }); @@ -460,7 +468,7 @@ function registerGlobal(basicInfo){ window.myGeneralID = basicInfo.generalID; window.isChief = basicInfo.isChief; window.myGeneralLevel = basicInfo.generalLevel; - window.permissionLevel = basicInfo.permissionLevel; + window.permissionLevel = basicInfo.permission; } function activateMessageForm(){