Rework g_spawn.c, add sanity checks and plug a memory

leak. Honor the COOP-Flag of item, this should be 
unused by the main game data but maybe some mappers
used it.
This commit is contained in:
Yamagi Burmeister 2011-10-01 08:36:02 +00:00
parent e426e7ab82
commit 74ff11850b

View file

@ -1,23 +1,3 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "g_local.h" #include "g_local.h"
typedef struct typedef struct
@ -26,7 +6,6 @@ typedef struct
void (*spawn)(edict_t *ent); void (*spawn)(edict_t *ent);
} spawn_t; } spawn_t;
void SP_item_health(edict_t *self); void SP_item_health(edict_t *self);
void SP_item_health_small(edict_t *self); void SP_item_health_small(edict_t *self);
void SP_item_health_large(edict_t *self); void SP_item_health_large(edict_t *self);
@ -144,7 +123,6 @@ void SP_turret_breach (edict_t *self);
void SP_turret_base(edict_t *self); void SP_turret_base(edict_t *self);
void SP_turret_driver(edict_t *self); void SP_turret_driver(edict_t *self);
spawn_t spawns[] = { spawn_t spawns[] = {
{"item_health", SP_item_health}, {"item_health", SP_item_health},
{"item_health_small", SP_item_health_small}, {"item_health_small", SP_item_health_small},
@ -269,54 +247,60 @@ spawn_t spawns[] = {
}; };
/* /*
=============== * Finds the spawn function for
ED_CallSpawn * the entity and calls it
Finds the spawn function for the entity and calls it
===============
*/ */
void ED_CallSpawn (edict_t *ent) void
ED_CallSpawn(edict_t *ent)
{ {
spawn_t *s; spawn_t *s;
gitem_t *item; gitem_t *item;
int i; int i;
if (!ent->classname) if (!ent)
{ {
gi.dprintf ("ED_CallSpawn: NULL classname\n");
return; return;
} }
// check item spawn functions if (!ent->classname)
{
gi.dprintf("ED_CallSpawn: NULL classname\n");
G_FreeEdict(ent);
return;
}
/* check item spawn functions */
for (i = 0, item = itemlist; i < game.num_items; i++, item++) for (i = 0, item = itemlist; i < game.num_items; i++, item++)
{ {
if (!item->classname) if (!item->classname)
{
continue; continue;
}
if (!strcmp(item->classname, ent->classname)) if (!strcmp(item->classname, ent->classname))
{ // found it {
/* found it */
SpawnItem(ent, item); SpawnItem(ent, item);
return; return;
} }
} }
// check normal spawn functions /* check normal spawn functions */
for (s = spawns; s->name; s++) for (s = spawns; s->name; s++)
{ {
if (!strcmp(s->name, ent->classname)) if (!strcmp(s->name, ent->classname))
{ // found it {
/* found it */
s->spawn(ent); s->spawn(ent);
return; return;
} }
} }
gi.dprintf("%s doesn't have a spawn function\n", ent->classname); gi.dprintf("%s doesn't have a spawn function\n", ent->classname);
} }
/* char *
============= ED_NewString(const char *string)
ED_NewString
=============
*/
char *ED_NewString (const char *string)
{ {
char *newb, *new_p; char *newb, *new_p;
int i, l; int i, l;
@ -329,44 +313,58 @@ char *ED_NewString (const char *string)
for (i = 0; i < l; i++) for (i = 0; i < l; i++)
{ {
if (string[i] == '\\' && i < l-1) if ((string[i] == '\\') && (i < l - 1))
{ {
i++; i++;
if (string[i] == 'n') if (string[i] == 'n')
{
*new_p++ = '\n'; *new_p++ = '\n';
else
*new_p++ = '\\';
} }
else else
{
*new_p++ = '\\';
}
}
else
{
*new_p++ = string[i]; *new_p++ = string[i];
} }
}
return newb; return newb;
} }
/* /*
=============== * Takes a key/value pair and sets
ED_ParseField * the binary values in an edict
Takes a key/value pair and sets the binary values
in an edict
===============
*/ */
void ED_ParseField (const char *key, const char *value, edict_t *ent) void
ED_ParseField(const char *key, const char *value, edict_t *ent)
{ {
field_t *f; field_t *f;
byte *b; byte *b;
float v; float v;
vec3_t vec; vec3_t vec;
if (!key || !value)
{
return;
}
for (f = fields; f->name; f++) for (f = fields; f->name; f++)
{ {
if (!(f->flags & FFL_NOSPAWN) && !Q_stricmp(f->name, key)) if (!(f->flags & FFL_NOSPAWN) && !Q_stricmp(f->name, key))
{ // found it {
/* found it */
if (f->flags & FFL_SPAWNTEMP) if (f->flags & FFL_SPAWNTEMP)
{
b = (byte *)&st; b = (byte *)&st;
}
else else
{
b = (byte *)ent; b = (byte *)ent;
}
switch (f->type) switch (f->type)
{ {
@ -396,21 +394,21 @@ void ED_ParseField (const char *key, const char *value, edict_t *ent)
default: default:
break; break;
} }
return; return;
} }
} }
gi.dprintf("%s is not a field\n", key); gi.dprintf("%s is not a field\n", key);
} }
/* /*
==================== * Parses an edict out of the given string,
ED_ParseEdict * returning the new position ed should be
* a properly initialized empty edict.
Parses an edict out of the given string, returning the new position
ed should be a properly initialized empty edict.
====================
*/ */
char *ED_ParseEdict (char *data, edict_t *ent) char *
ED_ParseEdict(char *data, edict_t *ent)
{ {
qboolean init; qboolean init;
char keyname[256]; char keyname[256];
@ -419,54 +417,66 @@ char *ED_ParseEdict (char *data, edict_t *ent)
init = false; init = false;
memset(&st, 0, sizeof(st)); memset(&st, 0, sizeof(st));
// go through all the dictionary pairs /* go through all the dictionary pairs */
while (1) while (1)
{ {
// parse key /* parse key */
com_token = COM_Parse(&data); com_token = COM_Parse(&data);
if (com_token[0] == '}') if (com_token[0] == '}')
{
break; break;
}
if (!data) if (!data)
{
gi.error("ED_ParseEntity: EOF without closing brace"); gi.error("ED_ParseEntity: EOF without closing brace");
}
strncpy(keyname, com_token, sizeof(keyname) - 1); strncpy(keyname, com_token, sizeof(keyname) - 1);
// parse value /* parse value */
com_token = COM_Parse(&data); com_token = COM_Parse(&data);
if (!data) if (!data)
{
gi.error("ED_ParseEntity: EOF without closing brace"); gi.error("ED_ParseEntity: EOF without closing brace");
}
if (com_token[0] == '}') if (com_token[0] == '}')
{
gi.error("ED_ParseEntity: closing brace without data"); gi.error("ED_ParseEntity: closing brace without data");
}
init = true; init = true;
// keynames with a leading underscore are used for utility comments, /* keynames with a leading underscore are
// and are immediately discarded by quake used for utility comments, and are
immediately discarded by quake */
if (keyname[0] == '_') if (keyname[0] == '_')
{
continue; continue;
}
ED_ParseField(keyname, com_token, ent); ED_ParseField(keyname, com_token, ent);
} }
if (!init) if (!init)
{
memset(ent, 0, sizeof(*ent)); memset(ent, 0, sizeof(*ent));
}
return data; return data;
} }
/* /*
================ * Chain together all entities with a matching team field.
G_FindTeams *
* All but the first will have the FL_TEAMSLAVE flag set.
Chain together all entities with a matching team field. * All but the last will have the teamchain field set to the next one
All but the first will have the FL_TEAMSLAVE flag set.
All but the last will have the teamchain field set to the next one
================
*/ */
void G_FindTeams (void) void
G_FindTeams(void)
{ {
edict_t *e, *e2, *chain; edict_t *e, *e2, *chain;
int i, j; int i, j;
@ -474,26 +484,46 @@ void G_FindTeams (void)
c = 0; c = 0;
c2 = 0; c2 = 0;
for (i = 1, e = g_edicts + i; i < globals.num_edicts; i++, e++) for (i = 1, e = g_edicts + i; i < globals.num_edicts; i++, e++)
{ {
if (!e->inuse) if (!e->inuse)
{
continue; continue;
}
if (!e->team) if (!e->team)
{
continue; continue;
}
if (e->flags & FL_TEAMSLAVE) if (e->flags & FL_TEAMSLAVE)
{
continue; continue;
}
chain = e; chain = e;
e->teammaster = e; e->teammaster = e;
c++; c++;
c2++; c2++;
for (j = i + 1, e2 = e + 1; j < globals.num_edicts; j++, e2++) for (j = i + 1, e2 = e + 1; j < globals.num_edicts; j++, e2++)
{ {
if (!e2->inuse) if (!e2->inuse)
{
continue; continue;
}
if (!e2->team) if (!e2->team)
{
continue; continue;
}
if (e2->flags & FL_TEAMSLAVE) if (e2->flags & FL_TEAMSLAVE)
{
continue; continue;
}
if (!strcmp(e->team, e2->team)) if (!strcmp(e->team, e2->team))
{ {
c2++; c2++;
@ -509,14 +539,11 @@ void G_FindTeams (void)
} }
/* /*
============== * Creates a server's entity / program execution context by
SpawnEntities * parsing textual entity definitions out of an ent file.
Creates a server's entity / program execution context by
parsing textual entity definitions out of an ent file.
==============
*/ */
void SpawnEntities (const char *mapname, char *entities, const char *spawnpoint) void
SpawnEntities(const char *mapname, char *entities, const char *spawnpoint)
{ {
edict_t *ent; edict_t *ent;
int inhibit; int inhibit;
@ -524,13 +551,27 @@ void SpawnEntities (const char *mapname, char *entities, const char *spawnpoint)
int i; int i;
float skill_level; float skill_level;
if (!mapname || !entities || !spawnpoint)
{
return;
}
skill_level = floor(skill->value); skill_level = floor(skill->value);
if (skill_level < 0) if (skill_level < 0)
{
skill_level = 0; skill_level = 0;
}
if (skill_level > 3) if (skill_level > 3)
{
skill_level = 3; skill_level = 3;
}
if (skill->value != skill_level) if (skill->value != skill_level)
{
gi.cvar_forceset("skill", va("%f", skill_level)); gi.cvar_forceset("skill", va("%f", skill_level));
}
SaveClientData(); SaveClientData();
@ -542,34 +583,52 @@ void SpawnEntities (const char *mapname, char *entities, const char *spawnpoint)
strncpy(level.mapname, mapname, sizeof(level.mapname) - 1); strncpy(level.mapname, mapname, sizeof(level.mapname) - 1);
strncpy(game.spawnpoint, spawnpoint, sizeof(game.spawnpoint) - 1); strncpy(game.spawnpoint, spawnpoint, sizeof(game.spawnpoint) - 1);
// set client fields on player ents /* set client fields on player ents */
for (i = 0; i < game.maxclients; i++) for (i = 0; i < game.maxclients; i++)
{
g_edicts[i + 1].client = game.clients + i; g_edicts[i + 1].client = game.clients + i;
}
ent = NULL; ent = NULL;
inhibit = 0; inhibit = 0;
// parse ents /* parse ents */
while (1) while (1)
{ {
// parse the opening brace /* parse the opening brace */
com_token = COM_Parse(&entities); com_token = COM_Parse(&entities);
if (!entities) if (!entities)
{
break; break;
}
if (com_token[0] != '{') if (com_token[0] != '{')
{
gi.error("ED_LoadFromFile: found %s when expecting {", com_token); gi.error("ED_LoadFromFile: found %s when expecting {", com_token);
}
if (!ent) if (!ent)
{
ent = g_edicts; ent = g_edicts;
}
else else
{
ent = G_Spawn(); ent = G_Spawn();
}
entities = ED_ParseEdict(entities, ent); entities = ED_ParseEdict(entities, ent);
// yet another map hack /* yet another map hack */
if (!Q_stricmp(level.mapname, "command") && !Q_stricmp(ent->classname, "trigger_once") && !Q_stricmp(ent->model, "*27")) if (!Q_stricmp(level.mapname, "command") &&
!Q_stricmp(ent->classname, "trigger_once") &&
!Q_stricmp(ent->model, "*27"))
{
ent->spawnflags &= ~SPAWNFLAG_NOT_HARD; ent->spawnflags &= ~SPAWNFLAG_NOT_HARD;
}
// remove things (except the world) from different skill levels or deathmatch /* remove things (except the world) from
different skill levels or deathmatch */
if (ent != g_edicts) if (ent != g_edicts)
{ {
if (deathmatch->value) if (deathmatch->value)
@ -581,12 +640,25 @@ void SpawnEntities (const char *mapname, char *entities, const char *spawnpoint)
continue; continue;
} }
} }
/* This statement was added by Yamagi. */
else if (coop->value)
{
if ( ent->spawnflags & SPAWNFLAG_NOT_COOP )
{
G_FreeEdict (ent);
inhibit++;
continue;
}
}
else else
{ {
if ( /* ((coop->value) && (ent->spawnflags & SPAWNFLAG_NOT_COOP)) || */ if (((skill->value == 0) &&
((skill->value == 0) && (ent->spawnflags & SPAWNFLAG_NOT_EASY)) || (ent->spawnflags & SPAWNFLAG_NOT_EASY)) ||
((skill->value == 1) && (ent->spawnflags & SPAWNFLAG_NOT_MEDIUM)) || ((skill->value == 1) &&
(((skill->value == 2) || (skill->value == 3)) && (ent->spawnflags & SPAWNFLAG_NOT_HARD)) (ent->spawnflags & SPAWNFLAG_NOT_MEDIUM)) ||
(((skill->value == 2) ||
(skill->value == 3)) &&
(ent->spawnflags & SPAWNFLAG_NOT_HARD))
) )
{ {
G_FreeEdict(ent); G_FreeEdict(ent);
@ -595,7 +667,10 @@ void SpawnEntities (const char *mapname, char *entities, const char *spawnpoint)
} }
} }
ent->spawnflags &= ~(SPAWNFLAG_NOT_EASY|SPAWNFLAG_NOT_MEDIUM|SPAWNFLAG_NOT_HARD|SPAWNFLAG_NOT_COOP|SPAWNFLAG_NOT_DEATHMATCH); ent->spawnflags &=
~(SPAWNFLAG_NOT_EASY | SPAWNFLAG_NOT_MEDIUM |
SPAWNFLAG_NOT_HARD |
SPAWNFLAG_NOT_COOP | SPAWNFLAG_NOT_DEATHMATCH);
} }
ED_CallSpawn(ent); ED_CallSpawn(ent);
@ -608,19 +683,18 @@ void SpawnEntities (const char *mapname, char *entities, const char *spawnpoint)
PlayerTrail_Init(); PlayerTrail_Init();
} }
/* =================================================================== */
//===================================================================
char *single_statusbar = char *single_statusbar =
"yb -24 " "yb -24 "
// health /* health */
"xv 0 " "xv 0 "
"hnum " "hnum "
"xv 50 " "xv 50 "
"pic 0 " "pic 0 "
// ammo /* ammo */
"if 2 " "if 2 "
" xv 100 " " xv 100 "
" anum " " anum "
@ -628,7 +702,7 @@ char *single_statusbar =
" pic 2 " " pic 2 "
"endif " "endif "
// armor /* armor */
"if 4 " "if 4 "
" xv 200 " " xv 200 "
" rnum " " rnum "
@ -636,7 +710,7 @@ char *single_statusbar =
" pic 4 " " pic 4 "
"endif " "endif "
// selected item /* selected item */
"if 6 " "if 6 "
" xv 296 " " xv 296 "
" pic 6 " " pic 6 "
@ -644,7 +718,7 @@ char *single_statusbar =
"yb -50 " "yb -50 "
// picked up item /* picked up item */
"if 7 " "if 7 "
" xv 0 " " xv 0 "
" pic 7 " " pic 7 "
@ -654,7 +728,7 @@ char *single_statusbar =
" yb -50 " " yb -50 "
"endif " "endif "
// timer /* timer */
"if 9 " "if 9 "
" xv 262 " " xv 262 "
" num 2 10 " " num 2 10 "
@ -662,7 +736,7 @@ char *single_statusbar =
" pic 9 " " pic 9 "
"endif " "endif "
// help / weapon icon /* help / weapon icon */
"if 11 " "if 11 "
" xv 148 " " xv 148 "
" pic 11 " " pic 11 "
@ -672,13 +746,13 @@ char *single_statusbar =
char *dm_statusbar = char *dm_statusbar =
"yb -24 " "yb -24 "
// health /* health */
"xv 0 " "xv 0 "
"hnum " "hnum "
"xv 50 " "xv 50 "
"pic 0 " "pic 0 "
// ammo /* ammo */
"if 2 " "if 2 "
" xv 100 " " xv 100 "
" anum " " anum "
@ -686,7 +760,7 @@ char *dm_statusbar =
" pic 2 " " pic 2 "
"endif " "endif "
// armor /* armor */
"if 4 " "if 4 "
" xv 200 " " xv 200 "
" rnum " " rnum "
@ -694,7 +768,7 @@ char *dm_statusbar =
" pic 4 " " pic 4 "
"endif " "endif "
// selected item /* selected item */
"if 6 " "if 6 "
" xv 296 " " xv 296 "
" pic 6 " " pic 6 "
@ -702,7 +776,7 @@ char *dm_statusbar =
"yb -50 " "yb -50 "
// picked up item /* picked up item */
"if 7 " "if 7 "
" xv 0 " " xv 0 "
" pic 7 " " pic 7 "
@ -712,7 +786,7 @@ char *dm_statusbar =
" yb -50 " " yb -50 "
"endif " "endif "
// timer /* timer */
"if 9 " "if 9 "
" xv 246 " " xv 246 "
" num 2 10 " " num 2 10 "
@ -720,25 +794,25 @@ char *dm_statusbar =
" pic 9 " " pic 9 "
"endif " "endif "
// help / weapon icon /* help / weapon icon */
"if 11 " "if 11 "
" xv 148 " " xv 148 "
" pic 11 " " pic 11 "
"endif " "endif "
// frags /* frags */
"xr -50 " "xr -50 "
"yt 2 " "yt 2 "
"num 3 14 " "num 3 14 "
// spectator /* spectator */
"if 17 " "if 17 "
"xv 0 " "xv 0 "
"yb -58 " "yb -58 "
"string2 \"SPECTATOR MODE\" " "string2 \"SPECTATOR MODE\" "
"endif " "endif "
// chase camera /* chase camera */
"if 16 " "if 16 "
"xv 0 " "xv 0 "
"yb -68 " "yb -68 "
@ -748,49 +822,62 @@ char *dm_statusbar =
"endif " "endif "
; ;
/*QUAKED worldspawn (0 0 0) ? /*QUAKED worldspawn (0 0 0) ?
*
Only used for the world. * Only used for the world.
"sky" environment map name * "sky" environment map name
"skyaxis" vector axis for rotating sky * "skyaxis" vector axis for rotating sky
"skyrotate" speed of rotation in degrees/second * "skyrotate" speed of rotation in degrees/second
"sounds" music cd track number * "sounds" music cd track number
"gravity" 800 is default gravity * "gravity" 800 is default gravity
"message" text to print at user logon * "message" text to print at user logon
*/ */
void SP_worldspawn (edict_t *ent) void
SP_worldspawn(edict_t *ent)
{ {
if (!ent)
{
return;
}
ent->movetype = MOVETYPE_PUSH; ent->movetype = MOVETYPE_PUSH;
ent->solid = SOLID_BSP; ent->solid = SOLID_BSP;
ent->inuse = true; // since the world doesn't use G_Spawn() ent->inuse = true; /* since the world doesn't use G_Spawn() */
ent->s.modelindex = 1; // world model is always index 1 ent->s.modelindex = 1; /* world model is always index 1 */
//--------------- /* --------------- */
// reserve some spots for dead player bodies for coop / deathmatch /* reserve some spots for dead
player bodies for coop / deathmatch */
InitBodyQue(); InitBodyQue();
// set configstrings for items /* set configstrings for items */
SetItemNames(); SetItemNames();
if (st.nextmap) if (st.nextmap)
{
strcpy(level.nextmap, st.nextmap); strcpy(level.nextmap, st.nextmap);
}
// make some data visible to the server /* make some data visible to the server */
if (ent->message && ent->message[0]) if (ent->message && ent->message[0])
{ {
gi.configstring(CS_NAME, ent->message); gi.configstring(CS_NAME, ent->message);
strncpy(level.level_name, ent->message, sizeof(level.level_name)); strncpy(level.level_name, ent->message, sizeof(level.level_name));
} }
else else
{
strncpy(level.level_name, level.mapname, sizeof(level.level_name)); strncpy(level.level_name, level.mapname, sizeof(level.level_name));
}
if (st.sky && st.sky[0]) if (st.sky && st.sky[0])
{
gi.configstring(CS_SKY, st.sky); gi.configstring(CS_SKY, st.sky);
}
else else
{
gi.configstring(CS_SKY, "unit1_"); gi.configstring(CS_SKY, "unit1_");
}
gi.configstring(CS_SKYROTATE, va("%f", st.skyrotate)); gi.configstring(CS_SKYROTATE, va("%f", st.skyrotate));
@ -801,27 +888,34 @@ void SP_worldspawn (edict_t *ent)
gi.configstring(CS_MAXCLIENTS, va("%i", (int)(maxclients->value))); gi.configstring(CS_MAXCLIENTS, va("%i", (int)(maxclients->value)));
// status bar program /* status bar program */
if (deathmatch->value) if (deathmatch->value)
{
gi.configstring(CS_STATUSBAR, dm_statusbar); gi.configstring(CS_STATUSBAR, dm_statusbar);
}
else else
{
gi.configstring(CS_STATUSBAR, single_statusbar); gi.configstring(CS_STATUSBAR, single_statusbar);
}
//--------------- /* --------------- */
/* help icon for statusbar */
// help icon for statusbar
gi.imageindex("i_help"); gi.imageindex("i_help");
level.pic_health = gi.imageindex("i_health"); level.pic_health = gi.imageindex("i_health");
gi.imageindex("help"); gi.imageindex("help");
gi.imageindex("field_3"); gi.imageindex("field_3");
if (!st.gravity) if (!st.gravity)
{
gi.cvar_set("sv_gravity", "800"); gi.cvar_set("sv_gravity", "800");
}
else else
{
gi.cvar_set("sv_gravity", st.gravity); gi.cvar_set("sv_gravity", st.gravity);
}
snd_fry = gi.soundindex ("player/fry.wav"); // standing in lava / slime snd_fry = gi.soundindex("player/fry.wav"); /* standing in lava / slime */
PrecacheItem(FindItem("Blaster")); PrecacheItem(FindItem("Blaster"));
@ -833,19 +927,19 @@ void SP_worldspawn (edict_t *ent)
gi.soundindex("misc/udeath.wav"); gi.soundindex("misc/udeath.wav");
// gibs /* gibs */
gi.soundindex("items/respawn1.wav"); gi.soundindex("items/respawn1.wav");
// sexed sounds /* sexed sounds */
gi.soundindex("*death1.wav"); gi.soundindex("*death1.wav");
gi.soundindex("*death2.wav"); gi.soundindex("*death2.wav");
gi.soundindex("*death3.wav"); gi.soundindex("*death3.wav");
gi.soundindex("*death4.wav"); gi.soundindex("*death4.wav");
gi.soundindex("*fall1.wav"); gi.soundindex("*fall1.wav");
gi.soundindex("*fall2.wav"); gi.soundindex("*fall2.wav");
gi.soundindex ("*gurp1.wav"); // drowning damage gi.soundindex("*gurp1.wav"); /* drowning damage */
gi.soundindex("*gurp2.wav"); gi.soundindex("*gurp2.wav");
gi.soundindex ("*jump1.wav"); // player jump gi.soundindex("*jump1.wav"); /* player jump */
gi.soundindex("*pain25_1.wav"); gi.soundindex("*pain25_1.wav");
gi.soundindex("*pain25_2.wav"); gi.soundindex("*pain25_2.wav");
gi.soundindex("*pain50_1.wav"); gi.soundindex("*pain50_1.wav");
@ -855,9 +949,9 @@ void SP_worldspawn (edict_t *ent)
gi.soundindex("*pain100_1.wav"); gi.soundindex("*pain100_1.wav");
gi.soundindex("*pain100_2.wav"); gi.soundindex("*pain100_2.wav");
// sexed models /* sexed models you can add more, max 15
// THIS ORDER MUST MATCH THE DEFINES IN g_local.h THIS ORDER MUST MATCH THE DEFINES IN
// you can add more, max 15 g_local.h */
gi.modelindex("#w_blaster.md2"); gi.modelindex("#w_blaster.md2");
gi.modelindex("#w_shotgun.md2"); gi.modelindex("#w_shotgun.md2");
gi.modelindex("#w_sshotgun.md2"); gi.modelindex("#w_sshotgun.md2");
@ -870,22 +964,22 @@ void SP_worldspawn (edict_t *ent)
gi.modelindex("#w_railgun.md2"); gi.modelindex("#w_railgun.md2");
gi.modelindex("#w_bfg.md2"); gi.modelindex("#w_bfg.md2");
//------------------- /* ------------------- */
gi.soundindex ("player/gasp1.wav"); // gasping for air gi.soundindex("player/gasp1.wav"); /* gasping for air */
gi.soundindex ("player/gasp2.wav"); // head breaking surface, not gasping gi.soundindex("player/gasp2.wav"); /* head breaking surface, not gasping */
gi.soundindex ("player/watr_in.wav"); // feet hitting water gi.soundindex("player/watr_in.wav"); /* feet hitting water */
gi.soundindex ("player/watr_out.wav"); // feet leaving water gi.soundindex("player/watr_out.wav"); /* feet leaving water */
gi.soundindex ("player/watr_un.wav"); // head going underwater gi.soundindex("player/watr_un.wav"); /* head going underwater */
gi.soundindex("player/u_breath1.wav"); gi.soundindex("player/u_breath1.wav");
gi.soundindex("player/u_breath2.wav"); gi.soundindex("player/u_breath2.wav");
gi.soundindex ("items/pkup.wav"); // bonus item pickup gi.soundindex("items/pkup.wav"); /* bonus item pickup */
gi.soundindex ("world/land.wav"); // landing thud gi.soundindex("world/land.wav"); /* landing thud */
gi.soundindex ("misc/h2ohit1.wav"); // landing splash gi.soundindex("misc/h2ohit1.wav"); /* landing splash */
gi.soundindex("items/damage.wav"); gi.soundindex("items/damage.wav");
gi.soundindex("items/protect.wav"); gi.soundindex("items/protect.wav");
@ -902,49 +996,48 @@ void SP_worldspawn (edict_t *ent)
gi.modelindex("models/objects/gibs/skull/tris.md2"); gi.modelindex("models/objects/gibs/skull/tris.md2");
gi.modelindex("models/objects/gibs/head2/tris.md2"); gi.modelindex("models/objects/gibs/head2/tris.md2");
// /* Setup light animation tables. 'a'
// Setup light animation tables. 'a' is total darkness, 'z' is doublebright. is total darkness, 'z' is doublebright. */
//
// 0 normal /* 0 normal */
gi.configstring(CS_LIGHTS + 0, "m"); gi.configstring(CS_LIGHTS + 0, "m");
// 1 FLICKER (first variety) /* 1 FLICKER (first variety) */
gi.configstring(CS_LIGHTS + 1, "mmnmmommommnonmmonqnmmo"); gi.configstring(CS_LIGHTS + 1, "mmnmmommommnonmmonqnmmo");
// 2 SLOW STRONG PULSE /* 2 SLOW STRONG PULSE */
gi.configstring(CS_LIGHTS + 2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); gi.configstring(CS_LIGHTS + 2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
// 3 CANDLE (first variety) /* 3 CANDLE (first variety) */
gi.configstring(CS_LIGHTS + 3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); gi.configstring(CS_LIGHTS + 3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
// 4 FAST STROBE /* 4 FAST STROBE */
gi.configstring(CS_LIGHTS + 4, "mamamamamama"); gi.configstring(CS_LIGHTS + 4, "mamamamamama");
// 5 GENTLE PULSE 1 /* 5 GENTLE PULSE 1 */
gi.configstring(CS_LIGHTS + 5, "jklmnopqrstuvwxyzyxwvutsrqponmlkj"); gi.configstring(CS_LIGHTS + 5, "jklmnopqrstuvwxyzyxwvutsrqponmlkj");
// 6 FLICKER (second variety) /* 6 FLICKER (second variety) */
gi.configstring(CS_LIGHTS + 6, "nmonqnmomnmomomno"); gi.configstring(CS_LIGHTS + 6, "nmonqnmomnmomomno");
// 7 CANDLE (second variety) /* 7 CANDLE (second variety) */
gi.configstring(CS_LIGHTS + 7, "mmmaaaabcdefgmmmmaaaammmaamm"); gi.configstring(CS_LIGHTS + 7, "mmmaaaabcdefgmmmmaaaammmaamm");
// 8 CANDLE (third variety) /* 8 CANDLE (third variety) */
gi.configstring(CS_LIGHTS + 8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); gi.configstring(CS_LIGHTS + 8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
// 9 SLOW STROBE (fourth variety) /* 9 SLOW STROBE (fourth variety) */
gi.configstring(CS_LIGHTS + 9, "aaaaaaaazzzzzzzz"); gi.configstring(CS_LIGHTS + 9, "aaaaaaaazzzzzzzz");
// 10 FLUORESCENT FLICKER /* 10 FLUORESCENT FLICKER */
gi.configstring(CS_LIGHTS + 10, "mmamammmmammamamaaamammma"); gi.configstring(CS_LIGHTS + 10, "mmamammmmammamamaaamammma");
// 11 SLOW PULSE NOT FADE TO BLACK /* 11 SLOW PULSE NOT FADE TO BLACK */
gi.configstring(CS_LIGHTS + 11, "abcdefghijklmnopqrrqponmlkjihgfedcba"); gi.configstring(CS_LIGHTS + 11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
// styles 32-62 are assigned by the light program for switchable lights /* styles 32-62 are assigned by the light program for switchable lights */
// 63 testing /* 63 testing */
gi.configstring(CS_LIGHTS + 63, "a"); gi.configstring(CS_LIGHTS + 63, "a");
} }