MCPcopy Create free account
hub / github.com/JACoders/OpenJK / SV_AddEntitiesVisibleFromPoint

Function SV_AddEntitiesVisibleFromPoint

code/server/sv_snapshot.cpp:342–491  ·  view source on GitHub ↗

=============== SV_AddEntitiesVisibleFromPoint =============== */

Source from the content-addressed store, hash-verified

340===============
341*/
342static void SV_AddEntitiesVisibleFromPoint( vec3_t origin, clientSnapshot_t *frame,
343 snapshotEntityNumbers_t *eNums, qboolean portal ) {
344 int e, i;
345 gentity_t *ent;
346 svEntity_t *svEnt;
347 int l;
348 int clientarea, clientcluster;
349 int leafnum;
350 const byte *clientpvs;
351 const byte *bitvector;
352#ifndef JK2_MODE
353 qboolean sightOn = qfalse;
354#endif
355
356 // during an error shutdown message we may need to transmit
357 // the shutdown message after the server has shutdown, so
358 // specfically check for it
359 if ( !sv.state ) {
360 return;
361 }
362
363 leafnum = CM_PointLeafnum (origin);
364 clientarea = CM_LeafArea (leafnum);
365 clientcluster = CM_LeafCluster (leafnum);
366
367 // calculate the visible areas
368 frame->areabytes = CM_WriteAreaBits( frame->areabits, clientarea );
369
370 clientpvs = CM_ClusterPVS (clientcluster);
371
372#ifndef JK2_MODE
373 if ( !portal )
374 {//not if this if through a portal...??? James said to do this...
375 if ( (frame->ps.forcePowersActive&(1<<FP_SEE)) )
376 {
377 sightOn = qtrue;
378 }
379 }
380#endif // !JK2_MODE
381
382 for ( e = 0 ; e < ge->num_entities ; e++ ) {
383 ent = SV_GentityNum(e);
384
385 if (!ent->inuse) {
386 continue;
387 }
388
389 if (ent->s.eFlags & EF_PERMANENT)
390 { // he's permanent, so don't send him down!
391 continue;
392 }
393
394 if (ent->s.number != e) {
395 Com_DPrintf ("FIXING ENT->S.NUMBER!!!\n");
396 ent->s.number = e;
397 }
398
399 // never send entities that aren't linked in

Callers 1

SV_BuildClientSnapshotFunction · 0.70

Calls 11

SV_PlayerCanSeeEntFunction · 0.85
SV_GentityNumFunction · 0.70
SV_SvEntityForGentityFunction · 0.70
SV_AddEntToSnapshotFunction · 0.70
CM_PointLeafnumFunction · 0.50
CM_LeafAreaFunction · 0.50
CM_LeafClusterFunction · 0.50
CM_WriteAreaBitsFunction · 0.50
CM_ClusterPVSFunction · 0.50
Com_DPrintfFunction · 0.50
CM_AreasConnectedFunction · 0.50

Tested by

no test coverage detected