void TGreedyAlg::addCascade(const TStr& cascadeStr) {
    TStrV NIdV;
    cascadeStr.SplitOnAllCh(';', NIdV);
    TCascade C;
    for (int i = 0; i < NIdV.Len(); i++) {
    	TStr NId, Tm; NIdV[i].SplitOnCh(NId, ',', Tm);
        IAssert( IsNodeNm(NId.GetInt()) );
        GetNodeInfo(NId.GetInt()).Vol = GetNodeInfo(NId.GetInt()).Vol + 1;
        C.Add(NId.GetInt(), Tm.GetFlt());
    }
    C.Sort();
    cascadeV.Add(C);
}
Exemplo n.º 2
0
void CZiMainFrame::handlerAddGroupVerify(AddGroupInfo_t *pAddgroup) {
	Assert(pAddgroup);
	// 显示验证请求框, 交给用户操作. 
	// 还需要显示请求者的信息, 未实现 ... ???
	char              szText[1024] = {0};
	if (pAddgroup->type == GROUP_INFO_VERIFY) {
		sprintf_s(szText, sizeof(szText)/sizeof(szText[0]), 
			"'%s' 请求加入群 <%s>, 验证信息: '%s'", 
			pAddgroup->strSenderName.c_str(),
			pAddgroup->groupinfo.name.c_str(),
			pAddgroup->strVerify.c_str());

		CNotifyWindow::MessageBoxX(m_hWnd, _T("验证消息"), 
			CA2T(szText), _T("同意"), _T("不同意"), 
			Msg_InAddGroupVerify, pAddgroup);
	}
	else { //GROUP_INFO_REPLY	
		//TODO 如果添加者 需要弹框提示
		if (IdNetToLocal(Type_ImcFriend, pAddgroup->nSenderId) == m_itemSelfInfo.nId) {
			sprintf_s(szText, sizeof(szText)/sizeof(szText[0]), 
				"加入群 %s %s", 
				pAddgroup->groupinfo.name.c_str(), (pAddgroup->succ == 0 ? "成功" : "失败"));
			CNotifyWindow::MessageBoxX(m_hWnd, _T("通知"),CA2T(szText), 0);
			if (pAddgroup->succ == 0) {
				//TODO 添加群
				ItemNodeInfo_t item;
				ItemDataNetToLocal(pAddgroup->groupinfo, item);
				AddItem(&item, 0);

				//添加成员
				CNodeList *pNodeParent = GetNodeInfo(item.nId);
				Assert(pNodeParent);
				for (size_t i = 0; i < pAddgroup->groupinfo.members.size(); i++) {
					ItemNodeInfo_t group_member;
					ItemDataNetToLocal(pAddgroup->groupinfo.members[i], group_member, Type_ImcFriendX);
					AddItem(&group_member, pNodeParent);
				}
			}
		}
		else if (IdNetToLocal(Type_ImcFriend, pAddgroup->nAdminId) != m_itemSelfInfo.nId && pAddgroup->succ == 0) {
			CNodeList *pNodeParent = GetNodeInfo(IdNetToLocal(Type_ImcGroup,pAddgroup->groupinfo.group_id));
			if (pNodeParent) {
				ItemNodeInfo_t item;
				ItemDataNetToLocal(pAddgroup->userinfo, item, Type_ImcFriend);
				AddItem(&item, pNodeParent);
			}
		}
		m_pMainMsger->FreeDataEx(Msg_ScAddGroupVerify, pAddgroup);
	}	
}
Exemplo n.º 3
0
void TNetInfBs::AddCasc(const TStr& CascStr, const int& Model, const double& alpha) {
    TStrV NIdV; CascStr.SplitOnAllCh(',', NIdV);
    TCascade C(alpha, Model);
    for (int i = 0; i < NIdV.Len(); i+=2) {
      int NId;
      double Tm; 
      NId = NIdV[i].GetInt();
      Tm = NIdV[i+1].GetFlt();
      GetNodeInfo(NId).Vol = GetNodeInfo(NId).Vol + 1;
      C.Add(NId, Tm);
    }
    C.Sort();
    CascV.Add(C);
}
Exemplo n.º 4
0
int CZiMainFrame::OnClickAddGroupResponse(WPARAM wp, LPARAM lp) {
	Assert(lp);
	AddGroupInfo_t *pAddgroup = (AddGroupInfo_t *)lp;

	if(wp == 1) { //ok
		//TODD 获取组 然后加入组
		CNodeList *pNodeParent = GetNodeInfo(IdNetToLocal(Type_ImcGroup,pAddgroup->groupinfo.group_id));
		if (pNodeParent) {
			ItemNodeInfo_t item;
			ItemDataNetToLocal(pAddgroup->userinfo, item, Type_ImcFriend);
			//TODO
			ImcGroupTable_t::iterator it = m_mapGroupTable.find(pNodeParent); 
			if(it != m_mapGroupTable.end()) {
				if (it->second.find(item.nId) == it->second.end()) {
					AddItem(&item, pNodeParent);
				}
			}
			else {
				AddItem(&item, pNodeParent);
			}
		}
	}
	// Msg_ScQueryVerify -> Msg_CsResponseVerify ..??
	//100 拒绝
	pAddgroup->succ = wp == 1 ? 0 : 100;
	pAddgroup->type = GROUP_INFO_REPLY;
	Assert(m_pMainMsger);
	m_pMainMsger->SendImMessage(Msg_CsAddGroupVerify, (LPARAM)pAddgroup, sizeof(AddGroupInfo_t));
	m_pMainMsger->FreeDataEx(Msg_ScAddGroupVerify, pAddgroup);
	return 0;
}
Exemplo n.º 5
0
    bool GetNodeText(_Ty Key, TSTRING &tsText) {

        bool r = false;

        HTREEITEM hItem = KeyToHandle(Key);

        if (NULL != hItem) {

            TCHAR pBuf[TV_MAXITEMTEXT]  = {0};
            TVITEM tvi                  = {0};

            tvi.cchTextMax  = TV_MAXITEMTEXT;
            tvi.pszText     = pBuf;
            tvi.mask        = TVIF_TEXT;
            tvi.hItem       = hItem;

            if (GetNodeInfo(&tvi)) {

                tsText  = pBuf;
                r       = true;

            }

        }

        return r;
    }
Exemplo n.º 6
0
int     CZiMainFrame::CreateChatDailog(int nId, CChatDialog ** ppChatDialog)
{
	CNodeList * pNode = GetNodeInfo(nId);
    if (!pNode) {
        return 1;
    }
	return CreateChatDailog(pNode, ppChatDialog);
}
Exemplo n.º 7
0
bool    CZiMainFrame::IsUnknownGroup(int nid) {
	bool bRet = true;
	CNodeList *pNode = GetNodeInfo(nid);
	if (pNode && pNode->GetNodeData().chType == Type_ImcGroup) {
		MessageBox(m_hWnd, _T("您已经加入了该群组"), _T("提示"), 0);
		bRet = false;
	}
	return bRet;
}
Exemplo n.º 8
0
CNodeList * CZiMainFrame::GetFriendTeamNode()
{
	// 获取 "好友" 组列表 Node 信息. 
	// 在原来的设置中没有这个
	// ...???
	#ifdef _DEBUG
		return GetNodeInfo(501);
	#endif

	return 0;
}
already_AddRefed<nsINodeInfo>
nsNodeInfoManager::GetDocumentNodeInfo()
{
  if (!mDocumentNodeInfo) {
    mDocumentNodeInfo = GetNodeInfo(nsGkAtoms::documentNodeName, nsnull, kNameSpaceID_None).get();
  }
  else {
    NS_ADDREF(mDocumentNodeInfo);
  }

  return mDocumentNodeInfo;
}
already_AddRefed<nsINodeInfo>
nsNodeInfoManager::GetCommentNodeInfo()
{
  if (!mCommentNodeInfo) {
    mCommentNodeInfo = GetNodeInfo(nsGkAtoms::commentTagName, nsnull, kNameSpaceID_None).get();
  }
  else {
    NS_ADDREF(mCommentNodeInfo);
  }

  return mCommentNodeInfo;
}
already_AddRefed<nsINodeInfo>
nsNodeInfoManager::GetTextNodeInfo()
{
  if (!mTextNodeInfo) {
    GetNodeInfo(nsGkAtoms::textTagName, nsnull, kNameSpaceID_None,
                &mTextNodeInfo);
  }
  else {
    NS_ADDREF(mTextNodeInfo);
  }

  return mTextNodeInfo;
}
Exemplo n.º 12
0
int     CZiMainFrame::AddItem (NetItemInfo_t  * pItemInfo, NetItemInfo_t * pItemInfoParent)
{
	Assert(pItemInfo);

	CNodeList * pNodeParent = 0;

	if(pItemInfoParent)
	{
		pNodeParent = GetNodeInfo(pItemInfoParent->nId);
	}

	return AddItem(pItemInfo, pNodeParent);
}
Exemplo n.º 13
0
ItemNodeInfo_t  * CZiMainFrame::GetNodeData(int nId)
{
	if(nId == m_itemSelfInfo.nId)
	{
		return &m_itemSelfInfo;
	}

	CNodeList * pNodeList = GetNodeInfo(nId);
	if(pNodeList)
	{
		return &pNodeList->GetNodeData();
	}

	return 0;
}
nsresult
nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
                               const nsAString& aNamespaceURI,
                               nsINodeInfo** aNodeInfo)
{
  nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aName);
  NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);

  PRInt32 nsid = kNameSpaceID_None;

  if (!aNamespaceURI.IsEmpty()) {
    nsresult rv = nsContentUtils::NameSpaceManager()->
      RegisterNameSpace(aNamespaceURI, nsid);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  *aNodeInfo = GetNodeInfo(nameAtom, aPrefix, nsid).get();
  return *aNodeInfo ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
Exemplo n.º 15
0
bool    CZiMainFrame::IsUnknownFriend(int nId)
{
	bool bRet = true;

	if(nId == m_itemSelfInfo.nId)
	{
		MessageBox(m_hWnd, _T("不能添加自己"), _T("提示"), 0);
		return false;
	}

	CNodeList * pNode = GetNodeInfo(nId);
	if(pNode && 
		pNode->GetNodeData().chType == Type_ImcFriend)
	{
		MessageBox(m_hWnd, _T("您已经添加了此好友"), _T("提示"), 0);
		return false;
	}

	return bRet;
}
nsresult
nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName,
                               const nsAString& aNamespaceURI,
                               nsINodeInfo** aNodeInfo)
{
  NS_ENSURE_ARG(!aQualifiedName.IsEmpty());

  nsAString::const_iterator start, end;
  aQualifiedName.BeginReading(start);
  aQualifiedName.EndReading(end);

  nsCOMPtr<nsIAtom> prefixAtom;

  nsAString::const_iterator iter(start);

  if (FindCharInReadable(':', iter, end)) {
    prefixAtom = do_GetAtom(Substring(start, iter));
    NS_ENSURE_TRUE(prefixAtom, NS_ERROR_OUT_OF_MEMORY);

    start = ++iter; // step over the ':'

    if (iter == end) {
      // No data after the ':'.

      return NS_ERROR_INVALID_ARG;
    }
  }

  nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(Substring(start, end));
  NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);

  PRInt32 nsid = kNameSpaceID_None;

  if (!aNamespaceURI.IsEmpty()) {
    nsresult rv = nsContentUtils::NameSpaceManager()->
      RegisterNameSpace(aNamespaceURI, nsid);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  return GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo);
}
Exemplo n.º 17
0
void CZiMainFrame::handleGreateGroup(GroupInfoData_t *pGroupInfoData) {
	if (pGroupInfoData->succ == 0) {
		//TODO 添加群
		ItemNodeInfo_t item;
		ItemDataNetToLocal(*pGroupInfoData, item);
		AddItem(&item, 0);

		//添加成员
		CNodeList *pNodeParent = GetNodeInfo(item.nId);
		Assert(pNodeParent);
		for (size_t i = 0; i < pGroupInfoData->groupinfo.members.size(); i++) {
			ItemNodeInfo_t group_member;
			ItemDataNetToLocal(pGroupInfoData->groupinfo.members[i], group_member, Type_ImcFriendX);
			AddItem(&group_member, pNodeParent);
		}
	}
	char szText[1024] = {0};
	sprintf_s(szText, sizeof(szText)/sizeof(char), "创建 %s %s", pGroupInfoData->groupinfo.name.c_str(),
		(pGroupInfoData->succ == 0 ? "成功" : "失败"));
	CNotifyWindow::MessageBoxX(m_hWnd, _T("通知"), CA2T(szText));
}
Exemplo n.º 18
0
void CZiMainFrame::handlerModifyGroup(GroupInfoData_t *pGroupInfoData) {
	if (pGroupInfoData->succ == 0) {
		//TODO 修改群名称
		CNodeList *pNode = GetNodeInfo(pGroupInfoData->groupinfo.group_id);
		Assert(pNode);
		tstring      strHtmlText;
		NodeData_t & itemNode = pNode->GetNodeData();
		itemNode.tstrNickName = CA2T(pGroupInfoData->groupinfo.name.c_str());
		// Team or Group' logo
		if(itemNode.bIsHasChild)
		{
			if(itemNode.bIsChildVisible)
				strHtmlText += _T("<i list_icon_b.png>");
			else
				strHtmlText += _T("<i list_icon_a.png>");
			TCHAR szBuf[MAX_PATH] = {0};
			_stprintf_s(szBuf, MAX_PATH - 1, _T("<x %d>"), 10);
			strHtmlText += szBuf;
		}
		// nick name
		strHtmlText += itemNode.tstrNickName;
		CLabelUI* tstrNickName = static_cast<CLabelUI*>(
			m_pmUi.FindSubControlByName(itemNode.pListElement, _T("nickname")));
		if (tstrNickName != NULL)
		{
			if (itemNode.bIsFolder)
				tstrNickName->SetFixedWidth(0);

			tstrNickName->SetShowHtml(true);
			tstrNickName->SetText(strHtmlText.c_str());
		}
	}
	char szText[1024] = {0};
	sprintf_s(szText, sizeof(szText)/sizeof(char), "修改群名称 %s %s", pGroupInfoData->groupinfo.name.c_str(),
		(pGroupInfoData->succ == 0 ? "成功" : "失败"));
	CNotifyWindow::MessageBoxX(m_hWnd, _T("通知"), CA2T(szText));
}
Exemplo n.º 19
0
// Callback that is triggered when a value, group or node changes
void ZWaveController::OnNotification(Notification const* _notification, void* _context){

	// Must do this inside a critical section to avoid conflicts with the main thread
	EnterCriticalSection(&g_criticalSection);

	switch (_notification->GetType())
	{
		case Notification::Type_ValueAdded:
		{
			if (NodeInfo* nodeInfo = GetNodeInfo(_notification))
			{

				// Add the new value to our list
				nodeInfo->m_values.push_back(_notification->GetValueID());

				ValueID v = _notification->GetValueID();

				Logger::LogNotice("added value id " + to_string(v.GetId())  + " to node " + to_string(v.GetNodeId()) );

				if (!ZWaveController::init_failed && ZWaveController::initial_node_queries_complete){
					if (ZWaveController::ExposeValue(v)){
						uint64 vid = v.GetId();
						ValueChange::add_change(vid);
					}
				}

			}
			break;
		}

		case Notification::Type_ValueRemoved:
		{
			if (NodeInfo* nodeInfo = GetNodeInfo(_notification))
			{
				// Remove the value from out list
				for (list<ValueID>::iterator it = nodeInfo->m_values.begin(); it != nodeInfo->m_values.end(); ++it)
				{

					if (!ZWaveController::init_failed && ZWaveController::initial_node_queries_complete){
						ValueID v = *it;
						uint64 vid = v.GetId();
						ValueChange::remove_change(vid);
					}

					if ((*it) == _notification->GetValueID())
					{
						nodeInfo->m_values.erase(it);
						break;
					}

				}
			}
			break;
		}

		case Notification::Type_ValueChanged:
		{
			// One of the node values has changed
			if (NodeInfo* nodeInfo = GetNodeInfo(_notification))
			{

				if (!ZWaveController::init_failed && ZWaveController::initial_node_queries_complete){

					// the value that changed
					ValueID v = _notification->GetValueID();

					string new_val;
					Manager::Get()->GetValueAsString(v, &new_val);
					Logger::LogNotice("node " + to_string(v.GetNodeId()) + ", value " + to_string(v.GetId()) + " (" + Manager::Get()->GetValueLabel(v) + "), has been changed to " + new_val);

					ValueChange::remove_expired_value_changes();

					// first remove this value from the change queue if it's already in there
					if (ZWaveController::ExposeValue(v)){
						string new_value;
						Manager::Get()->GetValueAsString(v, &new_value);

						uint64 vid = v.GetId();
						ValueChange::remove_change(vid);
						ValueChange::add_change(vid);
					}
				}

			}
			break;
		}

		case Notification::Type_Group:
		{
			// One of the node's association groups has changed
			if (NodeInfo* nodeInfo = GetNodeInfo(_notification))
			{
				nodeInfo = nodeInfo;		// placeholder for real action
			}
			break;
			}

		case Notification::Type_NodeAdded:
		{
			// Add the new node to our list
			NodeInfo* nodeInfo = new NodeInfo();

			nodeInfo->m_homeId = _notification->GetHomeId();
			nodeInfo->m_nodeId = _notification->GetNodeId();
			nodeInfo->m_polled = false;
			g_nodes.push_back(nodeInfo);

			Logger::LogNotice("node " + to_string(nodeInfo->m_nodeId) + " added");

			break;
		}

		case Notification::Type_NodeRemoved:
		{
			// Remove the node from our list
			uint32 const homeId = _notification->GetHomeId();
			uint8 const nodeId = _notification->GetNodeId();
			for (list<NodeInfo*>::iterator it = g_nodes.begin(); it != g_nodes.end(); ++it)
			{
				NodeInfo* nodeInfo = *it;
				if ((nodeInfo->m_homeId == homeId) && (nodeInfo->m_nodeId == nodeId))
				{
					g_nodes.erase(it);
					Logger::LogNotice("node " + to_string(nodeInfo->m_nodeId) + " removed");
					delete nodeInfo;
					break;
				}
			}
			break;
		}

		case Notification::Type_NodeEvent:
		{
			// We have received an event from the node, caused by a
			// basic_set or hail message.
			if (NodeInfo* nodeInfo = GetNodeInfo(_notification))
			{
				if (nodeInfo->m_nodeId == 5 || nodeInfo->m_nodeId == 6){
					Logger::LogNotice("node event received from node id " + to_string(nodeInfo->m_nodeId));
				}
				else {
					Logger::LogNotice("node event received from node id " + to_string(nodeInfo->m_nodeId));
				}
			}
			break;
		}

		case Notification::Type_PollingDisabled:
		{
			if (NodeInfo* nodeInfo = GetNodeInfo(_notification))
			{
				nodeInfo->m_polled = false;
			}
			break;
		}

		case Notification::Type_PollingEnabled:
		{
			if (NodeInfo* nodeInfo = GetNodeInfo(_notification))
			{
				nodeInfo->m_polled = true;
			}
			break;
		}

		case Notification::Type_DriverReady:
		{
			ZWaveController::homeId = _notification->GetHomeId();
			Logger::LogNotice("controller driver is ready");
			break;
		}

		case Notification::Type_DriverFailed:
		{
			ZWaveController::init_failed = true;
			Logger::LogNotice("controller initialization failed. make sure another program is not already controlling the controller");
			break;
		}

		case Notification::Type_AwakeNodesQueried:
		case Notification::Type_AllNodesQueried:
		case Notification::Type_AllNodesQueriedSomeDead:
		{
			ZWaveController::initial_node_queries_complete = true;
			Logger::LogNotice("all zwave node queries complete");
			break;
		}

		case Notification::Type_NodeQueriesComplete:
		{
			Logger::LogNotice("node " + to_string(_notification->GetNodeId()) + " queries complete");
			break;
		}

		case Notification::Type_DriverReset:
		case Notification::Type_NodeNaming:
		case Notification::Type_NodeProtocolInfo:
		default:
		{
//			Logger::LogNotice("node " + to_string(_notification->GetNodeId()) + "");
		}

	} // end of switch

	LeaveCriticalSection(&g_criticalSection);
}
Exemplo n.º 20
0
LRESULT CZiMainFrame::HandleCustomMessage(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	BOOL bFree = FALSE;

	switch(nMsg)
	{
	case WM_TIMER:
		if(wParam == 1) OnTimer();
		break;

	case Msg_InTray:
		{
			Assert(wParam == IDR_MAINFRAME);

			switch(lParam)
			{
			case WM_RBUTTONUP:
				{
					// 右键单击 -> 弹出右键菜单. 
					// ... 
				}
				break;

			case WM_LBUTTONDBLCLK:
				{
					// 左键双击 -> 1 消息, 2 显示. 
					BOOL bNoMsg  = true;
					BOOL bHide   = ::IsWindowVisible(m_hWnd);

					bNoMsg = HandleNetCmd();
					if(bNoMsg)
					{
						break;
					}
					{
						::ShowWindow(m_hWnd, SW_SHOW);
						::SetForegroundWindow(m_hWnd);
					}
				}
				break;
			}
		}
		break;

	case Msg_InQueryVerify:
		// 发送验证回复消息给对方. 
		Assert(lParam);
		OnClickVerifyResponse(wParam, lParam);
		break;

	case Msg_ScResponseUsers:
		{
			SearchScResponse_t * pResponse = (SearchScResponse_t*)lParam;
			if(wParam != 0)
			{
				CZimcHelper::ErrorMessageBox(m_hWnd, Msg_CsQueryUsers, wParam);
			}
			else if(m_pSearchWindow)
			{
				m_pSearchWindow->HandleResponseResult(pResponse);
			}

			bFree = TRUE;
		}
		break;
	case Msg_ScResponseGroup:
		{
			SearchGroup_t *pSearchGroup = (SearchGroup_t *)lParam;
			if (wParam != 0) {
				CZimcHelper::ErrorMessageBox(m_hWnd, nMsg, wParam);
			}
			else if (m_pSearchWindow) {
				m_pSearchWindow->HandleResponseResultForGroup(pSearchGroup);
			}
			bFree = TRUE;
		}
		break;
	case Msg_ScQueryVerify:
	case Msg_ScResponseVerify:
	case Msg_ScAddGroupVerify: 
		{
			Assert(lParam != 0);
			AddGroupInfo_t *pAddgroupinfo = (AddGroupInfo_t *)lParam;
			DelayDispatchNetCmd(nMsg, pAddgroupinfo->nSenderId, (void*)lParam);
		}
		break;
	case Msg_ScTextChat:
		{
			Assert(lParam != 0);
			CChatDialog * pChatDialog = 0;
            ChatCcTextData_t *pChatText = (ChatCcTextData_t *)lParam;
            if (pChatText->nRecvType == Type_ImcFriend) { //好友消息
                ImcSubWindowTable_t::iterator it = m_mapSubWindows.find(pChatText->nSenderId);
                if(it != m_mapSubWindows.end()) pChatDialog = static_cast<CChatDialog*>(it->second);
            }
            else { //群消息
                ImcSubWindowTable_t::iterator it = m_mapSubWindows.find(pChatText->nRecverId);
                if(it != m_mapSubWindows.end()) pChatDialog = static_cast<CChatDialog*>(it->second);
            }
			if(pChatDialog)
			{
				pChatDialog->OnTextMsgShow(pChatText);
				bFree = TRUE;
			}
			else
			{
				DelayDispatchNetCmd(nMsg, pChatText->nSenderId, (void*)lParam);
			}
		}
		break;
    case Msg_ScDelFriend:
        {
            Assert(lParam != 0);
			
			DelFriendItem *pDelFriend = (DelFriendItem *)lParam;
			int nDelId = IdNetToLocal(pDelFriend->type, pDelFriend->nDelId);
			int nSendId = IdNetToLocal(Type_ImcFriend, pDelFriend->nSendId);
			if (pDelFriend->succ == 0) {				
				//TODO
				if (pDelFriend->type == Type_ImcTeam) {
				}
				else if (pDelFriend->type == Type_ImcFriend) {
					CNodeList *pNodeinfo = NULL;
					if (nDelId == m_itemSelfInfo.nId) {
						pNodeinfo = GetNodeInfo(nSendId);
					}
					else {
						pNodeinfo = GetNodeInfo(nDelId);
					}
					if (pNodeinfo) {
						DelItem(pNodeinfo, pNodeinfo->GetParent());
					}
				}
				else if (pDelFriend->type == Type_ImcFriendX) {

				}
				else if (pDelFriend->type == Type_ImcGroup) {
					if (nDelId != m_itemSelfInfo.nId) {
						CNodeList *pNodeInfo = GetNodeInfo(nDelId);
						m_mapGroupTable.erase(pNodeInfo);
						Assert(pNodeInfo);
						ItemNodeInfo_t  & itemInfo    = pNodeInfo->GetNodeData();
						CBaseItemListUI * pItemListUi = GetNodeListUi(itemInfo.chType);
						Assert(pItemListUi);
						pItemListUi->RemoveNode(pNodeInfo);
						DeleteGroupNode(nDelId);
					}
				}
				else {
				}	
			}
			if (nDelId == m_itemSelfInfo.nId) {
				DelayDispatchNetCmd(nMsg, nSendId, (void*)lParam);
			}
			else {
				DelayDispatchNetCmd(nMsg, nDelId, (void*)lParam);
			}
        }
        break;
	case  Msg_ScEvilReport:
		{
			// 显示验证请求框, 交给用户操作. 
			// 还需要显示请求者的信息, 未实现 ... ???
			ReportCsEvilData_t * pReport = (ReportCsEvilData_t*)lParam;
			char              szText[1024] = {0};
			sprintf_s(szText, sizeof(szText)/sizeof(szText[0]), 
				"举报 %s", pReport->succ == 0 ? "成功" : "失败");

			CNotifyWindow::MessageBoxX(m_hWnd, _T("通知"), CA2T(szText));
			bFree = TRUE;
		}
		break;
	case Msg_ScCreateGroup:
		handleGreateGroup((GroupInfoData_t *)lParam);
		bFree = TRUE;
		break;
	case Msg_InAddGroupVerify:
		Assert(lParam);
		OnClickAddGroupResponse(wParam, lParam);
		break;
	case Msg_ScModifyGroup:
		Assert(lParam);
		handlerModifyGroup((GroupInfoData_t *)lParam);
		break;
	}

	if(bFree) m_pMainMsger->FreeDataEx(nMsg, (void*)lParam);
	return 0;
}
Exemplo n.º 21
0
BOOL EnvironmentConstruct::Init()
{
    int           nResult        = false;
    int           nRetCode       = false;
    ITabFile*     piTableFile    = NULL;
    KTRACK*       pThisTrack     = NULL;
    KROUTE_NODE*  pFromRouteNode = NULL;
    KROUTE_NODE*  pToRouteNode   = NULL;
    KTRACK*       pTrack         = NULL;
    int           nTrackID       = 0;
    int           nTabHeight     = 0;
    int           nDistance      = 0;
    int           nCurrentFrame  = 0;
    char          szScriptFile[MAX_PATH];
    KROUTE_NODE   RouteNode;
    KTRACK        Track;
    KTRACK_POINT  TrackPoint;
    KTRACK_POINT  PrevTrackPoint;
    std::pair<KTrackMap::iterator, bool> itRetCode;

    // Load RoadNode.tab
    //--------------------------------------------------------------------------
    piTableFile = g_OpenTabFile("RoadNode.tab");
    KGLOG_PROCESS_ERROR(piTableFile);

    nTabHeight = piTableFile->GetHeight();
    KGLOG_PROCESS_ERROR(nTabHeight > 1);

    for (int i = 2; i <= nTabHeight; i++)
    {
        nRetCode = piTableFile->GetInteger(i, "NodeID", -1, &RouteNode.nNodeID);
        KGLOG_PROCESS_ERROR(nRetCode && "Get NodeID");

        nRetCode = piTableFile->GetString(i, "Description", "", RouteNode.szDescription, sizeof(RouteNode.szDescription));
        KGLOG_PROCESS_ERROR(nRetCode && "Get Description");

        nRetCode = piTableFile->GetInteger(i, "MapID", 0, (int*)&RouteNode.dwMapID);
        KGLOG_PROCESS_ERROR(nRetCode && "Get MapID");

        nRetCode = piTableFile->GetInteger(i, "CityID", 0, (int*)&RouteNode.dwCityID);
        KGLOG_PROCESS_ERROR(nRetCode && "Get CityID");

        nRetCode = piTableFile->GetInteger(i, "ForceID", 0, (int*)&RouteNode.dwForceID);
        KGLOG_PROCESS_ERROR(nRetCode && "Get ForceID");

        RouteNode.dwDefaultForceID = RouteNode.dwForceID;

        nRetCode = piTableFile->GetInteger(i, "TongID", 0, (int*)&RouteNode.dwTongID);
        KGLOG_PROCESS_ERROR(nRetCode && "Get TongID");

        nRetCode = piTableFile->GetString(i, "ScriptFile", "", szScriptFile, sizeof(szScriptFile));
        KGLOG_PROCESS_ERROR(nRetCode);

        RouteNode.szScriptFile[0] = '\0';
        if (szScriptFile[0] != '\0')
        {
            snprintf(RouteNode.szScriptFile, sizeof(RouteNode.szScriptFile), "%s", szScriptFile);
            RouteNode.szScriptFile[sizeof(RouteNode.szScriptFile) - 1] = '\0';
        }

        nRetCode = piTableFile->GetInteger(i, "NeedOpen", false, &RouteNode.bIsNeedOpen);
        KGLOG_PROCESS_ERROR(nRetCode && "Get NeedOpen");

        nRetCode = piTableFile->GetInteger(i, "X", 0, &RouteNode.nX);
        KGLOG_PROCESS_ERROR(nRetCode && "Get X");

        nRetCode = piTableFile->GetInteger(i, "Y", 0, &RouteNode.nY);
        KGLOG_PROCESS_ERROR(nRetCode && "Get Y");

        nRetCode = piTableFile->GetInteger(i, "Z", 0, &RouteNode.nZ);
        KGLOG_PROCESS_ERROR(nRetCode && "Get Z");

        KG_PROCESS_ERROR(RouteNode.bIsNeedOpen || RouteNode.dwForceID == 0);

        m_RouteMap.insert(std::make_pair(RouteNode.nNodeID, RouteNode));
    }
    KG_COM_RELEASE(piTableFile);
    piTableFile = NULL;

    //Load RoadTrack.tab
    //--------------------------------------------------------------------------
    piTableFile = g_OpenTabFile("RoadTrack.tab");
    KGLOG_PROCESS_ERROR(piTableFile);

    nTabHeight = piTableFile->GetHeight();
    KGLOG_PROCESS_ERROR(nTabHeight > 1);

    for (int i = 2; i <= nTabHeight; i++)
    {
        nRetCode = piTableFile->GetInteger(i, "FromNodeID", 0, &Track.nFromNode);
        KGLOG_PROCESS_ERROR(nRetCode && "Get FromNodeID");

        nRetCode = piTableFile->GetInteger(i, "ToNodeID", 0, &Track.nToNode);
        KGLOG_PROCESS_ERROR(nRetCode && "Get ToNodeID");

        nRetCode = piTableFile->GetInteger(i, "CostMoney", 0, &Track.nCostMoney);
        KGLOG_PROCESS_ERROR(nRetCode && "Get Cost Money");

        nRetCode = piTableFile->GetInteger(i, "TrackID", 0, &Track.nTrackID);
        KGLOG_PROCESS_ERROR(nRetCode && "Get TrackID");

        KGLOG_PROCESS_ERROR(Track.nTrackID > 0 && Track.nTrackID <= MAX_TRACK_ID);

        nRetCode = piTableFile->GetInteger(i, "Velocity", 0, &Track.nVelocity);
        KGLOG_PROCESS_ERROR(nRetCode && "Get Velocity");

        KGLOG_PROCESS_ERROR(Track.nVelocity > 0);

        Track.nFrame = 0;   //  这里置0,将在读入路点的时候,累计每个路点的时间。

        itRetCode = m_TrackMap.insert(std::make_pair(Track.nTrackID, Track));
        KGLOG_PROCESS_ERROR(itRetCode.second);

        pThisTrack      = GetTrackInfo(Track.nTrackID);
        pFromRouteNode  = GetNodeInfo(Track.nFromNode);
        pToRouteNode    = GetNodeInfo(Track.nToNode);

        pFromRouteNode->vLinkNode.push_back(std::make_pair(pToRouteNode, pThisTrack));
        pToRouteNode->vLinkNode.push_back(std::make_pair(pFromRouteNode, pThisTrack));
    }
    KG_COM_RELEASE(piTableFile);
    piTableFile = NULL;

    //Load RoadPoint.tab
    //--------------------------------------------------------------------------
    piTableFile = g_OpenTabFile("RoadPoint.tab");
    KGLOG_PROCESS_ERROR(piTableFile);

    nTabHeight = piTableFile->GetHeight();
    KGLOG_PROCESS_ERROR(nTabHeight > 1);

    for (int i = 2; i <= nTabHeight; i++)
    {
        nRetCode = piTableFile->GetInteger(i, "TrackID", 0, &nTrackID);
        KG_PROCESS_ERROR(nRetCode && "Get TrackID");

        nRetCode = piTableFile->GetInteger(i, "X", 0, &TrackPoint.nX);
        KG_PROCESS_ERROR(nRetCode && "Get X");

        nRetCode = piTableFile->GetInteger(i, "Y", 0, &TrackPoint.nY);
        KG_PROCESS_ERROR(nRetCode && "Get Y");

        nRetCode = piTableFile->GetInteger(i, "Z", 0, &TrackPoint.nZ);
        KG_PROCESS_ERROR(nRetCode && "Get Z");

        pTrack = GetTrackInfo(nTrackID);
        KG_PROCESS_ERROR(pTrack);

        if (pTrack->vPoint.empty())
        {
            pTrack->nFrame = 0;
            TrackPoint.nFrame = 0;
            pTrack->vPoint.push_back(TrackPoint);
            continue;
        }

        PrevTrackPoint = pTrack->vPoint.back();

        nDistance = g_GetDistance3(
            PrevTrackPoint.nX, PrevTrackPoint.nY, PrevTrackPoint.nZ,
            TrackPoint.nX, TrackPoint.nY, TrackPoint.nZ
            );
        nCurrentFrame = (int)sqrt((double)nDistance) / pTrack->nVelocity;

        pTrack->nFrame += nCurrentFrame;
        TrackPoint.nFrame = pTrack->nFrame;

        pTrack->vPoint.push_back(TrackPoint);
    }

    nResult = true;
Exit0:
    if (!nResult)
    {
        m_RouteMap.clear();
        m_TrackMap.clear();
        pTrack->vPoint.clear();
    }
    KG_COM_RELEASE(piTableFile);
    return nResult;
}