MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DrawPlayerNameOnHud

Function DrawPlayerNameOnHud

Descent3/renderobject.cpp:2170–2221  ·  view source on GitHub ↗

Draws the player name on the hud

Source from the content-addressed store, hash-verified

2168}
2169// Draws the player name on the hud
2170void DrawPlayerNameOnHud(object *obj) {
2171 if (!(Game_mode & GM_MULTI))
2172 return;
2173 int slot = obj->id;
2174 int color;
2175 if (slot == Player_num)
2176 return;
2177 if (NetPlayers[slot].sequence != NETSEQ_PLAYING)
2178 return;
2179 if (HudNameTan <= 0)
2180 return;
2181 if (obj->effect_info && obj->effect_info->type_flags & EF_CLOAKED)
2182 return;
2183
2184 // Get color to draw this name in
2185 DLLInfo.me_handle = obj->handle;
2186 CallGameDLL(EVT_CLIENT_GETCOLOREDNAME, &DLLInfo);
2187 color = DLLInfo.iRet;
2188 if (color < 0)
2189 return;
2190
2191 // See if its in our viewcone
2192 vector subvec = obj->pos - Player_object->pos;
2193 vm_NormalizeVectorFast(&subvec);
2194 if ((vm_DotProduct(&subvec, &Player_object->orient.fvec)) < HudNameTan)
2195 return;
2196 // Find out if it is o.k. to draw here.
2197 fvi_query fq;
2198 fvi_info hit_data;
2199 int fate;
2200 fq.p0 = &Player_object->pos;
2201 fq.startroom = Player_object->roomnum;
2202 fq.p1 = &obj->pos;
2203 fq.rad = 0;
2204 fq.thisobjnum = -1;
2205 fq.ignore_obj_list = NULL;
2206 fq.flags = FQ_CHECK_OBJS | FQ_IGNORE_POWERUPS | FQ_IGNORE_WEAPONS;
2207 fate = fvi_FindIntersection(&fq, &hit_data);
2208 if (fate == HIT_NONE || (fate == HIT_SPHERE_2_POLY_OBJECT && hit_data.hit_object[0] == (obj - Objects))) {
2209 int half = Game_window_w / 2;
2210 // Draw this name on the hud
2211 g3Point pnt;
2212 g3_RotatePoint(&pnt, fq.p1);
2213 g3_ProjectPoint(&pnt);
2214 // put a centered name string in the text buffer.
2215
2216 grtext_SetFont(HUD_FONT);
2217 grtext_SetColor(color);
2218 grtext_CenteredPrintf(pnt.p3_sx - half, pnt.p3_sy, Players[slot].callsign);
2219 grtext_Flush();
2220 }
2221}
2222// Creates lightning sparks on a damaged object
2223void DrawSparkyDamageLightning(object *obj) {
2224 float max_shields = 100;

Callers 1

RenderObjectFunction · 0.85

Calls 10

CallGameDLLFunction · 0.85
vm_NormalizeVectorFastFunction · 0.85
fvi_FindIntersectionFunction · 0.85
g3_RotatePointFunction · 0.85
g3_ProjectPointFunction · 0.85
grtext_SetFontFunction · 0.85
grtext_SetColorFunction · 0.85
grtext_CenteredPrintfFunction · 0.85
grtext_FlushFunction · 0.85
vm_DotProductFunction · 0.50

Tested by

no test coverage detected