- int ret = Net_Wait(m_pInSocket, 0, 0);
- if (ret == -1)
- {
- globalOutputStream() << "WARNING: SOCKET_ERROR in CWatchBSP::RoutineProcessing\n";
- globalOutputStream() << "Terminating the connection.\n";
- EndMonitoringLoop();
- return;
- }
-
- if (ret == 1)
- {
- // the socket has been identified, there's something (message or disconnection)
- // see if there's anything in input
- ret = Net_Receive( m_pInSocket, &msg );
- if (ret > 0)
- {
- // unsigned int size = msg.size; //++timo just a check
- strcpy (m_xmlBuf, NMSG_ReadString (&msg));
- if (m_bNeedCtxtInit)
- {
- m_xmlParserCtxt = NULL;
- m_xmlParserCtxt = xmlCreatePushParserCtxt (&saxParser, &m_message_info, m_xmlBuf, static_cast<int>(strlen(m_xmlBuf)), NULL);
-
- if (m_xmlParserCtxt == NULL)
- {
- globalErrorStream() << "Failed to create the XML parser (incoming stream began with: " << m_xmlBuf << ")\n";
- EndMonitoringLoop();
- }
- m_bNeedCtxtInit = false;
- }
- else
- {
- xmlParseChunk(m_xmlParserCtxt, m_xmlBuf, static_cast<int>(strlen(m_xmlBuf)), 0);
- }
- }
- else
- {
- message_flush(&m_message_info);
- // error or connection closed/reset
- // NOTE: if we get an error down the XML stream we don't reach here
- Net_Disconnect( m_pInSocket );
- m_pInSocket = NULL;
- globalOutputStream() << "Connection closed.\n";
-#if 0
- if (m_bBSPPlugin)
- {
- EndMonitoringLoop();
- // let the BSP plugin know that the job is done
- g_BSPFrontendTable.m_pfnEndListen(0);
- return;
- }
-#endif
- // move to next step or finish
- m_iCurrentStep++;
- if (m_iCurrentStep < m_pCmd->len )
- {
- DoEBeginStep();
- }
- else
- {
- // launch the engine .. OMG
- if (g_WatchBSP_RunQuake)
- {
-#if 0
- // do we enter sleep mode before?
- if (g_WatchBSP_DoSleep)
- {
- globalOutputStream() << "Going into sleep mode..\n";
- g_pParentWnd->OnSleep();
- }
-#endif
- globalOutputStream() << "Running engine...\n";
- StringOutputStream cmd(256);
- // build the command line
- cmd << EnginePath_get();
- // this is game dependant
-
- RunEngineConfiguration engineConfig;
-
- if(engineConfig.do_sp_mp)
- {
- if (string_equal(gamemode_get(), "mp"))
- {
- cmd << engineConfig.mp_executable;
- }
- else
- {
- cmd << engineConfig.executable;
- }
- }
- else
- {
- cmd << engineConfig.executable;
- }
-
- StringOutputStream cmdline;
-
- GlobalGameDescription_string_write_mapparameter(cmdline, m_sBSPName);
-
- globalOutputStream() << cmd.c_str() << " " << cmdline.c_str() << "\n";
-
- // execute now
- if (!Q_Exec(cmd.c_str(), (char *)cmdline.c_str(), EnginePath_get(), false, false))
- {
- StringOutputStream msg;
- msg << "Failed to execute the following command: " << cmd.c_str() << cmdline.c_str();
- globalOutputStream() << msg.c_str();
- gtk_MessageBox(GTK_WIDGET(MainFrame_getWindow()), msg.c_str(), "Build monitoring", eMB_OK, eMB_ICONERROR );
- }
- }
- EndMonitoringLoop();
- }
- }
- }
- }
- break;
- default:
- break;
- }
-}
-
-GPtrArray* str_ptr_array_clone(GPtrArray* array)
-{
- GPtrArray* cloned = g_ptr_array_sized_new(array->len);
- for(guint i = 0; i < array->len; ++i)
- {
- g_ptr_array_add(cloned, g_strdup((char*)g_ptr_array_index(array, i)));
- }
- return cloned;
+ int ret = Net_Wait( m_pInSocket, 0, 0 );
+ if ( ret == -1 ) {
+ globalOutputStream() << "WARNING: SOCKET_ERROR in CWatchBSP::RoutineProcessing\n";
+ globalOutputStream() << "Terminating the connection.\n";
+ EndMonitoringLoop();
+ return;
+ }
+
+ if ( ret == 1 ) {
+ // the socket has been identified, there's something (message or disconnection)
+ // see if there's anything in input
+ ret = Net_Receive( m_pInSocket, &msg );
+ if ( ret > 0 ) {
+ // unsigned int size = msg.size; //++timo just a check
+ strcpy( m_xmlBuf, NMSG_ReadString( &msg ) );
+ if ( m_bNeedCtxtInit ) {
+ m_xmlParserCtxt = NULL;
+ m_xmlParserCtxt = xmlCreatePushParserCtxt( &saxParser, &m_message_info, m_xmlBuf, static_cast<int>( strlen( m_xmlBuf ) ), NULL );
+
+ if ( m_xmlParserCtxt == NULL ) {
+ globalErrorStream() << "Failed to create the XML parser (incoming stream began with: " << m_xmlBuf << ")\n";
+ EndMonitoringLoop();
+ }
+ m_bNeedCtxtInit = false;
+ }
+ else
+ {
+ xmlParseChunk( m_xmlParserCtxt, m_xmlBuf, static_cast<int>( strlen( m_xmlBuf ) ), 0 );
+ }
+ }
+ else
+ {
+ message_flush( &m_message_info );
+ // error or connection closed/reset
+ // NOTE: if we get an error down the XML stream we don't reach here
+ Net_Disconnect( m_pInSocket );
+ m_pInSocket = NULL;
+ globalOutputStream() << "Connection closed.\n";
+ // move to next step or finish
+ m_iCurrentStep++;
+ if ( m_iCurrentStep < m_pCmd->len ) {
+ DoEBeginStep();
+ }
+ else
+ {
+ // launch the engine .. OMG
+ if ( g_WatchBSP_RunQuake ) {
+ globalOutputStream() << "Running engine...\n";
+ StringOutputStream cmd( 256 );
+ // build the command line
+ cmd << EnginePath_get();
+ // this is game dependant
+
+ RunEngineConfiguration engineConfig;
+
+ if ( engineConfig.do_sp_mp ) {
+ if ( string_equal( gamemode_get(), "mp" ) ) {
+ cmd << engineConfig.mp_executable;
+ }
+ else
+ {
+ cmd << engineConfig.executable;
+ }
+ }
+ else
+ {
+ cmd << engineConfig.executable;
+ }
+
+ StringOutputStream cmdline;
+
+ GlobalGameDescription_string_write_mapparameter( cmdline, m_sBSPName );
+
+ globalOutputStream() << cmd.c_str() << " " << cmdline.c_str() << "\n";
+
+ // execute now
+ if ( !Q_Exec( cmd.c_str(), (char *)cmdline.c_str(), EnginePath_get(), false, false ) ) {
+ StringOutputStream msg;
+ msg << "Failed to execute the following command: " << cmd.c_str() << cmdline.c_str();
+ globalOutputStream() << msg.c_str();
+ gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg.c_str(), "Build monitoring", eMB_OK, eMB_ICONERROR );
+ }
+ }
+ EndMonitoringLoop();
+ }
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }