View Single Post
Re: send debug to HUD text?
Old
  (#6)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: send debug to HUD text? - 23-01-2004

ah no pierre, that's totally secret code ...

Code:
 
void ShowInfo (void)
{
   //return;
 
   //cout << g_pGame->getMaxCurrentPlayer () << endl;
 
#ifndef _DEBUG
   if (!g_bShowProfile && !g_bShowWPStat)
   {
	  return;
   }
#endif
 
   if (!IS_DEDICATED_SERVER ())
   {
	  if (g_pGame->m_pListenserverEdict.getEntity ())
	  {
		 static float fNext = 0;
		 static float fNextDiff = .2;
 
		 if (fNext < g_pGame->getTime ())
		 {
			fNextDiff = .42f;
			fNext = g_pGame->getTime () + .4f;
			g_debuginfo = true;
		 }
		 else
		 {
			if (g_pGame->getTime () < 30 && fNext > 31)
			   fNext = 0;
 
			g_debuginfo = false;
			return;
		 }
 
		 edict_t *pInfo = 0;
		 szDebugText[0] = 0;
 
		 if (!g_bShowProfile && !g_bShowWPStat)
		 {
#ifdef _DEBUG
			float fMin = 10;
			char szTemp[200];
 
			sprintf (szTemp, "time: %.0f\n", g_pGame->getTime ());
			strcat (szDebugText, szTemp);
			sprintf (szTemp, "Players : %i\n", g_pGame->getMaxCurrentPlayer ());
			strcat (szDebugText, szTemp);
			sprintf (szTemp, "ASMP : %li %3li %li/%li\n",
					 g_ASN_MPool.m_lCAlloc,
					 g_ASN_MPool.m_lCAlloc - g_ASN_MPool.m_lCFree,
					 g_ASN_MPool.m_lNextFree,
					 g_ASN_MPool.m_lCMax);
			strcat (szDebugText, szTemp);
			sprintf (szTemp, "ASTM : #%li/%li\n",
					 g_AStarTasks.getCurrentTotalTasks (),
					 g_AStarTasks.getTotalTasks ());
			strcat (szDebugText, szTemp);
 
			pInfo = 0;
			pInfo = UTIL_GetNearestPlayer (g_pGame->m_pListenserverEdict.getEntity (),
										   -1, fMin, true, true);
 
			fMin = 100000;
 
			if (!pInfo)
			{
			   pInfo = UTIL_GetNearestPlayer (g_pGame->m_pListenserverEdict.getEntity (),
											  -1, fMin, true, false);
			}
 
			if (pInfo)
			{
			   getInfo (szDebugText, pInfo);
			}
#endif
		 }
 
		 else if (g_bShowProfile)
		 {
			strcpy (szDebugText, g_szProfileOutput);
		 }
 
		 else /*if (g_bShowWPStat)*/
		 {
			if (!g_pGame->m_pListenserverEdict.getEntity ())
			   return;
 
			int iNWP = g_Map.m_Waypoints.getNearest (g_pGame->m_pListenserverEdict.getOrigin ());
 
			if (iNWP == -1)
			   return;
 
			char szTemp[80];
 
			sprintf (szDebugText, "WPStat Info (%i/%i)\n\n",
					 iNWP, g_Map.m_Waypoints.m_iNumWaypoints);
			sprintf (szTemp, "iVWP : %i\n",
					 g_Map.m_Waypoints[iNWP].m_iVisibleWaypoints);
			strcat (szDebugText, szTemp);
			sprintf (szTemp, "fAvDv : %.0f\n",
					 g_Map.m_Waypoints[iNWP].m_fAvDistVWP);
			strcat (szDebugText, szTemp);
 
			sprintf (szTemp, "D/Dd : %li/%li\n",
					 g_Map.m_Waypoints[iNWP].m_lTotalDamage,
					 g_Map.m_Waypoints[iNWP].m_lTotalDamaged);
			strcat (szDebugText, szTemp);
 
			sprintf (szTemp, "traffic : %li\n",
					 g_Map.m_Waypoints[iNWP].m_lTraffic);
			strcat (szDebugText, szTemp);
 
			g_pGame->drawBeam (g_pGame->m_pListenserverEdict.getEntity(),
							   g_pGame->m_pListenserverEdict.getOrigin (),
							   g_Map.m_Waypoints[iNWP].m_VOrigin,
							   2,
							   0,
							   Vector (255, 255, 255),
							   255,
							   0,
							   fNextDiff * 10);
 
			if (!g_Map.m_Waypoints.m_bDisplay)
			   g_pGame->drawBeam (g_pGame->m_pListenserverEdict.getEntity (),
								  g_Map.m_Waypoints[iNWP].m_VOrigin + Vector (0, 0, 20),
								  g_Map.m_Waypoints[iNWP].m_VOrigin - Vector (0, 0, 20),
								  10,
								  0,
								  Vector (255, 255, 255),
								  127,
								  0,
								  fNextDiff * 10);
		 }
 
		 hudtextparms_t message_params;
 
		 static float fLastTime = 0;
 
		 if (!pInfo)
			pInfo = g_pGame->m_pListenserverEdict.getEntity ();
 
		 message_params.x = 0;
		 message_params.y = 1;
		 message_params.effect = 0;
		 message_params.r1 = 0;
		 message_params.g1 = 255;
		 message_params.b1 = 255;
		 message_params.a1 = 1;
		 message_params.r2 = message_params.r1;
		 message_params.g2 = message_params.g1;
		 message_params.b2 = message_params.b1;
		 message_params.a2 = 1;
		 message_params.fadeinTime = 0.f;
		 message_params.fadeoutTime = 0.f;
		 message_params.holdTime = fNextDiff;
		 message_params.fxTime = 0.f;
		 message_params.channel = 1;
 
		 fLastTime = g_pGame->getTime ();
 
		 long lNL = UTIL_CountLines (szDebugText);
		 lNL = 17 - lNL;
 
		 for (; lNL > 0; lNL--)
		 {
			strcat (szDebugText, "\n");
		 }
 
		 szDebugText[400] = 0;
 
		 UTIL_ShowText (g_pGame->m_pListenserverEdict.getEntity (), message_params, szDebugText);
	  }
   }
}
( somehow it wont let me post tabs here ... and no spaces neither ... )

that is pretty similar to the code in old joebot, it looks like I just copied it ... cause it's not yet incorporated in my game class ...

and the client message idea was once again not mine, but killarunas ....



Last edited by Pierre-Marie Baty; 23-01-2004 at 17:56.. Reason: Formatted Joe's code to split the 3 million characters lines in something more readable...
  
Reply With Quote