summaryrefslogtreecommitdiff
path: root/src/baseq2/p_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/baseq2/p_client.c')
-rw-r--r--src/baseq2/p_client.c792
1 files changed, 351 insertions, 441 deletions
diff --git a/src/baseq2/p_client.c b/src/baseq2/p_client.c
index 6b1033f..ddabcb6 100644
--- a/src/baseq2/p_client.c
+++ b/src/baseq2/p_client.c
@@ -8,7 +8,7 @@ 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.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
@@ -20,9 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "g_local.h"
#include "m_player.h"
-void ClientUserinfoChanged (edict_t *ent, char *userinfo);
+void ClientUserinfoChanged(edict_t *ent, char *userinfo);
-void SP_misc_teleporter_dest (edict_t *ent);
+void SP_misc_teleporter_dest(edict_t *ent);
//
// Gross, ugly, disgustuing hack section
@@ -36,25 +36,22 @@ void SP_misc_teleporter_dest (edict_t *ent);
// we use carnal knowledge of the maps to fix the coop spot targetnames to match
// that of the nearest named single player spot
-void SP_FixCoopSpots (edict_t *self)
+void SP_FixCoopSpots(edict_t *self)
{
edict_t *spot;
vec3_t d;
spot = NULL;
- while(1)
- {
+ while (1) {
spot = G_Find(spot, FOFS(classname), "info_player_start");
if (!spot)
return;
if (!spot->targetname)
continue;
VectorSubtract(self->s.origin, spot->s.origin, d);
- if (VectorLength(d) < 384)
- {
- if ((!self->targetname) || Q_stricmp(self->targetname, spot->targetname) != 0)
- {
+ if (VectorLength(d) < 384) {
+ if ((!self->targetname) || Q_stricmp(self->targetname, spot->targetname) != 0) {
// gi.dprintf("FixCoopSpots changed %s at %s targetname from %s to %s\n", self->classname, vtos(self->s.origin), self->targetname, spot->targetname);
self->targetname = spot->targetname;
}
@@ -67,12 +64,11 @@ void SP_FixCoopSpots (edict_t *self)
// some maps don't have any coop spots at all, so we need to create them
// where they should have been
-void SP_CreateCoopSpots (edict_t *self)
+void SP_CreateCoopSpots(edict_t *self)
{
edict_t *spot;
- if(Q_stricmp(level.mapname, "security") == 0)
- {
+ if (Q_stricmp(level.mapname, "security") == 0) {
spot = G_Spawn();
spot->classname = "info_player_coop";
spot->s.origin[0] = 188 - 64;
@@ -109,8 +105,7 @@ void SP_info_player_start(edict_t *self)
{
if (!coop->value)
return;
- if(Q_stricmp(level.mapname, "security") == 0)
- {
+ if (Q_stricmp(level.mapname, "security") == 0) {
// invoke one of our gross, ugly, disgusting hacks
self->think = SP_CreateCoopSpots;
self->nextthink = level.time + FRAMETIME;
@@ -122,12 +117,11 @@ potential spawning position for deathmatch games
*/
void SP_info_player_deathmatch(edict_t *self)
{
- if (!deathmatch->value)
- {
- G_FreeEdict (self);
+ if (!deathmatch->value) {
+ G_FreeEdict(self);
return;
}
- SP_misc_teleporter_dest (self);
+ SP_misc_teleporter_dest(self);
}
/*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 32)
@@ -136,27 +130,25 @@ potential spawning position for coop games
void SP_info_player_coop(edict_t *self)
{
- if (!coop->value)
- {
- G_FreeEdict (self);
+ if (!coop->value) {
+ G_FreeEdict(self);
return;
}
- if((Q_stricmp(level.mapname, "jail2") == 0) ||
- (Q_stricmp(level.mapname, "jail4") == 0) ||
- (Q_stricmp(level.mapname, "mine1") == 0) ||
- (Q_stricmp(level.mapname, "mine2") == 0) ||
- (Q_stricmp(level.mapname, "mine3") == 0) ||
- (Q_stricmp(level.mapname, "mine4") == 0) ||
- (Q_stricmp(level.mapname, "lab") == 0) ||
- (Q_stricmp(level.mapname, "boss1") == 0) ||
- (Q_stricmp(level.mapname, "fact3") == 0) ||
- (Q_stricmp(level.mapname, "biggun") == 0) ||
- (Q_stricmp(level.mapname, "space") == 0) ||
- (Q_stricmp(level.mapname, "command") == 0) ||
- (Q_stricmp(level.mapname, "power2") == 0) ||
- (Q_stricmp(level.mapname, "strike") == 0))
- {
+ if ((Q_stricmp(level.mapname, "jail2") == 0) ||
+ (Q_stricmp(level.mapname, "jail4") == 0) ||
+ (Q_stricmp(level.mapname, "mine1") == 0) ||
+ (Q_stricmp(level.mapname, "mine2") == 0) ||
+ (Q_stricmp(level.mapname, "mine3") == 0) ||
+ (Q_stricmp(level.mapname, "mine4") == 0) ||
+ (Q_stricmp(level.mapname, "lab") == 0) ||
+ (Q_stricmp(level.mapname, "boss1") == 0) ||
+ (Q_stricmp(level.mapname, "fact3") == 0) ||
+ (Q_stricmp(level.mapname, "biggun") == 0) ||
+ (Q_stricmp(level.mapname, "space") == 0) ||
+ (Q_stricmp(level.mapname, "command") == 0) ||
+ (Q_stricmp(level.mapname, "power2") == 0) ||
+ (Q_stricmp(level.mapname, "strike") == 0)) {
// invoke one of our gross, ugly, disgusting hacks
self->think = SP_FixCoopSpots;
self->nextthink = level.time + FRAMETIME;
@@ -176,39 +168,39 @@ void SP_info_player_intermission(void)
//=======================================================================
-void player_pain (edict_t *self, edict_t *other, float kick, int damage)
+void player_pain(edict_t *self, edict_t *other, float kick, int damage)
{
// player pain is handled at the end of the frame in P_DamageFeedback
}
-qboolean IsFemale (edict_t *ent)
+qboolean IsFemale(edict_t *ent)
{
char *info;
if (!ent->client)
return qfalse;
- info = Info_ValueForKey (ent->client->pers.userinfo, "gender");
+ info = Info_ValueForKey(ent->client->pers.userinfo, "gender");
if (info[0] == 'f' || info[0] == 'F')
return qtrue;
return qfalse;
}
-qboolean IsNeutral (edict_t *ent)
+qboolean IsNeutral(edict_t *ent)
{
char *info;
if (!ent->client)
return qfalse;
- info = Info_ValueForKey (ent->client->pers.userinfo, "gender");
+ info = Info_ValueForKey(ent->client->pers.userinfo, "gender");
if (info[0] != 'f' && info[0] != 'F' && info[0] != 'm' && info[0] != 'M')
return qtrue;
return qfalse;
}
-void ClientObituary (edict_t *self, edict_t *inflictor, edict_t *attacker)
+void ClientObituary(edict_t *self, edict_t *inflictor, edict_t *attacker)
{
int mod;
char *message;
@@ -218,15 +210,13 @@ void ClientObituary (edict_t *self, edict_t *inflictor, edict_t *attacker)
if (coop->value && attacker->client)
meansOfDeath |= MOD_FRIENDLY_FIRE;
- if (deathmatch->value || coop->value)
- {
+ if (deathmatch->value || coop->value) {
ff = meansOfDeath & MOD_FRIENDLY_FIRE;
mod = meansOfDeath & ~MOD_FRIENDLY_FIRE;
message = NULL;
message2 = "";
- switch (mod)
- {
+ switch (mod) {
case MOD_SUICIDE:
message = "suicides";
break;
@@ -264,10 +254,8 @@ void ClientObituary (edict_t *self, edict_t *inflictor, edict_t *attacker)
message = "was in the wrong place";
break;
}
- if (attacker == self)
- {
- switch (mod)
- {
+ if (attacker == self) {
+ switch (mod) {
case MOD_HELD_GRENADE:
message = "tried to put the pin back in";
break;
@@ -301,9 +289,8 @@ void ClientObituary (edict_t *self, edict_t *inflictor, edict_t *attacker)
break;
}
}
- if (message)
- {
- gi.bprintf (PRINT_MEDIUM, "%s %s.\n", self->client->pers.netname, message);
+ if (message) {
+ gi.bprintf(PRINT_MEDIUM, "%s %s.\n", self->client->pers.netname, message);
if (deathmatch->value)
self->client->resp.score--;
self->enemy = NULL;
@@ -311,10 +298,8 @@ void ClientObituary (edict_t *self, edict_t *inflictor, edict_t *attacker)
}
self->enemy = attacker;
- if (attacker && attacker->client)
- {
- switch (mod)
- {
+ if (attacker && attacker->client) {
+ switch (mod) {
case MOD_BLASTER:
message = "was blasted by";
break;
@@ -384,11 +369,9 @@ void ClientObituary (edict_t *self, edict_t *inflictor, edict_t *attacker)
message2 = "'s personal space";
break;
}
- if (message)
- {
- gi.bprintf (PRINT_MEDIUM,"%s %s %s%s\n", self->client->pers.netname, message, attacker->client->pers.netname, message2);
- if (deathmatch->value)
- {
+ if (message) {
+ gi.bprintf(PRINT_MEDIUM, "%s %s %s%s\n", self->client->pers.netname, message, attacker->client->pers.netname, message2);
+ if (deathmatch->value) {
if (ff)
attacker->client->resp.score--;
else
@@ -399,15 +382,15 @@ void ClientObituary (edict_t *self, edict_t *inflictor, edict_t *attacker)
}
}
- gi.bprintf (PRINT_MEDIUM,"%s died.\n", self->client->pers.netname);
+ gi.bprintf(PRINT_MEDIUM, "%s died.\n", self->client->pers.netname);
if (deathmatch->value)
self->client->resp.score--;
}
-void Touch_Item (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);
+void Touch_Item(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);
-void TossClientWeapon (edict_t *self)
+void TossClientWeapon(edict_t *self)
{
gitem_t *item;
edict_t *drop;
@@ -418,9 +401,9 @@ void TossClientWeapon (edict_t *self)
return;
item = self->client->pers.weapon;
- if (! self->client->pers.inventory[self->client->ammo_index] )
+ if (! self->client->pers.inventory[self->client->ammo_index])
item = NULL;
- if (item && (strcmp (item->pickup_name, "Blaster") == 0))
+ if (item && (strcmp(item->pickup_name, "Blaster") == 0))
item = NULL;
if (!((int)(dmflags->value) & DF_QUAD_DROP))
@@ -433,18 +416,16 @@ void TossClientWeapon (edict_t *self)
else
spread = 0.0;
- if (item)
- {
+ if (item) {
self->client->v_angle[YAW] -= spread;
- drop = Drop_Item (self, item);
+ drop = Drop_Item(self, item);
self->client->v_angle[YAW] += spread;
drop->spawnflags = DROPPED_PLAYER_ITEM;
}
- if (quad)
- {
+ if (quad) {
self->client->v_angle[YAW] += spread;
- drop = Drop_Item (self, FindItemByClassname ("item_quad"));
+ drop = Drop_Item(self, FindItemByClassname("item_quad"));
self->client->v_angle[YAW] -= spread;
drop->spawnflags |= DROPPED_PLAYER_ITEM;
@@ -460,26 +441,21 @@ void TossClientWeapon (edict_t *self)
LookAtKiller
==================
*/
-void LookAtKiller (edict_t *self, edict_t *inflictor, edict_t *attacker)
+void LookAtKiller(edict_t *self, edict_t *inflictor, edict_t *attacker)
{
vec3_t dir;
- if (attacker && attacker != world && attacker != self)
- {
- VectorSubtract (attacker->s.origin, self->s.origin, dir);
- }
- else if (inflictor && inflictor != world && inflictor != self)
- {
- VectorSubtract (inflictor->s.origin, self->s.origin, dir);
- }
- else
- {
+ if (attacker && attacker != world && attacker != self) {
+ VectorSubtract(attacker->s.origin, self->s.origin, dir);
+ } else if (inflictor && inflictor != world && inflictor != self) {
+ VectorSubtract(inflictor->s.origin, self->s.origin, dir);
+ } else {
self->client->killer_yaw = self->s.angles[YAW];
return;
}
if (dir[0])
- self->client->killer_yaw = 180/M_PI*atan2(dir[1], dir[0]);
+ self->client->killer_yaw = 180 / M_PI * atan2(dir[1], dir[0]);
else {
self->client->killer_yaw = 0;
if (dir[1] > 0)
@@ -489,7 +465,7 @@ void LookAtKiller (edict_t *self, edict_t *inflictor, edict_t *attacker)
}
if (self->client->killer_yaw < 0)
self->client->killer_yaw += 360;
-
+
}
@@ -498,11 +474,11 @@ void LookAtKiller (edict_t *self, edict_t *inflictor, edict_t *attacker)
player_die
==================
*/
-void player_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
+void player_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
{
int n;
- VectorClear (self->avelocity);
+ VectorClear(self->avelocity);
self->takedamage = DAMAGE_YES;
self->movetype = MOVETYPE_TOSS;
@@ -520,20 +496,18 @@ void player_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damag
// self->solid = SOLID_NOT;
self->svflags |= SVF_DEADMONSTER;
- if (!self->deadflag)
- {
+ if (!self->deadflag) {
self->client->respawn_time = level.time + 1.0;
- LookAtKiller (self, inflictor, attacker);
+ LookAtKiller(self, inflictor, attacker);
self->client->ps.pmove.pm_type = PM_DEAD;
- ClientObituary (self, inflictor, attacker);
- TossClientWeapon (self);
+ ClientObituary(self, inflictor, attacker);
+ TossClientWeapon(self);
if (deathmatch->value)
- Cmd_Help_f (self); // show scores
+ Cmd_Help_f(self); // show scores
// clear inventory
// this is kind of ugly, but it's how we want to handle keys in coop
- for (n = 0; n < game.num_items; n++)
- {
+ for (n = 0; n < game.num_items; n++) {
if (coop->value && itemlist[n].flags & IT_KEY)
self->client->resp.coop_respawn.inventory[n] = self->client->pers.inventory[n];
self->client->pers.inventory[n] = 0;
@@ -547,51 +521,46 @@ void player_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damag
self->client->enviro_framenum = 0;
self->flags &= ~FL_POWER_ARMOR;
- if (self->health < -40)
- { // gib
- gi.sound (self, CHAN_BODY, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0);
- for (n= 0; n < 4; n++)
- ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
- ThrowClientHead (self, damage);
+ if (self->health < -40) {
+ // gib
+ gi.sound(self, CHAN_BODY, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0);
+ for (n = 0; n < 4; n++)
+ ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
+ ThrowClientHead(self, damage);
self->takedamage = DAMAGE_NO;
- }
- else
- { // normal death
- if (!self->deadflag)
- {
+ } else {
+ // normal death
+ if (!self->deadflag) {
static int i;
- i = (i+1)%3;
+ i = (i + 1) % 3;
// start a death animation
self->client->anim_priority = ANIM_DEATH;
- if (self->client->ps.pmove.pm_flags & PMF_DUCKED)
- {
- self->s.frame = FRAME_crdeath1-1;
+ if (self->client->ps.pmove.pm_flags & PMF_DUCKED) {
+ self->s.frame = FRAME_crdeath1 - 1;
self->client->anim_end = FRAME_crdeath5;
- }
- else switch (i)
- {
- case 0:
- self->s.frame = FRAME_death101-1;
- self->client->anim_end = FRAME_death106;
- break;
- case 1:
- self->s.frame = FRAME_death201-1;
- self->client->anim_end = FRAME_death206;
- break;
- case 2:
- self->s.frame = FRAME_death301-1;
- self->client->anim_end = FRAME_death308;
- break;
- }
- gi.sound (self, CHAN_VOICE, gi.soundindex(va("*death%i.wav", (rand()%4)+1)), 1, ATTN_NORM, 0);
+ } else switch (i) {
+ case 0:
+ self->s.frame = FRAME_death101 - 1;
+ self->client->anim_end = FRAME_death106;
+ break;
+ case 1:
+ self->s.frame = FRAME_death201 - 1;
+ self->client->anim_end = FRAME_death206;
+ break;
+ case 2:
+ self->s.frame = FRAME_death301 - 1;
+ self->client->anim_end = FRAME_death308;
+ break;
+ }
+ gi.sound(self, CHAN_VOICE, gi.soundindex(va("*death%i.wav", (rand() % 4) + 1)), 1, ATTN_NORM, 0);
}
}
self->deadflag = DEAD_DEAD;
- gi.linkentity (self);
+ gi.linkentity(self);
}
//=======================================================================
@@ -604,11 +573,11 @@ This is only called when the game first initializes in single player,
but is called after each death and level change in deathmatch
==============
*/
-void InitClientPersistant (gclient_t *client)
+void InitClientPersistant(gclient_t *client)
{
gitem_t *item;
- memset (&client->pers, 0, sizeof(client->pers));
+ memset(&client->pers, 0, sizeof(client->pers));
item = FindItem("Blaster");
client->pers.selected_item = ITEM_INDEX(item);
@@ -630,9 +599,9 @@ void InitClientPersistant (gclient_t *client)
}
-void InitClientResp (gclient_t *client)
+void InitClientResp(gclient_t *client)
{
- memset (&client->resp, 0, sizeof(client->resp));
+ memset(&client->resp, 0, sizeof(client->resp));
client->resp.enterframe = level.framenum;
client->resp.coop_respawn = client->pers;
}
@@ -641,31 +610,30 @@ void InitClientResp (gclient_t *client)
==================
SaveClientData
-Some information that should be persistant, like health,
+Some information that should be persistant, like health,
is still stored in the edict structure, so it needs to
be mirrored out to the client structure before all the
edicts are wiped.
==================
*/
-void SaveClientData (void)
+void SaveClientData(void)
{
int i;
edict_t *ent;
- for (i=0 ; i<game.maxclients ; i++)
- {
- ent = &g_edicts[1+i];
+ for (i = 0 ; i < game.maxclients ; i++) {
+ ent = &g_edicts[1 + i];
if (!ent->inuse)
continue;
game.clients[i].pers.health = ent->health;
game.clients[i].pers.max_health = ent->max_health;
- game.clients[i].pers.savedFlags = (ent->flags & (FL_GODMODE|FL_NOTARGET|FL_POWER_ARMOR));
+ game.clients[i].pers.savedFlags = (ent->flags & (FL_GODMODE | FL_NOTARGET | FL_POWER_ARMOR));
if (coop->value)
game.clients[i].pers.score = ent->client->resp.score;
}
}
-void FetchClientEntData (edict_t *ent)
+void FetchClientEntData(edict_t *ent)
{
ent->health = ent->client->pers.health;
ent->max_health = ent->client->pers.max_health;
@@ -691,7 +659,7 @@ PlayersRangeFromSpot
Returns the distance to the nearest player from the given spot
================
*/
-float PlayersRangeFromSpot (edict_t *spot)
+float PlayersRangeFromSpot(edict_t *spot)
{
edict_t *player;
float bestplayerdistance;
@@ -702,8 +670,7 @@ float PlayersRangeFromSpot (edict_t *spot)
bestplayerdistance = 9999999;
- for (n = 1; n <= maxclients->value; n++)
- {
+ for (n = 1; n <= maxclients->value; n++) {
player = &g_edicts[n];
if (!player->inuse)
@@ -712,8 +679,8 @@ float PlayersRangeFromSpot (edict_t *spot)
if (player->health <= 0)
continue;
- VectorSubtract (spot->s.origin, player->s.origin, v);
- playerdistance = VectorLength (v);
+ VectorSubtract(spot->s.origin, player->s.origin, v);
+ playerdistance = VectorLength(v);
if (playerdistance < bestplayerdistance)
bestplayerdistance = playerdistance;
@@ -730,7 +697,7 @@ go to a random point, but NOT the two points closest
to other players
================
*/
-edict_t *SelectRandomDeathmatchSpawnPoint (void)
+edict_t *SelectRandomDeathmatchSpawnPoint(void)
{
edict_t *spot, *spot1, *spot2;
int count = 0;
@@ -741,17 +708,13 @@ edict_t *SelectRandomDeathmatchSpawnPoint (void)
range1 = range2 = 99999;
spot1 = spot2 = NULL;
- while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL)
- {
+ while ((spot = G_Find(spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
count++;
range = PlayersRangeFromSpot(spot);
- if (range < range1)
- {
+ if (range < range1) {
range1 = range;
spot1 = spot;
- }
- else if (range < range2)
- {
+ } else if (range < range2) {
range2 = range;
spot2 = spot;
}
@@ -760,22 +723,19 @@ edict_t *SelectRandomDeathmatchSpawnPoint (void)
if (!count)
return NULL;
- if (count <= 2)
- {
+ if (count <= 2) {
spot1 = spot2 = NULL;
- }
- else
+ } else
count -= 2;
selection = rand() % count;
spot = NULL;
- do
- {
- spot = G_Find (spot, FOFS(classname), "info_player_deathmatch");
+ do {
+ spot = G_Find(spot, FOFS(classname), "info_player_deathmatch");
if (spot == spot1 || spot == spot2)
selection++;
- } while(selection--);
+ } while (selection--);
return spot;
}
@@ -786,7 +746,7 @@ SelectFarthestDeathmatchSpawnPoint
================
*/
-edict_t *SelectFarthestDeathmatchSpawnPoint (void)
+edict_t *SelectFarthestDeathmatchSpawnPoint(void)
{
edict_t *bestspot;
float bestdistance, bestplayerdistance;
@@ -796,39 +756,36 @@ edict_t *SelectFarthestDeathmatchSpawnPoint (void)
spot = NULL;
bestspot = NULL;
bestdistance = 0;
- while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL)
- {
- bestplayerdistance = PlayersRangeFromSpot (spot);
+ while ((spot = G_Find(spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
+ bestplayerdistance = PlayersRangeFromSpot(spot);
- if (bestplayerdistance > bestdistance)
- {
+ if (bestplayerdistance > bestdistance) {
bestspot = spot;
bestdistance = bestplayerdistance;
}
}
- if (bestspot)
- {
+ if (bestspot) {
return bestspot;
}
// if there is a player just spawned on each and every start spot
// we have no choice to turn one into a telefrag meltdown
- spot = G_Find (NULL, FOFS(classname), "info_player_deathmatch");
+ spot = G_Find(NULL, FOFS(classname), "info_player_deathmatch");
return spot;
}
-edict_t *SelectDeathmatchSpawnPoint (void)
+edict_t *SelectDeathmatchSpawnPoint(void)
{
- if ( (int)(dmflags->value) & DF_SPAWN_FARTHEST)
- return SelectFarthestDeathmatchSpawnPoint ();
+ if ((int)(dmflags->value) & DF_SPAWN_FARTHEST)
+ return SelectFarthestDeathmatchSpawnPoint();
else
- return SelectRandomDeathmatchSpawnPoint ();
+ return SelectRandomDeathmatchSpawnPoint();
}
-edict_t *SelectCoopSpawnPoint (edict_t *ent)
+edict_t *SelectCoopSpawnPoint(edict_t *ent)
{
int index;
edict_t *spot = NULL;
@@ -843,17 +800,16 @@ edict_t *SelectCoopSpawnPoint (edict_t *ent)
spot = NULL;
// assume there are four coop spots at each spawnpoint
- while (1)
- {
- spot = G_Find (spot, FOFS(classname), "info_player_coop");
+ while (1) {
+ spot = G_Find(spot, FOFS(classname), "info_player_coop");
if (!spot)
return NULL; // we didn't have enough...
target = spot->targetname;
if (!target)
target = "";
- if ( Q_stricmp(game.spawnpoint, target) == 0 )
- { // this is a coop spawn point for one of the clients here
+ if (Q_stricmp(game.spawnpoint, target) == 0) {
+ // this is a coop spawn point for one of the clients here
index--;
if (!index)
return spot; // this is it
@@ -872,20 +828,18 @@ SelectSpawnPoint
Chooses a player start, deathmatch start, coop start, etc
============
*/
-void SelectSpawnPoint (edict_t *ent, vec3_t origin, vec3_t angles)
+void SelectSpawnPoint(edict_t *ent, vec3_t origin, vec3_t angles)
{
edict_t *spot = NULL;
if (deathmatch->value)
- spot = SelectDeathmatchSpawnPoint ();
+ spot = SelectDeathmatchSpawnPoint();
else if (coop->value)
- spot = SelectCoopSpawnPoint (ent);
+ spot = SelectCoopSpawnPoint(ent);
// find a single player start spot
- if (!spot)
- {
- while ((spot = G_Find (spot, FOFS(classname), "info_player_start")) != NULL)
- {
+ if (!spot) {
+ while ((spot = G_Find(spot, FOFS(classname), "info_player_start")) != NULL) {
if (!game.spawnpoint[0] && !spot->targetname)
break;
@@ -896,86 +850,82 @@ void SelectSpawnPoint (edict_t *ent, vec3_t origin, vec3_t angles)
break;
}
- if (!spot)
- {
- if (!game.spawnpoint[0])
- { // there wasn't a spawnpoint without a target, so use any
- spot = G_Find (spot, FOFS(classname), "info_player_start");
+ if (!spot) {
+ if (!game.spawnpoint[0]) {
+ // there wasn't a spawnpoint without a target, so use any
+ spot = G_Find(spot, FOFS(classname), "info_player_start");
}
if (!spot)
- gi.error ("Couldn't find spawn point %s\n", game.spawnpoint);
+ gi.error("Couldn't find spawn point %s\n", game.spawnpoint);
}
}
- VectorCopy (spot->s.origin, origin);
+ VectorCopy(spot->s.origin, origin);
origin[2] += 9;
- VectorCopy (spot->s.angles, angles);
+ VectorCopy(spot->s.angles, angles);
}
//======================================================================
-void InitBodyQue (void)
+void InitBodyQue(void)
{
int i;
edict_t *ent;
level.body_que = 0;
- for (i=0; i<BODY_QUEUE_SIZE ; i++)
- {
+ for (i = 0; i < BODY_QUEUE_SIZE ; i++) {
ent = G_Spawn();
ent->classname = "bodyque";
}
}
-void body_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
+void body_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
{
int n;
- if (self->health < -40)
- {
- gi.sound (self, CHAN_BODY, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0);
- for (n= 0; n < 4; n++)
- ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
+ if (self->health < -40) {
+ gi.sound(self, CHAN_BODY, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0);
+ for (n = 0; n < 4; n++)
+ ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
self->s.origin[2] -= 48;
- ThrowClientHead (self, damage);
+ ThrowClientHead(self, damage);
self->takedamage = DAMAGE_NO;
}
}
-void CopyToBodyQue (edict_t *ent)
+void CopyToBodyQue(edict_t *ent)
{
edict_t *body;
- gi.unlinkentity (ent);
+ gi.unlinkentity(ent);
// grab a body que and cycle to the next one
body = &g_edicts[game.maxclients + level.body_que + 1];
level.body_que = (level.body_que + 1) % BODY_QUEUE_SIZE;
// send an effect on the removed body
- if (body->s.modelindex)
- {
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_BLOOD);
- gi.WritePosition (body->s.origin);
- gi.WriteDir (vec3_origin);
- gi.multicast (body->s.origin, MULTICAST_PVS);
- }
-
- gi.unlinkentity (body);
+ if (body->s.modelindex) {
+ gi.WriteByte(svc_temp_entity);
+ gi.WriteByte(TE_BLOOD);
+ gi.WritePosition(body->s.origin);
+ gi.WriteDir(vec3_origin);
+ gi.multicast(body->s.origin, MULTICAST_PVS);
+ }
+
+ gi.unlinkentity(body);
body->s = ent->s;
body->s.number = body - g_edicts;
body->s.event = EV_OTHER_TELEPORT;
body->svflags = ent->svflags;
- VectorCopy (ent->mins, body->mins);
- VectorCopy (ent->maxs, body->maxs);
- VectorCopy (ent->absmin, body->absmin);
- VectorCopy (ent->absmax, body->absmax);
- VectorCopy (ent->size, body->size);
- VectorCopy (ent->velocity, body->velocity);
- VectorCopy (ent->avelocity, body->avelocity);
+ VectorCopy(ent->mins, body->mins);
+ VectorCopy(ent->maxs, body->maxs);
+ VectorCopy(ent->absmin, body->absmin);
+ VectorCopy(ent->absmax, body->absmax);
+ VectorCopy(ent->size, body->size);
+ VectorCopy(ent->velocity, body->velocity);
+ VectorCopy(ent->avelocity, body->avelocity);
body->solid = ent->solid;
body->clipmask = ent->clipmask;
body->owner = ent->owner;
@@ -985,18 +935,17 @@ void CopyToBodyQue (edict_t *ent)
body->die = body_die;
body->takedamage = DAMAGE_YES;
- gi.linkentity (body);
+ gi.linkentity(body);
}
-void respawn (edict_t *self)
+void respawn(edict_t *self)
{
- if (deathmatch->value || coop->value)
- {
+ if (deathmatch->value || coop->value) {
// spectator's don't leave bodies
if (self->movetype != MOVETYPE_NOCLIP)
- CopyToBodyQue (self);
+ CopyToBodyQue(self);
self->svflags &= ~SVF_NOCLIENT;
- PutClientInServer (self);
+ PutClientInServer(self);
// add a teleportation effect
self->s.event = EV_PLAYER_TELEPORT;
@@ -1011,14 +960,14 @@ void respawn (edict_t *self)
}
// restart the entire server
- gi.AddCommandString ("menu_loadgame\n");
+ gi.AddCommandString("menu_loadgame\n");
}
-/*
+/*
* only called when pers.spectator changes
* note that resp.spectator should be the opposite of pers.spectator here
*/
-void spectator_respawn (edict_t *ent)
+void spectator_respawn(edict_t *ent)
{
int i, numspec;
@@ -1026,14 +975,14 @@ void spectator_respawn (edict_t *ent)
// exceed max_spectators
if (ent->client->pers.spectator) {
- char *value = Info_ValueForKey (ent->client->pers.userinfo, "spectator");
- if (*spectator_password->string &&
- strcmp(spectator_password->string, "none") &&
+ char *value = Info_ValueForKey(ent->client->pers.userinfo, "spectator");
+ if (*spectator_password->string &&
+ strcmp(spectator_password->string, "none") &&
strcmp(spectator_password->string, value)) {
gi.cprintf(ent, PRINT_HIGH, "Spectator password incorrect.\n");
ent->client->pers.spectator = qfalse;
- gi.WriteByte (svc_stufftext);
- gi.WriteString ("spectator 0\n");
+ gi.WriteByte(svc_stufftext);
+ gi.WriteString("spectator 0\n");
gi.unicast(ent, qtrue);
return;
}
@@ -1047,21 +996,21 @@ void spectator_respawn (edict_t *ent)
gi.cprintf(ent, PRINT_HIGH, "Server spectator limit is full.");
ent->client->pers.spectator = qfalse;
// reset his spectator var
- gi.WriteByte (svc_stufftext);
- gi.WriteString ("spectator 0\n");
+ gi.WriteByte(svc_stufftext);
+ gi.WriteString("spectator 0\n");
gi.unicast(ent, qtrue);
return;
}
} else {
// he was a spectator and wants to join the game
// he must have the right password
- char *value = Info_ValueForKey (ent->client->pers.userinfo, "password");
- if (*password->string && strcmp(password->string, "none") &&
+ char *value = Info_ValueForKey(ent->client->pers.userinfo, "password");
+ if (*password->string && strcmp(password->string, "none") &&
strcmp(password->string, value)) {
gi.cprintf(ent, PRINT_HIGH, "Password incorrect.\n");
ent->client->pers.spectator = qtrue;
- gi.WriteByte (svc_stufftext);
- gi.WriteString ("spectator 1\n");
+ gi.WriteByte(svc_stufftext);
+ gi.WriteString("spectator 1\n");
gi.unicast(ent, qtrue);
return;
}
@@ -1071,15 +1020,15 @@ void spectator_respawn (edict_t *ent)
ent->client->resp.score = ent->client->pers.score = 0;
ent->svflags &= ~SVF_NOCLIENT;
- PutClientInServer (ent);
+ PutClientInServer(ent);
// add a teleportation effect
if (!ent->client->pers.spectator) {
// send effect
- gi.WriteByte (svc_muzzleflash);
- gi.WriteShort (ent-g_edicts);
- gi.WriteByte (MZ_LOGIN);
- gi.multicast (ent->s.origin, MULTICAST_PVS);
+ gi.WriteByte(svc_muzzleflash);
+ gi.WriteShort(ent - g_edicts);
+ gi.WriteByte(MZ_LOGIN);
+ gi.multicast(ent->s.origin, MULTICAST_PVS);
// hold in place briefly
ent->client->ps.pmove.pm_flags = PMF_TIME_TELEPORT;
@@ -1088,10 +1037,10 @@ void spectator_respawn (edict_t *ent)
ent->client->respawn_time = level.time;
- if (ent->client->pers.spectator)
- gi.bprintf (PRINT_HIGH, "%s has moved to the sidelines\n", ent->client->pers.netname);
+ if (ent->client->pers.spectator)
+ gi.bprintf(PRINT_HIGH, "%s has moved to the sidelines\n", ent->client->pers.netname);
else
- gi.bprintf (PRINT_HIGH, "%s joined the game\n", ent->client->pers.netname);
+ gi.bprintf(PRINT_HIGH, "%s joined the game\n", ent->client->pers.netname);
}
//==============================================================
@@ -1105,9 +1054,9 @@ Called when a player connects to a server or respawns in
a deathmatch.
============
*/
-void PutClientInServer (edict_t *ent)
+void PutClientInServer(edict_t *ent)
{
- vec3_t mins = {-16, -16, -24};
+ vec3_t mins = { -16, -16, -24};
vec3_t maxs = {16, 16, 32};
int index;
vec3_t spawn_origin, spawn_angles;
@@ -1119,28 +1068,25 @@ void PutClientInServer (edict_t *ent)
// find a spawn point
// do it before setting health back up, so farthest
// ranging doesn't count this client
- SelectSpawnPoint (ent, spawn_origin, spawn_angles);
+ SelectSpawnPoint(ent, spawn_origin, spawn_angles);
- index = ent-g_edicts-1;
+ index = ent - g_edicts - 1;
client = ent->client;
// deathmatch wipes most client data every spawn
- if (deathmatch->value)
- {
+ if (deathmatch->value) {
char userinfo[MAX_INFO_STRING];
resp = client->resp;
- memcpy (userinfo, client->pers.userinfo, sizeof(userinfo));
- InitClientPersistant (client);
- ClientUserinfoChanged (ent, userinfo);
- }
- else if (coop->value)
- {
+ memcpy(userinfo, client->pers.userinfo, sizeof(userinfo));
+ InitClientPersistant(client);
+ ClientUserinfoChanged(ent, userinfo);
+ } else if (coop->value) {
// int n;
char userinfo[MAX_INFO_STRING];
resp = client->resp;
- memcpy (userinfo, client->pers.userinfo, sizeof(userinfo));
+ memcpy(userinfo, client->pers.userinfo, sizeof(userinfo));
// this is kind of ugly, but it's how we want to handle keys in coop
// for (n = 0; n < game.num_items; n++)
// {
@@ -1150,25 +1096,23 @@ void PutClientInServer (edict_t *ent)
resp.coop_respawn.game_helpchanged = client->pers.game_helpchanged;
resp.coop_respawn.helpchanged = client->pers.helpchanged;
client->pers = resp.coop_respawn;
- ClientUserinfoChanged (ent, userinfo);
+ ClientUserinfoChanged(ent, userinfo);
if (resp.score > client->pers.score)
client->pers.score = resp.score;
- }
- else
- {
- memset (&resp, 0, sizeof(resp));
+ } else {
+ memset(&resp, 0, sizeof(resp));
}
// clear everything but the persistant data
saved = client->pers;
- memset (client, 0, sizeof(*client));
+ memset(client, 0, sizeof(*client));
client->pers = saved;
if (client->pers.health <= 0)
InitClientPersistant(client);
client->resp = resp;
// copy some data from the client to the entity
- FetchClientEntData (ent);
+ FetchClientEntData(ent);
// clear entity values
ent->groundentity = NULL;
@@ -1191,23 +1135,20 @@ void PutClientInServer (edict_t *ent)
ent->flags &= ~FL_NO_KNOCKBACK;
ent->svflags &= ~SVF_DEADMONSTER;
- VectorCopy (mins, ent->mins);
- VectorCopy (maxs, ent->maxs);
- VectorClear (ent->velocity);
+ VectorCopy(mins, ent->mins);
+ VectorCopy(maxs, ent->maxs);
+ VectorClear(ent->velocity);
// clear playerstate values
- memset (&ent->client->ps, 0, sizeof(client->ps));
+ memset(&ent->client->ps, 0, sizeof(client->ps));
- client->ps.pmove.origin[0] = spawn_origin[0]*8;
- client->ps.pmove.origin[1] = spawn_origin[1]*8;
- client->ps.pmove.origin[2] = spawn_origin[2]*8;
+ client->ps.pmove.origin[0] = spawn_origin[0] * 8;
+ client->ps.pmove.origin[1] = spawn_origin[1] * 8;
+ client->ps.pmove.origin[2] = spawn_origin[2] * 8;
- if (deathmatch->value && ((int)dmflags->value & DF_FIXED_FOV))
- {
+ if (deathmatch->value && ((int)dmflags->value & DF_FIXED_FOV)) {
client->ps.fov = 90;
- }
- else
- {
+ } else {
client->ps.fov = atoi(Info_ValueForKey(client->pers.userinfo, "fov"));
if (client->ps.fov < 1)
client->ps.fov = 90;
@@ -1226,21 +1167,20 @@ void PutClientInServer (edict_t *ent)
ent->s.skinnum = ent - g_edicts - 1;
ent->s.frame = 0;
- VectorCopy (spawn_origin, ent->s.origin);
+ VectorCopy(spawn_origin, ent->s.origin);
ent->s.origin[2] += 1; // make sure off ground
- VectorCopy (ent->s.origin, ent->s.old_origin);
+ VectorCopy(ent->s.origin, ent->s.old_origin);
// set the delta angle
- for (i=0 ; i<3 ; i++)
- {
+ for (i = 0 ; i < 3 ; i++) {
client->ps.pmove.delta_angles[i] = ANGLE2SHORT(spawn_angles[i] - client->resp.cmd_angles[i]);
}
ent->s.angles[PITCH] = 0;
ent->s.angles[YAW] = spawn_angles[YAW];
ent->s.angles[ROLL] = 0;
- VectorCopy (ent->s.angles, client->ps.viewangles);
- VectorCopy (ent->s.angles, client->v_angle);
+ VectorCopy(ent->s.angles, client->ps.viewangles);
+ VectorCopy(ent->s.angles, client->v_angle);
// spawn a spectator
if (client->pers.spectator) {
@@ -1252,56 +1192,53 @@ void PutClientInServer (edict_t *ent)
ent->solid = SOLID_NOT;
ent->svflags |= SVF_NOCLIENT;
ent->client->ps.gunindex = 0;
- gi.linkentity (ent);
+ gi.linkentity(ent);
return;
} else
client->resp.spectator = qfalse;
- if (!KillBox (ent))
- { // could't spawn in?
+ if (!KillBox(ent)) {
+ // could't spawn in?
}
- gi.linkentity (ent);
+ gi.linkentity(ent);
// force the current weapon up
client->newweapon = client->pers.weapon;
- ChangeWeapon (ent);
+ ChangeWeapon(ent);
}
/*
=====================
ClientBeginDeathmatch
-A client has just connected to the server in
+A client has just connected to the server in
deathmatch mode, so clear everything out before starting them.
=====================
*/
-void ClientBeginDeathmatch (edict_t *ent)
+void ClientBeginDeathmatch(edict_t *ent)
{
- G_InitEdict (ent);
+ G_InitEdict(ent);
- InitClientResp (ent->client);
+ InitClientResp(ent->client);
// locate ent at a spawn point
- PutClientInServer (ent);
+ PutClientInServer(ent);
- if (level.intermissiontime)
- {
- MoveClientToIntermission (ent);
- }
- else
- {
+ if (level.intermissiontime) {
+ MoveClientToIntermission(ent);
+ } else {
// send effect
- gi.WriteByte (svc_muzzleflash);
- gi.WriteShort (ent-g_edicts);
- gi.WriteByte (MZ_LOGIN);
- gi.multicast (ent->s.origin, MULTICAST_PVS);
+ gi.WriteByte(svc_muzzleflash);
+ gi.WriteShort(ent - g_edicts);
+ gi.WriteByte(MZ_LOGIN);
+ gi.multicast(ent->s.origin, MULTICAST_PVS);
}
- gi.bprintf (PRINT_HIGH, "%s entered the game\n", ent->client->pers.netname);
+ gi.bprintf(PRINT_HIGH, "%s entered the game\n", ent->client->pers.netname);
// make sure all view stuff is valid
- ClientEndServerFrame (ent);
+ ClientEndServerFrame(ent);
}
@@ -1313,60 +1250,52 @@ called when a client has finished connecting, and is ready
to be placed into the game. This will happen every level load.
============
*/
-void ClientBegin (edict_t *ent)
+void ClientBegin(edict_t *ent)
{
int i;
ent->client = game.clients + (ent - g_edicts - 1);
- if (deathmatch->value)
- {
- ClientBeginDeathmatch (ent);
+ if (deathmatch->value) {
+ ClientBeginDeathmatch(ent);
return;
}
// if there is already a body waiting for us (a loadgame), just
// take it, otherwise spawn one from scratch
- if (ent->inuse == qtrue)
- {
+ if (ent->inuse == qtrue) {
// the client has cleared the client side viewangles upon
// connecting to the server, which is different than the
// state when the game is saved, so we need to compensate
// with deltaangles
- for (i=0 ; i<3 ; i++)
+ for (i = 0 ; i < 3 ; i++)
ent->client->ps.pmove.delta_angles[i] = ANGLE2SHORT(ent->client->ps.viewangles[i]);
- }
- else
- {
+ } else {
// a spawn point will completely reinitialize the entity
// except for the persistant data that was initialized at
// ClientConnect() time
- G_InitEdict (ent);
+ G_InitEdict(ent);
ent->classname = "player";
- InitClientResp (ent->client);
- PutClientInServer (ent);
+ InitClientResp(ent->client);
+ PutClientInServer(ent);
}
- if (level.intermissiontime)
- {
- MoveClientToIntermission (ent);
- }
- else
- {
+ if (level.intermissiontime) {
+ MoveClientToIntermission(ent);
+ } else {
// send effect if in a multiplayer game
- if (game.maxclients > 1)
- {
- gi.WriteByte (svc_muzzleflash);
- gi.WriteShort (ent-g_edicts);
- gi.WriteByte (MZ_LOGIN);
- gi.multicast (ent->s.origin, MULTICAST_PVS);
-
- gi.bprintf (PRINT_HIGH, "%s entered the game\n", ent->client->pers.netname);
+ if (game.maxclients > 1) {
+ gi.WriteByte(svc_muzzleflash);
+ gi.WriteShort(ent - g_edicts);
+ gi.WriteByte(MZ_LOGIN);
+ gi.multicast(ent->s.origin, MULTICAST_PVS);
+
+ gi.bprintf(PRINT_HIGH, "%s entered the game\n", ent->client->pers.netname);
}
}
// make sure all view stuff is valid
- ClientEndServerFrame (ent);
+ ClientEndServerFrame(ent);
}
/*
@@ -1379,23 +1308,22 @@ The game can override any of the settings in place
(forcing skins or names, etc) before copying it off.
============
*/
-void ClientUserinfoChanged (edict_t *ent, char *userinfo)
+void ClientUserinfoChanged(edict_t *ent, char *userinfo)
{
char *s;
int playernum;
// check for malformed or illegal info strings
- if (!Info_Validate(userinfo))
- {
- strcpy (userinfo, "\\name\\badinfo\\skin\\male/grunt");
+ if (!Info_Validate(userinfo)) {
+ strcpy(userinfo, "\\name\\badinfo\\skin\\male/grunt");
}
// set name
- s = Info_ValueForKey (userinfo, "name");
- strncpy (ent->client->pers.netname, s, sizeof(ent->client->pers.netname)-1);
+ s = Info_ValueForKey(userinfo, "name");
+ strncpy(ent->client->pers.netname, s, sizeof(ent->client->pers.netname) - 1);
// set spectator
- s = Info_ValueForKey (userinfo, "spectator");
+ s = Info_ValueForKey(userinfo, "spectator");
// spectators are only supported in deathmatch
if (deathmatch->value && *s && strcmp(s, "0"))
ent->client->pers.spectator = qtrue;
@@ -1403,20 +1331,17 @@ void ClientUserinfoChanged (edict_t *ent, char *userinfo)
ent->client->pers.spectator = qfalse;
// set skin
- s = Info_ValueForKey (userinfo, "skin");
+ s = Info_ValueForKey(userinfo, "skin");
- playernum = ent-g_edicts-1;
+ playernum = ent - g_edicts - 1;
// combine name and skin into a configstring
- gi.configstring (CS_PLAYERSKINS+playernum, va("%s\\%s", ent->client->pers.netname, s) );
+ gi.configstring(CS_PLAYERSKINS + playernum, va("%s\\%s", ent->client->pers.netname, s));
// fov
- if (deathmatch->value && ((int)dmflags->value & DF_FIXED_FOV))
- {
+ if (deathmatch->value && ((int)dmflags->value & DF_FIXED_FOV)) {
ent->client->ps.fov = 90;
- }
- else
- {
+ } else {
ent->client->ps.fov = atoi(Info_ValueForKey(userinfo, "fov"));
if (ent->client->ps.fov < 1)
ent->client->ps.fov = 90;
@@ -1425,14 +1350,13 @@ void ClientUserinfoChanged (edict_t *ent, char *userinfo)
}
// handedness
- s = Info_ValueForKey (userinfo, "hand");
- if (strlen(s))
- {
+ s = Info_ValueForKey(userinfo, "hand");
+ if (strlen(s)) {
ent->client->pers.hand = atoi(s);
}
// save off the userinfo in case we want to check something later
- strncpy (ent->client->pers.userinfo, userinfo, sizeof(ent->client->pers.userinfo)-1);
+ strncpy(ent->client->pers.userinfo, userinfo, sizeof(ent->client->pers.userinfo) - 1);
}
@@ -1448,24 +1372,24 @@ Changing levels will NOT cause this to be called again, but
loadgames will.
============
*/
-qboolean ClientConnect (edict_t *ent, char *userinfo)
+qboolean ClientConnect(edict_t *ent, char *userinfo)
{
char *value;
// check to see if they are on the banned IP list
- value = Info_ValueForKey (userinfo, "ip");
+ value = Info_ValueForKey(userinfo, "ip");
if (SV_FilterPacket(value)) {
Info_SetValueForKey(userinfo, "rejmsg", "Banned.");
return qfalse;
}
// check for a spectator
- value = Info_ValueForKey (userinfo, "spectator");
+ value = Info_ValueForKey(userinfo, "spectator");
if (deathmatch->value && *value && strcmp(value, "0")) {
int i, numspec;
- if (*spectator_password->string &&
- strcmp(spectator_password->string, "none") &&
+ if (*spectator_password->string &&
+ strcmp(spectator_password->string, "none") &&
strcmp(spectator_password->string, value)) {
Info_SetValueForKey(userinfo, "rejmsg", "Spectator password required or incorrect.");
return qfalse;
@@ -1473,7 +1397,7 @@ qboolean ClientConnect (edict_t *ent, char *userinfo)
// count spectators
for (i = numspec = 0; i < maxclients->value; i++)
- if (g_edicts[i+1].inuse && g_edicts[i+1].client->pers.spectator)
+ if (g_edicts[i + 1].inuse && g_edicts[i + 1].client->pers.spectator)
numspec++;
if (numspec >= maxspectators->value) {
@@ -1482,8 +1406,8 @@ qboolean ClientConnect (edict_t *ent, char *userinfo)
}
} else {
// check for a password
- value = Info_ValueForKey (userinfo, "password");
- if (*password->string && strcmp(password->string, "none") &&
+ value = Info_ValueForKey(userinfo, "password");
+ if (*password->string && strcmp(password->string, "none") &&
strcmp(password->string, value)) {
Info_SetValueForKey(userinfo, "rejmsg", "Password required or incorrect.");
return qfalse;
@@ -1496,18 +1420,17 @@ qboolean ClientConnect (edict_t *ent, char *userinfo)
// if there is already a body waiting for us (a loadgame), just
// take it, otherwise spawn one from scratch
- if (ent->inuse == qfalse)
- {
+ if (ent->inuse == qfalse) {
// clear the respawning variables
- InitClientResp (ent->client);
+ InitClientResp(ent->client);
if (!game.autosaved || !ent->client->pers.weapon)
- InitClientPersistant (ent->client);
+ InitClientPersistant(ent->client);
}
- ClientUserinfoChanged (ent, userinfo);
+ ClientUserinfoChanged(ent, userinfo);
if (game.maxclients > 1)
- gi.dprintf ("%s connected\n", ent->client->pers.netname);
+ gi.dprintf("%s connected\n", ent->client->pers.netname);
ent->svflags = 0; // make sure we start with known default
ent->client->pers.connected = qtrue;
@@ -1522,22 +1445,22 @@ Called when a player drops from the server.
Will not be called between levels.
============
*/
-void ClientDisconnect (edict_t *ent)
+void ClientDisconnect(edict_t *ent)
{
//int playernum;
if (!ent->client)
return;
- gi.bprintf (PRINT_HIGH, "%s disconnected\n", ent->client->pers.netname);
+ gi.bprintf(PRINT_HIGH, "%s disconnected\n", ent->client->pers.netname);
// send effect
- gi.WriteByte (svc_muzzleflash);
- gi.WriteShort (ent-g_edicts);
- gi.WriteByte (MZ_LOGOUT);
- gi.multicast (ent->s.origin, MULTICAST_PVS);
+ gi.WriteByte(svc_muzzleflash);
+ gi.WriteShort(ent - g_edicts);
+ gi.WriteByte(MZ_LOGOUT);
+ gi.multicast(ent->s.origin, MULTICAST_PVS);
- gi.unlinkentity (ent);
+ gi.unlinkentity(ent);
ent->s.modelindex = 0;
ent->s.sound = 0;
ent->s.event = 0;
@@ -1559,29 +1482,29 @@ void ClientDisconnect (edict_t *ent)
edict_t *pm_passent;
// pmove doesn't need to know about passent and contentmask
-trace_t PM_trace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end)
+trace_t PM_trace(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end)
{
if (pm_passent->health > 0)
- return gi.trace (start, mins, maxs, end, pm_passent, MASK_PLAYERSOLID);
+ return gi.trace(start, mins, maxs, end, pm_passent, MASK_PLAYERSOLID);
else
- return gi.trace (start, mins, maxs, end, pm_passent, MASK_DEADSOLID);
+ return gi.trace(start, mins, maxs, end, pm_passent, MASK_DEADSOLID);
}
-unsigned CheckBlock (void *b, int c)
+unsigned CheckBlock(void *b, int c)
{
- int v,i;
+ int v, i;
v = 0;
- for (i=0 ; i<c ; i++)
- v+= ((byte *)b)[i];
+ for (i = 0 ; i < c ; i++)
+ v += ((byte *)b)[i];
return v;
}
-void PrintPmove (pmove_t *pm)
+void PrintPmove(pmove_t *pm)
{
unsigned c1, c2;
- c1 = CheckBlock (&pm->s, sizeof(pm->s));
- c2 = CheckBlock (&pm->cmd, sizeof(pm->cmd));
- Com_Printf ("sv %3i:%i %i\n", pm->cmd.impulse, c1, c2);
+ c1 = CheckBlock(&pm->s, sizeof(pm->s));
+ c2 = CheckBlock(&pm->cmd, sizeof(pm->cmd));
+ Com_Printf("sv %3i:%i %i\n", pm->cmd.impulse, c1, c2);
}
/*
@@ -1592,7 +1515,7 @@ This will be called once for each client frame, which will
usually be a couple times for each server frame.
==============
*/
-void ClientThink (edict_t *ent, usercmd_t *ucmd)
+void ClientThink(edict_t *ent, usercmd_t *ucmd)
{
gclient_t *client;
edict_t *other;
@@ -1602,12 +1525,11 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
level.current_entity = ent;
client = ent->client;
- if (level.intermissiontime)
- {
+ if (level.intermissiontime) {
client->ps.pmove.pm_type = PM_FREEZE;
// can exit intermission after five seconds
- if (level.time > level.intermissiontime + 5.0
- && (ucmd->buttons & BUTTON_ANY) )
+ if (level.time > level.intermissiontime + 5.0
+ && (ucmd->buttons & BUTTON_ANY))
level.exitintermission = qtrue;
return;
}
@@ -1623,7 +1545,7 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
} else {
// set up for pmove
- memset (&pm, 0, sizeof(pm));
+ memset(&pm, 0, sizeof(pm));
if (ent->movetype == MOVETYPE_NOCLIP)
client->ps.pmove.pm_type = PM_SPECTATOR;
@@ -1637,16 +1559,14 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
client->ps.pmove.gravity = sv_gravity->value;
pm.s = client->ps.pmove;
- for (i=0 ; i<3 ; i++)
- {
- pm.s.origin[i] = ent->s.origin[i]*8;
- pm.s.velocity[i] = ent->velocity[i]*8;
+ for (i = 0 ; i < 3 ; i++) {
+ pm.s.origin[i] = ent->s.origin[i] * 8;
+ pm.s.velocity[i] = ent->velocity[i] * 8;
}
- if (memcmp(&client->old_pmove, &pm.s, sizeof(pm.s)))
- {
+ if (memcmp(&client->old_pmove, &pm.s, sizeof(pm.s))) {
pm.snapinitial = qtrue;
- // gi.dprintf ("pmove changed!\n");
+ // gi.dprintf ("pmove changed!\n");
}
pm.cmd = *ucmd;
@@ -1655,27 +1575,25 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
pm.pointcontents = gi.pointcontents;
// perform a pmove
- gi.Pmove (&pm);
+ gi.Pmove(&pm);
// save results of pmove
client->ps.pmove = pm.s;
client->old_pmove = pm.s;
- for (i=0 ; i<3 ; i++)
- {
- ent->s.origin[i] = pm.s.origin[i]*0.125;
- ent->velocity[i] = pm.s.velocity[i]*0.125;
+ for (i = 0 ; i < 3 ; i++) {
+ ent->s.origin[i] = pm.s.origin[i] * 0.125;
+ ent->velocity[i] = pm.s.velocity[i] * 0.125;
}
- VectorCopy (pm.mins, ent->mins);
- VectorCopy (pm.maxs, ent->maxs);
+ VectorCopy(pm.mins, ent->mins);
+ VectorCopy(pm.maxs, ent->maxs);
client->resp.cmd_angles[0] = SHORT2ANGLE(ucmd->angles[0]);
client->resp.cmd_angles[1] = SHORT2ANGLE(ucmd->angles[1]);
client->resp.cmd_angles[2] = SHORT2ANGLE(ucmd->angles[2]);
- if (ent->groundentity && !pm.groundentity && (pm.cmd.upmove >= 10) && (pm.waterlevel == 0))
- {
+ if (ent->groundentity && !pm.groundentity && (pm.cmd.upmove >= 10) && (pm.waterlevel == 0)) {
gi.sound(ent, CHAN_VOICE, gi.soundindex("*jump1.wav"), 1, ATTN_NORM, 0);
PlayerNoise(ent, ent->s.origin, PNOISE_SELF);
}
@@ -1687,35 +1605,31 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
if (pm.groundentity)
ent->groundentity_linkcount = pm.groundentity->linkcount;
- if (ent->deadflag)
- {
+ if (ent->deadflag) {
client->ps.viewangles[ROLL] = 40;
client->ps.viewangles[PITCH] = -15;
client->ps.viewangles[YAW] = client->killer_yaw;
- }
- else
- {
- VectorCopy (pm.viewangles, client->v_angle);
- VectorCopy (pm.viewangles, client->ps.viewangles);
+ } else {
+ VectorCopy(pm.viewangles, client->v_angle);
+ VectorCopy(pm.viewangles, client->ps.viewangles);
}
- gi.linkentity (ent);
+ gi.linkentity(ent);
if (ent->movetype != MOVETYPE_NOCLIP)
- G_TouchTriggers (ent);
+ G_TouchTriggers(ent);
// touch other objects
- for (i=0 ; i<pm.numtouch ; i++)
- {
+ for (i = 0 ; i < pm.numtouch ; i++) {
other = pm.touchents[i];
- for (j=0 ; j<i ; j++)
+ for (j = 0 ; j < i ; j++)
if (pm.touchents[j] == other)
break;
if (j != i)
continue; // duplicated
if (!other->touch)
continue;
- other->touch (other, ent, NULL, NULL);
+ other->touch(other, ent, NULL, NULL);
}
}
@@ -1729,8 +1643,7 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
ent->light_level = ucmd->lightlevel;
// fire weapon from final position if needed
- if (client->latched_buttons & BUTTON_ATTACK)
- {
+ if (client->latched_buttons & BUTTON_ATTACK) {
if (client->resp.spectator) {
client->latched_buttons = 0;
@@ -1743,7 +1656,7 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
} else if (!client->weapon_thunk) {
client->weapon_thunk = qtrue;
- Think_Weapon (ent);
+ Think_Weapon(ent);
}
}
@@ -1777,7 +1690,7 @@ This will be called once for each server frame, before running
any other entities in the world.
==============
*/
-void ClientBeginServerFrame (edict_t *ent)
+void ClientBeginServerFrame(edict_t *ent)
{
gclient_t *client;
int buttonMask;
@@ -1796,24 +1709,21 @@ void ClientBeginServerFrame (edict_t *ent)
// run weapon animations if it hasn't been done by a ucmd_t
if (!client->weapon_thunk && !client->resp.spectator)
- Think_Weapon (ent);
+ Think_Weapon(ent);
else
client->weapon_thunk = qfalse;
- if (ent->deadflag)
- {
+ if (ent->deadflag) {
// wait for any button just going down
- if ( level.time > client->respawn_time)
- {
+ if (level.time > client->respawn_time) {
// in deathmatch, only wait for attack button
if (deathmatch->value)
buttonMask = BUTTON_ATTACK;
else
buttonMask = -1;
- if ( ( client->latched_buttons & buttonMask ) ||
- (deathmatch->value && ((int)dmflags->value & DF_FORCE_RESPAWN) ) )
- {
+ if ((client->latched_buttons & buttonMask) ||
+ (deathmatch->value && ((int)dmflags->value & DF_FORCE_RESPAWN))) {
respawn(ent);
client->latched_buttons = 0;
}
@@ -1823,8 +1733,8 @@ void ClientBeginServerFrame (edict_t *ent)
// add player trail so monsters can follow
if (!deathmatch->value)
- if (!visible (ent, PlayerTrail_LastSpot() ) )
- PlayerTrail_Add (ent->s.old_origin);
+ if (!visible(ent, PlayerTrail_LastSpot()))
+ PlayerTrail_Add(ent->s.old_origin);
client->latched_buttons = 0;
}