2406 lines
58 KiB
C
2406 lines
58 KiB
C
/*
|
|
Copyright (C) 1996-1997 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.
|
|
|
|
*/
|
|
// cl_main.c -- client main loop
|
|
|
|
#include "quakedef.h"
|
|
|
|
|
|
extern progs_t con_prog;
|
|
|
|
// Tei -->
|
|
int CallFunctionGame (char *fname, progs_t *game_pr);
|
|
void R_TempusVivendi (vec3_t min, vec3_t max, int flakes);
|
|
void R_TempusFire (vec3_t min, vec3_t max, int flakes);
|
|
void R_TempusSmoke(vec3_t min, vec3_t max, int flakes);
|
|
void R_ShadowParticles (entity_t *ent);
|
|
void R_MagicFire (entity_t *ent, qboolean fire2);
|
|
void R_TempusDarkSmoke(vec3_t min, vec3_t max, int flakes);
|
|
void R_DarkRocketTrail (vec3_t start, vec3_t end, entity_t *ent, qboolean subtype);
|
|
void R_SmallDowFire (entity_t *ent, qboolean fire2);
|
|
void R_CircleRocketTrail (vec3_t start, vec3_t end, entity_t *ent);
|
|
void R_ParticleImplosion (vec3_t origin);
|
|
void R_TrailGray2 (entity_t * e);
|
|
void R_TrailGray3 (entity_t * e);
|
|
void R_Fire2 (entity_t *ent, qboolean fire2);
|
|
void R_FireBack (entity_t *ent, qboolean fire2);
|
|
void DefineFlare(vec3_t origin, int radius, int mode, int alfa);//Tei dp flares
|
|
void ResetRSkybox () ;
|
|
// <-- Tei
|
|
|
|
|
|
|
|
typedef enum {
|
|
pt_static, pt_grav, pt_slowgrav, pt_rise, pt_slowrise, pt_explode, pt_explode2, pt_blob, pt_blob2, pt_fire
|
|
} part_move_t;
|
|
|
|
typedef enum {
|
|
p_sparks, p_smoke, p_fire, p_blood, p_chunks, p_smoke_fade, p_custom
|
|
} p_type_t;
|
|
|
|
|
|
// we need to declare some mouse variables here, because the menu system
|
|
// references them even when on a unix system.
|
|
|
|
// these two are not intended to be set directly
|
|
|
|
cvar_t cl_name = {"_cl_name", "player", true};
|
|
cvar_t cl_color = {"_cl_color", "0", true};
|
|
|
|
cvar_t cl_shownet = {"cl_shownet","0"}; // can be 0, 1, or 2
|
|
cvar_t cl_nolerp = {"cl_nolerp","0"};
|
|
|
|
cvar_t cl_grenclassic = {"cl_grenclassic", "0", true};//Tei grensmoke color
|
|
|
|
cvar_t lookspring = {"lookspring","0", true};
|
|
cvar_t lookstrafe = {"lookstrafe","0", true};
|
|
cvar_t sensitivity = {"sensitivity","3", true};
|
|
|
|
cvar_t m_pitch = {"m_pitch","0.022", true};
|
|
cvar_t m_yaw = {"m_yaw","0.022", true};
|
|
cvar_t m_forward = {"m_forward","1", true};
|
|
cvar_t m_side = {"m_side","0.8", true};
|
|
|
|
// Tei -->
|
|
|
|
cvar_t autofovmax = {"autofovmax","50", true};
|
|
|
|
cvar_t mod_predator = {"mod_predator","0", false};
|
|
|
|
cvar_t r_efflies = {"r_efflies","2", true};//Tei: Warning, efflies save to disk
|
|
|
|
cvar_t mod_hdigits = {"mod_hdigits","3", false};
|
|
|
|
// Direct Mod support
|
|
cvar_t mod_kiu = {"mod_kiu","0", false};
|
|
cvar_t mod_prydon = {"mod_prydon","0", false};
|
|
cvar_t mod_tenebrae = {"mod_tenebrae","0", false};
|
|
// Direct Mod support
|
|
|
|
cvar_t centerprint_blend = {"centerprint_blend","1",false};
|
|
|
|
cvar_t mod_handicap = {"mod_handicap","0", false};
|
|
cvar_t mod_lsig = {"mod_lsig","0", false};
|
|
cvar_t mod_showbbox = {"mod_showbbox","0", false};
|
|
cvar_t mod_showspeed = {"mod_showspeed","0", false};
|
|
|
|
cvar_t mousehud = {"mousehud","0", false};
|
|
|
|
cvar_t r_aspect = {"r_aspect","0", false};
|
|
|
|
|
|
cvar_t mod_focus = {"mod_focus","0", false};
|
|
|
|
|
|
cvar_t r_cloudplane = {"r_cloudplane","0", false};
|
|
cvar_t r_cloudscale = {"r_cloudscale","32000", false};
|
|
cvar_t r_cloudz = {"r_cloudz","0", false};
|
|
cvar_t r_cloudimage = {"r_cloudimage","textures/clouds.tga", false};
|
|
|
|
|
|
cvar_t mod_progs = {"mod_progs","game.dat", false};
|
|
|
|
cvar_t mod_extendedparticle = {"mod_extendedparticle","1", true};
|
|
cvar_t mod_showlight = {"mod_showlight","0", false};
|
|
cvar_t mod_cityofangels = {"mod_cityofangels","0", false};
|
|
|
|
cvar_t gamedir = {"gamedir","ew", false};//dave
|
|
cvar_t level = {"level","", false};//
|
|
cvar_t timedemo_profile = {"timedemo_profile","normal", false};
|
|
cvar_t r_autofluor = {"r_autofluor","2", false};
|
|
|
|
// <-- Tei
|
|
|
|
cvar_t cl_autoswitch = {"cl_autoswitch","0", false};//koval
|
|
|
|
|
|
client_static_t cls;
|
|
client_state_t cl;
|
|
|
|
// FIXME: put these on hunk?
|
|
efrag_t cl_efrags[MAX_EFRAGS];
|
|
entity_t cl_entities[MAX_EDICTS];
|
|
entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
|
lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
|
dlight_t cl_dlights[MAX_DLIGHTS];
|
|
|
|
int cl_numvisedicts;
|
|
entity_t *cl_visedicts[MAX_VISEDICTS];
|
|
|
|
/*
|
|
=====================
|
|
CL_ClearState
|
|
|
|
=====================
|
|
*/
|
|
|
|
|
|
void CL_NewMap (void);
|
|
|
|
void CL_ClearState (void)
|
|
{
|
|
int i;
|
|
|
|
if (!sv.active)
|
|
Host_ClearMemory ();
|
|
|
|
// koval -->
|
|
CL_NewMap(); // Triggers...
|
|
// match_begins = 0;
|
|
// match_offset = 0;
|
|
// <-- koval
|
|
|
|
// wipe the entire cl structure
|
|
memset (&cl, 0, sizeof(cl));
|
|
|
|
SZ_Clear (&cls.message);
|
|
|
|
// clear other arrays
|
|
memset (cl_efrags, 0, sizeof(cl_efrags));
|
|
memset (cl_entities, 0, sizeof(cl_entities));
|
|
memset (cl_dlights, 0, sizeof(cl_dlights));
|
|
memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
|
|
memset (cl_temp_entities, 0, sizeof(cl_temp_entities));
|
|
memset (cl_beams, 0, sizeof(cl_beams));
|
|
//Q2!
|
|
//CL_ClearTEnts();
|
|
//Q2!
|
|
|
|
|
|
ResetRSkybox();//Tei bug?? ..here
|
|
|
|
|
|
//
|
|
// allocate the efrags and chain together into a free list
|
|
//
|
|
cl.free_efrags = cl_efrags;
|
|
for (i=0 ; i<MAX_EFRAGS-1 ; i++)
|
|
cl.free_efrags[i].entnext = &cl.free_efrags[i+1];
|
|
cl.free_efrags[i].entnext = NULL;
|
|
|
|
|
|
CallFunctionGame("NewMap",&con_prog);
|
|
}
|
|
|
|
/*
|
|
=====================
|
|
CL_Disconnect
|
|
|
|
Sends a disconnect message to the server
|
|
This is also called on Host_Error, so it shouldn't cause any errors
|
|
=====================
|
|
*/
|
|
void CL_Disconnect (void)
|
|
{
|
|
// stop sounds (especially looping!)
|
|
S_StopAllSounds (true);
|
|
|
|
// bring the console down and fade the colors back to normal
|
|
// SCR_BringDownConsole ();
|
|
|
|
// if running a local server, shut it down
|
|
if (cls.demoplayback)
|
|
CL_StopPlayback ();
|
|
else if (cls.state == ca_connected)
|
|
{
|
|
if (cls.demorecording)
|
|
CL_Stop_f ();
|
|
|
|
Con_DPrintf ("Sending clc_disconnect\n");
|
|
SZ_Clear (&cls.message);
|
|
MSG_WriteByte (&cls.message, clc_disconnect);
|
|
NET_SendUnreliableMessage (cls.netcon, &cls.message);
|
|
SZ_Clear (&cls.message);
|
|
NET_Close (cls.netcon);
|
|
|
|
cls.state = ca_disconnected;
|
|
if (sv.active)
|
|
Host_ShutdownServer(false);
|
|
}
|
|
|
|
cls.demoplayback = cls.timedemo = false;
|
|
cls.signon = 0;
|
|
}
|
|
|
|
void CL_Disconnect_f (void)
|
|
{
|
|
CL_Disconnect ();
|
|
if (sv.active)
|
|
Host_ShutdownServer (false);
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
=====================
|
|
CL_EstablishConnection
|
|
|
|
Host should be either "local" or a net address to be passed on
|
|
=====================
|
|
*/
|
|
|
|
|
|
void CL_EstablishConnection (char *host)
|
|
{
|
|
if (cls.state == ca_dedicated)
|
|
return;
|
|
|
|
if (cls.demoplayback)
|
|
return;
|
|
|
|
CL_Disconnect ();
|
|
|
|
cls.netcon = NET_Connect (host);
|
|
if (!cls.netcon)
|
|
Host_Error ("CL_Connect: connect failed\n");
|
|
Con_DPrintf ("CL_EstablishConnection: connected to %s\n", host);
|
|
|
|
cls.demonum = -1; // not in the demo loop now
|
|
cls.state = ca_connected;
|
|
cls.signon = 0; // need all the signon messages before playing
|
|
|
|
}
|
|
|
|
/*
|
|
=====================
|
|
CL_SignonReply
|
|
|
|
An svc_signonnum has been received, perform a client side setup
|
|
=====================
|
|
*/
|
|
|
|
void CL_SignonReply (void)
|
|
{
|
|
char str[8192];
|
|
|
|
//Con_DPrintf ("CL_SignonReply: %i\n", cls.signon);
|
|
|
|
|
|
switch (cls.signon)
|
|
{
|
|
case 1:
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
|
MSG_WriteString (&cls.message, "prespawn");
|
|
break;
|
|
|
|
case 2:
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
|
MSG_WriteString (&cls.message, va("name \"%s\"\n", cl_name.string));
|
|
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
|
MSG_WriteString (&cls.message, va("color %i %i\n", ((int)cl_color.value)>>4, ((int)cl_color.value)&15));
|
|
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
|
sprintf (str, "spawn %s", cls.spawnparms);
|
|
MSG_WriteString (&cls.message, str);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
|
MSG_WriteString (&cls.message, "begin");
|
|
Cache_Report (); // print remaining memory
|
|
break;
|
|
|
|
case 4:
|
|
SCR_EndLoadingPlaque (); // allow normal screen updates
|
|
break;
|
|
}
|
|
}
|
|
|
|
/*
|
|
=====================
|
|
CL_NextDemo
|
|
|
|
Called to play the next demo in the demo loop
|
|
=====================
|
|
*/
|
|
void CL_NextDemo (void)
|
|
{
|
|
char str[1024];
|
|
|
|
if (cls.demonum == -1)
|
|
return; // don't play demos
|
|
|
|
SCR_BeginLoadingPlaque ();
|
|
|
|
if (!cls.demos[cls.demonum][0] || cls.demonum == MAX_DEMOS)
|
|
{
|
|
cls.demonum = 0;
|
|
if (!cls.demos[cls.demonum][0])
|
|
{
|
|
Con_Printf ("No demos listed with startdemos\n");
|
|
cls.demonum = -1;
|
|
return;
|
|
}
|
|
}
|
|
|
|
sprintf (str,"playdemo %s\n", cls.demos[cls.demonum]);
|
|
Cbuf_InsertText (str);
|
|
cls.demonum++;
|
|
}
|
|
|
|
/*
|
|
==============
|
|
CL_PrintEntities_f
|
|
==============
|
|
*/
|
|
void CL_PrintEntities_f (void)
|
|
{
|
|
entity_t *ent;
|
|
int i;
|
|
|
|
for (i=0,ent=cl_entities ; i<cl.num_entities ; i++,ent++)
|
|
{
|
|
Con_Printf ("%3i:",i);
|
|
if (!ent->model)
|
|
{
|
|
Con_Printf ("EMPTY\n");
|
|
continue;
|
|
}
|
|
Con_Printf ("%s:%2i (%5.1f,%5.1f,%5.1f) [%5.1f %5.1f %5.1f]\n"
|
|
,ent->model->name,ent->frame, ent->origin[0], ent->origin[1], ent->origin[2], ent->angles[0], ent->angles[1], ent->angles[2]);
|
|
}
|
|
}
|
|
|
|
/*
|
|
===============
|
|
CL_AllocDlight
|
|
===============
|
|
*/
|
|
dlight_t *CL_AllocDlight (int key)
|
|
{
|
|
int i;
|
|
dlight_t *dl;
|
|
|
|
// first look for an exact key match
|
|
if (key)
|
|
{
|
|
dl = cl_dlights;
|
|
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
|
|
{
|
|
if (dl->key == key)
|
|
{
|
|
memset (dl, 0, sizeof(*dl));
|
|
dl->key = key;
|
|
|
|
// Tomaz - Lit Support Begin
|
|
/* ????
|
|
dl->color[0] = 1;
|
|
dl->color[1] = 0.5;
|
|
dl->color[2] = 0.25;
|
|
*/
|
|
|
|
dl->color[0] = 1; //Tei, with white color all look better..
|
|
dl->color[1] = 1;
|
|
dl->color[2] = 1;
|
|
|
|
// Tomaz - Lit Support End
|
|
|
|
return dl;
|
|
}
|
|
}
|
|
}
|
|
|
|
// then look for anything else
|
|
dl = cl_dlights;
|
|
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
|
|
{
|
|
if (!dl->radius || dl->die < cl.time)
|
|
{
|
|
memset (dl, 0, sizeof(*dl));
|
|
dl->key = key;
|
|
|
|
// Tomaz - Lit Support Begin
|
|
dl->color[0] = 1;
|
|
dl->color[1] = 1;//0.5;
|
|
dl->color[2] = 1;//0.25;
|
|
// Tomaz - Lit Support End
|
|
|
|
return dl;
|
|
}
|
|
}
|
|
|
|
dl = &cl_dlights[0];
|
|
memset (dl, 0, sizeof(*dl));
|
|
dl->key = key;
|
|
|
|
// Tomaz - Lit Support Begin
|
|
dl->color[0] = 1;
|
|
dl->color[1] = 1;//0.5;
|
|
dl->color[2] = 1;//0.25;
|
|
// Tomaz - Lit Support End
|
|
|
|
return dl;
|
|
}
|
|
|
|
|
|
/*
|
|
===============
|
|
CL_DecayLights
|
|
===============
|
|
*/
|
|
void CL_DecayLights (void)
|
|
{
|
|
int i;
|
|
dlight_t *dl;
|
|
float time;
|
|
|
|
time = cl.time - cl.oldtime;
|
|
|
|
dl = cl_dlights;
|
|
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
|
|
{
|
|
if (!dl->radius)
|
|
continue;
|
|
|
|
if (dl->die < cl.time)
|
|
continue;
|
|
|
|
dl->radius -= time*dl->decay;
|
|
if (dl->radius < 0)
|
|
dl->radius = 0;
|
|
}
|
|
}
|
|
|
|
/*
|
|
===============
|
|
CL_LerpPoint
|
|
|
|
Determines the fraction between the last two messages that the objects
|
|
should be put at.
|
|
===============
|
|
*/
|
|
float CL_LerpPoint (void)
|
|
{
|
|
float f, frac;
|
|
|
|
f = cl.mtime[0] - cl.mtime[1];
|
|
|
|
if (!f || cl_nolerp.value || cls.timedemo || sv.active)
|
|
{
|
|
cl.time = cl.mtime[0];
|
|
return 1;
|
|
}
|
|
|
|
if (f > 0.1)
|
|
{ // dropped packet, or start of demo
|
|
cl.mtime[1] = cl.mtime[0] - 0.1;
|
|
f = 0.1f;
|
|
}
|
|
frac = (cl.time - cl.mtime[1]) / f;
|
|
//Con_Printf ("frac: %f\n",frac);
|
|
if (frac < 0)
|
|
{
|
|
if (frac < -0.01)
|
|
{
|
|
cl.time = cl.mtime[1];
|
|
// Con_Printf ("low frac\n");
|
|
}
|
|
frac = 0;
|
|
}
|
|
else if (frac > 1)
|
|
{
|
|
if (frac > 1.01)
|
|
{
|
|
cl.time = cl.mtime[0];
|
|
// Con_Printf ("high frac\n");
|
|
}
|
|
frac = 1;
|
|
}
|
|
return frac;
|
|
}
|
|
|
|
|
|
/*
|
|
===============
|
|
CL_RelinkEntities
|
|
===============
|
|
*/
|
|
void R_TrailGray (entity_t * ent);
|
|
void R_GrenadeTrail (vec3_t start, vec3_t end, entity_t *ent);
|
|
void R_TracerWizard (vec3_t start, vec3_t end, entity_t *ent, byte color);
|
|
void R_FireRocketTrailX (entity_t *ent, qboolean fire2);
|
|
void R_TracerKTrail (vec3_t start, vec3_t end, entity_t *ent, byte color);
|
|
int dxvector (vec3_t *vec1, vec3_t * vec2);
|
|
void AddTrail(vec3_t start, vec3_t end, int type, float time);
|
|
void R_BeamZing (vec3_t origin, vec3_t end);
|
|
void HasFlies (entity_t *ent);
|
|
void CL_TraceLine_ScanForBModels (void);
|
|
extern cvar_t temp1;
|
|
|
|
void EFFECTS_Aply ( int effects, int effects2, int effects3, int flags, entity_t* ent, int i)
|
|
{
|
|
float bobjrotate;
|
|
dlight_t *dl;
|
|
vec3_t downmove;//, color;
|
|
|
|
bobjrotate = anglemod(100*cl.time);
|
|
|
|
if (effects)
|
|
{
|
|
if (effects & EF_MUZZLEFLASH)
|
|
{
|
|
vec3_t fv, rv, uv;
|
|
|
|
dl = CL_AllocDlight (i);//i is the key
|
|
VectorCopy (ent->origin, dl->origin);
|
|
dl->origin[2] += 16;
|
|
AngleVectors (ent->angles, fv, rv, uv);
|
|
|
|
VectorMA (dl->origin, 18, fv, dl->origin);
|
|
dl->radius = 130;
|
|
dl->minlight = 1;
|
|
dl->die = cl.time + 0.01;
|
|
DefineFlare(ent->origin, 200, 0,20);//Tei dp flare
|
|
}
|
|
|
|
if (effects & EF_BRIGHTLIGHT)
|
|
{
|
|
dl = CL_AllocDlight (i);
|
|
VectorCopy (ent->origin, dl->origin);
|
|
dl->origin[2] += 16;
|
|
dl->radius = 300;
|
|
dl->die = cl.time + 0.001;
|
|
dl->color[0] = 1.0f;
|
|
dl->color[1] = 1.0f;
|
|
dl->color[2] = 1.0f;
|
|
DefineFlare(ent->origin, 150, 0,20);//Tei dp flare
|
|
}
|
|
|
|
if (effects & EF_DIMLIGHT)
|
|
{
|
|
dl = CL_AllocDlight (i);
|
|
VectorCopy (ent->origin, dl->origin);
|
|
dl->radius = 230 + (rand()&31);
|
|
dl->die = cl.time + 0.001;
|
|
dl->color[0] = 1.0f;
|
|
dl->color[1] = 1.0f;
|
|
dl->color[2] = 1.0f;
|
|
DefineFlare(ent->origin,190+rand()&31, 0,20);//Tei dp flare
|
|
}
|
|
|
|
if (ent->effects & EF_BRIGHTFIELD)
|
|
{
|
|
R_EntityParticles (ent);
|
|
}
|
|
|
|
|
|
if (ent->effects & EF_BLUEFIRE)
|
|
R_FireBlue(ent, true);
|
|
|
|
if (ent->effects & EF_FIRE)
|
|
R_Fire(ent, true);
|
|
|
|
if (ent->effects & EF_DOWFIRE)
|
|
R_DowFire(ent, true);
|
|
}
|
|
|
|
if (effects2)
|
|
{
|
|
|
|
if ( effects2 & EF2_VOORTRAIL )
|
|
R_VoorTrail (ent->origin1,ent->origin2,ent);
|
|
|
|
if ( effects2 & EF2_BIGFIRE )
|
|
R_BigFire(ent, true);
|
|
|
|
if ( effects2 & EF2_FOGSPLASH )
|
|
R_FogSplash(ent->origin);
|
|
|
|
if ( effects2 & EF2_FOGSPLASHLITE )
|
|
R_FogSplashLite(ent->origin);
|
|
|
|
if ( effects2 & EF2_SPARKSHOWER ){
|
|
downmove[0] = 0;
|
|
downmove[1] = 0;
|
|
downmove[2] = 10;
|
|
R_SparkShower (ent->origin, downmove );
|
|
}
|
|
|
|
if ( effects2 & EF2_WATERFALL )
|
|
R_WaterFall(ent, true);
|
|
|
|
if ( effects2 & EF2_DARKFIELD )
|
|
R_DarkFieldParticles(ent);
|
|
|
|
if ( effects2 & EF2_ROTATEBIT )
|
|
ent->origin[2] += (( sin(bobjrotate/90*M_PI) * 3) + 3 );
|
|
|
|
}
|
|
|
|
if ( effects3)
|
|
{
|
|
|
|
switch (effects3)
|
|
{
|
|
case EF3_ROTATE1:
|
|
ent->angles[1] = bobjrotate;
|
|
break;
|
|
case EF3_ROTATE2:
|
|
ent->angles[2] = bobjrotate;
|
|
break;
|
|
case EF3_ROTATE0:
|
|
ent->angles[0] = bobjrotate;
|
|
break;
|
|
case EF3_ROTATE012:
|
|
ent->angles[0] = bobjrotate;
|
|
ent->angles[1] = bobjrotate;
|
|
ent->angles[2] = bobjrotate;
|
|
break;
|
|
case EF3_ROTATEZ:
|
|
ent->origin[2] += (( sin(bobjrotate/90*M_PI) * 5) + 5 );
|
|
break;
|
|
case EF3_ROTATEZDESINCRO:
|
|
ent->origin[2] += (( sin(bobjrotate/90*M_PI+(int)(ent)) * 5) + 5 );
|
|
break;
|
|
case EF3_AUTOSNOW:
|
|
R_Snow (ent->origin1,ent->origin2, 1);
|
|
break;
|
|
case EF3_TEMPUSVIVENDI:
|
|
R_TempusVivendi(ent->origin1,ent->origin2, 1);
|
|
break;
|
|
case EF3_TEMPUSFIRE:
|
|
R_TempusFire(ent->origin1,ent->origin2, 1);
|
|
break;
|
|
case EF3_TEMPUSSMOKE:
|
|
R_TempusSmoke(ent->origin1,ent->origin2, 1);
|
|
break;
|
|
case EF3_SHADOWSHIELD:
|
|
R_ShadowParticles(ent);
|
|
break;
|
|
case EF3_FLUXFIRE:
|
|
R_DowFire(ent, true);
|
|
break;
|
|
case EF3_ROTATEZ10:
|
|
ent->origin[2] += 10 - (( sin(bobjrotate/90*M_PI) * 5) + 5 );
|
|
break;
|
|
case EF3_ROTATEZ5:
|
|
ent->origin[2] += 5 - (( sin(bobjrotate/90*M_PI) * 5) + 5 );
|
|
break;
|
|
case EF3_MAGICFIRE:
|
|
R_MagicFire (ent, true);
|
|
break;
|
|
case EF3_DARKSMOKE:
|
|
R_TempusDarkSmoke(ent->origin1,ent->origin2, 1);
|
|
break;
|
|
case EF3_DARKTRAIL:
|
|
R_DarkRocketTrail (ent->origin, ent->oldorg2, ent, false);
|
|
break;
|
|
case EF3_DARKTRAIL2:
|
|
R_DarkRocketTrail (ent->origin, ent->oldorg2, ent, true);
|
|
break;
|
|
case EF3_FLUXFIRESMALL:
|
|
R_SmallDowFire (ent, true);
|
|
break;
|
|
case EF3_CIRCLETRAIL:
|
|
R_CircleRocketTrail (ent->origin, ent->oldorg2, ent);
|
|
break;
|
|
case EF3_CLASSICDOWNFIRE:
|
|
R_FireClassic(ent, true);
|
|
break;
|
|
case EF3_Q3AUTOGUN:
|
|
if (rand()&1)
|
|
return;
|
|
dl = CL_AllocDlight (i);
|
|
VectorCopy (ent->origin, dl->origin);
|
|
dl->radius = 250 + (rand()&31);
|
|
dl->die = cl.time;
|
|
dl->color[0] = 1.0f;
|
|
dl->color[1] = 1.0f;
|
|
dl->color[2] = 1.0f;
|
|
break;
|
|
|
|
case EF3_GRAYBITS:
|
|
R_TrailGray (ent);
|
|
break;
|
|
case EF3_GRAYBITS2:
|
|
R_TrailGray2 (ent);
|
|
break;
|
|
case EF3_GRAYBITS3:
|
|
R_TrailGray3 (ent);
|
|
break;
|
|
|
|
case EF3_FULLUX:
|
|
ent->last_light[0] = 255;
|
|
ent->last_light[1] = 255;
|
|
ent->last_light[2] = 255;
|
|
break;
|
|
case EF3_NOLUX:
|
|
ent->last_light[0] = -255;
|
|
ent->last_light[1] = -255;
|
|
ent->last_light[2] = -255;
|
|
break;
|
|
|
|
case EF3_FOXFIRE:
|
|
R_TrailGray3 (ent);
|
|
R_Fire2(ent, true);
|
|
if (rand()&1)
|
|
R_Fire2(ent, true);
|
|
|
|
dl = CL_AllocDlight (i);
|
|
VectorCopy (ent->origin, dl->origin);
|
|
dl->radius = 150 + (rand()&7);
|
|
dl->die = cl.time;
|
|
dl->color[0] = 1.0f;
|
|
dl->color[1] = 1.0f;
|
|
dl->color[2] = 1.0f;
|
|
|
|
break;
|
|
case EF3_EFIRE:
|
|
R_FireBack(ent, true);
|
|
break;
|
|
|
|
case EF3_DPXFLARE:
|
|
DefineFlare(ent->origin,200, 0,20);//Tei dp flare
|
|
break;
|
|
|
|
|
|
case EF3_DPXNUKE:
|
|
DefineFlare(ent->origin,2000, 0,100);//Tei dp flare nuke
|
|
break;
|
|
|
|
case EF3_ALIENBLOOD:
|
|
R_TracerWizard (ent->origin, ent->oldorg2, ent, 63);
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (flags)
|
|
{
|
|
if (flags & EF_ROTATE)
|
|
{
|
|
ent->angles[1] = bobjrotate;
|
|
if (r_bobbing.value)
|
|
ent->origin[2] += (( sin(bobjrotate/90*M_PI) * 5) + 5 );
|
|
}
|
|
|
|
if (flags & EF_ROCKET)
|
|
{
|
|
R_FireRocketTrailX(ent,true);
|
|
dl = CL_AllocDlight (i);
|
|
VectorCopy (ent->oldorg2, dl->origin);
|
|
dl->radius = 250;
|
|
dl->die = cl.time + 0.01;
|
|
}
|
|
|
|
if (flags & EF_GRENADE)
|
|
{
|
|
R_GrenadeTrail (ent->oldorg2, ent->origin, ent);
|
|
dl = CL_AllocDlight (i);
|
|
VectorCopy (ent->origin, dl->origin);
|
|
dl->radius = 25;
|
|
dl->die = cl.time + 0.01;
|
|
dl->color[0] = dl->color[1] = dl->color[2] = 1;
|
|
}
|
|
|
|
if (flags & EF_GIB)
|
|
R_BloodTrail (ent->oldorg2, ent->origin, ent);
|
|
|
|
if (flags & EF_ZOMGIB)
|
|
R_BloodTrail (ent->oldorg2, ent->origin, ent);
|
|
|
|
if (flags & EF_TRACER)
|
|
{
|
|
R_TracerWizard (ent->oldorg, ent->origin, ent, 63);
|
|
dl = CL_AllocDlight (i);
|
|
VectorCopy (ent->origin, dl->origin);
|
|
dl->radius = 250;
|
|
dl->die = cl.time + 0.01;
|
|
dl->color[0] = 0.42f;
|
|
dl->color[1] = 0.42f;
|
|
dl->color[2] = 0.06f;
|
|
}
|
|
|
|
if (flags & EF_TRACER2)
|
|
{
|
|
R_FireBlue(ent,true);
|
|
R_TracerTrail (ent->oldorg, ent->origin, ent, 77);
|
|
//R_TracerKTrail (ent->oldorg2, ent->origin, ent, 236);
|
|
dl = CL_AllocDlight (i);
|
|
VectorCopy (ent->origin, dl->origin);
|
|
dl->radius = 150;
|
|
dl->die = cl.time + 0.01;
|
|
dl->color[0] = 0.88f;
|
|
dl->color[1] = 0.58f;
|
|
dl->color[2] = 0.31f;
|
|
}
|
|
|
|
if (flags & EF_TRACER3)
|
|
{
|
|
R_VoorTrail (ent->origin, ent->oldorg2, ent);
|
|
dl = CL_AllocDlight (i);
|
|
VectorCopy (ent->origin, dl->origin);
|
|
dl->radius = 250;
|
|
dl->die = cl.time + 0.01;
|
|
dl->color[0] = 0.73f;
|
|
dl->color[1] = 0.45f;
|
|
dl->color[2] = 0.62f;
|
|
}
|
|
|
|
if (flags & 0x100)//Zboobing
|
|
ent->origin[2] += (( sin(bobjrotate/90*M_PI + (int)ent) * 5) + 5 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void CL_RelinkEntities (void)
|
|
{
|
|
entity_t *ent;
|
|
int i, j;
|
|
float frac, f, d;
|
|
vec3_t delta;
|
|
float bobjrotate;
|
|
dlight_t *dl;
|
|
|
|
// determine partial update time
|
|
frac = CL_LerpPoint ();
|
|
|
|
cl_numvisedicts = 0;
|
|
|
|
//
|
|
// interpolate player info
|
|
//
|
|
cl.velocity[0] = cl.mvelocity[1][0] + frac * (cl.mvelocity[0][0] - cl.mvelocity[1][0]);
|
|
cl.velocity[1] = cl.mvelocity[1][1] + frac * (cl.mvelocity[0][1] - cl.mvelocity[1][1]);
|
|
cl.velocity[2] = cl.mvelocity[1][2] + frac * (cl.mvelocity[0][2] - cl.mvelocity[1][2]);
|
|
|
|
if (cls.demoplayback)
|
|
{
|
|
// interpolate the angles
|
|
for (j=0 ; j<3 ; j++)
|
|
{
|
|
d = cl.mviewangles[0][j] - cl.mviewangles[1][j];
|
|
if (d > 180)
|
|
d -= 360;
|
|
else if (d < -180)
|
|
d += 360;
|
|
cl.viewangles[j] = cl.mviewangles[1][j] + frac*d;
|
|
}
|
|
}
|
|
|
|
bobjrotate = anglemod(100*cl.time);
|
|
|
|
// start on the entity after the world
|
|
for (i=1,ent=cl_entities+1 ; i<cl.num_entities ; i++,ent++)
|
|
{
|
|
if (!ent->model)
|
|
{ // empty slot
|
|
if (ent->forcelink)
|
|
R_RemoveEfrags (ent); // just became empty
|
|
continue;
|
|
}
|
|
|
|
// if the object wasn't included in the last packet, remove it
|
|
if (ent->msgtime != cl.mtime[0])
|
|
{
|
|
|
|
ent->model = NULL;
|
|
// Tomaz - Model Transform Interpolation Begin
|
|
ent->translate_start_time = 0;
|
|
ent->rotate_start_time = 0;
|
|
VectorClear (ent->last_light);
|
|
// Tomaz - Model Transform Interpolation End
|
|
|
|
continue;
|
|
}
|
|
|
|
|
|
if (ent->model->effect == MFX_LASER && dxvector ((vec3_t *)ent->origin,(vec3_t *) ent->oldorg)<100)
|
|
R_BeamZing(ent->origin, ent->oldorg);//XFX XFX !!!
|
|
|
|
|
|
//VectorCopy (ent->oldorg, oldorg2);
|
|
VectorCopy (ent->oldorg, ent->oldorg2);
|
|
VectorCopy (ent->origin, ent->oldorg);
|
|
//VectorCopy (ent->origin, oldorg);//Standard oldorg = ent->origin
|
|
|
|
if (ent->forcelink)
|
|
{ // the entity was not updated in the last message
|
|
// so move to the final spot
|
|
VectorCopy (ent->msg_origins[0], ent->origin);
|
|
VectorCopy (ent->msg_angles[0], ent->angles);
|
|
}
|
|
else
|
|
{ // if the delta is large, assume a teleport and don't lerp
|
|
f = frac;
|
|
for (j=0 ; j<3 ; j++)
|
|
{
|
|
delta[j] = ent->msg_origins[0][j] - ent->msg_origins[1][j];
|
|
if (delta[j] > 100 || delta[j] < -100)
|
|
f = 1; // assume a teleportation, not a motion
|
|
}
|
|
|
|
// Tomaz - Model Transform Interpolation Begin
|
|
if (f >= 1)
|
|
{
|
|
ent->translate_start_time = 0;
|
|
ent->rotate_start_time = 0;
|
|
VectorClear (ent->last_light);
|
|
}
|
|
// Tomaz - Model Transform Interpolation End
|
|
// interpolate the origin and angles
|
|
for (j=0 ; j<3 ; j++)
|
|
{
|
|
ent->origin[j] = ent->msg_origins[1][j] + f*delta[j];
|
|
|
|
d = ent->msg_angles[0][j] - ent->msg_angles[1][j];
|
|
if (d > 180)
|
|
d -= 360;
|
|
else if (d < -180)
|
|
d += 360;
|
|
ent->angles[j] = ent->msg_angles[1][j] + f*d;
|
|
}
|
|
|
|
}
|
|
|
|
EFFECTS_Aply(ent->effects,ent->effects2,ent->effects3, ent->model->flags, ent, i);
|
|
|
|
if (ent->model->effect == MFX_FLAGS)
|
|
{
|
|
Con_Printf(" and 4 is %d \n", ent->model->ef3);
|
|
EFFECTS_Aply(ent->model->ef1,ent->model->ef2,ent->model->ef3, ent->model->flags, ent, i);
|
|
}
|
|
|
|
if ( mod_predator.value )
|
|
DefineFlare(ent->origin,200,0,20);//Tei dp flare
|
|
|
|
// Tomaz - QC Glow Begin
|
|
if (ent->glow_size)
|
|
{
|
|
dl = CL_AllocDlight (i);
|
|
VectorCopy (ent->origin, dl->origin);
|
|
dl->radius = ent->glow_size;
|
|
dl->die = cl.time + 0.01;
|
|
dl->color[0] = ent->glow_red;
|
|
dl->color[1] = ent->glow_green;
|
|
dl->color[2] = ent->glow_blue;
|
|
}
|
|
// Tomaz - QC Glow End
|
|
|
|
|
|
ent->forcelink = false;
|
|
|
|
if (i == cl.viewentity && !chase_active.value)
|
|
continue;
|
|
|
|
if ( ent->effects3 == EF3_NODRAW )
|
|
continue;
|
|
|
|
if (cl_numvisedicts < MAX_VISEDICTS)
|
|
{
|
|
cl_visedicts[cl_numvisedicts] = ent;
|
|
cl_numvisedicts++;
|
|
}
|
|
}
|
|
|
|
CL_TraceLine_ScanForBModels();//Tei this is good location
|
|
}
|
|
|
|
/*
|
|
===============
|
|
CL_ReadFromServer
|
|
|
|
Read all incoming data from the server
|
|
===============
|
|
*/
|
|
int CL_ReadFromServer (void)
|
|
{
|
|
int ret;
|
|
|
|
cl.oldtime = cl.time;
|
|
cl.time += host_frametime;
|
|
|
|
do
|
|
{
|
|
ret = CL_GetMessage ();
|
|
|
|
if (ret == -1)
|
|
Host_Error ("CL_ReadFromServer: lost server connection");
|
|
|
|
if (!ret)
|
|
break;
|
|
|
|
|
|
cl.last_received_message = realtime;
|
|
CL_ParseServerMessage ();
|
|
} while (ret && cls.state == ca_connected);
|
|
|
|
|
|
CL_RelinkEntities ();
|
|
|
|
//Addd more entitis here.
|
|
CL_UpdateTEnts ();
|
|
|
|
|
|
//
|
|
// bring the links up to date
|
|
//
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
=================
|
|
CL_SendCmd
|
|
=================
|
|
*/
|
|
void CL_SendCmd (void)
|
|
{
|
|
usercmd_t cmd;
|
|
|
|
if (cls.state != ca_connected)
|
|
return;
|
|
|
|
if (cls.signon == SIGNONS)
|
|
{
|
|
// get basic movement from keyboard
|
|
CL_BaseMove (&cmd);
|
|
|
|
// allow mice or other external controllers to add to the move
|
|
IN_Move (&cmd);
|
|
|
|
// send the unreliable message
|
|
CL_SendMove (&cmd);
|
|
|
|
}
|
|
#ifndef NOROUTINGFIX
|
|
/*
|
|
else if (cls.signon == 0 && !cls.demoplayback)
|
|
{
|
|
// LordHavoc: fix for NAT routing of netquake:
|
|
// bounce back a clc_nop message to the newly allocated server port,
|
|
// to establish a routing connection for incoming frames,
|
|
// the server waits for this before sending anything
|
|
if (realtime > cl.sendnoptime)
|
|
{
|
|
cl.sendnoptime = realtime + 3;
|
|
Con_DPrintf("sending clc_nop to get server's attention\n");
|
|
{
|
|
sizebuf_t buf;
|
|
qbyte data[128];
|
|
buf.maxsize = 128;
|
|
buf.cursize = 0;
|
|
buf.data = data;
|
|
MSG_WriteByte(&buf, clc_nop);
|
|
if (NET_SendUnreliableMessage (cls.netcon, &buf) == -1)
|
|
{
|
|
Con_Printf ("CL_SendCmd: lost server connection\n");
|
|
CL_Disconnect ();
|
|
}
|
|
}
|
|
}
|
|
}*/
|
|
#endif
|
|
|
|
if (cls.demoplayback)
|
|
{
|
|
SZ_Clear (&cls.message);
|
|
return;
|
|
}
|
|
|
|
// send the reliable message
|
|
if (!cls.message.cursize)
|
|
return; // no message at all
|
|
|
|
if (!NET_CanSendMessage (cls.netcon))
|
|
{
|
|
Con_DPrintf ("CL_WriteToServer: can't send\n");
|
|
return;
|
|
}
|
|
|
|
if (NET_SendMessage (cls.netcon, &cls.message) == -1)
|
|
Host_Error ("CL_WriteToServer: lost server connection");
|
|
|
|
SZ_Clear (&cls.message);
|
|
}
|
|
|
|
|
|
//FH!
|
|
void CL_Fog_f (void)
|
|
{
|
|
if (Cmd_Argc () == 1)
|
|
{
|
|
Con_Printf ("\"fog\" is \"%f %f %f\"\n", gl_fogred.value, gl_foggreen.value, gl_fogblue.value);
|
|
return;
|
|
}
|
|
gl_fogenable.value = 1;
|
|
|
|
gl_fogred.value = atof(Cmd_Argv(1));
|
|
gl_foggreen.value = atof(Cmd_Argv(2));
|
|
gl_fogblue.value = atof(Cmd_Argv(3));
|
|
|
|
|
|
}
|
|
//FH!
|
|
|
|
|
|
/*
|
|
=============
|
|
CL_Tracepos_f -- johnfitz
|
|
|
|
display impact point of trace along VPN
|
|
=============
|
|
*/
|
|
|
|
//float TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal);
|
|
|
|
void CL_Tracepos_f (void)
|
|
{
|
|
// vec3_t v, w;
|
|
|
|
return;
|
|
#if 0 //This cant really work, different traceline function?
|
|
VectorScale(vpn, 8192.0, v);
|
|
TraceLine(r_refdef.vieworg, v, w);
|
|
|
|
if (Length(w) == 0)
|
|
Con_Printf ("Tracepos: trace didn't hit anything\n");
|
|
else
|
|
Con_Printf ("Tracepos: (%i %i %i)\n", (int)w[0], (int)w[1], (int)w[2]);
|
|
#endif
|
|
}
|
|
|
|
|
|
/*
|
|
=============
|
|
CL_Viewpos_f -- johnfitz
|
|
|
|
display client's position and angles
|
|
=============
|
|
*/
|
|
void CL_Viewpos_f (void)
|
|
{
|
|
#if 0
|
|
//camera position
|
|
Con_Printf ("Viewpos: (%i %i %i) %i %i %i\n",
|
|
(int)r_refdef.vieworg[0],
|
|
(int)r_refdef.vieworg[1],
|
|
(int)r_refdef.vieworg[2],
|
|
(int)r_refdef.viewangles[PITCH],
|
|
(int)r_refdef.viewangles[YAW],
|
|
(int)r_refdef.viewangles[ROLL]);
|
|
#else
|
|
//player position
|
|
Con_Printf ("Viewpos: (%i %i %i) %i %i %i\n",
|
|
(int)cl_entities[cl.viewentity].origin[0],
|
|
(int)cl_entities[cl.viewentity].origin[1],
|
|
(int)cl_entities[cl.viewentity].origin[2],
|
|
(int)cl.viewangles[PITCH],
|
|
(int)cl.viewangles[YAW],
|
|
(int)cl.viewangles[ROLL]);
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
=============
|
|
CL_Mapname_f -- johnfitz
|
|
=============
|
|
*/
|
|
void CL_Mapname_f (void)
|
|
{
|
|
char name[MAX_QPATH];
|
|
COM_StripExtension (cl.worldmodel->name + 5, name);
|
|
Con_Printf ("\"mapname\" is \"%s\"\n", name);
|
|
}
|
|
|
|
progs_t fx_progs;
|
|
int fx_loaded;
|
|
|
|
|
|
#ifndef PROGHEADER101_CRC
|
|
#define PROGHEADER101_CRC 5927
|
|
#endif
|
|
|
|
//extern struct builtin_t pr_builtin[];
|
|
extern builtin_t pr_builtin[];
|
|
|
|
void LoadFXEngine()
|
|
{
|
|
int prsize;
|
|
|
|
memset(&fx_progs,0,sizeof(progs_t));
|
|
|
|
fx_progs.builtins = pr_builtin;
|
|
|
|
if(!(prsize=PR_LoadProgset("fx.dat", &fx_progs, PROGHEADER101_CRC)))
|
|
{
|
|
Con_Printf("Can't load fx.dat file!\n");
|
|
memset(&fx_progs,0,sizeof(progs_t));
|
|
fx_loaded = false;
|
|
}
|
|
else
|
|
{
|
|
fx_progs.edict_size = prsize;
|
|
fx_loaded = true;
|
|
}
|
|
}
|
|
int CallFunction(char *fname);
|
|
int CallFunctionGame(char *fname, progs_t *game_pr);
|
|
|
|
|
|
|
|
void CL_SetupProgs (void)
|
|
{
|
|
// int t;
|
|
// float *f;
|
|
// static char params[10][200];
|
|
|
|
if (!con_prog.progs)
|
|
{
|
|
PR_LoadProgset("conproc.dat", &con_prog, PROGHEADER101_CRC);
|
|
if (con_prog.progs)
|
|
CallFunctionGame("Loaded",&con_prog);
|
|
else
|
|
return;
|
|
}
|
|
};
|
|
|
|
|
|
void CL_LoadPr_f (void)
|
|
{
|
|
int t;
|
|
// float *f;
|
|
static char params[10][200];
|
|
|
|
if (!con_prog.progs)
|
|
return;
|
|
|
|
if (active_pr!= &con_prog)
|
|
PR_SetProgset(&con_prog);
|
|
|
|
for(t=1;t<Cmd_Argc () && t<7;t++)
|
|
{
|
|
// Con_Printf("var %s\n",Cmd_Argv(t));
|
|
strcpy(params[t],Cmd_Argv(t));
|
|
G_INT(OFS_PARM0+(t-1)*3) = params[t] - pr_strings;
|
|
}
|
|
|
|
CallFunctionGame(Cmd_Argv(0),&con_prog);
|
|
};
|
|
|
|
|
|
void PR_AddCommand (void)
|
|
{
|
|
char * m = G_STRING(OFS_PARM0);
|
|
Cmd_AddCommand (m, CL_LoadPr_f);
|
|
}
|
|
|
|
|
|
cvar_t sv_triggers = {"sv_triggers", "0", false, true};
|
|
cvar_t cl_triggers = {"cl_triggers", "1", true, false};
|
|
|
|
cvar_t cl_fxprog = {"cl_fxprog", "1", true, false};
|
|
|
|
//cvar_t _cmd_macros = {"_cmd_macros", "0"};
|
|
cvar_t cl_parsesay = {"cl_parsesay", "0"};
|
|
cvar_t cl_loadlocs = {"cl_loadlocs", "1"};
|
|
cvar_t cl_autoimpulse = {"cl_autoimpulse", "0"};
|
|
//cvar_t cl_staticsounds = {"cl_staticsounds", "0"};
|
|
//cvar_t r_fastsky = {"r_fastsky", "0"};
|
|
//cvar_t r_turb = {"r_turb", "1"};
|
|
//cvar_t r_skycolor = {"r_skycolor", "40"};
|
|
//cvar_t r_turbcolor = {"r_turbcolor", "24"};
|
|
|
|
char *Cmd_Macro_Location_f (void);
|
|
char *Cmd_Macro_PointName_f (void);
|
|
char *Cmd_Macro_PointLocation_f (void);
|
|
void *Cmd_FindAlias(char *s);
|
|
qboolean temp_notrig;
|
|
|
|
#define MAX_LOC_NAME 32
|
|
|
|
long last_health = 0;
|
|
long last_items = 0;
|
|
long last_respawntrigger = 0;
|
|
long last_deathtrigger = 0;
|
|
long last_listtrigger = 0;
|
|
|
|
char lastdeathloc[MAX_LOC_NAME];
|
|
|
|
void CL_ExecTrigger (char *s)
|
|
{
|
|
char *cmd;
|
|
|
|
if (!cl_triggers.value || cls.demoplayback)
|
|
return;
|
|
|
|
// if (Cmd_FindAlias(s))
|
|
cmd = Cmd_CompleteAlias (s);
|
|
if(!cmd)
|
|
return;
|
|
|
|
if (!strcmp(cmd, s))
|
|
{
|
|
// Cmd_ExecuteString (va("%s\n", s), src_command);
|
|
Cbuf_AddText (va("%s\n", s));
|
|
// Cbuf_AddText ("\n");
|
|
}
|
|
}
|
|
|
|
#define IT_WEAPONS (2|4|8|16|32|64)
|
|
void CL_StatChanged (long value)
|
|
{
|
|
// int i;
|
|
|
|
if (value > 0)
|
|
{
|
|
if (last_health <= 0)
|
|
{
|
|
last_respawntrigger = realtime;
|
|
CL_ExecTrigger ("f_respawn");
|
|
}
|
|
last_health = value;
|
|
return;
|
|
}
|
|
if (last_health > 0)
|
|
{
|
|
last_deathtrigger = realtime;
|
|
strcpy (lastdeathloc, Cmd_Macro_Location_f());
|
|
CL_ExecTrigger ("f_death");
|
|
}
|
|
last_health = value;
|
|
// }
|
|
/*
|
|
else if (stat == STAT_ITEMS)
|
|
{
|
|
i = value &~ last_items;
|
|
if (i & IT_WEAPONS && (i & IT_WEAPONS != IT_WEAPONS)
|
|
|| i & (IT_ARMOR1|IT_ARMOR2|IT_ARMOR3|IT_SUPERHEALTH)
|
|
|| i & (IT_INVISIBILITY|IT_INVULNERABILITY|IT_SUIT|IT_QUAD))
|
|
{
|
|
// ...
|
|
//CL_ExecTrigger ("f_took");
|
|
}
|
|
last_items = value;
|
|
}
|
|
*/
|
|
}
|
|
|
|
void CL_NewMap (void)
|
|
{
|
|
last_health = 0;
|
|
}
|
|
|
|
/*
|
|
=============================================================================
|
|
MESSAGE TRIGGERS
|
|
=============================================================================
|
|
*/
|
|
|
|
typedef struct msg_trigger_s
|
|
{
|
|
char name[32];
|
|
char string[64];
|
|
struct msg_trigger_s *next;
|
|
} msg_trigger_t;
|
|
|
|
static msg_trigger_t *msg_triggers;
|
|
|
|
msg_trigger_t *CL_FindTrigger (char *name)
|
|
{
|
|
msg_trigger_t *t;
|
|
|
|
for (t=msg_triggers; t; t=t->next)
|
|
if (!strcmp(t->name, name))
|
|
return t;
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
void CL_MsgTrigger_f (void)
|
|
{
|
|
int c;
|
|
char *name;
|
|
msg_trigger_t *trig;
|
|
|
|
c = Cmd_Argc();
|
|
|
|
if (c > 3)
|
|
{
|
|
Con_Printf ("msg_trigger <alias name> \"string\"\n");
|
|
return;
|
|
}
|
|
|
|
if (c == 1)
|
|
{
|
|
temp_notrig = 1;
|
|
last_listtrigger = realtime;
|
|
if (!msg_triggers)
|
|
Con_Printf ("no triggers defined\n");
|
|
else
|
|
for (trig=msg_triggers; trig; trig=trig->next)
|
|
Con_Printf ("%s : \"%s\"\n", trig->name, trig->string);
|
|
|
|
temp_notrig = 0;
|
|
return;
|
|
}
|
|
|
|
name = Cmd_Argv(1);
|
|
if (strlen(name) > 31)
|
|
{
|
|
Con_Printf ("trigger name too long\n");
|
|
return;
|
|
}
|
|
|
|
if (c == 2)
|
|
{
|
|
trig = CL_FindTrigger (name);
|
|
if (trig)
|
|
Con_Printf ("%s: \"%s\"\n", trig->name, trig->string);
|
|
else
|
|
Con_Printf ("trigger \"%s\" not found\n", name);
|
|
return;
|
|
}
|
|
|
|
if (c == 3)
|
|
{
|
|
if (strlen(Cmd_Argv(2)) > 63)
|
|
{
|
|
Con_Printf ("trigger string too long\n");
|
|
return;
|
|
}
|
|
|
|
trig = CL_FindTrigger (name);
|
|
|
|
if (!trig)
|
|
{
|
|
// allocate new trigger
|
|
trig = Z_Malloc (sizeof(msg_trigger_t));
|
|
trig->next = msg_triggers;
|
|
msg_triggers = trig;
|
|
strcpy (trig->name, name);
|
|
}
|
|
|
|
strcpy (trig->string, Cmd_Argv(2));
|
|
}
|
|
}
|
|
|
|
|
|
void CL_SearchForMsgTriggers (char *s)
|
|
{
|
|
msg_trigger_t *t;
|
|
// char *string;
|
|
|
|
if (!sv_triggers.value || !cl_triggers.value || temp_notrig)
|
|
return;
|
|
|
|
for (t=msg_triggers; t; t=t->next)
|
|
{
|
|
if (t->string[0] && strstr(s, t->string))
|
|
{
|
|
// Cbuf_InsertText (va("%s\n", t->name));
|
|
Cmd_ExecuteString (va("%s\n", t->name), src_command);
|
|
// Cbuf_AddText (va("%s\n", t->name));
|
|
|
|
// Con_Printf("\nechoed \"%s\"\nmust be executed \"%s\"\n", t->string, t->name);
|
|
// Con_Printf(va("\nmust be executed \"%s\"\n", t->name));
|
|
// Con_Printf("\nmust be executed \"str\"\n");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
============
|
|
Msg_WriteTriggers
|
|
|
|
Writes lines containing "msg_trigger aliasname <string>"
|
|
============
|
|
*/
|
|
void Msg_WriteTriggers (FILE *f)
|
|
{
|
|
msg_trigger_t *a;
|
|
|
|
for (a = msg_triggers ; a ; a=a->next)
|
|
fprintf (f, "msg_trigger \"%s\" \"%s\"\n", a->name, a->string);
|
|
}
|
|
|
|
/*
|
|
=============================================================================
|
|
MACROS
|
|
=============================================================================
|
|
*/
|
|
|
|
typedef char *(*mcommand_t) (void);
|
|
|
|
typedef struct cmd_macro_s
|
|
{
|
|
struct cmd_macro_s *next;
|
|
char *name;
|
|
mcommand_t function;
|
|
} cmd_macro_t;
|
|
|
|
cmd_macro_t *cmd_macros;
|
|
|
|
#define MAX_MACRO_VALUE 255
|
|
|
|
|
|
void Cmd_AddMacro (char *macro_name, mcommand_t function)
|
|
{
|
|
cmd_macro_t *macro;
|
|
|
|
if (host_initialized) // because hunk allocation would get stomped
|
|
Sys_Error ("Cmd_AddMacro after host_initialized");
|
|
|
|
// fail if the macro is a variable name
|
|
if (Cvar_VariableString(macro_name)[0])
|
|
{
|
|
Con_Printf ("Cmd_AddMacro: %s already defined as a var\n", macro_name);
|
|
return;
|
|
}
|
|
|
|
// fail if the macro already exists
|
|
for (macro=cmd_macros ; macro ; macro=macro->next)
|
|
{
|
|
if (!strcmp (macro_name, macro->name))
|
|
{
|
|
Con_Printf ("Cmd_AddMacro: %s already defined\n", macro_name);
|
|
return;
|
|
}
|
|
}
|
|
|
|
macro = Hunk_Alloc (sizeof(cmd_macro_t)); // FIXME: use zone memory?
|
|
macro->name = macro_name;
|
|
macro->function = function;
|
|
macro->next = cmd_macros;
|
|
cmd_macros = macro;
|
|
}
|
|
|
|
/*
|
|
==========================================================================
|
|
MACRO FUNCTIONS DEFINITION
|
|
==========================================================================
|
|
*/
|
|
|
|
static char macro_buf[MAX_MACRO_VALUE];
|
|
|
|
char *Cmd_Macro_Health_f (void)
|
|
{
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_HEALTH]);
|
|
return macro_buf;
|
|
}
|
|
|
|
char *Cmd_Macro_Armor_f (void)
|
|
{
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_ARMOR]);
|
|
return macro_buf;
|
|
}
|
|
|
|
char *Cmd_Macro_Shells_f (void)
|
|
{
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_SHELLS]);
|
|
return macro_buf;
|
|
}
|
|
|
|
char *Cmd_Macro_Nails_f (void)
|
|
{
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_NAILS]);
|
|
return macro_buf;
|
|
}
|
|
|
|
char *Cmd_Macro_Rockets_f (void)
|
|
{
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_ROCKETS]);
|
|
return macro_buf;
|
|
}
|
|
|
|
char *Cmd_Macro_Cells_f (void)
|
|
{
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_CELLS]);
|
|
return macro_buf;
|
|
}
|
|
|
|
char *Cmd_Macro_Ammo_f (void)
|
|
{
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_AMMO]);
|
|
return macro_buf;
|
|
}
|
|
|
|
char *Cmd_Macro_Weapon_f (void)
|
|
{
|
|
switch (cl.stats[STAT_ACTIVEWEAPON])
|
|
{
|
|
case IT_AXE: return "axe";
|
|
case IT_SHOTGUN: return "sg";
|
|
case IT_SUPER_SHOTGUN: return "ssg";
|
|
case IT_NAILGUN: return "ng";
|
|
case IT_SUPER_NAILGUN: return "sng";
|
|
case IT_GRENADE_LAUNCHER: return "gl";
|
|
case IT_ROCKET_LAUNCHER: return "rl";
|
|
case IT_LIGHTNING: return "lg";
|
|
default:
|
|
return "something";
|
|
}
|
|
}
|
|
|
|
int _Cmd_Macro_BestWeapon (void)
|
|
{
|
|
int best;
|
|
|
|
best = 0;
|
|
if (cl.items & IT_AXE)
|
|
best = IT_AXE;
|
|
if (cl.items & IT_SHOTGUN && cl.stats[STAT_SHELLS] >= 1)
|
|
best = IT_SHOTGUN;
|
|
if (cl.items & IT_SUPER_SHOTGUN && cl.stats[STAT_SHELLS] >= 2)
|
|
best = IT_SUPER_SHOTGUN;
|
|
if (cl.items & IT_NAILGUN && cl.stats[STAT_NAILS] >= 1)
|
|
best = IT_NAILGUN;
|
|
if (cl.items & IT_SUPER_NAILGUN && cl.stats[STAT_NAILS] >= 2)
|
|
best = IT_SUPER_NAILGUN;
|
|
if (cl.items & IT_GRENADE_LAUNCHER && cl.stats[STAT_ROCKETS] >= 1)
|
|
best = IT_GRENADE_LAUNCHER;
|
|
if (cl.items & IT_LIGHTNING && cl.stats[STAT_CELLS] >= 1)
|
|
best = IT_LIGHTNING;
|
|
if (cl.items & IT_ROCKET_LAUNCHER && cl.stats[STAT_ROCKETS] >= 1)
|
|
best = IT_ROCKET_LAUNCHER;
|
|
|
|
return best;
|
|
}
|
|
|
|
|
|
char *Cmd_Macro_BestWeapon_f (void)
|
|
{
|
|
switch (_Cmd_Macro_BestWeapon())
|
|
{
|
|
case IT_AXE: return "axe";
|
|
case IT_SHOTGUN: return "sg";
|
|
case IT_SUPER_SHOTGUN: return "ssg";
|
|
case IT_NAILGUN: return "ng";
|
|
case IT_SUPER_NAILGUN: return "sng";
|
|
case IT_GRENADE_LAUNCHER: return "gl";
|
|
case IT_ROCKET_LAUNCHER: return "rl";
|
|
case IT_LIGHTNING: return "lg";
|
|
default:
|
|
return "something";
|
|
}
|
|
}
|
|
|
|
char *Cmd_Macro_BestAmmo_f (void)
|
|
{
|
|
switch (_Cmd_Macro_BestWeapon())
|
|
{
|
|
case IT_SHOTGUN: case IT_SUPER_SHOTGUN:
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_SHELLS]);
|
|
return macro_buf;
|
|
|
|
case IT_NAILGUN: case IT_SUPER_NAILGUN:
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_NAILS]);
|
|
return macro_buf;
|
|
|
|
case IT_GRENADE_LAUNCHER: case IT_ROCKET_LAUNCHER:
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_ROCKETS]);
|
|
return macro_buf;
|
|
|
|
case IT_LIGHTNING:
|
|
sprintf(macro_buf, "%i", cl.stats[STAT_CELLS]);
|
|
return macro_buf;
|
|
|
|
default:
|
|
return "0";
|
|
}
|
|
}
|
|
|
|
char *Cmd_Macro_ArmorType_f (void)
|
|
{
|
|
if (cl.items & IT_ARMOR1)
|
|
return "ga";
|
|
else if (cl.items & IT_ARMOR2)
|
|
return "ya";
|
|
else if (cl.items & IT_ARMOR3)
|
|
return "ra";
|
|
else
|
|
return ""; // no armor at all
|
|
}
|
|
|
|
char *Cmd_Macro_Powerups_f (void)
|
|
{
|
|
macro_buf[0] = 0;
|
|
|
|
if (cl.items & IT_QUAD)
|
|
strcpy(macro_buf, "quad");
|
|
|
|
if (cl.items & IT_INVULNERABILITY)
|
|
{
|
|
if (macro_buf[0])
|
|
strcat(macro_buf, "/");
|
|
strcat(macro_buf, "pent");
|
|
}
|
|
|
|
if (cl.items & IT_INVISIBILITY)
|
|
{
|
|
if (macro_buf[0])
|
|
strcat(macro_buf, "/");
|
|
strcat(macro_buf, "ring");
|
|
}
|
|
|
|
return macro_buf;
|
|
}
|
|
|
|
char *Cmd_Macro_Location2_f (void)
|
|
{
|
|
if (last_deathtrigger && realtime - last_deathtrigger <= 5)
|
|
return lastdeathloc;
|
|
return Cmd_Macro_Location_f();
|
|
}
|
|
|
|
char *Cmd_Macro_LastDeath_f (void)
|
|
{
|
|
if (last_deathtrigger)
|
|
return lastdeathloc;
|
|
else
|
|
return "somewhere";
|
|
}
|
|
|
|
|
|
#define MAX_MACRO_STRING 1024
|
|
|
|
// TODO: rewrite this!
|
|
char *CL_ParseMacroString (char *string)
|
|
{
|
|
static char buf[MAX_MACRO_STRING];
|
|
char *s;
|
|
int i;
|
|
cmd_macro_t *macro;
|
|
char *macro_string;
|
|
char ch;
|
|
|
|
// if (!_cmd_macros.value && !cl_parsesay.value)
|
|
if (!cl_parsesay.value)
|
|
return string;
|
|
|
|
s = string;
|
|
i = 0;
|
|
|
|
while (*s && i < MAX_MACRO_STRING-1)
|
|
{
|
|
if (cl_parsesay.value)
|
|
{
|
|
if (*s == '%')
|
|
{
|
|
macro_string = NULL;
|
|
switch (s[1])
|
|
{
|
|
case 'a': macro_string = Cmd_Macro_Armor_f(); break;
|
|
case 'A': macro_string = Cmd_Macro_ArmorType_f(); break;
|
|
case 'h': macro_string = Cmd_Macro_Health_f(); break;
|
|
|
|
case 's': macro_string = Cmd_Macro_Shells_f(); break;
|
|
case 'n': macro_string = Cmd_Macro_Nails_f(); break;
|
|
case 'r': macro_string = Cmd_Macro_Rockets_f(); break;
|
|
case 'c': macro_string = Cmd_Macro_Cells_f(); break;
|
|
|
|
case 'w': macro_string = Cmd_Macro_Weapon_f(); break;
|
|
case 'W': macro_string = Cmd_Macro_Ammo_f(); break;
|
|
|
|
case 'p':
|
|
case 'P': macro_string = Cmd_Macro_Powerups_f(); break;
|
|
|
|
case 'l': macro_string = Cmd_Macro_Location_f(); break;
|
|
case 'L': macro_string = Cmd_Macro_Location2_f(); break;
|
|
case 'd': macro_string = Cmd_Macro_LastDeath_f(); break;
|
|
|
|
case 'x': macro_string = Cmd_Macro_PointName_f(); break;
|
|
case 'y': macro_string = Cmd_Macro_PointLocation_f(); break;
|
|
|
|
default:
|
|
buf[i++] = *s++;
|
|
continue;
|
|
}
|
|
if (i + strlen(macro_string) >= MAX_MACRO_STRING-1) // !!! is this right?
|
|
Sys_Error("CL_ParseMacroString: macro string length > MAX_MACRO_STRING)");
|
|
strcpy (&buf[i], macro_string);
|
|
i += strlen(macro_string);
|
|
s += 2; // skip % and letter
|
|
continue;
|
|
}
|
|
|
|
if (*s == '$')
|
|
{
|
|
ch = 0;
|
|
switch (s[1])
|
|
{
|
|
case '\\': ch = 0x0D; break;
|
|
case ':': ch = 0x0A; break;
|
|
case '[': ch = 0x10; break;
|
|
case ']': ch = 0x11; break;
|
|
case 'W': ch = 0x84; break;
|
|
// case 'P': ch = 0x85; break;
|
|
case 'G': ch = 0x86; break;
|
|
case 'R': ch = 0x87; break;
|
|
case 'Y': ch = 0x88; break;
|
|
case 'B': ch = 0x89; break;
|
|
case '(': ch = 0x80; break;
|
|
case '=': ch = 0x81; break;
|
|
case ')': ch = 0x82; break;
|
|
case 'a': ch = 0x83; break;
|
|
case '<': ch = 0x1d; break;
|
|
case '-': ch = 0x1e; break;
|
|
case '>': ch = 0x1f; break;
|
|
case ',': ch = 0x1c; break;
|
|
case '.': ch = 0x9c; break;
|
|
case 'b': ch = 0x8b; break;
|
|
case 'c': ch = 0x8c; break;
|
|
case 'd': ch = 0x8d; break;
|
|
case '$': ch = '$'; break;
|
|
}
|
|
if (s[1] >= '0' && s[1] <= '9')
|
|
ch = s[1] - '0' + 0x12;
|
|
if (ch)
|
|
{
|
|
buf[i++] = ch;
|
|
s += 2;
|
|
continue;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
// if (_cmd_macros.value)
|
|
if (*s == '$')
|
|
{
|
|
s++;
|
|
|
|
if (*s == '$')
|
|
{
|
|
buf[i++] = '$';
|
|
s++;
|
|
continue;
|
|
}
|
|
|
|
// macro search
|
|
// if (_cmd_macros.value)
|
|
// {
|
|
macro = cmd_macros;
|
|
while (macro)
|
|
{
|
|
if (!strncmp(s, macro->name, strlen(macro->name)))
|
|
{
|
|
macro_string = macro->function();
|
|
if (i + strlen(macro_string) >= MAX_MACRO_STRING-1) // !!! is this right?
|
|
Sys_Error("CL_ParseMacroString: macro string length > MAX_MACRO_STRING)");
|
|
strcpy (&buf[i], macro_string);
|
|
i += strlen(macro_string);
|
|
s += strlen(macro->name);
|
|
goto _continue;
|
|
}
|
|
macro = macro->next;
|
|
}
|
|
// }
|
|
|
|
// skip unknown macro name
|
|
while (*s && ((*s >= 'A' && *s <= 'Z') || (*s >= 'a' && *s <= 'z')))
|
|
s++;
|
|
continue;
|
|
}
|
|
|
|
buf[i++] = *s++;
|
|
|
|
_continue: ;
|
|
}
|
|
buf[i] = 0;
|
|
|
|
return buf;
|
|
}
|
|
|
|
|
|
|
|
void Cmd_Macro_Init (void)
|
|
{
|
|
Cmd_AddMacro("health", Cmd_Macro_Health_f);
|
|
Cmd_AddMacro("armortype", Cmd_Macro_ArmorType_f);
|
|
Cmd_AddMacro("armor", Cmd_Macro_Armor_f);
|
|
Cmd_AddMacro("shells", Cmd_Macro_Shells_f);
|
|
Cmd_AddMacro("nails", Cmd_Macro_Nails_f);
|
|
Cmd_AddMacro("rockets", Cmd_Macro_Rockets_f);
|
|
Cmd_AddMacro("cells", Cmd_Macro_Cells_f);
|
|
Cmd_AddMacro("weapon", Cmd_Macro_Weapon_f);
|
|
Cmd_AddMacro("ammo", Cmd_Macro_Ammo_f);
|
|
Cmd_AddMacro("bestweapon", Cmd_Macro_BestWeapon_f);
|
|
Cmd_AddMacro("bestammo", Cmd_Macro_BestAmmo_f);
|
|
Cmd_AddMacro("powerups", Cmd_Macro_Powerups_f);
|
|
Cmd_AddMacro("location", Cmd_Macro_Location_f);
|
|
}
|
|
|
|
|
|
/*
|
|
=============================================================================
|
|
PROXY .LOC FILES
|
|
=============================================================================
|
|
*/
|
|
|
|
typedef struct locdata_s {
|
|
vec3_t coord;
|
|
char name[MAX_LOC_NAME];
|
|
} locdata_t;
|
|
|
|
#define MAX_LOC_ENTRIES 1024
|
|
|
|
locdata_t locdata[MAX_LOC_ENTRIES]; // FIXME: allocate dynamically?
|
|
int loc_numentries;
|
|
|
|
#define SKIPBLANKS(ptr) while (*ptr == ' ' || *ptr == 9 || *ptr == 13) ptr++
|
|
#define SKIPTOEOL(ptr) while (*ptr != 10 && *ptr == 0) ptr++
|
|
|
|
void CL_LoadLocFile (char *path, qboolean quiet)
|
|
{
|
|
char *buf, *p;
|
|
int i, n, sign;
|
|
int line;
|
|
int nameindex;
|
|
int mark;
|
|
char locname[MAX_OSPATH];
|
|
|
|
if (!*path)
|
|
return;
|
|
|
|
strcpy (locname, "locs/");
|
|
if (strlen(path) + strlen(locname) + 2+4 > MAX_OSPATH)
|
|
{
|
|
Con_Printf ("CL_LoadLocFile: path name > MAX_OSPATH\n");
|
|
return;
|
|
}
|
|
strcat (locname, path);
|
|
if (!strstr(locname, "."))
|
|
strcat (locname, ".loc"); // Add default extension
|
|
|
|
mark = Hunk_LowMark ();
|
|
buf = (char *) COM_LoadHunkFile (locname);
|
|
|
|
if (!buf)
|
|
{
|
|
if (!quiet)
|
|
Con_Printf ("Could not load %s\n", locname);
|
|
return;
|
|
}
|
|
|
|
// Parse the whole file now
|
|
|
|
loc_numentries = 0;
|
|
|
|
p = buf;
|
|
line = 1;
|
|
|
|
while (1)
|
|
{
|
|
// while (*buf == ' ' || *buf == 9)
|
|
// buf++;
|
|
SKIPBLANKS(p);
|
|
|
|
if (*p == 0)
|
|
goto _endoffile;
|
|
|
|
if (*p == 10 || (*p == '/' && p[1] == '/'))
|
|
{
|
|
p++;
|
|
goto _endofline;
|
|
}
|
|
|
|
for (i = 0; i < 3; i++)
|
|
{
|
|
n = 0;
|
|
sign = 1;
|
|
while (1)
|
|
{
|
|
switch (*p++)
|
|
{
|
|
case ' ': case 9:
|
|
goto _next;
|
|
|
|
case '-':
|
|
if (n)
|
|
{
|
|
Con_Printf ("Error in loc file on line #%i\n", line);
|
|
SKIPTOEOL(p);
|
|
goto _endofline;
|
|
}
|
|
sign = -1;
|
|
break;
|
|
|
|
case '0': case '1': case '2': case '3': case '4':
|
|
case '5': case '6': case '7': case '8': case '9':
|
|
n = n*10 + (p[-1] - '0');
|
|
break;
|
|
|
|
default: // including eol or eof
|
|
Con_Printf ("Error in loc file on line #%i\n", line);
|
|
SKIPTOEOL(p);
|
|
goto _endofline;
|
|
}
|
|
}
|
|
_next:
|
|
n *= sign;
|
|
locdata[loc_numentries].coord[i] = n;
|
|
|
|
SKIPBLANKS(p);
|
|
}
|
|
|
|
|
|
// Save the location's name
|
|
//
|
|
nameindex = 0;
|
|
|
|
while (1)
|
|
{
|
|
switch (*p)
|
|
{
|
|
case 13:
|
|
p++;
|
|
break;
|
|
|
|
case 10: case 0:
|
|
locdata[loc_numentries].name[nameindex] = 0;
|
|
loc_numentries++;
|
|
|
|
if (loc_numentries >= MAX_LOC_ENTRIES)
|
|
goto _endoffile;
|
|
|
|
// leave the 0 or 10 in buffer, so it is parsed properly
|
|
goto _endofline;
|
|
|
|
default:
|
|
if (nameindex < MAX_LOC_NAME-1)
|
|
locdata[loc_numentries].name[nameindex++] = *p;
|
|
p++;
|
|
}
|
|
}
|
|
_endofline:
|
|
line++;
|
|
}
|
|
_endoffile:
|
|
|
|
Hunk_FreeToLowMark (mark);
|
|
|
|
Con_Printf ("Loaded %s (%i locations)\n", locname, loc_numentries);
|
|
}
|
|
|
|
void CL_LoadLocFile_f (void)
|
|
{
|
|
if (Cmd_Argc() != 2)
|
|
{
|
|
Con_Printf ("loadloc <filename> : load a loc file\n");
|
|
return;
|
|
}
|
|
|
|
CL_LoadLocFile (Cmd_Argv(1), false);
|
|
}
|
|
|
|
extern int parsecountmod;
|
|
|
|
#define vec_t float
|
|
|
|
char *Cmd_Macro_Location_f (void)
|
|
{
|
|
int i;
|
|
int min_num;
|
|
vec_t min_dist;
|
|
vec3_t vec;
|
|
vec3_t org;
|
|
|
|
if (!loc_numentries || (cls.state != ca_connected))
|
|
return "somewhere";
|
|
|
|
VectorCopy (cl_entities[cl.viewentity].origin, org);
|
|
for (i = 0; i < 3; i++)
|
|
org[i] *= 8;
|
|
|
|
min_num = 0;
|
|
min_dist = 9999999;
|
|
|
|
for (i = 0; i < loc_numentries; i++)
|
|
{
|
|
// Con_DPrintf ("%f %f %f: %s\n", locdata[i].coord[0], locdata[i].coord[1], locdata[i].coord[2], locdata[i].name);
|
|
VectorSubtract (org, locdata[i].coord, vec);
|
|
if (Length(vec) < min_dist)
|
|
{
|
|
min_num = i;
|
|
min_dist = Length(vec);
|
|
}
|
|
}
|
|
|
|
return locdata[min_num].name;
|
|
}
|
|
|
|
char *Cmd_Macro_PointName_f (void)
|
|
{
|
|
vec3_t forward, right, up;
|
|
vec3_t ang;//, temp;
|
|
vec3_t vieworg, endorg;
|
|
static trace_t l_trace;
|
|
// int i;
|
|
// int min_num;
|
|
// vec_t min_dist;
|
|
// vec3_t vec;
|
|
// vec3_t org;
|
|
|
|
ang[0] = cl.viewangles[0];
|
|
ang[1] = cl.viewangles[1];
|
|
ang[2] = 0;
|
|
|
|
AngleVectors (ang, forward, right, up);
|
|
VectorScale (forward, 2000, forward);
|
|
VectorCopy (cl_entities[cl.viewentity].origin, vieworg);
|
|
vieworg[2] += 22; // adjust for view height
|
|
VectorAdd (vieworg, forward, endorg);
|
|
|
|
memset (&l_trace, 0, sizeof(trace_t));
|
|
// if(!SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 0, vieworg, endorg, &l_trace))
|
|
// if (l_trace.fraction < 1)
|
|
// VectorCopy (l_trace.endpos, endorg);
|
|
// TraceLine (vieworg, endorg, trace);
|
|
// l_trace = SV_Move (vieworg, vec3_origin, vec3_origin, endorg, 0, sv_player);
|
|
|
|
SV_RecursiveHullCheck (cl.worldmodel->hulls, cl.worldmodel->hulls->firstclipnode, 0, 1, vieworg, endorg, &l_trace);
|
|
|
|
if (l_trace.ent)
|
|
{
|
|
return pr_strings + l_trace.ent->v.classname;
|
|
}
|
|
else
|
|
{
|
|
return "something";
|
|
}
|
|
}
|
|
|
|
char *Cmd_Macro_PointLocation_f (void)
|
|
{
|
|
vec3_t forward, right, up;
|
|
vec3_t ang;//, temp;
|
|
vec3_t vieworg, endorg;
|
|
static trace_t l_trace;
|
|
int i;
|
|
int min_num;
|
|
vec_t min_dist;
|
|
vec3_t vec;
|
|
vec3_t org;
|
|
|
|
if (!loc_numentries || (cls.state != ca_connected))
|
|
return "somewhere";
|
|
|
|
ang[0] = cl.viewangles[0];
|
|
ang[1] = cl.viewangles[1];
|
|
ang[2] = 0;
|
|
|
|
AngleVectors (ang, forward, right, up);
|
|
VectorScale (forward, 2000, forward);
|
|
VectorCopy (cl_entities[cl.viewentity].origin, vieworg);
|
|
vieworg[2] += 22; // adjust for view height
|
|
VectorAdd (vieworg, forward, endorg);
|
|
|
|
memset (&l_trace, 0, sizeof(trace_t));
|
|
if(!SV_RecursiveHullCheck (cl.worldmodel->hulls, cl.worldmodel->hulls->firstclipnode, 0, 1, vieworg, endorg, &l_trace))
|
|
// if (l_trace.fraction < 1)
|
|
// VectorCopy (l_trace.ent->v.origin, endorg);
|
|
VectorCopy (l_trace.endpos, endorg);
|
|
// TraceLine (vieworg, endorg, trace);
|
|
|
|
VectorCopy (endorg, org);
|
|
for (i = 0; i < 3; i++)
|
|
org[i] *= 8;
|
|
|
|
min_num = 0;
|
|
min_dist = 9999999;
|
|
|
|
for (i = 0; i < loc_numentries; i++)
|
|
{
|
|
// Con_DPrintf ("%f %f %f: %s\n", locdata[i].coord[0], locdata[i].coord[1], locdata[i].coord[2], locdata[i].name);
|
|
VectorSubtract (org, locdata[i].coord, vec);
|
|
if (Length(vec) < min_dist)
|
|
{
|
|
min_num = i;
|
|
min_dist = Length(vec);
|
|
}
|
|
}
|
|
|
|
return locdata[min_num].name;
|
|
}
|
|
/*
|
|
=============================================================================
|
|
FORCED CLIENT SETTINGS
|
|
=============================================================================
|
|
*/
|
|
void SV_ForcedSettings(void)
|
|
{
|
|
int i;
|
|
cvar_t *var;
|
|
|
|
for (i=0 ; i<svs.maxclients ; i++)
|
|
if (svs.clients[i].active && svs.clients[i].spawned)
|
|
{
|
|
for (var=cvar_vars ; var ; var=var->next)
|
|
if (var->server || strstr(var->name, "sv_"))
|
|
{
|
|
MSG_WriteByte (&svs.clients[i].message, svc_stufftext);
|
|
MSG_WriteString (&svs.clients[i].message, va("%s \"%s\"\n", var->name, var->string));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CL_InitExt()
|
|
{
|
|
// Cvar_RegisterVariable (&_cmd_macros);
|
|
Cvar_RegisterVariable (&cl_parsesay);
|
|
Cvar_RegisterVariable (&cl_loadlocs);
|
|
Cvar_RegisterVariable (&sv_triggers);
|
|
Cvar_RegisterVariable (&cl_triggers);
|
|
//Cvar_RegisterVariable (&r_turbcolor);
|
|
//Cvar_RegisterVariable (&r_skycolor);
|
|
//Cvar_RegisterVariable (&r_turb);
|
|
//Cvar_RegisterVariable (&r_fastsky);
|
|
//Cvar_RegisterVariable (&cl_staticsounds);
|
|
Cvar_RegisterVariable (&cl_autoswitch);
|
|
|
|
Cmd_Macro_Init();
|
|
Cmd_AddCommand ("loadloc", CL_LoadLocFile_f);
|
|
Cmd_AddCommand ("msg_trigger", CL_MsgTrigger_f);
|
|
Cmd_AddCommand ("sv2cl_settings", SV_ForcedSettings);
|
|
}
|
|
|
|
|
|
/*
|
|
=================
|
|
CL_Init
|
|
=================
|
|
*/
|
|
|
|
void Cvar_List_f (void);//Q2!
|
|
void Cvar_Init (void);//Q2!
|
|
void CL_LocalMenus_Init(void);//Tei localmenus
|
|
|
|
void CL_Init (void)
|
|
{
|
|
SZ_Alloc (&cls.message, 1024);
|
|
|
|
//Moved here
|
|
Cvar_RegisterVariable (&gamedir);//dave
|
|
|
|
|
|
CL_InitInput ();
|
|
CL_InitTEnts ();
|
|
|
|
//
|
|
// register our commands
|
|
//
|
|
Cvar_RegisterVariable (&cl_name);
|
|
Cvar_RegisterVariable (&cl_color);
|
|
Cvar_RegisterVariable (&cl_upspeed);
|
|
Cvar_RegisterVariable (&cl_forwardspeed);
|
|
Cvar_RegisterVariable (&cl_backspeed);
|
|
Cvar_RegisterVariable (&cl_sidespeed);
|
|
Cvar_RegisterVariable (&cl_movespeedkey);
|
|
Cvar_RegisterVariable (&cl_yawspeed);
|
|
Cvar_RegisterVariable (&cl_pitchspeed);
|
|
Cvar_RegisterVariable (&cl_anglespeedkey);
|
|
Cvar_RegisterVariable (&cl_shownet);
|
|
Cvar_RegisterVariable (&cl_nolerp);
|
|
|
|
Cvar_RegisterVariable (&cl_grenclassic);//Tei gren color
|
|
|
|
Cvar_RegisterVariable (&lookspring);
|
|
Cvar_RegisterVariable (&lookstrafe);
|
|
Cvar_RegisterVariable (&sensitivity);
|
|
Cvar_RegisterVariable (&in_mlook); // Tomaz - MouseLook
|
|
Cvar_RegisterVariable (&m_pitch);
|
|
Cvar_RegisterVariable (&m_yaw);
|
|
Cvar_RegisterVariable (&m_forward);
|
|
Cvar_RegisterVariable (&m_side);
|
|
|
|
|
|
// Tei mod support
|
|
Cvar_RegisterVariable (&autofovmax);
|
|
Cvar_RegisterVariable (&mod_predator);
|
|
|
|
Cvar_RegisterVariable (&r_efflies);
|
|
Cvar_RegisterVariable (&mod_hdigits);
|
|
Cvar_RegisterVariable (&mod_kiu); //Tei: kiu mode
|
|
Cvar_RegisterVariable (&mod_prydon); //Tei: prydon gate mode
|
|
Cvar_RegisterVariable (&mod_tenebrae); //Tei: prydon gate mode
|
|
Cvar_RegisterVariable (&mod_handicap); //Tei: JudicatorOmega suggestion
|
|
Cvar_RegisterVariable (&mod_lsig);
|
|
Cvar_RegisterVariable (&mod_showbbox);
|
|
Cvar_RegisterVariable (&mod_showspeed);
|
|
Cvar_RegisterVariable (&mousehud);
|
|
|
|
|
|
Cvar_RegisterVariable (¢erprint_blend); //Tei for prydon
|
|
|
|
Cvar_RegisterVariable (&r_aspect);
|
|
|
|
Cvar_RegisterVariable (&r_cloudplane);
|
|
Cvar_RegisterVariable (&r_cloudimage);
|
|
Cvar_RegisterVariable (&r_cloudz);
|
|
Cvar_RegisterVariable (&r_cloudscale);
|
|
|
|
|
|
|
|
Cvar_RegisterVariable (&mod_focus);
|
|
Cvar_RegisterVariable (&mod_extendedparticle);
|
|
Cvar_RegisterVariable (&mod_showlight);
|
|
Cvar_RegisterVariable (&mod_cityofangels);
|
|
|
|
Cvar_RegisterVariable (&r_autofluor);
|
|
|
|
Cvar_RegisterVariable (&mod_progs);
|
|
|
|
Cvar_RegisterVariable (&timedemo_profile);//
|
|
|
|
|
|
Cvar_RegisterVariable (&cl_autoimpulse);//kov
|
|
|
|
Cvar_RegisterVariable (&cl_fxprog);
|
|
|
|
|
|
Cmd_AddCommand ("entities", CL_PrintEntities_f);
|
|
Cmd_AddCommand ("disconnect", CL_Disconnect_f);
|
|
Cmd_AddCommand ("record", CL_Record_f);
|
|
Cmd_AddCommand ("stop", CL_Stop_f);
|
|
Cmd_AddCommand ("playdemo", CL_PlayDemo_f);
|
|
Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
|
|
Cmd_AddCommand ("fog",CL_Fog_f);//FH!
|
|
|
|
|
|
Cmd_AddCommand ("tracepos", CL_Tracepos_f); //johnfitz
|
|
Cmd_AddCommand ("viewpos", CL_Viewpos_f); //johnfitz
|
|
Cmd_AddCommand ("mapname", CL_Mapname_f); //
|
|
|
|
// Cmd_AddCommand ("run", CL_LoadPr_f);//Tei
|
|
|
|
// Q2!
|
|
//Cmd_AddCommand ("cvarlist", Cvar_List_f );
|
|
//Cvar_Init();
|
|
// Q2!
|
|
|
|
CL_InitExt(); //koval
|
|
CL_LocalMenus_Init();//Tei localmenus
|
|
|
|
LoadFXEngine();
|
|
memset(&con_prog,0,sizeof(progs_t));
|
|
CL_SetupProgs();
|
|
}
|
|
|
|
|