// ----------------------------------------------------------------------- // // // ROUTINE: CDebugLineFX::Update // // PURPOSE: Checks for new lines, clients, or a clear line and sends // the data down to any clients. // // ----------------------------------------------------------------------- // void DebugLineSystem::Update() { if( !m_hObject ) return; if( nextLineToSend != lines.end() || m_bClearOldLines ) { // Set up the message. CAutoMessage cMsg; cMsg.Writeuint8( MID_SFX_MESSAGE ); // Record the ID and server object, used to route the message. cMsg.Writeuint8( SFX_DEBUGLINE_ID ); cMsg.WriteObject( m_hObject ); // Record the number of entries. const int num_lines_left = (lines.end() - nextLineToSend); if( num_lines_left < s_MaxLinesPerMessage ) { cMsg.Writeuint16( num_lines_left ); } else { cMsg.Writeuint16( s_MaxLinesPerMessage ); } // Record the maximum number of lines. cMsg.Writeuint32( m_nMaxLines ); // Tell whether we want to clear old lines or not, cMsg.Writeuint8( m_bClearOldLines ); // Record each entry. int num_lines_sent = 0; LTVector system_center(0,0,0); LTFLOAT system_center_count = 0; while( nextLineToSend != lines.end() && num_lines_sent < s_MaxLinesPerMessage) { cMsg.WriteType( *nextLineToSend ); ++nextLineToSend; ++num_lines_sent; } #ifdef LINESYSTEM_DEBUG g_pLTServer->CPrint("Sent %d lines. %d lines left to send.", num_lines_sent, lines.end() - nextLineToSend ); #endif cMsg.WriteString( m_DebugString.c_str() ); // Send the message! g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED); // If we have cleared out our lines and have no more to send, // why should we exist? if( m_bClearOldLines && lines.empty() ) { char szObjectName[256]; g_pLTServer->GetObjectName(m_hObject, szObjectName, 256); LineSystem::SystemMap::iterator iter = LineSystem::g_systems.find( std::string(szObjectName) ); if( iter != LineSystem::g_systems.end() ) { LineSystem::g_systems.erase(iter); } g_pLTServer->RemoveObject(m_hObject); } // Reset m_bClearOldLines so that we don't re-enter this block. m_bClearOldLines = false; } }
// ----------------------------------------------------------------------- // // // ROUTINE: CDebugLineFX::Update // // PURPOSE: Checks for new lines, clients, or a clear line and sends // the data down to any clients. // // ----------------------------------------------------------------------- // void DebugLineSystem::Update() { if( !m_hObject ) return; while( ( !m_lstDebugLines.empty() ) || m_bClearOldLines ) { // Set up the message. CAutoMessage cMsg; cMsg.Writeuint8( MID_SFX_MESSAGE ); // Record the ID and server object, used to route the message. cMsg.Writeuint8( SFX_DEBUGLINE_ID ); cMsg.WriteObject( m_hObject ); // Record the number of entries. int cLines = m_lstDebugLines.size(); if( cLines < s_MaxLinesPerMessage ) { cMsg.Writeuint16( cLines ); } else { cMsg.Writeuint16( s_MaxLinesPerMessage ); } // Tell whether we want to clear old lines or not, cMsg.Writebool( m_bClearOldLines ); cMsg.Writebool( m_bRelative ); // Record each entry. int iLine=0; DEBUG_LINE_LIST::iterator itLine; for( itLine = m_lstDebugLines.begin(); itLine != m_lstDebugLines.end(); ++itLine ) { cMsg.WriteType( *itLine ); ++iLine; if( iLine >= s_MaxLinesPerMessage ) { break; } } m_lstDebugLines.erase( m_lstDebugLines.begin(), itLine ); cMsg.WriteString( m_DebugString.c_str() ); cMsg.WriteLTVector( m_vDebugStringPos ); // Send the message! g_pLTServer->SendToClient(cMsg.Read(), NULL, MESSAGE_GUARANTEED); // If we have cleared out our lines and have no more to send, // why should we exist? if( m_bClearOldLines && ( cLines == 0 ) ) { char szObjectName[256]; g_pLTServer->GetObjectName(m_hObject, szObjectName, LTARRAYSIZE(szObjectName)); LineSystem::SystemMap::iterator iter = LineSystem::g_systems.find( szObjectName ); if( iter != LineSystem::g_systems.end() ) { LineSystem::g_systems.erase(iter); } g_pLTServer->RemoveObject(m_hObject); } // Reset m_bClearOldLines so that we don't re-enter this block. m_bClearOldLines = false; } }