메시지 전송 과정에서 전송자에 id, nation_id만 필요하도록 변경

This commit is contained in:
2018-03-01 20:18:54 +09:00
parent de4c2e0678
commit a72452454c
5 changed files with 40 additions and 53 deletions
+14 -2
View File
@@ -105,6 +105,15 @@ function getMessage($msgType, $nationID=null, $limit=30, $fromSeq=NULL){
function sendRawMessage($msgType, $isSender, $mailbox, $src, $dest, $msg, $date, $validUntil, $msgOption){
$srcNation = getNationStaticInfo($src['nation_id']);
$destNation = getNationStaticInfo($dest['nation_id']);
$src['nation'] = util::array_get($srcNation['name'], '재야');
$src['color'] = util::array_get($srcNation['color'], '#ffffff');
$dest['nation'] = util::array_get($destNation['name'], '재야');
$dest['color'] = util::array_get($destNation['color'], '#ffffff');
if(!$isSender && $mailBox < 9000){
//TODO:newmsg보단 lastmsg로 datetime을 넣는게 더 나아보임
getDB()->update('general', array(
@@ -181,10 +190,13 @@ function sendScoutMsg($src, $dest, $date) {
//$msgType, $isSender, $mailbox, $src, $dest, $msg, $date, $validUntil, $msgOption
if(!$src || !$src['id'] || !$src['nation_id'] || !$src['nation']){
if(!$src || !$src['id'] || !$src['nation_id']){
return false;
}
$nation = getNationStaticInfo($src['nation_id']);
$nationName = util::array_get($nation['name'], '재야');
if(!$dest || !$dest['id']){
return false;
}
@@ -195,7 +207,7 @@ function sendScoutMsg($src, $dest, $date) {
];
$msg = "{$src['nation']}(으)로 망명 권유 서신";
$validUntil = "9999-12-31 23:59:59";//등용장의 시간 제한 없음
$validUntil = "9999-12-31 12:59:59";//등용장의 시간 제한 없음
sendRawMessage('private', false, $dest['id'], $src, $dest, $msg, $date, $validUntil, $option);
+3 -11
View File
@@ -1406,22 +1406,14 @@ function process_22($connect, &$general) {
// 성격 보정
$exp = CharExperience($exp, $general['personal']);
$ded = CharDedication($ded, $general['personal']);
$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')
'nation_id' => util::array_get($general['nation'], 0)
],[
'id' => $you['no'],
'nation_id' => util::array_get($youNation['nation'], 0),
'nation' => util::array_get($youNation['name'], '재야'),
'color' => util::array_get($youNation['color'], '#ffffff')
'nation_id' => util::array_get($you['nation'], 0)
],$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']}'";
+11 -32
View File
@@ -54,7 +54,7 @@ if(getBlockLevel() == 1 || getBlockLevel() == 3) {
$conlimit = $db->queryFirstField('select conlimit from game where no=1');
$me = $db->queryFirstRow('select `no`,`name`,`nation`,`level`,`msgindex`,`userlevel`,`con`,`picture`,`imgsvr` from `general` where `owner` = %i', getUserID());
$me = $db->queryFirstRow('select `no`,`name`,`nation`,`level`,`userlevel`,`con`,`picture`,`imgsvr` from `general` where `owner` = %i', getUserID());
if(!$me){
resetSessionGeneralValues();
@@ -91,14 +91,7 @@ $src = [
'name' => $me['name'],
'icon' => $me['picture'],
'nation_id' => $me['nation'],
'nation' => null
];
if($src['nation_id'] != 0) {
$nation = getNationStaticInfo($src_nation_id);
$src['nation'] = $nation['name'];
$src['color'] = '#'.$nation['color'];
$src['color'] = str_replace('##', '#', $src['color']); //FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
}
// 전체 메세지
if($destMailbox == 9999) {
@@ -112,21 +105,15 @@ if($destMailbox == 9999) {
else{
$real_nation = $dest - 9000;
}
$nation = getNationStaticInfo($real_nation);
if($nation === null || empty($nation)){
$dest = ['nation_id' => 0];
}
else{
$color = '#'.$nation['color'];
$color = str_replace('##', '#', $color);
//FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
$dest = [
'nation_id' => $nation['nation'],
'color' => $color
];
if(!getNationStaticInfo($real_nation)){
$real_nation = $me['nation_id'];
}
$dest = [
'nation_id' => $real_nation
];
sendMessage('national', $src, $dest, $msg, $date);
// 개인 메세지
@@ -142,7 +129,6 @@ if($destMailbox == 9999) {
'newSeq' => false
]);
}
$destUser = $db->queryFirstRow('select `no`,`name`,`nation` from `general` where `no` = %s',$destMailbox);
@@ -158,17 +144,10 @@ if($destMailbox == 9999) {
$dest = [
'id' => $destMailbox,
'name' => $dest_user['name']
'name' => $dest_user['name'],
'nation_id' => $dest_user['nation']
];
$destNation = getNationStaticInfo($dest_user['nation']);
if($destNation){
$color = $destNation['color'];
$color = str_replace('##', '#', $color);
//FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
$dest['color'] = $color;
$dest['nation'] = $destNation['name'];
$dest['nation_id'] = $destNation['nation'];
}
sendMessage('private', $src, $dest, $msg, $date);
}
else{
+11 -7
View File
@@ -1688,11 +1688,8 @@ function ConquerCity($connect, $game, $general, $city, $nation, $destnation) {
$citycount = MYDB_num_rows($result);
// 국가 멸망시
//TODO: 국가 멸망 코드를 별도로 작성
if($citycount == 1 && $city['nation'] != 0) {
$query = "select nation,name,history,tech,type from nation where nation='{$nation['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$nation = MYDB_fetch_array($result);
$query = "select nation,name,gold,rice from nation where nation='{$city['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$losenation = MYDB_fetch_array($result);
@@ -1712,7 +1709,7 @@ function ConquerCity($connect, $game, $general, $city, $nation, $destnation) {
$loseGeneralGold = 0;
$loseGeneralRice = 0;
//멸망국 장수들 역사 기록 및 로그 전달
$query = "select no,name,nation,npc,gold,rice,history,msgindex from general where nation='{$city['nation']}'";
$query = "select no,name,nation,npc,gold,rice,history from general where nation='{$city['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gencount = MYDB_num_rows($result);
$genlog[0] = "<C>●</><D><b>{$losenation['name']}</b></>(이)가 <R>멸망</>했습니다.";
@@ -1738,8 +1735,15 @@ function ConquerCity($connect, $game, $general, $city, $nation, $destnation) {
|| $nation['name'] == "남만족" || $nation['name'] == "산월족" || $nation['name'] == "오환족"
|| $nation['name'] == "왜족") {
//등용장 미발부
} elseif(rand() % 100 < 50) {
sendScoutMsg($connect, $ruler['no'], $nation['name'], $gen['no'], $gen['msgindex']);
} elseif(randBool(0.5)) {
sendScoutMsg([
'id' => $ruler['no'],
'nation_id' => $ruler['nation']
],[
'id' => $gen['no'],
'nation_id' => $gen['nation']
],$general['turntime']);
//TODO: msgindex 사용하는 코드 모두 제거
}
//NPC인 경우 10% 확률로 임관(엔장, 인재, 의병)
+1 -1
View File
@@ -12,7 +12,7 @@ $query = "select conlimit from game where no=1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$query = "select no,name,nation,msgindex,userlevel,con from general where owner='{$_SESSION['noMember']}'";
$query = "select no,name,nation,userlevel,con from general where owner='{$_SESSION['noMember']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$me = MYDB_fetch_array($result);