Extended dlight support

This commit is contained in:
unknown 2022-04-08 16:49:19 -04:00
parent 33ee073d60
commit 08edd64d75
7 changed files with 232 additions and 171 deletions

View file

@ -513,9 +513,6 @@ void CL_RelinkEntities (void)
if (ent->model->flags & EF_ROTATE) if (ent->model->flags & EF_ROTATE)
ent->angles[1] = bobjrotate; ent->angles[1] = bobjrotate;
if (ent->effects & EF_BRIGHTFIELD)
R_EntityParticles (ent);
if (ent->effects & EF_MUZZLEFLASH) if (ent->effects & EF_MUZZLEFLASH)
{ {
if (i == cl.viewentity /*&& qmb_initialized && r_part_muzzleflash.value*/) if (i == cl.viewentity /*&& qmb_initialized && r_part_muzzleflash.value*/)
@ -570,6 +567,10 @@ void CL_RelinkEntities (void)
dl->die = cl.time + 0.001; dl->die = cl.time + 0.001;
} }
//
// Perk Machine Lights
//
if (ent->effects & EF_BLUELIGHT) if (ent->effects & EF_BLUELIGHT)
{ {
dl = CL_AllocDlight (i); dl = CL_AllocDlight (i);
@ -586,7 +587,6 @@ void CL_RelinkEntities (void)
dl = CL_AllocDlight (i); dl = CL_AllocDlight (i);
VectorCopy (ent->origin, dl->origin); VectorCopy (ent->origin, dl->origin);
dl->die = cl.time + 0.001; dl->die = cl.time + 0.001;
dl->radius = 100;
dl->color[0] = 2; dl->color[0] = 2;
dl->color[1] = 0.25; dl->color[1] = 0.25;
dl->color[2] = 0.25; dl->color[2] = 0.25;
@ -603,27 +603,6 @@ void CL_RelinkEntities (void)
dl->color[2] = 0; dl->color[2] = 0;
} }
if (ent->effects & EF_GREENLIGHT)
{
dl = CL_AllocDlight (i);
VectorCopy (ent->origin, dl->origin);
dl->die = cl.time + 0.001;
dl->radius = 100;
dl->color[0] = 0.25;
dl->color[1] = 2;
dl->color[2] = 0.25;
}
if (ent->effects & EF_ORANGELIGHT)
{
dl = CL_AllocDlight (i);
VectorCopy (ent->origin, dl->origin);
dl->die = cl.time + 0.001;
dl->radius = 100;
dl->color[0] = 2;
dl->color[1] = 1;
dl->color[2] = 0;
}
if (ent->effects & EF_GREENLIGHT) if (ent->effects & EF_GREENLIGHT)
{ {
dl = CL_AllocDlight (i); dl = CL_AllocDlight (i);
@ -646,6 +625,55 @@ void CL_RelinkEntities (void)
dl->color[2] = 2; dl->color[2] = 2;
} }
if (ent->effects & EF_CYANLIGHT)
{
dl = CL_AllocDlight (i);
VectorCopy (ent->origin, dl->origin);
dl->die = cl.time + 0.001;
dl->radius = 100;
dl->color[0] = 0.765;
dl->color[1] = 1.40;
dl->color[2] = 1.95;
}
if (ent->effects & EF_PINKLIGHT)
{
dl = CL_AllocDlight (i);
VectorCopy (ent->origin, dl->origin);
dl->die = cl.time + 0.001;
if (ent->light_lev != 0)
dl->radius = ent->light_lev;
else
dl->radius = 100;
dl->color[0] = 2.37;
dl->color[1] = 1.35;
dl->color[2] = 1.35;
}
if (ent->effects & EF_LIMELIGHT)
{
dl = CL_AllocDlight (i);
VectorCopy (ent->origin, dl->origin);
dl->die = cl.time + 0.001;
dl->radius = 100;
dl->color[0] = 1;
dl->color[1] = 2;
dl->color[2] = 1;
}
if (ent->effects & EF_YELLOWLIGHT)
{
dl = CL_AllocDlight (i);
VectorCopy (ent->origin, dl->origin);
dl->die = cl.time + 0.001;
dl->radius = 100;
dl->color[0] = 2;
dl->color[1] = 2;
dl->color[2] = 1;
}
// naievil -- fixme // naievil -- fixme
/* /*
if (ent->effects & EF_RAYGREEN) if (ent->effects & EF_RAYGREEN)

View file

@ -589,6 +589,11 @@ void CL_ParseUpdate (int bits)
ent->lerpflags &= ~LERP_MOVESTEP; ent->lerpflags &= ~LERP_MOVESTEP;
//johnfitz //johnfitz
// NZP START
if (bits & U_LIGHTLEVEL)
ent->light_lev = MSG_ReadByte();
// NZP END
//johnfitz -- PROTOCOL_FITZQUAKE and PROTOCOL_NEHAHRA //johnfitz -- PROTOCOL_FITZQUAKE and PROTOCOL_NEHAHRA
if (cl.protocol == PROTOCOL_FITZQUAKE || cl.protocol == PROTOCOL_RMQ) if (cl.protocol == PROTOCOL_FITZQUAKE || cl.protocol == PROTOCOL_RMQ)
{ {
@ -685,6 +690,7 @@ void CL_ParseBaseline (entity_t *ent, int version) //johnfitz -- added argument
ent->baseline.colormap = MSG_ReadByte(); ent->baseline.colormap = MSG_ReadByte();
ent->baseline.skin = MSG_ReadByte(); ent->baseline.skin = MSG_ReadByte();
ent->baseline.light_lev = MSG_ReadByte();
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
ent->baseline.origin[i] = MSG_ReadCoord (cl.protocolflags); ent->baseline.origin[i] = MSG_ReadCoord (cl.protocolflags);

View file

@ -42,15 +42,15 @@ m*_t structures are in-memory
#define EF_REDLIGHT 8 #define EF_REDLIGHT 8
#define EF_ORANGELIGHT 16 #define EF_ORANGELIGHT 16
#define EF_GREENLIGHT 32 #define EF_GREENLIGHT 32
#define EF_LIGHT 64 #define EF_PINKLIGHT 64 // formerly EF_LIGHT
#define EF_NODRAW 128 #define EF_NODRAW 128
#define EF_BRIGHTFIELD 256 #define EF_LIMELIGHT 256 // formerly EF_BRIGHTFIELD
#define EF_FULLBRIGHT 512 #define EF_FULLBRIGHT 512
#define EF_DARKLIGHT 1024 #define EF_CYANLIGHT 1024 // formerly EF_DARKLIGHT
#define EF_DARKFIELD 2048 #define EF_YELLOWLIGHT 2048 // formerly EF_DARKFIELD
#define EF_PURPLELIGHT 4096 #define EF_PURPLELIGHT 4096
#define EF_RAYRED 8196 // red trail for porter x2 #define EF_RAYRED 8196 // red trail for porter x2
#define EF_RAYGREEN 16384 // gree trail for ray gun #define EF_RAYGREEN 16384 // green trail for ray gun
/* /*

View file

@ -2,166 +2,169 @@
/* file generated by qcc, do not modify */ /* file generated by qcc, do not modify */
typedef struct typedef struct
{ int pad[28]; { int pad[28];
int self; int self;
int other; int other;
int world; int world;
float time; float time;
float frametime; float frametime;
float force_retouch; float force_retouch;
string_t mapname; string_t mapname;
float deathmatch; float deathmatch;
float coop; float coop;
float teamplay; float teamplay;
float serverflags; float serverflags;
float rounds; float rounds;
float rounds_change; float rounds_change;
float parm1; float parm1;
float parm2; float parm2;
float parm3; float parm3;
float parm4; float parm4;
float parm5; float parm5;
float parm6; float parm6;
float parm7; float parm7;
float parm8; float parm8;
float parm9; float parm9;
float parm10; float parm10;
float parm11; float parm11;
float parm12; float parm12;
float parm13; float parm13;
float parm14; float parm14;
float parm15; float parm15;
float parm16; float parm16;
vec3_t v_forward; vec3_t v_forward;
vec3_t v_up; vec3_t v_up;
vec3_t v_right; vec3_t v_right;
float trace_allsolid; float trace_allsolid;
float trace_startsolid; float trace_startsolid;
float trace_fraction; float trace_fraction;
vec3_t trace_endpos; vec3_t trace_endpos;
vec3_t trace_plane_normal; vec3_t trace_plane_normal;
float trace_plane_dist; float trace_plane_dist;
int trace_ent; int trace_ent;
float trace_inopen; float trace_inopen;
float trace_inwater; float trace_inwater;
int msg_entity; int msg_entity;
func_t main; func_t main;
func_t StartFrame; func_t StartFrame;
func_t EndFrame; func_t EndFrame;
func_t PlayerPreThink; func_t PlayerPreThink;
func_t PlayerPostThink; func_t PlayerPostThink;
func_t ClientKill; func_t ClientKill;
func_t ClientConnect; func_t ClientConnect;
func_t PutClientInServer; func_t PutClientInServer;
func_t ClientDisconnect; func_t ClientDisconnect;
func_t SetNewParms; func_t SetNewParms;
func_t SetChangeParms; func_t SetChangeParms;
} globalvars_t; } globalvars_t;
typedef struct typedef struct
{ {
float modelindex; float modelindex;
vec3_t absmin; vec3_t absmin;
vec3_t absmax; vec3_t absmax;
float ltime; float ltime;
float movetype; float movetype;
float solid; float solid;
vec3_t origin; vec3_t origin;
vec3_t oldorigin; vec3_t oldorigin;
vec3_t velocity; vec3_t velocity;
vec3_t angles; vec3_t angles;
vec3_t avelocity; vec3_t avelocity;
vec3_t punchangle; vec3_t punchangle;
string_t classname; string_t classname;
string_t model; string_t model;
float frame; float frame;
float skin; float skin;
float effects; float effects;
vec3_t mins; vec3_t mins;
vec3_t maxs; vec3_t maxs;
vec3_t size; vec3_t size;
func_t touch; func_t touch;
func_t use; func_t use;
func_t think; func_t think;
func_t blocked; func_t blocked;
float nextthink; float nextthink;
int groundentity; int groundentity;
float health; float health;
float points; float points;
float kills; float kills;
float weapon; float weapon;
string_t weaponmodel; string_t weaponmodel;
string_t weapon2model; string_t weapon2model;
float weaponframe; float weaponframe;
float weapon2frame; float weapon2frame;
float currentammo; float currentammo;
float currentmag; float currentmag;
float zoom; float zoom;
float weaponskin; float weaponskin;
float weapon2skin; float weapon2skin;
float primary_grenades; float primary_grenades;
float secondary_grenades; float secondary_grenades;
float grenades; float grenades;
float perks; float perks;
float takedamage; float takedamage;
int chain; int chain;
float deadflag; float deadflag;
vec3_t view_ofs; vec3_t view_ofs;
float button0; float button0;
float button1; float button1;
float button2; float button2;
float button3; float button3;
float button4; float button4;
float button5; float button5;
float button6; float button6;
float button7; float button7;
float button8; float button8;
float impulse; float impulse;
float fixangle; float fixangle;
vec3_t v_angle; vec3_t v_angle;
float idealpitch; float idealpitch;
string_t netname; string_t netname;
int enemy; int enemy;
float flags; float flags;
float colormap; float colormap;
float team; float team;
float max_health; float max_health;
float teleport_time; float teleport_time;
float armortype; float armortype;
float armorvalue; float armorvalue;
float waterlevel; float waterlevel;
float watertype; float watertype;
float ideal_yaw; float ideal_yaw;
float yaw_speed; float yaw_speed;
int aiment; int aiment;
int head; int head;
int larm; int larm;
int rarm; int rarm;
int goalentity; int goalentity;
float spawnflags; float spawnflags;
string_t target; string_t target;
string_t targetname; string_t targetname;
float dmg_take; float dmg_take;
float dmg_save; float dmg_save;
float progress_bar; float progress_bar;
int dmg_inflictor; int dmg_inflictor;
int owner; int owner;
vec3_t movedir; vec3_t movedir;
string_t message; string_t message;
float sounds; float sounds;
string_t noise; string_t noise;
string_t noise1; string_t noise1;
string_t noise2; string_t noise2;
string_t noise3; string_t noise3;
float x2_icon; float x2_icon;
float insta_icon; float insta_icon;
string_t Weapon_Name_Touch; string_t Weapon_Name_Touch;
vec3_t ADS_Offset; vec3_t ADS_Offset;
vec3_t Flash_Offset; vec3_t Flash_Offset;
float Flash_Size; float Flash_Size;
float currentmag2; float currentmag2;
float maxspeed; float maxspeed;
float renderGrayscale; float renderGrayscale;
vec3_t colormod;
vec3_t glowmod;
float light_lev;
} entvars_t; } entvars_t;
#define PROGHEADER_CRC 5927 #define PROGHEADER_CRC 5927

View file

@ -73,6 +73,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define U_TRANS (1<<15) #define U_TRANS (1<<15)
//johnfitz //johnfitz
// NZP START
#define U_LIGHTLEVEL (1<<24)
// NZP END
#define SU_VIEWHEIGHT (1<<0) #define SU_VIEWHEIGHT (1<<0)
#define SU_IDEALPITCH (1<<1) #define SU_IDEALPITCH (1<<1)
#define SU_PUNCH1 (1<<2) #define SU_PUNCH1 (1<<2)
@ -127,6 +131,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define B_ALPHA (1<<2) // 1 byte, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT #define B_ALPHA (1<<2) // 1 byte, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT
//johnfitz //johnfitz
// NZP START
#define B_LIGHTLEVEL (1<<3)
// NZP END
//johnfitz -- PROTOCOL_FITZQUAKE -- alpha encoding //johnfitz -- PROTOCOL_FITZQUAKE -- alpha encoding
#define ENTALPHA_DEFAULT 0 //entity's alpha is "default" (i.e. water obeys r_wateralpha) -- must be zero so zeroed out memory works #define ENTALPHA_DEFAULT 0 //entity's alpha is "default" (i.e. water obeys r_wateralpha) -- must be zero so zeroed out memory works
#define ENTALPHA_ZERO 1 //entity is invisible (lowest possible alpha) #define ENTALPHA_ZERO 1 //entity is invisible (lowest possible alpha)
@ -246,6 +254,7 @@ typedef struct
unsigned char colormap; //johnfitz -- was int unsigned char colormap; //johnfitz -- was int
unsigned char skin; //johnfitz -- was int unsigned char skin; //johnfitz -- was int
unsigned char alpha; //johnfitz -- added unsigned char alpha; //johnfitz -- added
unsigned char light_lev;
int effects; int effects;
} entity_state_t; } entity_state_t;

View file

@ -71,6 +71,7 @@ typedef struct entity_s
int dlightframe; // dynamic lighting int dlightframe; // dynamic lighting
int dlightbits; int dlightbits;
float light_lev;
// FIXME: could turn these into a union // FIXME: could turn these into a union
int trivial_accept; int trivial_accept;

View file

@ -648,6 +648,9 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
if (ent->baseline.modelindex != ent->v.modelindex) if (ent->baseline.modelindex != ent->v.modelindex)
bits |= U_MODEL; bits |= U_MODEL;
if (ent->baseline.light_lev != ent->v.light_lev)
bits |= U_LIGHTLEVEL;
//johnfitz -- alpha //johnfitz -- alpha
if (pr_alpha_supported) if (pr_alpha_supported)
{ {
@ -725,6 +728,11 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
if (bits & U_ANGLE3) if (bits & U_ANGLE3)
MSG_WriteAngle(msg, ent->v.angles[2], sv.protocolflags); MSG_WriteAngle(msg, ent->v.angles[2], sv.protocolflags);
// NZP START
if (bits & U_LIGHTLEVEL)
MSG_WriteByte(msg, ent->v.light_lev);
// NZP END
//johnfitz -- PROTOCOL_FITZQUAKE //johnfitz -- PROTOCOL_FITZQUAKE
if (bits & U_ALPHA) if (bits & U_ALPHA)
MSG_WriteByte(msg, ent->alpha); MSG_WriteByte(msg, ent->alpha);
@ -1184,12 +1192,14 @@ void SV_CreateBaseline (void)
svent->baseline.colormap = entnum; svent->baseline.colormap = entnum;
svent->baseline.modelindex = SV_ModelIndex("models/player.mdl"); svent->baseline.modelindex = SV_ModelIndex("models/player.mdl");
svent->baseline.alpha = ENTALPHA_DEFAULT; //johnfitz -- alpha support svent->baseline.alpha = ENTALPHA_DEFAULT; //johnfitz -- alpha support
svent->baseline.light_lev = 0; // motolegacy -- light level support
} }
else else
{ {
svent->baseline.colormap = 0; svent->baseline.colormap = 0;
svent->baseline.modelindex = SV_ModelIndex(PR_GetString(svent->v.model)); svent->baseline.modelindex = SV_ModelIndex(PR_GetString(svent->v.model));
svent->baseline.alpha = svent->alpha; //johnfitz -- alpha support svent->baseline.alpha = svent->alpha; //johnfitz -- alpha support
svent->baseline.light_lev = 0; // motolegacy -- light level support
} }
//johnfitz -- PROTOCOL_FITZQUAKE //johnfitz -- PROTOCOL_FITZQUAKE
@ -1201,6 +1211,7 @@ void SV_CreateBaseline (void)
if (svent->baseline.frame & 0xFF00) if (svent->baseline.frame & 0xFF00)
svent->baseline.frame = 0; svent->baseline.frame = 0;
svent->baseline.alpha = ENTALPHA_DEFAULT; svent->baseline.alpha = ENTALPHA_DEFAULT;
svent->baseline.light_lev = 0;
} }
else //decide which extra data needs to be sent else //decide which extra data needs to be sent
{ {
@ -1210,6 +1221,8 @@ void SV_CreateBaseline (void)
bits |= B_LARGEFRAME; bits |= B_LARGEFRAME;
if (svent->baseline.alpha != ENTALPHA_DEFAULT) if (svent->baseline.alpha != ENTALPHA_DEFAULT)
bits |= B_ALPHA; bits |= B_ALPHA;
if (svent->baseline.light_lev != 0)
bits |= B_LIGHTLEVEL;
} }
//johnfitz //johnfitz
@ -1242,6 +1255,7 @@ void SV_CreateBaseline (void)
MSG_WriteByte (&sv.signon, svent->baseline.colormap); MSG_WriteByte (&sv.signon, svent->baseline.colormap);
MSG_WriteByte (&sv.signon, svent->baseline.skin); MSG_WriteByte (&sv.signon, svent->baseline.skin);
MSG_WriteByte (&sv.signon, svent->baseline.light_lev);
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
{ {
MSG_WriteCoord(&sv.signon, svent->baseline.origin[i], sv.protocolflags); MSG_WriteCoord(&sv.signon, svent->baseline.origin[i], sv.protocolflags);