g_spawn.c File Reference

Brings new objects into the world. More...

#include "g_local.h"
#include "../shared/parse.h"
Include dependency graph for g_spawn.c:

Go to the source code of this file.

Data Structures

struct  spawn_t
struct  field_t

Defines

#define MISC_MODEL_SOLID   256

Enumerations

enum  fieldtype_t {
  F_INT, F_FLOAT, F_LSTRING, F_VECTOR,
  F_IGNORE
}

Functions

static void SP_light (edict_t *ent)
 light (0 1 0) (-8 -8 -8) (8 8 8)
static void SP_dummy (edict_t *ent)
 a dummy to get rid of local entities
static void SP_player_start (edict_t *ent)
 info_player_start (1 0 0) (-16 -16 -24) (16 16 32) Starting point for a player. "team" the number of the team for this player starting point "0" is reserved for civilians and critters (use info_civilian_start instead)
static void SP_human_start (edict_t *ent)
 info_human_start (1 0 0) (-16 -16 -24) (16 16 32) Starting point for a single player human.
static void SP_alien_start (edict_t *ent)
 info_alien_start (1 0 0) (-16 -16 -24) (16 16 32) Starting point for a single player alien.
static void SP_civilian_start (edict_t *ent)
 info_civilian_start (0 1 1) (-16 -16 -24) (16 16 32) Starting point for a civilian.
static void SP_worldspawn (edict_t *ent)
 Spawns the world entity.
static void SP_2x2_start (edict_t *ent)
 info_2x2_start (1 1 0) (-32 -32 -24) (32 32 32) Starting point for a 2x2 unit.
static void SP_civilian_target (edict_t *ent)
 info_civilian_start (0 1 1) (-16 -16 -24) (16 16 32) Way point for a civilian.
static void SP_misc_model (edict_t *ent)
 Spawns a misc_model if there is a solid state.
static void SP_misc_item (edict_t *ent)
 Spawns an item to the ground container.
static void SP_misc_mission (edict_t *ent)
 Initializes the human/phalanx mission entity.
static void SP_misc_mission_aliens (edict_t *ent)
 Initializes the alien mission entity.
static void SP_misc_message (edict_t *ent)
static void ED_CallSpawn (edict_t *ent)
 Finds the spawn function for the entity and calls it.
static char * ED_NewString (const char *string)
 Allocated memory for the given string in the level context (TAG_LEVEL).
static void ED_ParseField (const char *key, const char *value, edict_t *ent)
 Takes a key/value pair and sets the binary values in an edict.
static const char * ED_ParseEdict (const char *data, edict_t *ent)
 Parses an edict out of the given string, returning the new position.
static void G_FindEdictGroups (void)
 Chain together all entities with a matching team field. All but the first will have the FL_GROUPSLAVE flag set. All but the last will have the groupchain field set to the next one.
void G_SpawnEntities (const char *mapname, qboolean day, const char *entities)
 Creates a server's entity / program execution context by parsing textual entity definitions out of an ent file.
static void G_InitEdict (edict_t *ent)
edict_tG_Spawn (void)
 Either finds a free edict, or allocates a new one.
edict_tG_SpawnFloor (const pos3_t pos)
 Spawns a new entity at the floor.
edict_tG_SpawnParticle (const vec3_t origin, int spawnflags, const char *particle)
static void G_ActorSpawn (edict_t *ent)
 Spawn a 1x1 unit.
static void G_Actor2x2Spawn (edict_t *ent)
 Spawn a singleplayer 2x2 unit.
static void G_BuildForbiddenListForEntity (edict_t *ent)
static qboolean Message_Use (edict_t *self, edict_t *activator)

Variables

static spawn_temp_t st
static const spawn_t spawns []
static const field_t fields []

Detailed Description

Brings new objects into the world.

Definition in file g_spawn.c.


Define Documentation

#define MISC_MODEL_SOLID   256

Definition at line 778 of file g_spawn.c.

Referenced by SP_misc_model().


Enumeration Type Documentation

Enumerator:
F_INT 
F_FLOAT 
F_LSTRING 
F_VECTOR 
F_IGNORE 

Definition at line 82 of file g_spawn.c.


Function Documentation

static void ED_CallSpawn ( edict_t ent  )  [static]

Finds the spawn function for the entity and calls it.

Definition at line 136 of file g_spawn.c.

References edict_s::classname, edict_s::inuse, spawn_t::name, qfalse, and spawn_t::spawn.

Referenced by G_SpawnEntities().

static char* ED_NewString ( const char *  string  )  [static]

Allocated memory for the given string in the level context (TAG_LEVEL).

Note:
This memory is automatically freed when we close or change the level
Parameters:
[in] string The string to copy

Definition at line 160 of file g_spawn.c.

References G_TagMalloc, i, and TAG_LEVEL.

Referenced by ED_ParseField().

static const char* ED_ParseEdict ( const char *  data,
edict_t ent 
) [static]

Parses an edict out of the given string, returning the new position.

Parameters:
[in] data The string to parse from
[in] ent should be a properly initialized empty edict.

Definition at line 230 of file g_spawn.c.

References Com_Parse(), ED_ParseField(), gi, MAX_VAR, Q_strncpyz(), qfalse, and qtrue.

Referenced by G_SpawnEntities().

static void ED_ParseField ( const char *  key,
const char *  value,
edict_t ent 
) [static]

Takes a key/value pair and sets the binary values in an edict.

Definition at line 187 of file g_spawn.c.

References byte, ED_NewString(), f, F_FLOAT, F_IGNORE, F_INT, F_LSTRING, F_VECTOR, FFL_NOSPAWN, FFL_SPAWNTEMP, field_t::flags, field_t::name, field_t::ofs, Q_strcasecmp, and field_t::type.

Referenced by ED_ParseEdict().

static void G_Actor2x2Spawn ( edict_t ent  )  [static]
static void G_ActorSpawn ( edict_t ent  )  [static]
static void G_BuildForbiddenListForEntity ( edict_t ent  )  [static]
Note:
This is only working for one z-level. But our models should be split for each level anyway.
Parameters:
ent The edict to fill the forbidden list for

Definition at line 747 of file g_spawn.c.

References edict_s::absmax, edict_s::absmin, edict_s::forbiddenListPos, edict_s::forbiddenListSize, G_TagMalloc, i, edict_s::origin, TAG_LEVEL, VecToPos, VectorAdd, VectorCenterFromMinsMaxs(), and VectorSet.

Referenced by SP_misc_model().

static void G_FindEdictGroups ( void   )  [static]

Chain together all entities with a matching team field. All but the first will have the FL_GROUPSLAVE flag set. All but the last will have the groupchain field set to the next one.

Definition at line 278 of file g_spawn.c.

References FL_GROUPSLAVE, edict_s::flags, G_EdictsGetFirst(), G_EdictsGetNextInUse(), edict_s::group, edict_s::groupChain, and edict_s::groupMaster.

Referenced by G_SpawnEntities().

static void G_InitEdict ( edict_t ent  )  [inline, static]
edict_t* G_Spawn ( void   ) 

Either finds a free edict, or allocates a new one.

Note:
Try to avoid reusing an entity that was recently freed, because it can cause the player to think the entity morphed into something else instead of being removed and recreated, which can cause interpolated angles and bad trails.
See also:
G_InitEdict
G_FreeEdict

Definition at line 400 of file g_spawn.c.

References G_EdictsGetNewEdict(), G_InitEdict(), and gi.

Referenced by G_SpawnEntities(), G_SpawnFloor(), G_SpawnParticle(), and G_TriggerSpawn().

void G_SpawnEntities ( const char *  mapname,
qboolean  day,
const char *  entities 
)
edict_t* G_SpawnFloor ( const pos3_t  pos  ) 

Spawns a new entity at the floor.

Note:
This is e.g. used to place dropped weapons/items at the floor

Definition at line 415 of file g_spawn.c.

References ACTOR_SIZE_NORMAL, edict_s::classname, ET_ITEM, edict_s::fieldSize, G_EdictCalcOrigin(), G_Spawn(), gi, edict_s::pos, game_import_t::routingMap, edict_s::type, and VectorCopy.

Referenced by G_ActorInvMove(), G_AddItemToFloor(), G_InventoryToFloor(), and G_SpawnItemOnFloor().

edict_t* G_SpawnParticle ( const vec3_t  origin,
int  spawnflags,
const char *  particle 
)

This is only for particles that are spawned during a match - not for map particles.

Returns:
A particle edict

Definition at line 434 of file g_spawn.c.

References edict_s::classname, ET_PARTICLE, G_CheckVis(), G_Spawn(), edict_s::origin, edict_s::particle, edict_s::pos, qtrue, edict_s::spawnflags, edict_s::type, VecToPos, and VectorCopy.

Referenced by Destroy_Breakable(), G_MissionThink(), G_ShootSingle(), and G_SplashDamage().

static qboolean Message_Use ( edict_t self,
edict_t activator 
) [static]

Definition at line 828 of file g_spawn.c.

References G_ClientPrintf(), G_FreeEdict(), G_IsActor, G_PLAYER_FROM_ENT, PRINT_HUD, and qfalse.

Referenced by SP_misc_message().

static void SP_2x2_start ( edict_t ent  )  [static]

info_2x2_start (1 1 0) (-32 -32 -24) (32 32 32) Starting point for a 2x2 unit.

Definition at line 572 of file g_spawn.c.

References G_Actor2x2Spawn(), G_FreeEdict(), edict_s::HP, cvar_s::integer, MAX_HP, edict_s::maxs, edict_s::mins, PLAYER_MIN, PLAYER_STAND, PLAYER_WIDTH, edict_s::STUN, sv_maxclients, edict_s::team, TEAM_PHALANX, and VectorSet.

static void SP_alien_start ( edict_t ent  )  [static]

info_alien_start (1 0 0) (-16 -16 -24) (16 16 32) Starting point for a single player alien.

Definition at line 598 of file g_spawn.c.

References ai_numactors, f, frand(), G_ActorSpawn(), G_FreeEdict(), edict_s::HP, level_locals_t::hurtAliens, cvar_s::integer, level, MAX_HP, random, edict_s::STUN, sv_maxclients, edict_s::team, and TEAM_ALIEN.

static void SP_civilian_start ( edict_t ent  )  [static]

info_civilian_start (0 1 1) (-16 -16 -24) (16 16 32) Starting point for a civilian.

Todo:
Does anybody know _why_ this is set to 99?

Definition at line 631 of file g_spawn.c.

References ai_numcivilians, edict_s::count, G_ActorSpawn(), G_FreeEdict(), edict_s::HP, cvar_s::integer, MAX_HP, edict_s::STUN, sv_maxclients, edict_s::team, and TEAM_CIVILIAN.

static void SP_civilian_target ( edict_t ent  )  [static]

info_civilian_start (0 1 1) (-16 -16 -24) (16 16 32) Way point for a civilian.

See also:
SP_civilian_start
Todo:
These waypoints should be placeable by the human player (e.g. spawn a special particle on the waypoint) to direct the civilians to a special location

Definition at line 653 of file g_spawn.c.

References ACTOR_SIZE_NORMAL, edict_s::classname, ET_CIVILIANTARGET, edict_s::fieldSize, G_AddToWayPointList(), G_EdictCalcOrigin(), gi, PATHFINDING_HEIGHT, edict_s::pos, game_import_t::routingMap, edict_s::team, TEAM_CIVILIAN, and edict_s::type.

static void SP_dummy ( edict_t ent  )  [static]

a dummy to get rid of local entities

Definition at line 865 of file g_spawn.c.

References G_FreeEdict().

static void SP_human_start ( edict_t ent  )  [static]

info_human_start (1 0 0) (-16 -16 -24) (16 16 32) Starting point for a single player human.

Definition at line 554 of file g_spawn.c.

References G_ActorSpawn(), G_FreeEdict(), edict_s::HP, cvar_s::integer, MAX_HP, edict_s::STUN, sv_maxclients, edict_s::team, and TEAM_PHALANX.

static void SP_light ( edict_t ent  )  [static]

light (0 1 0) (-8 -8 -8) (8 8 8)

Definition at line 519 of file g_spawn.c.

References G_FreeEdict().

static void SP_misc_item ( edict_t ent  )  [static]

Spawns an item to the ground container.

Definition at line 814 of file g_spawn.c.

References G_AddItemToFloor(), G_FreeEdict(), gi, edict_s::item, and edict_s::pos.

static void SP_misc_message ( edict_t ent  )  [static]
static void SP_misc_mission ( edict_t ent  )  [static]
static void SP_misc_mission_aliens ( edict_t ent  )  [static]
static void SP_misc_model ( edict_t ent  )  [static]

Spawns a misc_model if there is a solid state.

Todo:
is fieldsize and forbidden list update really needed here?

Definition at line 782 of file g_spawn.c.

References edict_s::absmax, edict_s::absmin, ACTOR_SIZE_NORMAL, edict_s::classname, ET_SOLID, edict_s::fieldSize, edict_s::frame, G_BuildForbiddenListForEntity(), G_FreeEdict(), gi, MISC_MODEL_SOLID, edict_s::model, edict_s::solid, SOLID_BBOX, edict_s::spawnflags, edict_s::type, and VectorCopy.

static void SP_player_start ( edict_t ent  )  [static]

info_player_start (1 0 0) (-16 -16 -24) (16 16 32) Starting point for a player. "team" the number of the team for this player starting point "0" is reserved for civilians and critters (use info_civilian_start instead)

Todo:
Wrong place here

Definition at line 532 of file g_spawn.c.

References G_ActorSpawn(), G_FreeEdict(), edict_s::HP, cvar_s::integer, level, MAX_HP, level_locals_t::num_spawnpoints, edict_s::STUN, sv_maxclients, sv_maxsoldiersperteam, and edict_s::team.

static void SP_worldspawn ( edict_t ent  )  [static]

Spawns the world entity.

Only used for the world. "sounds" music cd track number "maxlevel" max. level to use in the map "maxteams" max team amount for multiplayergames for the current map

Definition at line 880 of file g_spawn.c.

References edict_s::classname, CS_ENABLEMORALE, CS_MAXCLIENTS, CS_MAXSOLDIERSPERPLAYER, CS_MAXSOLDIERSPERTEAM, CS_MAXTEAMS, gi, cvar_s::integer, edict_s::inuse, level, level_locals_t::nextmap, spawn_temp_t::nextmap, Q_strncpyz(), qtrue, spawn_temp_t::randomSpawn, level_locals_t::randomSpawn, edict_s::solid, SOLID_BSP, cvar_s::string, sv_enablemorale, sv_maxclients, sv_maxsoldiersperplayer, sv_maxsoldiersperteam, and sv_maxteams.


Variable Documentation

const field_t fields[] [static]

Definition at line 97 of file g_spawn.c.

const spawn_t spawns[] [static]
Initial value:
 {
    {"worldspawn", SP_worldspawn},
    {"light", SP_light},
    {"misc_item", SP_misc_item},
    {"misc_sound", SP_dummy},
    {"misc_model", SP_misc_model},
    {"misc_particle", SP_dummy},
    {"misc_mission", SP_misc_mission},
    {"misc_mission_aliens", SP_misc_mission_aliens},
    {"info_player_start", SP_player_start},
    {"info_human_start", SP_human_start},
    {"info_alien_start", SP_alien_start},
    {"info_civilian_start", SP_civilian_start},
    {"info_civilian_target", SP_civilian_target},
    {"info_2x2_start", SP_2x2_start},
    {"info_null", SP_dummy},
    {"func_breakable", SP_func_breakable},
    {"func_door", SP_func_door},
    {"func_rotating", SP_func_rotating},
    {"trigger_hurt", SP_trigger_hurt},
    {"trigger_touch", SP_trigger_touch},
    {"trigger_rescue", SP_trigger_rescue},
    {"misc_message", SP_misc_message},

    {NULL, NULL}
}

Definition at line 55 of file g_spawn.c.

spawn_temp_t st [static]

Generated by  doxygen 1.6.2