예제 #1
0
bool CJsonOverUTTPWriter::ContinueWithReply()
{
    for (;;)
        if (m_CurrentOutputNode.m_Node.IsArray()) {
            if (m_CurrentOutputNode.m_ArrayIterator ==
                    m_CurrentOutputNode.m_Node.GetArray().end()) {
                if (m_OutputStack.empty()) {
                    m_UTTPWriter.SendControlSymbol('\n');
                    return false;
                }
                m_CurrentOutputNode = m_OutputStack.back();
                m_OutputStack.pop_back();
                if (!m_UTTPWriter.SendControlSymbol(']'))
                    return true;
            } else
                if (!SendNode(*m_CurrentOutputNode.m_ArrayIterator++))
                    return true;
        } else { // The current node is eObject.
            if (m_CurrentOutputNode.m_ObjectIterator ==
                    m_CurrentOutputNode.m_Node.GetObject().end()) {
                m_CurrentOutputNode = m_OutputStack.back();
                m_OutputStack.pop_back();
                if (!m_UTTPWriter.SendControlSymbol('}'))
                    return true;
            } else {
                if (!m_SendHashValue) {
                    string key(m_CurrentOutputNode.m_ObjectIterator->first);
                    if (!m_UTTPWriter.SendChunk(
                            key.data(), key.length(), false)) {
                        m_SendHashValue = true;
                        return true;
                    }
                }

                m_SendHashValue = false;

                if (!SendNode(m_CurrentOutputNode.m_ObjectIterator++->second))
                    return true;
            }
        }
}
예제 #2
0
void LiveServer::BroadcastNodes(DirtyList& dirty_list)
{
	if(dirty_list.Empty())
		return;

	DirtyList::SetType ds = dirty_list.GetPosList();
	for(DirtyList::SetType::const_iterator iter = ds.begin(); iter != ds.end(); ++iter)
	{
		const DirtyList::ValueType& ind = *iter;

		int ndx = ind.pos >> 18;
		int ndy = (ind.pos >> 4) & 0x3FFF;
		uint32_t floors = ind.floors;

		QTreeNode* node = editor->map.getLeaf(ndx*4, ndy*4);
		if(!node)
			continue;

		for(PeerList::iterator citer = connected_clients.begin(); citer != connected_clients.end(); ++citer)
		{
			if(dirty_list.owner != 0 && dirty_list.owner == (*citer)->GetClientID())
			{
				continue;
			}

			bool seen_ug = node->isVisible((*citer)->GetClientID(), true);
			bool seen_og = node->isVisible((*citer)->GetClientID(), false);
			if(seen_ug)
			{
				SendNode(*citer, node, ndx, ndy, floors & 0xff00);
			}
			if(seen_og)
			{
				SendNode(*citer, node, ndx, ndy, floors & 0x00ff);
			}
		}
	}
}
예제 #3
0
void LiveServer::OnReceiveNodeRequest(LivePeer* connection, NetworkMessage* nmsg)
{
	uint32_t nodes = nmsg->ReadU32();
	while(nodes--)
	{
		// Read position
		uint32_t ind = nmsg->ReadU32();			

		// Extract node position
		int ndx = ind >> 18;
		int ndy = (ind >> 4) & 0x3FFF;
		bool underground = ind & 1;

		QTreeNode* node = editor->map.createLeaf(ndx * 4, ndy * 4);
		if (node) {
			SendNode(connection, node, ndx, ndy, underground? 0xff00 : 0x00ff);
		}
	}
}