2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
view.c
|
|
|
|
|
|
|
|
@description@
|
|
|
|
|
|
|
|
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-03-27 20:33:07 +00:00
|
|
|
#include "QF/compat.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "view.h"
|
|
|
|
#include "vid.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/console.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "host.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "draw.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_UpdatePalette
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
V_UpdatePalette (void)
|
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, j;
|
|
|
|
qboolean new;
|
|
|
|
byte *basepal, *newpal;
|
|
|
|
byte pal[768];
|
|
|
|
int r, g, b;
|
|
|
|
qboolean force;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
V_CalcPowerupCshift ();
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
new = false;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_CSHIFTS; i++) {
|
|
|
|
if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) {
|
2001-02-19 21:15:25 +00:00
|
|
|
new = true;
|
|
|
|
cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) {
|
2001-02-19 21:15:25 +00:00
|
|
|
new = true;
|
|
|
|
cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
|
|
|
|
}
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// drop the damage value
|
2001-02-26 06:48:02 +00:00
|
|
|
cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime * 150;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0)
|
|
|
|
cl.cshifts[CSHIFT_DAMAGE].percent = 0;
|
|
|
|
|
|
|
|
// drop the bonus value
|
2001-02-26 06:48:02 +00:00
|
|
|
cl.cshifts[CSHIFT_BONUS].percent -= host_frametime * 100;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cl.cshifts[CSHIFT_BONUS].percent <= 0)
|
|
|
|
cl.cshifts[CSHIFT_BONUS].percent = 0;
|
|
|
|
|
|
|
|
force = V_CheckGamma ();
|
|
|
|
if (!new && !force)
|
|
|
|
return;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
basepal = host_basepal;
|
|
|
|
newpal = pal;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
r = basepal[0];
|
|
|
|
g = basepal[1];
|
|
|
|
b = basepal[2];
|
|
|
|
basepal += 3;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (j = 0; j < NUM_CSHIFTS; j++) {
|
|
|
|
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
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
newpal[0] = gammatable[r];
|
|
|
|
newpal[1] = gammatable[g];
|
|
|
|
newpal[2] = gammatable[b];
|
|
|
|
newpal += 3;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
VID_ShiftPalette (pal);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
V_RenderView
|
|
|
|
|
|
|
|
The player's clipping box goes from (-16 -16 -24) to (16 16 32) from
|
|
|
|
the entity origin, so any view position inside that will be valid
|
|
|
|
==================
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
extern vrect_t scr_vrect;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
V_RenderView (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-21 21:44:57 +00:00
|
|
|
if (!cl.worldmodel || cls.signon != SIGNONS)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// don't allow cheats in multiplayer
|
2001-02-26 06:48:02 +00:00
|
|
|
if (cl.maxclients > 1) {
|
|
|
|
Cvar_Set (scr_ofsx, "0");
|
|
|
|
Cvar_Set (scr_ofsy, "0");
|
|
|
|
Cvar_Set (scr_ofsz, "0");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (cl.intermission) { // intermission / finale rendering
|
|
|
|
V_CalcIntermissionRefdef ();
|
|
|
|
} else {
|
|
|
|
if (!cl.paused /* && (sv.maxclients > 1 || key_dest
|
|
|
|
== key_game) */ )
|
2001-02-19 21:15:25 +00:00
|
|
|
V_CalcRefdef ();
|
|
|
|
}
|
|
|
|
|
|
|
|
R_PushDlights (vec3_origin);
|
|
|
|
|
|
|
|
R_RenderView ();
|
|
|
|
|
|
|
|
if (crosshair->int_val)
|
2001-02-26 06:48:02 +00:00
|
|
|
Draw_Crosshair ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BuildGammaTable (float b, float c)
|
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, j;
|
|
|
|
int inf = 0;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if ((b == 1.0) && (c == 1.0)) {
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
gammatable[i] = i;
|
|
|
|
return;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!(i == 128)) {
|
|
|
|
if (i < 128) {
|
|
|
|
j = i + (int) ((128 - i) * (1 - c));
|
|
|
|
} else {
|
|
|
|
j = i + (int) ((i - 128) * (1 - c));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
j = i;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
inf = (j * b); // gamma is brightness now, and
|
|
|
|
// positive
|
|
|
|
inf = bound (0, inf, 255);
|
2001-02-19 21:15:25 +00:00
|
|
|
gammatable[i] = inf;
|
|
|
|
}
|
|
|
|
}
|