sv_world.c File Reference

World query functions. More...

#include "server.h"
Include dependency graph for sv_world.c:

Go to the source code of this file.

Data Structures

struct  areaParms_t
struct  moveclip_t
 Client side moveclip. More...

Defines

#define AREA_DEPTH   4

Functions

static worldSector_tSV_CreateWorldSector (int depth, const vec3_t mins, const vec3_t maxs)
 Builds a uniformly subdivided tree for the given world size.
void SV_ClearWorld (void)
 Clear physics interaction links.
static sv_edict_tSV_GetServerDataForEdict (const edict_t *ent)
void SV_UnlinkEdict (edict_t *ent)
 call before removing an entity, and before trying to move one, so it doesn't clip against itself
void SV_LinkEdict (edict_t *ent)
 Needs to be called any time an entity changes origin, mins, maxs, or solid. Automatically unlinks if needed. Sets ent->absmin and ent->absmax.
static qboolean SV_BoundingBoxesIntersect (const vec3_t mins, const vec3_t maxs, const edict_t *ent)
 Checks whether the bounding box of the given edict will intersect with the given bbox.
static void SV_AreaEdicts_r (worldSector_t *node, areaParms_t *ap)
 fills in a table of edict pointers with edicts that have bounding boxes that intersect the given area. It is possible for a non-axial bmodel to be returned that doesn't actually intersect the area on an exact test.
int SV_AreaEdicts (const vec3_t mins, const vec3_t maxs, edict_t **list, int maxCount)
int SV_TouchEdicts (const vec3_t mins, const vec3_t maxs, edict_t **list, int maxCount, edict_t *skip)
 Fills a list with edicts that are in use and are touching the given bounding box.
static int SV_HullForEntity (const edict_t *ent, int *tile, vec3_t rmaShift)
 Returns a headnode that can be used for testing or clipping an object of mins/maxs size. Offset is filled in to contain the adjustment that must be added to the testing object's origin to get a point to use with the returned hull.
static void SV_ClipMoveToEntities (moveclip_t *clip)
int SV_PointContents (vec3_t p)
 Returns the content flags for a given point.
static void SV_TraceBounds (const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs)
 calculates the bounding box for the whole trace
trace_t SV_Trace (const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const edict_t *passedict, int contentmask)
 Moves the given mins/maxs volume through the world from start to end.
const char * SV_GetFootstepSound (const char *texture)
float SV_GetBounceFraction (const char *texture)
 Different terrain types might have different bounce fraction.
static void SV_ModLoadAliasMD2Model (sv_model_t *mod, const byte *buffer)
 Loads the mins/maxs for a md2 mesh model.
static void SV_ModLoadAliasMD3Model (sv_model_t *mod, const byte *buffer)
 Loads the mins/maxs for a md3 mesh model.
static void SV_ModLoadAliasDPMModel (sv_model_t *mod, const byte *buffer)
 Loads the mins/maxs for a dpm mesh model.
static void SV_ModLoadObjModel (sv_model_t *mod, const byte *buffer, int bufferLength)
 Loads the mins/maxs for a obj mesh model.
qboolean SV_LoadModelMinsMaxs (const char *model, int frame, vec3_t mins, vec3_t maxs)
 Load the mins, maxs for the model on the serverside for pathfinding and clipping.

Detailed Description

World query functions.

Definition in file sv_world.c.


Define Documentation

#define AREA_DEPTH   4

Definition at line 31 of file sv_world.c.

Referenced by SV_CreateWorldSector().


Function Documentation

int SV_AreaEdicts ( const vec3_t  mins,
const vec3_t  maxs,
edict_t **  list,
int  maxCount 
)
See also:
SV_AreaEdicts_r
Parameters:
[in] mins The mins of the bounding box
[in] maxs The maxs of the bounding box
[out] list The edict list that this trace is hitting
[in] maxCount The size of the given list
Returns:
the number of pointers filled in

Definition at line 313 of file sv_world.c.

References areaParms_t::areaEdictList, areaParms_t::areaEdictListCount, areaParms_t::areaEdictListMaxCount, areaParms_t::areaMaxs, areaParms_t::areaMins, sv, SV_AreaEdicts_r(), and serverInstanceGame_t::worldSectors.

Referenced by SV_ClipMoveToEntities(), and SV_InitGameProgs().

static void SV_AreaEdicts_r ( worldSector_t node,
areaParms_t ap 
) [static]

fills in a table of edict pointers with edicts that have bounding boxes that intersect the given area. It is possible for a non-axial bmodel to be returned that doesn't actually intersect the area on an exact test.

See also:
SV_AreaEdicts
Parameters:
[out] node 
[out] ap 

Definition at line 269 of file sv_world.c.

References areaParms_t::areaEdictList, areaParms_t::areaEdictListCount, areaParms_t::areaEdictListMaxCount, areaParms_t::areaMaxs, areaParms_t::areaMins, worldSector_s::axis, check, worldSector_s::children, Com_Printf(), worldSector_s::dist, sv_edict_s::ent, worldSector_s::entities, edict_s::inuse, LEAFNODE, next, sv_edict_s::nextEntityInWorldSector, edict_s::solid, SOLID_NOT, and SV_BoundingBoxesIntersect().

Referenced by SV_AreaEdicts().

static qboolean SV_BoundingBoxesIntersect ( const vec3_t  mins,
const vec3_t  maxs,
const edict_t ent 
) [static]

Checks whether the bounding box of the given edict will intersect with the given bbox.

Parameters:
mins The mins of the bounding box
maxs The maxs of the bounding box
ent The edict to check the intersection for
Returns:
true if intersect, false otherwise

Definition at line 246 of file sv_world.c.

References edict_s::absmax, edict_s::absmin, qfalse, and qtrue.

Referenced by SV_AreaEdicts_r(), and SV_TouchEdicts().

void SV_ClearWorld ( void   ) 

Clear physics interaction links.

Note:
Called after the world model has been loaded, before linking any entities
See also:
SV_SpawnServer
SV_CreateAreaNode

Definition at line 87 of file sv_world.c.

References serverInstanceGame_t::mapData, mapData_s::mapMax, mapData_s::mapMin, sv, and SV_CreateWorldSector().

Referenced by SV_Map().

static void SV_ClipMoveToEntities ( moveclip_t clip  )  [static]
static worldSector_t* SV_CreateWorldSector ( int  depth,
const vec3_t  mins,
const vec3_t  maxs 
) [static]

Builds a uniformly subdivided tree for the given world size.

See also:
SV_ClearWorld
SV_LinkEdict
Parameters:
[in] mins 
[in] maxs 
[in] depth 

Definition at line 41 of file sv_world.c.

References AREA_DEPTH, worldSector_s::axis, worldSector_s::children, Com_Error(), worldSector_s::dist, worldSector_s::entities, ERR_DROP, LEAFNODE, lengthof, serverInstanceGame_t::numWorldSectors, PLANE_X, PLANE_Y, sv, VectorCopy, VectorSubtract, and serverInstanceGame_t::worldSectors.

Referenced by SV_ClearWorld().

float SV_GetBounceFraction ( const char *  texture  ) 

Different terrain types might have different bounce fraction.

See also:
Com_GetTerrainType
GenerateFootstepList

Definition at line 604 of file sv_world.c.

References terrainType_s::bounceFraction, and Com_GetTerrainType().

Referenced by SV_InitGameProgs().

const char* SV_GetFootstepSound ( const char *  texture  ) 
static sv_edict_t* SV_GetServerDataForEdict ( const edict_t ent  )  [inline, static]

Definition at line 92 of file sv_world.c.

References Com_Error(), serverInstanceGame_t::edicts, ERR_DROP, lengthof, edict_s::number, and sv.

Referenced by SV_LinkEdict(), and SV_UnlinkEdict().

static int SV_HullForEntity ( const edict_t ent,
int *  tile,
vec3_t  rmaShift 
) [static]

Returns a headnode that can be used for testing or clipping an object of mins/maxs size. Offset is filled in to contain the adjustment that must be added to the testing object's origin to get a point to use with the returned hull.

Parameters:
[in] ent The edict to get the bmodel from (at least in case of SOLID_BSP)
[out] tile The maptile the bmodel belongs, too (at least in case of SOLID_BSP)
[out] rmaShift the shift vector in case of an RMA (needed for doors)
Returns:
The headnode for the edict
See also:
CL_HullForEntity

Definition at line 381 of file sv_world.c.

References CM_HeadnodeForBox(), Com_Error(), ERR_FATAL, cBspModel_s::headnode, mapTiles_t::mapTiles, serverInstanceGame_t::mapTiles, MAX_MAP_NODES, MAX_MODELS, edict_s::maxs, edict_s::mins, edict_s::modelindex, serverInstanceGame_t::models, cBspModel_s::shift, edict_s::solid, SOLID_BSP, SOLID_NOT, SOLID_TRIGGER, sv, cBspModel_s::tile, vec3_origin, and VectorCopy.

Referenced by SV_ClipMoveToEntities().

void SV_LinkEdict ( edict_t ent  ) 
qboolean SV_LoadModelMinsMaxs ( const char *  model,
int  frame,
vec3_t  mins,
vec3_t  maxs 
)

Load the mins, maxs for the model on the serverside for pathfinding and clipping.

Parameters:
[in] model The relative model path to load the mins, maxs for
[in] frame The frame to load the mins and maxs vectors for
[out] mins The mins vector of the model - this is absolute to the worldorigin (0,0,0)
[out] maxs The maxs vector of the model - this is absolute to the worldorigin (0,0,0)

Definition at line 708 of file sv_world.c.

References byte, ClearBounds(), Com_Error(), com_genericPool, DPMHEADER, ERR_DROP, sv_model_s::frame, FS_FreeFile(), FS_LoadFile(), i, IDALIASHEADER, IDMD3HEADER, LittleLong(), MAX_MOD_KNOWN, sv_model_s::maxs, Mem_PoolStrDup, sv_model_s::mins, sv_model_s::name, serverInstanceGame_t::numSVModels, Q_strcasecmp, qfalse, qtrue, sv, SV_ModLoadAliasDPMModel(), SV_ModLoadAliasMD2Model(), SV_ModLoadAliasMD3Model(), SV_ModLoadObjModel(), serverInstanceGame_t::svModels, vec3_origin, and VectorCopy.

Referenced by SV_InitGameProgs().

static void SV_ModLoadAliasDPMModel ( sv_model_t mod,
const byte buffer 
) [static]

Loads the mins/maxs for a dpm mesh model.

Parameters:
[in,out] mod The server side model struct to store the results in
[in] buffer The mesh model buffer
[in] bufferLength The mesh model buffer length

Definition at line 670 of file sv_world.c.

References BigFloat(), BigLong(), byte, sv_model_s::frame, dpmframe_s::maxs, sv_model_s::maxs, dpmframe_s::mins, sv_model_s::mins, dpmheader_s::num_frames, and dpmheader_s::ofs_frames.

Referenced by SV_LoadModelMinsMaxs().

static void SV_ModLoadAliasMD2Model ( sv_model_t mod,
const byte buffer 
) [static]

Loads the mins/maxs for a md2 mesh model.

Parameters:
[in,out] mod The server side model struct to store the results in
[in] buffer The mesh model buffer
[in] bufferLength The mesh model buffer length

Definition at line 616 of file sv_world.c.

References AddPointToBounds(), byte, sv_model_s::frame, dMD2Model_t::framesize, LittleFloat(), LittleLong(), sv_model_s::maxs, sv_model_s::mins, dMD2Model_t::num_frames, dMD2Model_t::ofs_frames, dAliasFrame_s::scale, scale, dAliasFrame_s::translate, and VectorMA().

Referenced by SV_LoadModelMinsMaxs().

static void SV_ModLoadAliasMD3Model ( sv_model_t mod,
const byte buffer 
) [static]

Loads the mins/maxs for a md3 mesh model.

Parameters:
[in,out] mod The server side model struct to store the results in
[in] buffer The mesh model buffer
[in] bufferLength The mesh model buffer length

Definition at line 644 of file sv_world.c.

References AddPointToBounds(), byte, sv_model_s::frame, LittleFloat(), LittleLong(), sv_model_s::maxs, dmd3frame_t::maxs, sv_model_s::mins, dmd3frame_t::mins, dmd3_t::num_frames, and dmd3_t::ofs_frames.

Referenced by SV_LoadModelMinsMaxs().

static void SV_ModLoadObjModel ( sv_model_t mod,
const byte buffer,
int  bufferLength 
) [static]

Loads the mins/maxs for a obj mesh model.

Parameters:
[in,out] mod The server side model struct to store the results in
[in] buffer The mesh model buffer
[in] bufferLength The mesh model buffer length

Todo:
implement me

Definition at line 696 of file sv_world.c.

Referenced by SV_LoadModelMinsMaxs().

int SV_PointContents ( vec3_t  p  ) 

Returns the content flags for a given point.

Note:
Useful to determine whether an actor is e.g. inside of a water brush
See also:
CM_TestInLeaf
CM_TestBoxInBrush
CM_CompleteBoxTrace

Definition at line 491 of file sv_world.c.

References CM_CompleteBoxTrace(), trace_s::contentFlags, trace_s::fraction, serverInstanceGame_t::mapTiles, MASK_ALL, sv, TRACING_ALL_VISIBLE_LEVELS, and vec3_origin.

Referenced by SV_InitGameProgs().

int SV_TouchEdicts ( const vec3_t  mins,
const vec3_t  maxs,
edict_t **  list,
int  maxCount,
edict_t skip 
)

Fills a list with edicts that are in use and are touching the given bounding box.

Parameters:
[in] mins The mins of the bounding box
[in] maxs The maxs of the bounding box
[out] list The edict list that this trace is hitting
[in] maxCount The size of the given list
[in] skip An edict to skip (e.g. pointer to the calling edict)
Returns:
the number of pointers filled in

Definition at line 338 of file sv_world.c.

References EDICT_NUM, serverInstanceStatic_t::ge, i, game_export_t::num_edicts, edict_s::solid, SOLID_NOT, SV_BoundingBoxesIntersect(), and svs.

Referenced by SV_InitGameProgs().

trace_t SV_Trace ( const vec3_t  start,
const vec3_t  mins,
const vec3_t  maxs,
const vec3_t  end,
const edict_t passedict,
int  contentmask 
)

Moves the given mins/maxs volume through the world from start to end.

Note:
Passedict and edicts owned by passedict are explicitly not checked.
See also:
SV_TraceBounds
CL_Trace
Parameters:
[in] start The starting position in the world for this trace
[in] end The position in the world where this trace should stop
[in] passedict is explicitly excluded from clipping checks (normally NULL) if the entire move stays in a solid volume, trace.allsolid will be set, trace.startsolid will be set, and trace.fraction will be 0 if the starting point is in a solid, it will be allowed to move out to an open area
[in] contentmask brushes the trace should stop at (see MASK_*)
[in] mins The mins of the bounding box that is moved through the world
[in] maxs The maxs of the bounding box that is moved through the world

Todo:
There is more than one world in case of a map assembly - use clip.trace.mapTile to get the correct one

Definition at line 546 of file sv_world.c.

References moveclip_t::boxmaxs, moveclip_t::boxmins, CM_CompleteBoxTrace(), Com_Printf(), moveclip_t::contentmask, game_export_t::edicts, moveclip_t::end, trace_s::ent, trace_s::fraction, serverInstanceStatic_t::ge, serverInstanceGame_t::mapTiles, moveclip_t::maxs, moveclip_t::mins, moveclip_t::passedict, moveclip_t::start, sv, SV_ClipMoveToEntities(), SV_TraceBounds(), svs, moveclip_t::trace, TRACING_ALL_VISIBLE_LEVELS, and vec3_origin.

Referenced by SV_InitGameProgs().

static void SV_TraceBounds ( const vec3_t  start,
const vec3_t  mins,
const vec3_t  maxs,
const vec3_t  end,
vec3_t  boxmins,
vec3_t  boxmaxs 
) [static]

calculates the bounding box for the whole trace

Parameters:
[in] start The starting point of the trace
[in] mins extents of the box we are moving through the world
[in] maxs guess what
[in] end The point where the trace should end
[out] boxmins The lower bounds of the trace
[out] boxmaxs The upper bounds
See also:
SV_Trace

Definition at line 510 of file sv_world.c.

References i.

Referenced by SV_Trace().

void SV_UnlinkEdict ( edict_t ent  ) 

call before removing an entity, and before trying to move one, so it doesn't clip against itself

Definition at line 103 of file sv_world.c.

References edict_s::child, Com_Printf(), worldSector_s::entities, sv_edict_s::linked, sv_edict_s::nextEntityInWorldSector, qfalse, SV_GetServerDataForEdict(), SV_UnlinkEdict(), and sv_edict_s::worldSector.

Referenced by SV_InitGameProgs(), SV_LinkEdict(), and SV_UnlinkEdict().


Generated by  doxygen 1.6.2