새메시지, contact_list 코드를 func_message.php로 이동
This commit is contained in:
+37
-34
@@ -197,48 +197,51 @@ function sendScoutMsg($src, $dest, $date) {
|
|||||||
|
|
||||||
|
|
||||||
function getMailboxList(){
|
function getMailboxList(){
|
||||||
$result = [];
|
|
||||||
|
$generalNations = [];
|
||||||
|
|
||||||
$generalID = getGeneralID(false);
|
foreach(getDB()->query('select `no`, `name`, `nation`, `level`, `npc` from `general` where `npc` < 2') as $general)
|
||||||
|
{
|
||||||
if(!$generalID){
|
list($generalID, $generalName, $nationID, $level, $npc) = $general;
|
||||||
|
if(!isset($generalNations[$nationID])){
|
||||||
}
|
$generalNations[$nationID] = [];
|
||||||
|
|
||||||
$db = getDB();
|
|
||||||
$me = $db->queryFirstRow('select no,nation,level from general where no=%i', $generalID);
|
|
||||||
|
|
||||||
//가장 최근에 주고 받은 사람.
|
|
||||||
$latestMessage = util::array_get(getMessage('private', 1)[0], null);
|
|
||||||
if($latestMessage !== null){
|
|
||||||
if($latestMessage->src == $generalID){
|
|
||||||
$latestMessage = $latestMessage->dest;
|
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
$latestMessage = $latestMessage->src;
|
$isChief = ($level == 12);
|
||||||
|
|
||||||
|
$obj = [$generalID, $generalName];
|
||||||
|
if($isChief){
|
||||||
|
$obj[] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: 빙의장 정보 추가
|
||||||
|
$generalNations[$nationID][] = $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nations = [];
|
$neutral = [
|
||||||
foreach (getAllNationStaticInfo() as $nation) {
|
"nation"=>0,
|
||||||
$nations[$nation['nation']] = $nation;
|
"name"=>"재야",
|
||||||
}
|
"color"=>"#ffffff"
|
||||||
$nations[0] = [
|
|
||||||
'nation' => 0,
|
|
||||||
'name' => '재야',
|
|
||||||
'color' => '#ffffff'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$generals = $db->query('select no, nation, name, level from general where npc < 2 and no != %i order by name asc', $generalID);
|
$result = array_map(function($nation){
|
||||||
foreach ($generals as $general) {
|
$nationID = $nation['nation'];
|
||||||
$nations[$general['nation']] = $general;
|
$mailbox = $nationID + 9000;
|
||||||
}
|
$nation = $nation['name'];
|
||||||
|
$color = ('#'.$nation['color']).replace('##','#');//xxx: #기호 없는 이전 코드 대비용
|
||||||
|
$generals = util::array_get($generalNations[$nationID], []);
|
||||||
|
|
||||||
|
return [
|
||||||
|
"nationID"=>$nationID,
|
||||||
|
"mailbox"=>$mailbox,
|
||||||
|
"nation"=>$nationID,
|
||||||
|
"color"=>$color,
|
||||||
|
"general"=>$generals
|
||||||
|
];
|
||||||
|
}, array_merge([$neutral], getAllNationStaticInfo()));
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
return [
|
|
||||||
'me' => $me,
|
|
||||||
'latest' => $latestMessage,
|
|
||||||
'nations' => $nations
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function genList($connect) {
|
function genList($connect) {
|
||||||
|
|||||||
@@ -10,52 +10,8 @@ if(!getGeneralID()){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
session_write_close(); // 세션 안쓴다
|
|
||||||
|
|
||||||
//NOTE: 모든 국가, 모든 장수에 대해서 같은 결과라면 캐싱 가능하지 않을까?
|
//NOTE: 모든 국가, 모든 장수에 대해서 같은 결과라면 캐싱 가능하지 않을까?
|
||||||
|
|
||||||
$generalNations = [];
|
|
||||||
|
|
||||||
foreach(getDB()->query('select `no`, `name`, `nation`, `level`, `npc` from `general` where `npc` < 2') as $general)
|
|
||||||
{
|
|
||||||
list($generalID, $generalName, $nationID, $level, $npc) = $general;
|
|
||||||
if(!isset($generalNations[$nationID])){
|
|
||||||
$generalNations[$nationID] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$isChief = ($level == 12);
|
|
||||||
|
|
||||||
$obj = [$generalID, $generalName];
|
|
||||||
if($isChief){
|
|
||||||
$obj[] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: 빙의장 정보 추가
|
|
||||||
$generalNations[$nationID][] = $obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
$neutral = [
|
|
||||||
"nation"=>0,
|
|
||||||
"name"=>"재야",
|
|
||||||
"color"=>"#ffffff"
|
|
||||||
];
|
|
||||||
|
|
||||||
$result = array_map(function($nation){
|
|
||||||
$nationID = $nation['nation'];
|
|
||||||
$mailbox = $nationID + 9000;
|
|
||||||
$nation = $nation['name'];
|
|
||||||
$color = ('#'.$nation['color']).replace('##','#');//xxx: #기호 없는 이전 코드 대비용
|
|
||||||
$generals = util::array_get($generalNations[$nationID], []);
|
|
||||||
|
|
||||||
return [
|
|
||||||
"nationID"=>$nationID,
|
|
||||||
"mailbox"=>$mailbox,
|
|
||||||
"nation"=>$nationID,
|
|
||||||
"color"=>$color,
|
|
||||||
"general"=>$generals
|
|
||||||
];
|
|
||||||
}, array_merge([$neutral], getAllNationStaticInfo()));
|
|
||||||
|
|
||||||
returnJson([
|
returnJson([
|
||||||
"nation"=>$result
|
"nation"=>getMailboxList()
|
||||||
]);
|
]);
|
||||||
Reference in New Issue
Block a user