Example #1
0
char *CG_BuildLocationString(int clientNum, vec3_t origin, int flag)
{
	char   *locStr = NULL;
	vec2_t loc;

	loc[0] = origin[0];
	loc[1] = origin[1];

	if (cg_locations.integer & flag)
	{
		qboolean locValid = qtrue;

		if (cg_locations.integer & LOC_SHOWDISTANCE)
		{
			if (clientNum == cg.clientNum)
			{
				locStr = va("^3     ");
				CG_Printf("same client\n");
			}
			else
			{
				vec3_t myOrigin, v;
				float  dist;

				myOrigin[0] = cgs.clientinfo[cg.clientNum].location[0];
				myOrigin[1] = cgs.clientinfo[cg.clientNum].location[1];
				myOrigin[2] = cgs.clientinfo[cg.clientNum].location[2];

				VectorSubtract(origin, myOrigin, v);
				dist   = VectorLength(v);
				locStr = va("^3%5i", (int)dist);
			}
		}
		else
		{
			locStr = va("^3%s", CG_GetLocationMsg(clientNum, origin));
			if (!(cg_locations.integer & LOC_KEEPUNKNOWN))
			{
				if (!Q_stricmp(locStr, "Unknown"))
				{
					locStr   = va("^3(%s)", BG_GetLocationString(loc));
					locValid = qfalse; // don't draw it twice..
				}
			}
		}

		if ((cg_locations.integer & LOC_SHOWCOORDS) && locValid)
		{
			Q_strcat(locStr, 64, va(" ^3(%s)", BG_GetLocationString(loc)));   // append a location
		}
	}
	else
	{
		locStr = va("^3(%s)", BG_GetLocationString(loc));
	}

	return locStr;
}
Example #2
0
const char* CG_GetPMItemText( centity_t* cent ) {
	switch( cent->currentState.effect1Time ) {
		case PM_DYNAMITE:
			switch( cent->currentState.effect2Time ) {
				case 0:
					return va( "Planted at %s.", CG_ConfigString( CS_OID_TRIGGERS + cent->currentState.effect3Time ) );
				case 1:
					return va( "Defused at %s.", CG_ConfigString( CS_OID_TRIGGERS + cent->currentState.effect3Time ) );
			}
			break;
		case PM_CONSTRUCTION:
			switch( cent->currentState.effect2Time ) {
				case -1:
					return CG_ConfigString( CS_STRINGS + cent->currentState.effect3Time );
				case 0:
					return va( "%s has been constructed.", CG_ConfigString( CS_OID_TRIGGERS + cent->currentState.effect3Time ) );
			}
			break;
		case PM_DESTRUCTION:
			switch( cent->currentState.effect2Time ) {
				case 0:
					return va( "%s has been damaged.", CG_ConfigString( CS_OID_TRIGGERS + cent->currentState.effect3Time ) );
				case 1:
					return va( "%s has been destroyed.", CG_ConfigString( CS_OID_TRIGGERS + cent->currentState.effect3Time ) );
			}
			break;
		case PM_MINES:
			 // CHRUKER: b009 - Prevent spectators from being 
			 //          informed when a mine is spotted
			if(cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR)
		       		return NULL;
			if( cgs.clientinfo[cg.clientNum].team == cent->currentState.effect2Time ) {
				return NULL;
			}
			{
				vec2_t	loc;
				char *locStr = NULL;

				loc[0] =  cent->currentState.origin[0];
				loc[1] =  cent->currentState.origin[1];

				if (cg_locations.integer > 0){
					vec3_t	origin;
					qboolean locValid = qtrue;

					origin[0] =  cent->currentState.origin[0];
					origin[1] =  cent->currentState.origin[1];
					origin[2] =  cent->currentState.origin[2];

					locStr = CG_GetLocationMsg(origin);

					if (!Q_stricmp( locStr, "Unknown")){
						locStr = va( "%s", BG_GetLocationString( loc ));
						locValid = qfalse;
					}

					if(cg_locations.integer > 1 && locValid)
						Q_strcat( locStr, 64, va(" (%s)", BG_GetLocationString( loc )) );

				} else {
					locStr = BG_GetLocationString( loc );
				}

				if( !locStr || !*locStr )
				locStr = "";
				
				return va( "Spotted by %s^7 at %s", cgs.clientinfo[cent->currentState.effect3Time].name, locStr );
			}
		case PM_OBJECTIVE:
			switch( cent->currentState.density ) {
				case 0:
					return va( "%s have stolen %s!", cent->currentState.effect2Time == TEAM_ALLIES ? "Allies" : "Axis", CG_ConfigString( CS_STRINGS + cent->currentState.effect3Time ));
				case 1:
					return va( "%s have returned %s!", cent->currentState.effect2Time == TEAM_ALLIES ? "Allies" : "Axis", CG_ConfigString( CS_STRINGS + cent->currentState.effect3Time ));
			}
			break;
		case PM_TEAM:
			switch( cent->currentState.density ) {
				case 0: // joined
					{
						const char* teamstr = NULL;
						switch( cent->currentState.effect2Time ) {
							case TEAM_AXIS:
								teamstr = "Axis team";
								break;
							case TEAM_ALLIES:
								teamstr = "Allied team";
								break;
							default:
								teamstr = "Spectators";
								break;
						}

						return va( "%s^7 has joined the %s^7!", cgs.clientinfo[cent->currentState.effect3Time].name, teamstr );
					}
				case 1:
					return va( "%s^7 disconnected", cgs.clientinfo[cent->currentState.effect3Time].name );
			}
	}

	return NULL;
}
Example #3
0
void CG_DrawFireTeamOverlay( rectDef_t* rect ) {
	int x = rect->x;
	int y = rect->y + 1;	// +1, jitter it into place in 1024 :)
	int boxWidth = 204;
	int bestWidth = -1;
	char *locStr[MAX_FIRETEAM_MEMBERS];
	vec2_t loc;
	float h;
	clientInfo_t* ci = NULL;
	char buffer[64];
	fireteamData_t* f = NULL;
	int i;
	vec4_t clr1 =	{ .16f,		.2f,	.17f,	.8f };
	vec4_t clr2 =	{ 0.f,		0.f,		0.f,		.2f };
	vec4_t clr3 =	{ 0.25f,		0.f,		0.f,		153/255.f };
	vec4_t tclr =	{ 0.6f,		0.6f,		0.6f,		1.0f };
	vec4_t bgColor		= { 0.0f, 0.0f, 0.0f, 0.6f };		// window
	vec4_t borderColor	= { 0.5f, 0.5f, 0.5f, 0.5f };	// window
	centity_t*	cent;

	bgColor[3] = cg_fireteamAlpha.value;

	if(cg.hudEditor.showHudEditor) {
		//draw a fake fireteam box...
		CG_DrawFakeFireTeamOverlay(rect);
		return;
	} else 	if(!(f = CG_IsOnFireteam( cg.clientNum ))) {
		return;
	}

	h = 12 + 2 + 2;
	for(i = 0; i < MAX_FIRETEAM_MEMBERS; i++) {
		int		locwidth;
		vec3_t	origin;

		ci = CG_SortedFireTeamPlayerForPosition( i );
		if(!ci) {
			break;
		}

		h += FT_BAR_HEIGHT + FT_BAR_YSPACING;

		loc[0] = ci->location[0];
		loc[1] = ci->location[1];

		if(cg_locations.integer > 0) {
			qboolean locValid = qtrue;
			cent = &cg_entities[ci->clientNum];

			// Dens: use lerpOrigin for now
			origin[0] = cent->lerpOrigin[0];
			origin[1] = cent->lerpOrigin[1];
			origin[2] = cent->lerpOrigin[2];
	
			locStr[i] = va( "^3%s", CG_GetLocationMsg(origin));

			if (!Q_stricmp( locStr[i], "^3Unknown")){
				locStr[i] = va( "^3(%s)", BG_GetLocationString( loc ));
				locValid = qfalse;
			}

			if(cg_locations.integer > 1 && locValid)
				Q_strcat( locStr[i], 64, va(" ^3(%s)", BG_GetLocationString( loc )) );

		} else {
			locStr[i] = va( "^3(%s)", BG_GetLocationString( loc ));
		}

		if( !locStr[i][1] || !*locStr[i] )
			locStr[i] = " ";
	
		locwidth = CG_Text_Width_Ext( locStr[i], 0.2f, 0, &cgs.media.font3 );
	
		if(locwidth > bestWidth)
			bestWidth = locwidth;
	}

	boxWidth += bestWidth;

	CG_DrawRect( x, y, boxWidth, h, 1, borderColor);
	CG_FillRect( x + 1, y + 1, boxWidth - 2, h - 2, bgColor);

	x += 2;
	y += 2;

	CG_FillRect( x, y, boxWidth - 4, 12, clr1 );

	Com_sprintf( buffer, 64, "Fireteam: %s", bg_fireteamNames[f->ident] );
	//sprintf( buffer, "Fireteam: %s", bg_fireteamNames[f->ident] );
	Q_strupr( buffer );
	CG_Text_Paint_Ext( x + 3, y + FT_BAR_HEIGHT, .19f, .19f, tclr, buffer, 0, 0, 0, &cgs.media.font1 );

	x += 2;
	//y += 2;

	for(i = 0; i < MAX_FIRETEAM_MEMBERS; i++) {
		y += FT_BAR_HEIGHT + FT_BAR_YSPACING;
		x = rect->x + 2;

		ci = CG_SortedFireTeamPlayerForPosition( i );
		if(!ci) {
			break;;
		}
		
		if( ci->selected ) {
			CG_FillRect( x, y + FT_BAR_YSPACING, boxWidth - 4, FT_BAR_HEIGHT, clr3 );
		} else {
			CG_FillRect( x, y + FT_BAR_YSPACING, boxWidth - 4, FT_BAR_HEIGHT, clr2 );
		}

		x += 4;
				
		//draw class
		if(cg_drawClassIcons.integer & CLASSICON_FIRETEAM){
			trap_R_SetColor( colorWhite );
			CG_DrawPic(x-2, y+2, FT_BAR_HEIGHT, FT_BAR_HEIGHT,
				cgs.media.skillPics[BG_ClassSkillForClass( ci->cls )]);
			trap_R_SetColor( NULL );
		}else{
			CG_Text_Paint_Ext( x, y + FT_BAR_HEIGHT, .2f, .2f, colorWhite, BG_ClassLetterForNumber( ci->cls ), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.font3 );	
		}
		x += 10;
		
		// quad: draw latched class
		// pheno: not with an old server, that doesn't send the latched class
		if( ci->cls != ci->latchClass ) {
			//draw separator
			CG_Text_Paint_Ext( x, y + FT_BAR_HEIGHT, .2f, .2f, colorYellow, ">", 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.font3 );
			x += 10;
			
			//draw class
			if(cg_drawClassIcons.integer & CLASSICON_FIRETEAM) {
				trap_R_SetColor( colorYellow );
				CG_DrawPic(x - 2, y + 2, FT_BAR_HEIGHT, FT_BAR_HEIGHT,
					cgs.media.skillPics[BG_ClassSkillForClass(ci->latchClass)]);
				trap_R_SetColor(NULL);
			} else {
				CG_Text_Paint_Ext( x, y + FT_BAR_HEIGHT, .2f, .2f, colorYellow, BG_ClassLetterForNumber( ci->latchClass ), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.font3 );
			}
			x += 10;
		}
		else
			x += 20;
		
		CG_Text_Paint_Ext( x, y + FT_BAR_HEIGHT, .2f, .2f, tclr, ci->team == TEAM_AXIS ? miniRankNames_Axis[ci->rank] : miniRankNames_Allies[ci->rank], 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.font3 );	
		x += 22;
		
		CG_Text_Paint_Ext(x, y + FT_BAR_HEIGHT, .2f, .2f, tclr, ci->name, 0, 17, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.font3 );
		x += 90;

/*		CG_DrawPic(x + 2, y + 2, FT_BAR_HEIGHT - 4, FT_BAR_HEIGHT - 4, cgs.media.movementAutonomyIcons[0]);
		x += FT_BAR_HEIGHT;

		CG_DrawPic(x + 2, y + 2, FT_BAR_HEIGHT - 4, FT_BAR_HEIGHT - 4, cgs.media.weaponAutonomyIcons[0]);
		x += FT_BAR_HEIGHT;
		x += 4;*/

/*		if( isLeader ) {
			CG_Text_Paint_Ext(x, y + FT_BAR_HEIGHT, .2f, .2f, tclr, va("%i", i+4), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.font3 );
		}*/
		x += 20;
		
		if( ci->health > 80 ) {
			CG_Text_Paint_Ext(x, y + FT_BAR_HEIGHT,  .2f, .2f, tclr, va("%i", ci->health < 0 ? 0 : ci->health ), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.font3 );
		} else if( ci->health > 0 ) {
			CG_Text_Paint_Ext(x, y + FT_BAR_HEIGHT,  .2f, .2f, colorYellow, va("%i", ci->health < 0 ? 0 : ci->health ), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.font3 );
		} else {
			CG_Text_Paint_Ext(x, y + FT_BAR_HEIGHT,  .2f, .2f, colorRed, va("0%s", ci->health < 0 ? "" : "*" ), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.font3 );
		}
		x += 30;

		CG_Text_Paint_Ext( x, y + FT_BAR_HEIGHT,  .2f, .2f, tclr, locStr[i], 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.font3 );
	}
}