UFO: Alien Invasion
Loading...
Searching...
No Matches
sv_world.cpp File Reference

World query functions. More...

#include "../shared/moveclip.h"
#include "server.h"
#include "../common/qfiles.h"
Include dependency graph for sv_world.cpp:

Go to the source code of this file.

Data Structures

struct  areaParms_t
class  MoveClipSV
 Server side moveclip - see cmodel.c. More...

Macros

#define AREA_DEPTH   4

Functions

static worldSector_tSV_CreateWorldSector (int depth, const AABB &sBox)
 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->absBox.maxs.
static bool SV_BoundingBoxesIntersect (const AABB &aabb, 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.
static int SV_AreaEdicts (const AABB &abox, edict_t **list, int maxCount)
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 (MoveClipSV *clip)
int SV_PointContents (const vec3_t p)
 Returns the content flags for a given point.
trace_t SV_Trace (const Line &traceLine, const AABB &box, 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)
 Query the footstep sound for the given surface 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_ModLoadObjModel (sv_model_t *mod, const byte *buffer, int bufferLength)
 Loads the mins/maxs for a obj mesh model.
bool SV_LoadModelAABB (const char *model, int frame, AABB &aabb)
 Load the bounding box for the model on the serverside for pathfinding and clipping.

Variables

static char const *const mod_extensions []
 all supported model formats

Detailed Description

World query functions.

Definition in file sv_world.cpp.

Macro Definition Documentation

◆ AREA_DEPTH

#define AREA_DEPTH   4

Definition at line 33 of file sv_world.cpp.

Referenced by SV_CreateWorldSector().

Function Documentation

◆ SV_AreaEdicts()

int SV_AreaEdicts ( const AABB & abox,
edict_t ** list,
int maxCount )
static
See also
SV_AreaEdicts_r
Parameters
[in]aboxThe bounding box
[out]listThe edict list that this trace is hitting
[in]maxCountThe size of the given list
Returns
the number of pointers filled in

Definition at line 256 of file sv_world.cpp.

References areaParms_t::areaBox, areaParms_t::areaEdictList, areaParms_t::areaEdictListCount, areaParms_t::areaEdictListMaxCount, AABB::set(), sv, and SV_AreaEdicts_r().

Referenced by SV_ClipMoveToEntities().

◆ SV_AreaEdicts_r()

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

Definition at line 213 of file sv_world.cpp.

References areaParms_t::areaBox, areaParms_t::areaEdictList, areaParms_t::areaEdictListCount, areaParms_t::areaEdictListMaxCount, worldSector_t::axis, worldSector_t::children, Com_Printf(), worldSector_t::dist, sv_edict_t::ent, worldSector_t::entities, SrvEdict::inuse, LEAFNODE, AABB::maxs, AABB::mins, sv_edict_t::nextEntityInWorldSector, SrvEdict::solid, SOLID_NOT, SV_AreaEdicts_r(), and SV_BoundingBoxesIntersect().

Referenced by SV_AreaEdicts(), and SV_AreaEdicts_r().

◆ SV_BoundingBoxesIntersect()

bool SV_BoundingBoxesIntersect ( const AABB & aabb,
const edict_t * ent )
static

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

Parameters
[in]aabbthe bounding box
[in]entThe edict to check the intersection for
Returns
true if intersect, false otherwise

Definition at line 196 of file sv_world.cpp.

References SrvEdict::absBox, and AABB::doesIntersect().

Referenced by SV_AreaEdicts_r().

◆ SV_ClearWorld()

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 81 of file sv_world.cpp.

References sv, and SV_CreateWorldSector().

Referenced by SV_BroadcastPrintf(), SV_Map(), and TEST_F().

◆ SV_ClipMoveToEntities()

◆ SV_CreateWorldSector()

worldSector_t * SV_CreateWorldSector ( int depth,
const AABB & sBox )
static

◆ SV_GetBounceFraction()

float SV_GetBounceFraction ( const char * texture)

Different terrain types might have different bounce fraction.

See also
Com_GetTerrainType
GenerateFootstepList

Definition at line 462 of file sv_world.cpp.

References terrainType_t::bounceFraction, and Com_GetTerrainType().

Referenced by SV_BroadcastPrintf(), and SV_InitGameProgs().

◆ SV_GetFootstepSound()

const char * SV_GetFootstepSound ( const char * texture)

Query the footstep sound for the given surface texture.

See also
Com_GetTerrainType
GenerateFootstepList
Returns
either nullptr or the footstep sound filename if there is one assigned in the scripts

Definition at line 451 of file sv_world.cpp.

References Com_GetTerrainType(), and terrainType_t::footstepSound.

Referenced by SV_BroadcastPrintf(), SV_InitGameProgs(), and TEST_F().

◆ SV_GetServerDataForEdict()

sv_edict_t * SV_GetServerDataForEdict ( const edict_t * ent)
inlinestatic

Definition at line 86 of file sv_world.cpp.

References Com_Error(), ERR_DROP, lengthof, SrvEdict::number, and sv.

Referenced by SV_LinkEdict(), and SV_UnlinkEdict().

◆ SV_HullForEntity()

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]entThe edict to get the bmodel from (at least in case of SOLID_BSP)
[out]tileThe maptile the bmodel belongs, too (at least in case of SOLID_BSP)
[out]rmaShiftthe shift vector in case of an RMA (needed for doors)
Returns
The headnode for the edict
See also
CL_HullForEntity

Definition at line 290 of file sv_world.cpp.

References CM_HeadnodeForBox(), Com_Error(), SrvEdict::entBox, ERR_FATAL, cBspModel_t::headnode, MAX_MAP_NODES, MAX_MODELS, SrvEdict::modelindex, cBspModel_t::shift, SrvEdict::solid, SOLID_BSP, SOLID_NOT, SOLID_TRIGGER, sv, cBspModel_t::tile, vec3_origin, and VectorCopy.

Referenced by SV_ClipMoveToEntities().

◆ SV_LinkEdict()

◆ SV_LoadModelAABB()

bool SV_LoadModelAABB ( const char * model,
int frame,
AABB & aabb )

Load the bounding box for the model on the serverside for pathfinding and clipping.

Parameters
[in]modelThe relative model path to load the bounding box for
[in]frameThe frame to load the bounding box for
[out]aabbThe bounding box of the model - this is absolute to the worldorigin (0,0,0)

Definition at line 543 of file sv_world.cpp.

References sv_model_t::aabb, Com_Error(), com_genericPool, Com_GetExtension(), Com_sprintf(), ERR_DROP, sv_model_t::frame, FS_FreeFile(), FS_LoadFile(), i, IDALIASHEADER, IDMD3HEADER, LittleLong, MAX_MOD_KNOWN, MAX_QPATH, Mem_PoolStrDup, mod_extensions, sv_model_t::name, OBJZERO, Q_strcasecmp, Q_streq, AABB::reset(), AABB::set(), AABB::setNegativeVolume(), sv, SV_ModLoadAliasMD2Model(), SV_ModLoadAliasMD3Model(), and SV_ModLoadObjModel().

Referenced by SV_BroadcastPrintf(), and SV_InitGameProgs().

◆ SV_ModLoadAliasMD2Model()

void SV_ModLoadAliasMD2Model ( sv_model_t * mod,
const byte * buffer )
static

Loads the mins/maxs for a md2 mesh model.

Parameters
[in,out]modThe server side model struct to store the results in
[in]bufferThe mesh model buffer

Definition at line 473 of file sv_world.cpp.

References sv_model_t::aabb, AABB::add(), sv_model_t::frame, dMD2Model_t::framesize, LittleFloat, LittleLong, dMD2Model_t::num_frames, dMD2Model_t::ofs_frames, dMD2Frame_t::scale, scale, dMD2Frame_t::translate, and VectorMA().

Referenced by SV_LoadModelAABB().

◆ SV_ModLoadAliasMD3Model()

void SV_ModLoadAliasMD3Model ( sv_model_t * mod,
const byte * buffer )
static

Loads the mins/maxs for a md3 mesh model.

Parameters
[in,out]modThe server side model struct to store the results in
[in]bufferThe mesh model buffer

Definition at line 499 of file sv_world.cpp.

References sv_model_t::aabb, AABB::add(), sv_model_t::frame, LittleFloat, LittleLong, dmd3frame_t::maxs, dmd3frame_t::mins, dmd3_t::num_frames, and dmd3_t::ofs_frames.

Referenced by SV_LoadModelAABB().

◆ SV_ModLoadObjModel()

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]modThe server side model struct to store the results in
[in]bufferThe mesh model buffer
[in]bufferLengthThe mesh model buffer length
Todo
implement me

Definition at line 524 of file sv_world.cpp.

Referenced by SV_LoadModelAABB().

◆ SV_PointContents()

int SV_PointContents ( const 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 395 of file sv_world.cpp.

References CM_CompleteBoxTrace(), trace_t::contentFlags, AABB::EMPTY, trace_t::fraction, MASK_ALL, sv, and TRACE_ALL_LEVELS.

Referenced by SV_BroadcastPrintf(), and SV_InitGameProgs().

◆ SV_Trace()

trace_t SV_Trace ( const Line & traceLine,
const AABB & box,
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]traceLineThe from/to position in the world for this trace
[in]boxThe bounding box that is moved through the world
[in]passedictis explicitly excluded from clipping checks (normally nullptr) 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]contentmaskbrushes the trace should stop at (see MASK_*)
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 417 of file sv_world.cpp.

References MoveClip::calcBounds(), CM_CompleteBoxTrace(), MoveClip::contentmask, trace_t::entNum, trace_t::fraction, MoveClip::moveLine, MoveClip::objBox, OBJZERO, MoveClipSV::passedict, AABB::set(), Line::set(), sv, SV_ClipMoveToEntities(), MoveClipSV::trace, and TRACE_ALL_LEVELS.

Referenced by SV_BroadcastPrintf(), SV_InitGameProgs(), and TEST_F().

◆ SV_UnlinkEdict()

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 97 of file sv_world.cpp.

References Com_Printf(), worldSector_t::entities, sv_edict_t::linked, sv_edict_t::nextEntityInWorldSector, SV_GetServerDataForEdict(), and sv_edict_t::worldSector.

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

Variable Documentation

◆ mod_extensions

char const* const mod_extensions[]
static
Initial value:
= {
"md2", "md3", "obj", nullptr
}

all supported model formats

See also
modtype_t

Definition at line 533 of file sv_world.cpp.