MCPcopy Create free account
hub / github.com/assaultcube/AC / drawradar_showmap

Function drawradar_showmap

source/src/renderhud.cpp:464–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462VARP(radarheight, 5, 150, 500);
463
464void drawradar_showmap(playerent *p, int w, int h)
465{
466 float minimapviewsize = 3*min(VIRTW,VIRTH)/4; //minimap default size
467 float halfviewsize = minimapviewsize/2.0f;
468 float iconsize = radarentsize/0.2f;
469 glColor3f(1.0f, 1.0f, 1.0f);
470 glPushMatrix();
471 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
472 bool spect3rd = p->spectatemode > SM_FOLLOW1ST && p->spectatemode <= SM_FOLLOW3RD_TRANSPARENT;
473 playerent *d = spect3rd ? players[p->followplayercn] : p;
474 int p_baseteam = p->team == TEAM_SPECT && spect3rd ? team_base(players[p->followplayercn]->team) : team_base(p->team);
475 extern GLuint minimaptex;
476 vec centerpos(VIRTW/2 , VIRTH/2, 0.0f);
477 if(showmapbackdrop)
478 {
479 glDisable(GL_TEXTURE_2D);
480 if(showmapbackdrop==2) glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_COLOR);
481 loopi(2)
482 {
483 int cg = i?(showmapbackdrop==2?((int)(255*(100-showmapbackdroptransparency)/100.0f)):0):(showmapbackdrop==2?((int)(255*(100-showmapbackdroptransparency)/100.0f)):64);
484 int co = i?0:4;
485 glColor3ub(cg, cg, cg);
486 glBegin(GL_QUADS);
487 glVertex2f( centerpos.x - halfviewsize - co, centerpos.y + halfviewsize + co);
488 glVertex2f( centerpos.x + halfviewsize + co, centerpos.y + halfviewsize + co);
489 glVertex2f( centerpos.x + halfviewsize + co, centerpos.y - halfviewsize - co);
490 glVertex2f( centerpos.x - halfviewsize - co, centerpos.y - halfviewsize - co);
491 glEnd();
492 }
493 glColor3ub(255,255,255);
494 glEnable(GL_TEXTURE_2D);
495 }
496 glTranslatef(centerpos.x - halfviewsize, centerpos.y - halfviewsize , 0);
497 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
498 quad(minimaptex, 0, 0, minimapviewsize, 0.0f, 0.0f, 1.0f);
499 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
500 glDisable(GL_BLEND);
501
502 float gdim = max(clmapdims.xspan, clmapdims.yspan); //no border
503 float offd = fabs((clmapdims.yspan - clmapdims.xspan) / 2.0f);
504 if(!gdim) { gdim = ssize/2.0f; offd = 0; }
505 float coordtrans = minimapviewsize / gdim;
506 float offx = gdim == clmapdims.yspan ? offd : 0;
507 float offy = gdim == clmapdims.xspan ? offd : 0;
508
509 vec mdd = vec(clmapdims.x1 - offx, clmapdims.y1 - offy, 0);
510 vec ppv = vec(p->o).sub(mdd).mul(coordtrans);
511
512 if(!(p->isspectating() && spect3rd)) drawradarent(ppv.x, ppv.y, p->yaw, (p->state==CS_ALIVE || p->state==CS_EDITING) ? (isattacking(p) ? 2 : 0) : 1, 2, iconsize, isattacking(p), "%s", colorname(p)); // local player
513 loopv(players) // other players
514 {
515 playerent *pl = players[i];
516 if(!pl || pl == p || !team_isactive(pl->team)) continue;
517 if(OUTBORD(pl->o.x, pl->o.y)) continue;
518 int pl_baseteam = team_base(pl->team);
519 if(p->team < TEAM_SPECT && ((m_teammode && !isteam(p_baseteam, pl_baseteam)) || (!m_teammode && !(spect3rd && d == pl)))) continue;
520 if(p->team == TEAM_SPECT && !(spect3rd && (isteam(p_baseteam, pl_baseteam) || d == pl))) continue;
521 vec rtmp = vec(pl->o).sub(mdd).mul(coordtrans);

Callers 1

drawradarFunction · 0.85

Calls 11

minFunction · 0.85
quadFunction · 0.85
maxFunction · 0.85
vecClass · 0.85
drawradarentFunction · 0.85
isattackingFunction · 0.85
colornameFunction · 0.85
mulMethod · 0.80
isspectatingMethod · 0.80
loopiFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected