void FriendMemoSend(FHP_FRIEND_MEMO_SEND* lpMsg,int index)
{
FHP_FRIEND_MEMO_SEND_RESULT pMsg;
pMsg.h.set(0x70,sizeof(pMsg));
pMsg.Number = lpMsg->Number;
memcpy(pMsg.Name,lpMsg->Name,sizeof(pMsg.Name));
pMsg.Result = 1;
pMsg.WindowGuid = lpMsg->WindowGuid;
gQueryManager.BindParameterAsString(1, lpMsg->ToName, sizeof(lpMsg->ToName)); //Fix DataServer N#1
gQueryManager.BindParameterAsString(2, lpMsg->Subject, sizeof(lpMsg->Subject));
gQueryManager.ExecQuery("WZ_WriteMail '%s',?,?,%d,%d", lpMsg->Name, lpMsg->Dir, lpMsg->Action);
gQueryManager.Fetch();
DWORD memo = gQueryManager.GetResult(0);
DWORD guid = gQueryManager.GetResult(1);
gQueryManager.Close();
if(memo <= 10)
{
pMsg.Result = (BYTE)memo;
CSDataSend(index,(BYTE*)&pMsg,pMsg.h.size);
return;
}
BYTE MemoBuff[1000];
memset(MemoBuff,0,sizeof(MemoBuff));
memcpy(MemoBuff,lpMsg->Memo,lpMsg->MemoSize);
gQueryManager.BindParameterAsBinary(1,MemoBuff,sizeof(MemoBuff));
gQueryManager.BindParameterAsBinary(2,lpMsg->Photo,sizeof(lpMsg->Photo));
gQueryManager.ExecQuery("UPDATE T_FriendMail SET Memo=?,Photo=? WHERE MemoIndex=%d AND GUID=%d",memo,guid);
gQueryManager.Close();
CSDataSend(index,(BYTE*)&pMsg,pMsg.h.size);
if(pMsg.Result == 1)
{
CHARACTER_INFO CharacterInfo;
if(gCharacterManager.GetCharacterInfo(&CharacterInfo,lpMsg->ToName) != 0)
{
gQueryManager.ExecQuery("SELECT MemoIndex,FriendName,wDate,Subject,bRead FROM T_FriendMail WHERE MemoIndex=%d AND GUID=%d",memo,guid);
gQueryManager.Fetch();
FHP_FRIEND_MEMO_LIST pMsg;
pMsg.h.set(0x71,sizeof(pMsg));
pMsg.Number = CharacterInfo.UserIndex;
pMsg.MemoIndex = gQueryManager.GetAsInteger("MemoIndex");
gQueryManager.GetAsString("FriendName",pMsg.SendName,sizeof(pMsg.SendName));
memcpy(pMsg.RecvName,lpMsg->ToName,sizeof(pMsg.RecvName));
gQueryManager.GetAsString("wDate",pMsg.Date,sizeof(pMsg.Date));
gQueryManager.GetAsString("Subject",pMsg.Subject,sizeof(pMsg.Subject));
pMsg.read = gQueryManager.GetAsInteger("bRead");
CServerManager* lpServerManager = FindServerByCode(CharacterInfo.GameServerCode);
if(lpServerManager != 0){CSDataSend(lpServerManager->m_index,(BYTE*)&pMsg,sizeof(pMsg));}
gQueryManager.Close();
}
}
}