2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
sw_view.c
|
|
|
|
|
|
|
|
player eye positioning
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-11 07:16:34 +00:00
|
|
|
#include "QF/compat.h"
|
2001-05-21 04:41:57 +00:00
|
|
|
#include "QF/info.h"
|
2001-05-10 06:01:11 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "bothdefs.h"
|
2001-05-10 06:01:11 +00:00
|
|
|
#include "client.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "host.h"
|
|
|
|
#include "r_local.h"
|
|
|
|
#include "view.h"
|
|
|
|
|
|
|
|
extern cvar_t *cl_cshift_powerup;
|
|
|
|
|
|
|
|
extern byte gammatable[256];
|
|
|
|
|
2001-05-21 19:53:57 +00:00
|
|
|
|
|
|
|
extern void V_CalcGlowCshift (void);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
V_CalcPowerupCshift (void)
|
|
|
|
{
|
|
|
|
if (!cl_cshift_powerup->int_val
|
|
|
|
|| (atoi (Info_ValueForKey (cl.serverinfo, "cshifts")) & INFO_CSHIFT_POWERUP))
|
|
|
|
return;
|
|
|
|
|
2001-05-21 19:53:57 +00:00
|
|
|
V_CalcGlowCshift ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
V_UpdatePalette (void)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
qboolean new;
|
|
|
|
byte *basepal, *newpal;
|
|
|
|
byte pal[768];
|
|
|
|
int r, g, b;
|
|
|
|
|
|
|
|
V_CalcPowerupCshift ();
|
|
|
|
|
|
|
|
new = false;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_CSHIFTS; i++) {
|
|
|
|
if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) {
|
|
|
|
new = true;
|
|
|
|
cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
|
|
|
|
}
|
|
|
|
for (j = 0; j < 3; j++) {
|
|
|
|
if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) {
|
|
|
|
new = true;
|
|
|
|
cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// drop the damage value
|
|
|
|
cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime * 150;
|
2001-05-15 04:50:53 +00:00
|
|
|
if (cl.cshifts[CSHIFT_DAMAGE].percent < 0)
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.cshifts[CSHIFT_DAMAGE].percent = 0;
|
|
|
|
|
|
|
|
// drop the bonus value
|
|
|
|
cl.cshifts[CSHIFT_BONUS].percent -= host_frametime * 100;
|
2001-05-15 04:50:53 +00:00
|
|
|
if (cl.cshifts[CSHIFT_BONUS].percent < 0)
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.cshifts[CSHIFT_BONUS].percent = 0;
|
|
|
|
|
2001-05-24 18:50:02 +00:00
|
|
|
if (!new && !vid.recalc_refdef)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
basepal = vid_basepal;
|
2001-02-19 21:15:25 +00:00
|
|
|
newpal = pal;
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
r = basepal[0];
|
|
|
|
g = basepal[1];
|
|
|
|
b = basepal[2];
|
|
|
|
basepal += 3;
|
|
|
|
|
|
|
|
for (j = 0; j < NUM_CSHIFTS; j++) {
|
2001-04-13 08:02:11 +00:00
|
|
|
r += (cl.cshifts[j].percent * (cl.cshifts[j].destcolor[0] - r)) >> 8;
|
|
|
|
g += (cl.cshifts[j].percent * (cl.cshifts[j].destcolor[1] - g)) >> 8;
|
|
|
|
b += (cl.cshifts[j].percent * (cl.cshifts[j].destcolor[2] - b)) >> 8;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
newpal[0] = gammatable[r];
|
|
|
|
newpal[1] = gammatable[g];
|
|
|
|
newpal[2] = gammatable[b];
|
|
|
|
newpal += 3;
|
|
|
|
}
|
|
|
|
VID_ShiftPalette (pal);
|
|
|
|
}
|