Ejemplo n.º 1
0
void CG_DrawMap(float x, float y, float w, float h, int mEntFilter, mapScissor_t *scissor, qboolean interactive, float alpha, qboolean borderblend)
{
	int             i;
	snapshot_t      *snap;
	mapEntityData_t *mEnt = &mapEntities[0];
	int             icon_size;
	int             exspawn = qfalse;

	if (cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport)
	{
		snap = cg.nextSnap;
	}
	else
	{
		snap = cg.snap;
	}

	if (scissor)
	{
		//icon_size = AUTOMAP_PLAYER_ICON_SIZE;
		icon_size = h / 26;
		if (icon_size < 4)
		{
			icon_size = 4;
		}

		if (scissor->br[0] >= scissor->tl[0])
		{
			float s0, s1, t0, t1;
			float sc_x = x, sc_y = y, sc_w = w, sc_h = h;

			CG_DrawPic(sc_x, sc_y, sc_w, sc_h, cgs.media.commandCentreAutomapMaskShader);

			s0 = (scissor->tl[0]) / (w * scissor->zoomFactor);
			s1 = (scissor->br[0]) / (w * scissor->zoomFactor);
			t0 = (scissor->tl[1]) / (h * scissor->zoomFactor);
			t1 = (scissor->br[1]) / (h * scissor->zoomFactor);

			CG_AdjustFrom640(&sc_x, &sc_y, &sc_w, &sc_h);
			if (cgs.ccLayers)
			{
				trap_R_DrawStretchPic(sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[cgs.ccSelectedLayer]);
			}
			else
			{
				trap_R_DrawStretchPic(sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[0]);
			}
			trap_R_DrawStretchPic(0, 0, 0, 0, 0, 0, 0, 0, cgs.media.whiteShader);   // HACK : the code above seems to do weird things to
			// the next trap_R_DrawStretchPic issued. This works
			// around this.
		}

		// Draw the grid
		//CG_DrawGrid(x, y, w, h, scissor);
	}
	else
	{
		vec4_t color;

		icon_size = COMMANDMAP_PLAYER_ICON_SIZE;

		Vector4Set(color, 1.f, 1.f, 1.f, alpha);
		trap_R_SetColor(color);
		if (cgs.ccLayers)
		{
			CG_DrawPic(x, y, w, h, cgs.media.commandCentreMapShaderTrans[cgs.ccSelectedLayer]);
		}
		else
		{
			CG_DrawPic(x, y, w, h, cgs.media.commandCentreMapShaderTrans[0]);
		}
		trap_R_SetColor(NULL);

		// Draw the grid
		CG_DrawGrid(x, y, w, h, NULL);
	}

	if (borderblend)
	{
		vec4_t clr = { 0.f, 0.f, 0.f, 0.75f };

		trap_R_SetColor(clr);
		CG_DrawPic(x, y, w, h, cgs.media.limboBlendThingy);
		trap_R_SetColor(NULL);
	}

	exspawn = CG_DrawSpawnPointInfo(x, y, w, h, qfalse, scissor, -1);

	for (i = 0, mEnt = &mapEntities[0]; i < mapEntityCount; i++, mEnt++)
	{
		if (mEnt->team != CG_LimboPanel_GetRealTeam())
		{
			continue;
		}

		if (mEnt->type == ME_PLAYER ||
		    mEnt->type == ME_PLAYER_DISGUISED ||
		    mEnt->type == ME_PLAYER_REVIVE)
		{
			continue;
		}

		CG_DrawMapEntity(mEnt, x, y, w, h, mEntFilter, scissor, interactive, snap, icon_size);
	}

	CG_DrawSpawnPointInfo(x, y, w, h, qtrue, scissor, exspawn);

	CG_DrawMortarMarker(x, y, w, h, qtrue, scissor, exspawn);

	for (i = 0, mEnt = &mapEntities[0]; i < mapEntityCount; i++, mEnt++)
	{
		if (mEnt->team != CG_LimboPanel_GetRealTeam())
		{
			continue;
		}

		if (mEnt->type != ME_PLAYER &&
		    mEnt->type != ME_PLAYER_DISGUISED &&
		    mEnt->type != ME_PLAYER_REVIVE)
		{
			continue;
		}

		CG_DrawMapEntity(mEnt, x, y, w, h, mEntFilter, scissor, interactive, snap, icon_size);
	}
}
Ejemplo n.º 2
0
void CG_DrawMap(float x, float y, float w, float h, int mEntFilter, mapScissor_t *scissor, qboolean interactive, float alpha, qboolean borderblend)
{
	int             i;
	snapshot_t      *snap;
	mapEntityData_t *mEnt = &mapEntities[0];
	int             icon_size;
	int             exspawn;
	team_t          RealTeam = CG_LimboPanel_GetRealTeam();

	expanded = qfalse;

	if (cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport)
	{
		snap = cg.nextSnap;
	}
	else
	{
		snap = cg.snap;
	}

	if (scissor)
	{
		icon_size = AUTOMAP_PLAYER_ICON_SIZE;

		if (scissor->br[0] >= scissor->tl[0])
		{
			float s0, s1, t0, t1;
			float sc_x = x, sc_y = y, sc_w = w, sc_h = h;

			CG_DrawPic(sc_x, sc_y, sc_w, sc_h, cgs.media.commandCentreAutomapMaskShader);

			s0 = (scissor->tl[0]) / (w * scissor->zoomFactor);
			s1 = (scissor->br[0]) / (w * scissor->zoomFactor);
			t0 = (scissor->tl[1]) / (h * scissor->zoomFactor);
			t1 = (scissor->br[1]) / (h * scissor->zoomFactor);

			CG_AdjustFrom640(&sc_x, &sc_y, &sc_w, &sc_h);

			if (cgs.ccLayers)
			{
				trap_R_DrawStretchPic(sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[cgs.ccSelectedLayer]);
			}
			else
			{
				trap_R_DrawStretchPic(sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[0]);
			}
			// FIXME: the code above seems to do weird things to the next trap_R_DrawStretchPic issued.
			// This hack works around this.
			trap_R_DrawStretchPic(0, 0, 0, 0, 0, 0, 0, 0, cgs.media.whiteShader);
		}

		// Draw the grid
		CG_DrawGrid(x, y, w, h, scissor);
	}
	else
	{
		vec4_t color;

		icon_size = COMMANDMAP_PLAYER_ICON_SIZE;

		Vector4Set(color, 1.f, 1.f, 1.f, alpha);
		trap_R_SetColor(color);
		CG_DrawPic(x, y, w, h, cgs.media.blackmask);

		if (cgs.ccLayers)
		{
			CG_DrawPic(x, y, w, h, cgs.media.commandCentreMapShaderTrans[cgs.ccSelectedLayer]);
		}
		else
		{
			CG_DrawPic(x, y, w, h, cgs.media.commandCentreMapShaderTrans[0]);
		}
		trap_R_SetColor(NULL);

		// Draw the grid
		CG_DrawGrid(x, y, w, h, NULL);
	}

	if (borderblend)
	{
		trap_R_SetColor(clrBorderblend);
		CG_DrawPic(x, y, w, h, cgs.media.limboBlendThingy);
		trap_R_SetColor(NULL);
	}

	exspawn = CG_DrawSpawnPointInfo(x, y, w, h, qfalse, scissor, -1);

	// entnfo data
	for (i = 0, mEnt = &mapEntities[0]; i < mapEntityCount; ++i, ++mEnt)
	{
		// spectators can see icons of both teams
		if ((interactive && mEnt->team != RealTeam) ||
		    (mEnt->team != snap->ps.persistant[PERS_TEAM] && snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR))
		{
			goto CG_DrawMap_check;
		}

		if (mEnt->type == ME_PLAYER ||
		    mEnt->type == ME_PLAYER_DISGUISED ||
		    mEnt->type == ME_PLAYER_OBJECTIVE ||
		    mEnt->type == ME_PLAYER_REVIVE)
		{
			goto CG_DrawMap_check;
		}
		goto CG_DrawMap_draw;

CG_DrawMap_check:
		if (mEnt->team != RealTeam && !CG_DisguiseMapCheck(mEnt))
		{
			continue;
		}

		if (mEnt->type != ME_PLAYER &&
		    mEnt->type != ME_PLAYER_DISGUISED &&
		    mEnt->type != ME_PLAYER_OBJECTIVE &&
		    mEnt->type != ME_PLAYER_REVIVE)
		{
			continue;
		}

CG_DrawMap_draw:
		CG_DrawMapEntity(mEnt, x, y, w, h, mEntFilter, scissor, interactive, snap, icon_size);
	}

	// entnfo2 data, draw non-players & non-tanks
	//for(i = 0, mEnt = &mapEntities2[0]; i < mapEntityCount2; ++i, ++mEnt ) {
	//  CG_DrawMapEntity( mEnt, x, y, w, h, mEntFilter, scissor, interactive, snap, icon_size );
	//}

	CG_DrawSpawnPointInfo(x, y, w, h, qtrue, scissor, exspawn);

	CG_DrawMortarMarker(x, y, w, h, qtrue, scissor, exspawn);

	// draw spectator position and direction
	if (cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR)
	{
		vec2_t           pos, size;
		bg_playerclass_t *classInfo;

		if (snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR)
		{
			size[0] = size[1] = 16;
		}
		else
		{
			size[0] = size[1] = 12;
		}

		if (scissor)
		{
			size[0] *= (scissor->zoomFactor / AUTOMAP_ZOOM);
			size[1] *= (scissor->zoomFactor / AUTOMAP_ZOOM);
		}
		else
		{
			size[0] *= cgs.ccZoomFactor;
			size[1] *= cgs.ccZoomFactor;
		}
		if (scissor)
		{
			pos[0] = ((cg.predictedPlayerEntity.lerpOrigin[0] - cg.mapcoordsMins[0]) * cg.mapcoordsScale[0]) * w * scissor->zoomFactor - scissor->tl[0] + x;
			pos[1] = ((cg.predictedPlayerEntity.lerpOrigin[1] - cg.mapcoordsMins[1]) * cg.mapcoordsScale[1]) * h * scissor->zoomFactor - scissor->tl[1] + y;
		}
		else
		{
			pos[0] = x + ((cg.predictedPlayerEntity.lerpOrigin[0] - cg.mapcoordsMins[0]) * cg.mapcoordsScale[0]) * w;
			pos[1] = y + ((cg.predictedPlayerEntity.lerpOrigin[1] - cg.mapcoordsMins[1]) * cg.mapcoordsScale[1]) * h;
		}

		if (snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR)
		{
			// draw a arrow when free-spectating.
			// FIXME: don't reuse the ccMortarTargetArrow
			CG_DrawRotatedPic(pos[0] - (size[0] * 0.5f), pos[1] - (size[1] * 0.5f), size[0], size[1], cgs.media.ccMortarTargetArrow, (0.625 - (cg.predictedPlayerState.viewangles[YAW] - 180.f) / 360.f));
		}
		else
		{
			// show only current player position to spectators
			classInfo = CG_PlayerClassForClientinfo(&cgs.clientinfo[snap->ps.clientNum], &cg_entities[snap->ps.clientNum]);

			if (snap->ps.powerups[PW_OPS_DISGUISED])
			{
				CG_DrawPic(pos[0] - (size[0] * 0.5f), pos[1] - (size[1] * 0.5f), size[0], size[1], classInfo->icon);
				CG_DrawPic(pos[0] - (size[0] * 0.5f), pos[1] - (size[1] * 0.5f), size[0], size[1], cgs.media.friendShader);
			}
			else if (snap->ps.powerups[PW_REDFLAG] || snap->ps.powerups[PW_BLUEFLAG])
			{
				CG_DrawPic(pos[0] - (size[0] * 0.5f), pos[1] - (size[1] * 0.5f), size[0], size[1], cgs.media.objectiveShader);
			}
			else
			{
				CG_DrawPic(pos[0] - (size[0] * 0.5f), pos[1] - (size[1] * 0.5f), size[0], size[1], classInfo->icon);
			}

			CG_DrawRotatedPic(pos[0] - (size[0] * 0.5f) - 1, pos[1] - (size[1] * 0.5f) - 1, size[0] + 2, size[1] + 2, classInfo->arrow, (0.5 - (cg.predictedPlayerState.viewangles[YAW] - 180.f) / 360.f));
		}
	}
}