mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
kill r_fullbright and r_draworder
`merge' skin handling
This commit is contained in:
parent
266e6b3474
commit
72cc67e863
21 changed files with 779 additions and 319 deletions
|
@ -49,6 +49,7 @@ extern byte player_8bit_texels[320 * 200];
|
|||
extern skin_t skin_cache[MAX_CACHED_SKINS];
|
||||
struct tex_s;
|
||||
struct player_info_s;
|
||||
struct model_s;
|
||||
|
||||
void Skin_Find (struct player_info_s *sc);
|
||||
struct tex_s *Skin_Cache (skin_t *skin);
|
||||
|
@ -58,6 +59,7 @@ void Skin_Init_Cvars (void);
|
|||
void Skin_Init_Translation (void);
|
||||
void Skin_Set_Translate (int top, int bottom, byte *dest);
|
||||
void Skin_Do_Translation (skin_t *player_skin, int slot);
|
||||
void Skin_Do_Translation_Model (struct model_s *model, int skinnum, int slot);
|
||||
void Skin_Process (skin_t *skin, struct tex_s *);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,7 @@ soft_ASM= d_draw.S d_draw16.S d_parta.S d_polysa.S d_scana.S d_spr8.S \
|
|||
surf16.S surf8.S
|
||||
common_ASM= sys_ia32.S worlda.S $(math_ASM)
|
||||
|
||||
common_SOURCES= game.c wad.c world.c com.c $(common_ASM)
|
||||
common_SOURCES= game.c host_skin.c skin.c wad.c world.c com.c $(common_ASM)
|
||||
|
||||
# ... System type
|
||||
if SYSTYPE_WIN32
|
||||
|
@ -87,9 +87,9 @@ combined_SOURCES= $(common_SOURCES) $(client_SOURCES) $(server_SOURCES) \
|
|||
# ... Common stuff
|
||||
soft_SOURCES= d_edge.c d_fill.c d_init.c d_modech.c d_part.c d_polyse.c \
|
||||
d_scan.c d_sky.c d_sprite.c d_surf.c d_vars.c d_zpoint.c \
|
||||
draw.c sw_raclip.c sw_ralias.c sw_rbsp.c sw_rdraw.c sw_redge.c \
|
||||
sw_rlight.c sw_rmain.c sw_rmisc.c sw_rpart.c sw_rsky.c sw_rsprite.c \
|
||||
sw_rsurf.c sw_rvars.c screen.c \
|
||||
draw.c screen.c sw_raclip.c sw_ralias.c sw_rbsp.c sw_rdraw.c \
|
||||
sw_redge.c sw_rlight.c sw_rmain.c sw_rmisc.c sw_rpart.c sw_rsky.c \
|
||||
sw_rsprite.c sw_rsurf.c sw_rvars.c sw_skin.c \
|
||||
sw_view.c $(soft_ASM)
|
||||
|
||||
# ... Linux FBDev
|
||||
|
@ -123,7 +123,7 @@ nq_x11_DEPENDENCIES=$(client_LIB_DEPS)
|
|||
ogl_SOURCES= noisetextures.c gl_textures.c gl_draw.c gl_dyn_fires.c \
|
||||
gl_dyn_part.c gl_dyn_textures.c \
|
||||
gl_rlight.c gl_rmain.c gl_rmisc.c gl_rsurf.c \
|
||||
gl_screen.c gl_sky.c gl_sky_clip.c gl_view.c gl_warp.c
|
||||
gl_screen.c gl_skin.c gl_sky.c gl_sky_clip.c gl_view.c gl_warp.c
|
||||
|
||||
# ... 3Dfx Voodoo 1 and 2 SVGAlib-based console GL
|
||||
nq_3dfx_SOURCES= $(combined_SOURCES) $(ogl_SOURCES)
|
||||
|
|
|
@ -55,7 +55,6 @@ byte *vid_colormap;
|
|||
|
||||
// these two are not intended to be set directly
|
||||
cvar_t *cl_name;
|
||||
cvar_t *cl_color;
|
||||
|
||||
cvar_t *writecfg;
|
||||
|
||||
|
|
|
@ -397,7 +397,7 @@ CL_ParseUpdate (int bits)
|
|||
forcelink = true; // hack to make null model players
|
||||
// work
|
||||
if (num > 0 && num <= cl.maxclients)
|
||||
R_TranslatePlayerSkin (num - 1);
|
||||
CL_NewTranslation (num - 1);
|
||||
}
|
||||
|
||||
if (bits & U_FRAME)
|
||||
|
@ -424,7 +424,7 @@ CL_ParseUpdate (int bits)
|
|||
if (skin != ent->skinnum) {
|
||||
ent->skinnum = skin;
|
||||
if (num > 0 && num <= cl.maxclients)
|
||||
R_TranslatePlayerSkin (num - 1);
|
||||
CL_NewTranslation (num - 1);
|
||||
}
|
||||
|
||||
if (bits & U_EFFECTS)
|
||||
|
@ -597,39 +597,6 @@ CL_ParseClientdata (int bits)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
CL_NewTranslation (int slot)
|
||||
{
|
||||
int i, j;
|
||||
int top, bottom;
|
||||
byte *dest, *source;
|
||||
|
||||
if (slot > cl.maxclients)
|
||||
Sys_Error ("CL_NewTranslation: slot > cl.maxclients");
|
||||
dest = cl.scores[slot].translations;
|
||||
source = vid.colormap;
|
||||
memcpy (dest, vid.colormap, sizeof (cl.scores[slot].translations));
|
||||
top = cl.scores[slot].colors & 0xf0;
|
||||
bottom = (cl.scores[slot].colors & 15) << 4;
|
||||
R_TranslatePlayerSkin (slot);
|
||||
|
||||
for (i = 0; i < VID_GRADES; i++, dest += 256, source += 256) {
|
||||
if (top < 128) // the artists made some backwards
|
||||
// ranges. sigh.
|
||||
memcpy (dest + TOP_RANGE, source + top, 16);
|
||||
else
|
||||
for (j = 0; j < 16; j++)
|
||||
dest[TOP_RANGE + j] = source[top + 15 - j];
|
||||
|
||||
if (bottom < 128)
|
||||
memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
|
||||
else
|
||||
for (j = 0; j < 16; j++)
|
||||
dest[BOTTOM_RANGE + j] = source[bottom + 15 - j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CL_ParseStatic (void)
|
||||
{
|
||||
|
|
|
@ -926,9 +926,6 @@ R_SetFrustum (void)
|
|||
void
|
||||
R_SetupFrame (void)
|
||||
{
|
||||
// don't allow cheats in multiplayer
|
||||
Cvar_SetValue (r_fullbright, 0);
|
||||
|
||||
R_AnimateLight ();
|
||||
|
||||
r_framecount++;
|
||||
|
|
|
@ -212,154 +212,6 @@ R_Init (void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
R_TranslatePlayerSkin
|
||||
|
||||
Translates a skin texture by the per-player color lookup
|
||||
*/
|
||||
void
|
||||
R_TranslatePlayerSkin (int playernum)
|
||||
{
|
||||
int top, bottom;
|
||||
byte translate[256];
|
||||
unsigned translate32[256];
|
||||
int i, j, s;
|
||||
model_t *model;
|
||||
aliashdr_t *paliashdr;
|
||||
byte *original;
|
||||
unsigned pixels[512 * 256], *out;
|
||||
unsigned scaled_width, scaled_height;
|
||||
int inwidth, inheight;
|
||||
byte *inrow;
|
||||
unsigned frac, fracstep;
|
||||
|
||||
top = cl.scores[playernum].colors & 0xf0;
|
||||
bottom = (cl.scores[playernum].colors & 15) << 4;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
translate[i] = i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (top < 128) // the artists made some backwards
|
||||
// ranges. sigh.
|
||||
translate[TOP_RANGE + i] = top + i;
|
||||
else
|
||||
translate[TOP_RANGE + i] = top + 15 - i;
|
||||
|
||||
if (bottom < 128)
|
||||
translate[BOTTOM_RANGE + i] = bottom + i;
|
||||
else
|
||||
translate[BOTTOM_RANGE + i] = bottom + 15 - i;
|
||||
}
|
||||
|
||||
//
|
||||
// locate the original skin pixels
|
||||
//
|
||||
currententity = &cl_entities[1 + playernum];
|
||||
model = currententity->model;
|
||||
if (!model)
|
||||
return; // player doesn't have a model yet
|
||||
if (model->type != mod_alias)
|
||||
return; // only translate skins on alias
|
||||
// models
|
||||
|
||||
paliashdr = (aliashdr_t *) Mod_Extradata (model);
|
||||
s = paliashdr->mdl.skinwidth * paliashdr->mdl.skinheight;
|
||||
if (currententity->skinnum < 0
|
||||
|| currententity->skinnum >= paliashdr->mdl.numskins) {
|
||||
Con_Printf ("(%d): Invalid player skin #%d\n", playernum,
|
||||
currententity->skinnum);
|
||||
original = (byte *) paliashdr + paliashdr->texels[0];
|
||||
} else
|
||||
original =
|
||||
(byte *) paliashdr + paliashdr->texels[currententity->skinnum];
|
||||
if (s & 3)
|
||||
Sys_Error ("R_TranslateSkin: s&3");
|
||||
|
||||
inwidth = paliashdr->mdl.skinwidth;
|
||||
inheight = paliashdr->mdl.skinheight;
|
||||
|
||||
// because this happens during gameplay, do it fast
|
||||
// instead of sending it through gl_upload 8
|
||||
glBindTexture (GL_TEXTURE_2D, playertextures + playernum);
|
||||
|
||||
#if 0
|
||||
byte translated[320 * 200];
|
||||
|
||||
for (i = 0; i < s; i += 4) {
|
||||
translated[i] = translate[original[i]];
|
||||
translated[i + 1] = translate[original[i + 1]];
|
||||
translated[i + 2] = translate[original[i + 2]];
|
||||
translated[i + 3] = translate[original[i + 3]];
|
||||
}
|
||||
|
||||
|
||||
// don't mipmap these, because it takes too long
|
||||
GL_Upload8 (translated, paliashdr->skinwidth, paliashdr->skinheight, false,
|
||||
false, true);
|
||||
#else
|
||||
scaled_width = gl_max_size->int_val < 512 ? gl_max_size->int_val : 512;
|
||||
scaled_height = gl_max_size->int_val < 256 ? gl_max_size->int_val : 256;
|
||||
|
||||
// allow users to crunch sizes down even more if they want
|
||||
scaled_width >>= gl_playermip->int_val;
|
||||
scaled_height >>= gl_playermip->int_val;
|
||||
|
||||
if (VID_Is8bit ()) { // 8bit texture upload
|
||||
byte *out2;
|
||||
|
||||
out2 = (byte *) pixels;
|
||||
memset (pixels, 0, sizeof (pixels));
|
||||
fracstep = inwidth * 0x10000 / scaled_width;
|
||||
for (i = 0; i < scaled_height; i++, out2 += scaled_width) {
|
||||
inrow = original + inwidth * (i * inheight / scaled_height);
|
||||
frac = fracstep >> 1;
|
||||
for (j = 0; j < scaled_width; j += 4) {
|
||||
out2[j] = translate[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out2[j + 1] = translate[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out2[j + 2] = translate[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out2[j + 3] = translate[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
}
|
||||
}
|
||||
|
||||
GL_Upload8_EXT ((byte *) pixels, scaled_width, scaled_height, false,
|
||||
false);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
translate32[i] = d_8to24table[translate[i]];
|
||||
|
||||
out = pixels;
|
||||
fracstep = inwidth * 0x10000 / scaled_width;
|
||||
for (i = 0; i < scaled_height; i++, out += scaled_width) {
|
||||
inrow = original + inwidth * (i * inheight / scaled_height);
|
||||
frac = fracstep >> 1;
|
||||
for (j = 0; j < scaled_width; j += 4) {
|
||||
out[j] = translate32[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out[j + 1] = translate32[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out[j + 2] = translate32[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out[j + 3] = translate32[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
}
|
||||
}
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, scaled_width,
|
||||
scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_NewMap (void)
|
||||
{
|
||||
|
|
240
nq/source/gl_skin.c
Normal file
240
nq/source/gl_skin.c
Normal file
|
@ -0,0 +1,240 @@
|
|||
/*
|
||||
gl_skin.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
|
||||
|
||||
#include "QF/compat.h"
|
||||
#include "QF/console.h"
|
||||
#include "QF/skin.h"
|
||||
#include "QF/texture.h"
|
||||
|
||||
#include "glquake.h"
|
||||
#include "render.h"
|
||||
|
||||
static byte translate[256];
|
||||
static unsigned int translate32[256];
|
||||
|
||||
void
|
||||
Skin_Set_Translate (int top, int bottom, byte *dest)
|
||||
{
|
||||
int i;
|
||||
|
||||
top = bound (0, top, 13) * 16;
|
||||
bottom = bound (0, bottom, 13) * 16;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (top < 128) // the artists made some backwards
|
||||
// ranges. sigh.
|
||||
translate[TOP_RANGE + i] = top + i;
|
||||
else
|
||||
translate[TOP_RANGE + i] = top + 15 - i;
|
||||
|
||||
if (bottom < 128)
|
||||
translate[BOTTOM_RANGE + i] = bottom + i;
|
||||
else
|
||||
translate[BOTTOM_RANGE + i] = bottom + 15 - i;
|
||||
}
|
||||
if (!VID_Is8bit()) { // 32 bit upload, the norm.
|
||||
for (i = 0; i < 256; i++)
|
||||
translate32[i] = d_8to24table[translate[i]];
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
build_skin_8 (byte * original, int tinwidth, int tinheight,
|
||||
unsigned int scaled_width, unsigned int scaled_height,
|
||||
int inwidth, qboolean alpha)
|
||||
{
|
||||
unsigned int frac, fracstep;
|
||||
byte *inrow;
|
||||
byte pixels[512 * 256], *out;
|
||||
int i, j;
|
||||
|
||||
out = pixels;
|
||||
memset (pixels, 0, sizeof (pixels));
|
||||
fracstep = tinwidth * 0x10000 / scaled_width;
|
||||
for (i = 0; i < scaled_height; i++, out += scaled_width) {
|
||||
inrow = original + inwidth * (i * tinheight / scaled_height);
|
||||
frac = fracstep >> 1;
|
||||
for (j = 0; j < scaled_width; j += 4) {
|
||||
out[j] = translate[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out[j + 1] = translate[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out[j + 2] = translate[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out[j + 3] = translate[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
}
|
||||
}
|
||||
|
||||
GL_Upload8_EXT ((byte *) pixels, scaled_width, scaled_height, false, alpha);
|
||||
}
|
||||
|
||||
static void
|
||||
build_skin_32 (byte * original, int tinwidth, int tinheight,
|
||||
unsigned int scaled_width, unsigned int scaled_height,
|
||||
int inwidth, qboolean alpha)
|
||||
{
|
||||
unsigned int frac, fracstep;
|
||||
byte *inrow;
|
||||
unsigned int pixels[512 * 256], *out;
|
||||
int i, j;
|
||||
int samples = alpha ? gl_alpha_format : gl_solid_format;
|
||||
|
||||
out = pixels;
|
||||
memset (pixels, 0, sizeof (pixels));
|
||||
fracstep = tinwidth * 0x10000 / scaled_width;
|
||||
for (i = 0; i < scaled_height; i++, out += scaled_width) {
|
||||
inrow = original + inwidth * (i * tinheight / scaled_height);
|
||||
frac = fracstep >> 1;
|
||||
for (j = 0; j < scaled_width; j += 4) {
|
||||
out[j] = translate32[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out[j + 1] = translate32[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out[j + 2] = translate32[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
out[j + 3] = translate32[inrow[frac >> 16]];
|
||||
frac += fracstep;
|
||||
}
|
||||
}
|
||||
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, samples,
|
||||
scaled_width, scaled_height, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
|
||||
static void
|
||||
build_skin (int texnum, byte *ptexels, int width, int height,
|
||||
int owidth, int oheight, qboolean alpha)
|
||||
{
|
||||
unsigned int scaled_width, scaled_height;
|
||||
|
||||
// because this happens during gameplay, do it fast
|
||||
// instead of sending it through GL_Upload8()
|
||||
glBindTexture (GL_TEXTURE_2D, texnum);
|
||||
|
||||
// FIXME deek: This 512x256 limit sucks!
|
||||
scaled_width = min (gl_max_size->int_val, 512);
|
||||
scaled_height = min (gl_max_size->int_val, 256);
|
||||
|
||||
// allow users to crunch sizes down even more if they want
|
||||
scaled_width >>= gl_playermip->int_val;
|
||||
scaled_height >>= gl_playermip->int_val;
|
||||
|
||||
if (VID_Is8bit ()) { // 8bit texture upload
|
||||
build_skin_8 (ptexels, owidth, oheight, scaled_width,
|
||||
scaled_height, width, alpha);
|
||||
} else {
|
||||
build_skin_32 (ptexels, owidth, oheight, scaled_width,
|
||||
scaled_height, width, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Skin_Do_Translation (skin_t *player_skin, int slot)
|
||||
{
|
||||
int texnum;
|
||||
int inwidth, inheight;
|
||||
byte *original;
|
||||
tex_t *skin;
|
||||
|
||||
if ((skin = (tex_t*)Skin_Cache (player_skin)) != NULL) {
|
||||
// skin data width
|
||||
inwidth = 320;
|
||||
inheight = 200;
|
||||
original = skin->data;
|
||||
} else {
|
||||
original = player_8bit_texels;
|
||||
inwidth = 296;
|
||||
inheight = 194;
|
||||
}
|
||||
texnum = playertextures + slot;
|
||||
build_skin (texnum, original, inwidth, inheight, 296, 194, false);
|
||||
}
|
||||
|
||||
void
|
||||
Skin_Do_Translation_Model (model_t *model, int skinnum, int slot)
|
||||
{
|
||||
int texnum;
|
||||
int inwidth, inheight;
|
||||
aliashdr_t *paliashdr;
|
||||
byte *original;
|
||||
|
||||
if (!model) // player doesn't have a model yet
|
||||
return;
|
||||
if (model->type != mod_alias) // only translate skins on alias models
|
||||
return;
|
||||
|
||||
paliashdr = (aliashdr_t *) Mod_Extradata (model);
|
||||
if (skinnum < 0
|
||||
|| skinnum >= paliashdr->mdl.numskins) {
|
||||
Con_Printf ("(%d): Invalid player skin #%d\n", slot,
|
||||
skinnum);
|
||||
original = (byte *) paliashdr + paliashdr->texels[0];
|
||||
} else {
|
||||
original =
|
||||
(byte *) paliashdr + paliashdr->texels[skinnum];
|
||||
}
|
||||
|
||||
inwidth = paliashdr->mdl.skinwidth;
|
||||
inheight = paliashdr->mdl.skinheight;
|
||||
|
||||
texnum = playertextures + slot;
|
||||
build_skin (texnum, original, inwidth, inheight, inwidth, inheight, false);
|
||||
}
|
||||
|
||||
void
|
||||
Skin_Init_Translation (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
translate[i] = i;
|
||||
translate32[i] = d_8to24table[i];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Skin_Process (skin_t *skin, tex_t *tex)
|
||||
{
|
||||
int pixels = tex->width * tex->height;
|
||||
byte *ptexels = Hunk_TempAlloc (pixels);
|
||||
|
||||
if (Mod_CalcFullbright (tex->data, ptexels, pixels)) {
|
||||
skin->fb_texture = player_fb_textures + (skin - skin_cache);
|
||||
build_skin (skin->fb_texture, ptexels, tex->width, tex->height,
|
||||
296, 194, true);
|
||||
}
|
||||
}
|
|
@ -57,6 +57,8 @@
|
|||
|
||||
extern void R_Particles_Init_Cvars (void);
|
||||
extern void R_Init_Cvars (void);
|
||||
extern void Host_Skin_Init (void);
|
||||
extern void Host_Skin_Init_Cvars (void);
|
||||
|
||||
/*
|
||||
|
||||
|
@ -861,7 +863,6 @@ Host_Init (quakeparms_t *parms)
|
|||
Cmd_Init_Hash ();
|
||||
Memory_Init (parms->membase, parms->memsize);
|
||||
Cvar_Init ();
|
||||
CL_InitCvars ();
|
||||
|
||||
Cbuf_Init ();
|
||||
Cmd_Init ();
|
||||
|
@ -879,6 +880,7 @@ Host_Init (quakeparms_t *parms)
|
|||
Cmd_Exec_File (fs_globalcfg->string);
|
||||
Cbuf_Execute_Sets ();
|
||||
|
||||
CL_InitCvars ();
|
||||
IN_Init_Cvars ();
|
||||
VID_Init_Cvars ();
|
||||
S_Init_Cvars ();
|
||||
|
@ -889,6 +891,7 @@ Host_Init (quakeparms_t *parms)
|
|||
R_Init_Cvars ();
|
||||
R_Particles_Init_Cvars ();
|
||||
Mod_Init_Cvars ();
|
||||
Host_Skin_Init_Cvars ();
|
||||
|
||||
Cmd_StuffCmds_f ();
|
||||
Cbuf_Execute_Sets ();
|
||||
|
@ -920,6 +923,7 @@ Host_Init (quakeparms_t *parms)
|
|||
Mod_Init ();
|
||||
NET_Init ();
|
||||
SV_Init ();
|
||||
Host_Skin_Init ();
|
||||
|
||||
Con_Printf ("Exe: " __TIME__ " " __DATE__ "\n");
|
||||
Con_Printf ("%4.1f megabyte heap\n", parms->memsize / (1024 * 1024.0));
|
||||
|
|
|
@ -1073,57 +1073,6 @@ Host_Tell_f (void)
|
|||
host_client = save;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
Host_Color_f
|
||||
==================
|
||||
*/
|
||||
void
|
||||
Host_Color_f (void)
|
||||
{
|
||||
int top, bottom;
|
||||
int playercolor;
|
||||
|
||||
if (Cmd_Argc () == 1) {
|
||||
Con_Printf ("\"color\" is \"%i %i\"\n", (cl_color->int_val) >> 4,
|
||||
(cl_color->int_val) & 0x0f);
|
||||
Con_Printf ("color <0-13> [0-13]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc () == 2)
|
||||
top = bottom = atoi (Cmd_Argv (1));
|
||||
else {
|
||||
top = atoi (Cmd_Argv (1));
|
||||
bottom = atoi (Cmd_Argv (2));
|
||||
}
|
||||
|
||||
top &= 15;
|
||||
if (top > 13)
|
||||
top = 13;
|
||||
bottom &= 15;
|
||||
if (bottom > 13)
|
||||
bottom = 13;
|
||||
|
||||
playercolor = top * 16 + bottom;
|
||||
|
||||
if (cmd_source == src_command) {
|
||||
Cvar_SetValue (cl_color, playercolor);
|
||||
if (cls.state == ca_connected)
|
||||
Cmd_ForwardToServer ();
|
||||
return;
|
||||
}
|
||||
|
||||
host_client->colors = playercolor;
|
||||
SVFIELD (host_client->edict, team, float) = bottom + 1;
|
||||
|
||||
// send notification to all clients
|
||||
MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
|
||||
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
|
||||
MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Host_Kill_f
|
||||
|
@ -1819,7 +1768,6 @@ Host_InitCommands (void)
|
|||
Cmd_AddCommand ("say", Host_Say_f, "No Description");
|
||||
Cmd_AddCommand ("say_team", Host_Say_Team_f, "No Description");
|
||||
Cmd_AddCommand ("tell", Host_Tell_f, "No Description");
|
||||
Cmd_AddCommand ("color", Host_Color_f, "No Description");
|
||||
Cmd_AddCommand ("kill", Host_Kill_f, "No Description");
|
||||
Cmd_AddCommand ("pause", Host_Pause_f, "No Description");
|
||||
Cmd_AddCommand ("spawn", Host_Spawn_f, "No Description");
|
||||
|
|
143
nq/source/host_skin.c
Normal file
143
nq/source/host_skin.c
Normal file
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
skin.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
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "QF/cmd.h"
|
||||
#include "QF/compat.h"
|
||||
#include "QF/console.h"
|
||||
#include "QF/msg.h"
|
||||
#include "QF/screen.h"
|
||||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "host.h"
|
||||
#include "server.h"
|
||||
|
||||
cvar_t *noskins; //XXX FIXME
|
||||
cvar_t *skin;
|
||||
cvar_t *topcolor;
|
||||
cvar_t *bottomcolor;
|
||||
cvar_t *cl_color;
|
||||
|
||||
char allskins[128];
|
||||
|
||||
|
||||
void
|
||||
Host_Color_f (void)
|
||||
{
|
||||
// just for quake compatability...
|
||||
int top, bottom;
|
||||
char playercolor;
|
||||
|
||||
if (Cmd_Argc () == 1) {
|
||||
Con_Printf ("\"color\" is \"%d %d\"\n", (cl_color->int_val) >> 4,
|
||||
(cl_color->int_val) & 0x0f);
|
||||
Con_Printf ("color <0-13> [0-13]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc () == 2)
|
||||
top = bottom = atoi (Cmd_Argv (1));
|
||||
else {
|
||||
top = atoi (Cmd_Argv (1));
|
||||
bottom = atoi (Cmd_Argv (2));
|
||||
}
|
||||
|
||||
top = min (top &= 15, 13);
|
||||
bottom = min (bottom &= 15, 13);
|
||||
|
||||
playercolor = top * 16 + bottom;
|
||||
|
||||
if (cmd_source == src_command) {
|
||||
Cvar_SetValue (cl_color, playercolor);
|
||||
if (cls.state == ca_connected)
|
||||
Cmd_ForwardToServer ();
|
||||
return;
|
||||
}
|
||||
|
||||
host_client->colors = playercolor;
|
||||
SVFIELD (host_client->edict, team, float) = bottom + 1;
|
||||
|
||||
// send notification to all clients
|
||||
MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
|
||||
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
|
||||
MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Host_Skin_Init (void)
|
||||
{
|
||||
Skin_Init ();
|
||||
Cmd_AddCommand ("color", Host_Color_f, "The pant and shirt color (color "
|
||||
"shirt pants) Note that if only shirt color is given, "
|
||||
"pants will match");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Host_Skin_Init_Cvars (void)
|
||||
{
|
||||
Skin_Init_Cvars ();
|
||||
cl_color = Cvar_Get ("_cl_color", "0", CVAR_ARCHIVE, NULL, "Player color");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CL_NewTranslation (int slot)
|
||||
{
|
||||
scoreboard_t *player;
|
||||
int top, bottom;
|
||||
byte *dest;
|
||||
model_t *model;
|
||||
int skinnum;
|
||||
|
||||
if (slot > cl.maxclients)
|
||||
Sys_Error ("Host_NewTranslation: slot > cl.maxclients");
|
||||
|
||||
player = &cl.scores[slot];
|
||||
dest = player->translations;
|
||||
top = (player->colors & 0xf0) >> 4;
|
||||
bottom = player->colors & 15;
|
||||
model = cl_entities[1 + slot].model;
|
||||
skinnum = cl_entities[1 + slot].skinnum;
|
||||
|
||||
Skin_Set_Translate (top, bottom, dest);
|
||||
Skin_Do_Translation_Model (model, skinnum, slot);
|
||||
}
|
|
@ -46,11 +46,9 @@ cvar_t *r_ambient;
|
|||
cvar_t *r_clearcolor;
|
||||
cvar_t *r_drawentities;
|
||||
cvar_t *r_drawflat;
|
||||
cvar_t *r_draworder;
|
||||
cvar_t *r_drawviewmodel;
|
||||
cvar_t *r_dspeeds;
|
||||
cvar_t *r_dynamic;
|
||||
cvar_t *r_fullbright;
|
||||
cvar_t *r_graphheight;
|
||||
cvar_t *r_maxedges;
|
||||
cvar_t *r_maxsurfs;
|
||||
|
@ -202,15 +200,12 @@ R_Init_Cvars (void)
|
|||
"everything but the world)");
|
||||
r_drawflat = Cvar_Get ("r_drawflat", "0", CVAR_NONE, NULL,
|
||||
"Toggles the drawing of textures");
|
||||
r_draworder = Cvar_Get ("r_draworder", "0", CVAR_NONE, NULL,
|
||||
"Toggles drawing order");
|
||||
r_drawviewmodel = Cvar_Get ("r_drawviewmodel", "1", CVAR_NONE, NULL,
|
||||
"Toggles view model drawing (your weapons)");
|
||||
r_dspeeds = Cvar_Get ("r_dspeeds", "0", CVAR_NONE, NULL,
|
||||
"Toggles the display of drawing speed information");
|
||||
r_dynamic = Cvar_Get ("r_dynamic", "1", CVAR_NONE, NULL,
|
||||
"Set to 0 to disable lightmap changes");
|
||||
r_fullbright = Cvar_Get ("r_fullbright", "0", CVAR_NONE, NULL, "None");
|
||||
r_graphheight = Cvar_Get ("r_graphheight", "10", CVAR_NONE, NULL,
|
||||
"Set the number of lines displayed in the "
|
||||
"various graphs");
|
||||
|
|
223
nq/source/skin.c
Normal file
223
nq/source/skin.c
Normal file
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
skin.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
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "QF/compat.h"
|
||||
#include "QF/console.h"
|
||||
#include "QF/hash.h"
|
||||
#include "QF/pcx.h"
|
||||
#include "QF/quakefs.h"
|
||||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/texture.h"
|
||||
|
||||
#include "client.h"
|
||||
|
||||
extern cvar_t *noskins; // XXX FIXME, this shouldn't be here?
|
||||
|
||||
cvar_t *baseskin;
|
||||
cvar_t *skin;
|
||||
cvar_t *topcolor;
|
||||
cvar_t *bottomcolor;
|
||||
|
||||
char allskins[128];
|
||||
|
||||
skin_t skin_cache[MAX_CACHED_SKINS];
|
||||
hashtab_t *skin_hash;
|
||||
int numskins;
|
||||
|
||||
|
||||
static char *
|
||||
skin_get_key (void *_skin, void *unused)
|
||||
{
|
||||
skin_t *skin = (skin_t*)_skin;
|
||||
return skin->name;
|
||||
}
|
||||
|
||||
#if 0 //XXX qw only atm
|
||||
/*
|
||||
Skin_Find
|
||||
|
||||
Determines the best skin for the given scoreboard
|
||||
slot, and sets scoreboard->skin
|
||||
*/
|
||||
void
|
||||
Skin_Find (player_info_t *sc)
|
||||
{
|
||||
skin_t *skin;
|
||||
char name[128], *s;
|
||||
|
||||
if (allskins[0])
|
||||
strncpy (name, allskins, sizeof (name));
|
||||
else {
|
||||
s = Info_ValueForKey (sc->userinfo, "skin");
|
||||
if (s && s[0])
|
||||
strncpy (name, s, sizeof (name));
|
||||
else
|
||||
strncpy (name, baseskin->string, sizeof (name));
|
||||
}
|
||||
|
||||
if (strstr (name, "..") || *name == '.')
|
||||
strcpy (name, "base");
|
||||
|
||||
COM_StripExtension (name, name);
|
||||
|
||||
skin = Hash_Find (skin_hash, name);
|
||||
if (skin) {
|
||||
sc->skin = skin;
|
||||
Skin_Cache (sc->skin);
|
||||
return;
|
||||
}
|
||||
|
||||
if (numskins == MAX_CACHED_SKINS) { // ran out of spots, so flush
|
||||
// everything
|
||||
Skin_Flush ();
|
||||
return;
|
||||
}
|
||||
|
||||
skin = &skin_cache[numskins];
|
||||
sc->skin = skin;
|
||||
numskins++;
|
||||
|
||||
memset (skin, 0, sizeof (*skin));
|
||||
strncpy (skin->name, name, sizeof (skin->name) - 1);
|
||||
|
||||
Hash_Add (skin_hash, skin);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Skin_Cache
|
||||
|
||||
Returns a pointer to the skin bitmap, or NULL to use the default
|
||||
*/
|
||||
tex_t *
|
||||
Skin_Cache (skin_t *skin)
|
||||
{
|
||||
char name[1024];
|
||||
tex_t *out;
|
||||
QFile *file;
|
||||
tex_t *tex;
|
||||
int pixels;
|
||||
byte *ipix, *opix;
|
||||
int i;
|
||||
|
||||
#if 0 //XXX qw only atm
|
||||
if (cls.downloadtype == dl_skin) // use base until downloaded
|
||||
return NULL;
|
||||
#endif
|
||||
// NOSKINS > 1 will show skins, but not download new ones.
|
||||
if (noskins->int_val == 1) //XXX FIXME
|
||||
return NULL;
|
||||
|
||||
if (skin->failedload)
|
||||
return NULL;
|
||||
|
||||
out = Cache_Check (&skin->cache);
|
||||
if (out)
|
||||
return out;
|
||||
|
||||
// load the pic from disk
|
||||
snprintf (name, sizeof (name), "skins/%s.pcx", skin->name);
|
||||
COM_FOpenFile (name, &file);
|
||||
if (!file) {
|
||||
Con_Printf ("Couldn't load skin %s\n", name);
|
||||
snprintf (name, sizeof (name), "skins/%s.pcx", baseskin->string);
|
||||
COM_FOpenFile (name, &file);
|
||||
if (!file) {
|
||||
skin->failedload = true;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
tex = LoadPCX (file, 0);
|
||||
Qclose (file);
|
||||
|
||||
if (!tex || tex->width > 320 || tex->height > 200) {
|
||||
skin->failedload = true;
|
||||
Con_Printf ("Bad skin %s\n", name);
|
||||
return NULL;
|
||||
}
|
||||
pixels = 320 * 200;
|
||||
|
||||
out = Cache_Alloc (&skin->cache, sizeof (tex_t) + pixels, skin->name);
|
||||
if (!out)
|
||||
Sys_Error ("Skin_Cache: couldn't allocate");
|
||||
opix = out->data;
|
||||
out->width = 320;
|
||||
out->height = 200;
|
||||
out->palette = tex->palette; //FIXME assumes 0 or vid_basepal
|
||||
memset (opix, 0, pixels);
|
||||
for (i = 0, ipix = tex->data; i < tex->height;
|
||||
i++, opix += 320, ipix += tex->width)
|
||||
memcpy (opix, ipix, tex->width);
|
||||
|
||||
Skin_Process (skin, out);
|
||||
|
||||
skin->failedload = false;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Skin_Flush (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numskins; i++) {
|
||||
if (skin_cache[i].cache.data)
|
||||
Cache_Free (&skin_cache[i].cache);
|
||||
}
|
||||
numskins = 0;
|
||||
Hash_FlushTable (skin_hash);
|
||||
}
|
||||
|
||||
void
|
||||
Skin_Init (void)
|
||||
{
|
||||
skin_hash = Hash_NewTable (1021, skin_get_key, 0, 0);
|
||||
Skin_Init_Translation ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Skin_Init_Cvars (void)
|
||||
{
|
||||
baseskin = Cvar_Get ("baseskin", "base", CVAR_NONE, NULL,
|
||||
"default base skin name");
|
||||
}
|
|
@ -128,15 +128,9 @@ R_BeginEdgeFrame (void)
|
|||
surfaces[1].flags = SURF_DRAWBACKGROUND;
|
||||
|
||||
// put the background behind everything in the world
|
||||
if (r_draworder->int_val) {
|
||||
pdrawfunc = R_GenerateSpansBackward;
|
||||
surfaces[1].key = 0;
|
||||
r_currentkey = 1;
|
||||
} else {
|
||||
pdrawfunc = R_GenerateSpans;
|
||||
surfaces[1].key = 0x7FFFFFFF;
|
||||
r_currentkey = 0;
|
||||
}
|
||||
pdrawfunc = R_GenerateSpans;
|
||||
surfaces[1].key = 0x7FFFFFFF;
|
||||
r_currentkey = 0;
|
||||
|
||||
// FIXME: set with memset
|
||||
for (v = r_refdef.vrect.y; v < r_refdef.vrectbottom; v++) {
|
||||
|
|
|
@ -49,12 +49,6 @@ qboolean allowskybox; // whether or not to allow skyboxes --KB
|
|||
void
|
||||
R_CheckVariables (void)
|
||||
{
|
||||
static int oldbright;
|
||||
|
||||
if (r_fullbright->int_val != oldbright) {
|
||||
oldbright = r_fullbright->int_val;
|
||||
D_FlushCaches (); // so all lighting changes
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -430,7 +424,6 @@ R_SetupFrame (void)
|
|||
float w, h;
|
||||
|
||||
// don't allow cheats in multiplayer
|
||||
Cvar_SetValue (r_draworder, 0);
|
||||
Cvar_SetValue (r_ambient, 0);
|
||||
Cvar_SetValue (r_drawflat, 0);
|
||||
|
||||
|
@ -454,9 +447,6 @@ R_SetupFrame (void)
|
|||
|
||||
r_refdef.ambientlight = max (r_ambient->value, 0);
|
||||
|
||||
if (!sv.active)
|
||||
Cvar_SetValue (r_draworder, 0); // don't let cheaters look behind walls
|
||||
|
||||
R_CheckVariables ();
|
||||
|
||||
R_AnimateLight ();
|
||||
|
@ -561,9 +551,3 @@ R_SetupFrame (void)
|
|||
|
||||
D_SetupFrame ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_TranslatePlayerSkin (int playernum)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -56,9 +56,8 @@ void R_DrawSurfaceBlock8_mip2 (void);
|
|||
void R_DrawSurfaceBlock8_mip3 (void);
|
||||
|
||||
static void (*surfmiptable[4]) (void) = {
|
||||
R_DrawSurfaceBlock8_mip0,
|
||||
R_DrawSurfaceBlock8_mip1,
|
||||
R_DrawSurfaceBlock8_mip2, R_DrawSurfaceBlock8_mip3};
|
||||
R_DrawSurfaceBlock8_mip0, R_DrawSurfaceBlock8_mip1,
|
||||
R_DrawSurfaceBlock8_mip2, R_DrawSurfaceBlock8_mip3};
|
||||
|
||||
unsigned int blocklights[18 * 18];
|
||||
|
||||
|
@ -148,7 +147,7 @@ R_BuildLightMap (void)
|
|||
size = smax * tmax;
|
||||
lightmap = surf->samples;
|
||||
|
||||
if (r_fullbright->int_val || !cl.worldmodel->lightdata) {
|
||||
if (!cl.worldmodel->lightdata) {
|
||||
for (i = 0; i < size; i++)
|
||||
blocklights[i] = 0;
|
||||
return;
|
||||
|
@ -186,7 +185,7 @@ R_BuildLightMap (void)
|
|||
|
||||
Returns the proper texture for a given time and base texture
|
||||
*/
|
||||
texture_t *
|
||||
texture_t *
|
||||
R_TextureAnimation (texture_t *base)
|
||||
{
|
||||
int reletive;
|
||||
|
@ -353,8 +352,8 @@ R_DrawSurfaceBlock8_mip1 (void)
|
|||
prowdest = prowdestbase;
|
||||
|
||||
for (v = 0; v < r_numvblocks; v++) {
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
lightleft = r_lightptr[0];
|
||||
lightright = r_lightptr[1];
|
||||
r_lightptr += r_lightwidth;
|
||||
|
@ -396,8 +395,8 @@ R_DrawSurfaceBlock8_mip2 (void)
|
|||
prowdest = prowdestbase;
|
||||
|
||||
for (v = 0; v < r_numvblocks; v++) {
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
lightleft = r_lightptr[0];
|
||||
lightright = r_lightptr[1];
|
||||
r_lightptr += r_lightwidth;
|
||||
|
@ -439,8 +438,8 @@ R_DrawSurfaceBlock8_mip3 (void)
|
|||
prowdest = prowdestbase;
|
||||
|
||||
for (v = 0; v < r_numvblocks; v++) {
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
lightleft = r_lightptr[0];
|
||||
lightright = r_lightptr[1];
|
||||
r_lightptr += r_lightwidth;
|
||||
|
|
96
nq/source/sw_skin.c
Normal file
96
nq/source/sw_skin.c
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
sw_skin.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
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "QF/compat.h"
|
||||
#include "QF/model.h"
|
||||
#include "QF/skin.h"
|
||||
|
||||
#include "render.h"
|
||||
|
||||
|
||||
void
|
||||
Skin_Set_Translate (int top, int bottom, byte *dest)
|
||||
{
|
||||
int i, j;
|
||||
byte *source;
|
||||
|
||||
top = bound (0, top, 13) * 16;
|
||||
bottom = bound (0, bottom, 13) * 16;
|
||||
|
||||
source = vid.colormap;
|
||||
memcpy (dest, vid.colormap, VID_GRADES*256);
|
||||
|
||||
for (i = 0; i < VID_GRADES; i++, dest += 256, source += 256) {
|
||||
if (top < 128) // the artists made some backwards
|
||||
// ranges. sigh.
|
||||
memcpy (dest + TOP_RANGE, source + top, 16);
|
||||
else
|
||||
for (j = 0; j < 16; j++)
|
||||
dest[TOP_RANGE + j] = source[top + 15 - j];
|
||||
|
||||
if (bottom < 128)
|
||||
memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
|
||||
else
|
||||
for (j = 0; j < 16; j++)
|
||||
dest[BOTTOM_RANGE + j] = source[bottom + 15 - j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Skin_Do_Translation (skin_t *player_skin, int slot)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Skin_Do_Translation_Model (model_t *model, int skinnum, int slot)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Skin_Init_Translation (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Skin_Process (skin_t *skin, struct tex_s *tex)
|
||||
{
|
||||
}
|
|
@ -31,6 +31,7 @@
|
|||
#endif
|
||||
|
||||
#include "QF/compat.h"
|
||||
#include "QF/console.h"
|
||||
#include "QF/skin.h"
|
||||
#include "QF/texture.h"
|
||||
|
||||
|
@ -135,15 +136,11 @@ build_skin_32 (byte * original, int tinwidth, int tinheight,
|
|||
}
|
||||
|
||||
static void
|
||||
build_skin (int texnum, byte *ptexels, int width, int height, qboolean alpha)
|
||||
build_skin (int texnum, byte *ptexels, int width, int height,
|
||||
int owidth, int oheight, qboolean alpha)
|
||||
{
|
||||
int tinwidth, tinheight;
|
||||
unsigned int scaled_width, scaled_height;
|
||||
|
||||
// locate the original skin pixels
|
||||
tinwidth = 296; // real model width
|
||||
tinheight = 194; // real model height
|
||||
|
||||
// because this happens during gameplay, do it fast
|
||||
// instead of sending it through GL_Upload8()
|
||||
glBindTexture (GL_TEXTURE_2D, texnum);
|
||||
|
@ -157,10 +154,10 @@ build_skin (int texnum, byte *ptexels, int width, int height, qboolean alpha)
|
|||
scaled_height >>= gl_playermip->int_val;
|
||||
|
||||
if (VID_Is8bit ()) { // 8bit texture upload
|
||||
build_skin_8 (ptexels, tinwidth, tinheight, scaled_width,
|
||||
build_skin_8 (ptexels, owidth, oheight, scaled_width,
|
||||
scaled_height, width, alpha);
|
||||
} else {
|
||||
build_skin_32 (ptexels, tinwidth, tinheight, scaled_width,
|
||||
build_skin_32 (ptexels, owidth, oheight, scaled_width,
|
||||
scaled_height, width, alpha);
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +181,38 @@ Skin_Do_Translation (skin_t *player_skin, int slot)
|
|||
inheight = 194;
|
||||
}
|
||||
texnum = playertextures + slot;
|
||||
build_skin (texnum, original, inwidth, inheight, false);
|
||||
build_skin (texnum, original, inwidth, inheight, 296, 194, false);
|
||||
}
|
||||
|
||||
void
|
||||
Skin_Do_Translation_Model (model_t *model, int skinnum, int slot)
|
||||
{
|
||||
int texnum;
|
||||
int inwidth, inheight;
|
||||
aliashdr_t *paliashdr;
|
||||
byte *original;
|
||||
|
||||
if (!model) // player doesn't have a model yet
|
||||
return;
|
||||
if (model->type != mod_alias) // only translate skins on alias models
|
||||
return;
|
||||
|
||||
paliashdr = (aliashdr_t *) Mod_Extradata (model);
|
||||
if (skinnum < 0
|
||||
|| skinnum >= paliashdr->mdl.numskins) {
|
||||
Con_Printf ("(%d): Invalid player skin #%d\n", slot,
|
||||
skinnum);
|
||||
original = (byte *) paliashdr + paliashdr->texels[0];
|
||||
} else {
|
||||
original =
|
||||
(byte *) paliashdr + paliashdr->texels[skinnum];
|
||||
}
|
||||
|
||||
inwidth = paliashdr->mdl.skinwidth;
|
||||
inheight = paliashdr->mdl.skinheight;
|
||||
|
||||
texnum = playertextures + slot;
|
||||
build_skin (texnum, original, inwidth, inheight, inwidth, inheight, false);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -206,6 +234,7 @@ Skin_Process (skin_t *skin, tex_t *tex)
|
|||
|
||||
if (Mod_CalcFullbright (tex->data, ptexels, pixels)) {
|
||||
skin->fb_texture = player_fb_textures + (skin - skin_cache);
|
||||
build_skin (skin->fb_texture, ptexels, tex->width, tex->height, true);
|
||||
build_skin (skin->fb_texture, ptexels, tex->width, tex->height,
|
||||
296, 194, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ cvar_t *r_ambient;
|
|||
cvar_t *r_clearcolor;
|
||||
cvar_t *r_drawentities;
|
||||
cvar_t *r_drawflat;
|
||||
cvar_t *r_draworder;
|
||||
cvar_t *r_drawviewmodel;
|
||||
cvar_t *r_dspeeds;
|
||||
cvar_t *r_dynamic;
|
||||
|
@ -188,8 +187,6 @@ R_Init_Cvars (void)
|
|||
"everything but the world)");
|
||||
r_drawflat = Cvar_Get ("r_drawflat", "0", CVAR_NONE, NULL,
|
||||
"Toggles the drawing of textures");
|
||||
r_draworder = Cvar_Get ("r_draworder", "0", CVAR_NONE, NULL,
|
||||
"Toggles drawing order");
|
||||
r_drawviewmodel = Cvar_Get ("r_drawviewmodel", "1", CVAR_ARCHIVE, NULL,
|
||||
"Toggles view model drawing (your weapons)");
|
||||
r_dspeeds = Cvar_Get ("r_dspeeds", "0", CVAR_NONE, NULL,
|
||||
|
|
|
@ -130,15 +130,9 @@ R_BeginEdgeFrame (void)
|
|||
surfaces[1].flags = SURF_DRAWBACKGROUND;
|
||||
|
||||
// put the background behind everything in the world
|
||||
if (r_draworder->int_val) {
|
||||
pdrawfunc = R_GenerateSpansBackward;
|
||||
surfaces[1].key = 0;
|
||||
r_currentkey = 1;
|
||||
} else {
|
||||
pdrawfunc = R_GenerateSpans;
|
||||
surfaces[1].key = 0x7FFFFFFF;
|
||||
r_currentkey = 0;
|
||||
}
|
||||
pdrawfunc = R_GenerateSpans;
|
||||
surfaces[1].key = 0x7FFFFFFF;
|
||||
r_currentkey = 0;
|
||||
|
||||
// FIXME: set with memset
|
||||
for (v = r_refdef.vrect.y; v < r_refdef.vrectbottom; v++) {
|
||||
|
|
|
@ -423,7 +423,6 @@ R_SetupFrame (void)
|
|||
float w, h;
|
||||
|
||||
// don't allow cheats in multiplayer
|
||||
Cvar_SetValue (r_draworder, 0);
|
||||
Cvar_SetValue (r_ambient, 0);
|
||||
Cvar_SetValue (r_drawflat, 0);
|
||||
|
||||
|
@ -447,8 +446,6 @@ R_SetupFrame (void)
|
|||
|
||||
r_refdef.ambientlight = max (r_ambient->value, 0);
|
||||
|
||||
Cvar_SetValue (r_draworder, 0);
|
||||
|
||||
R_CheckVariables ();
|
||||
|
||||
R_AnimateLight ();
|
||||
|
|
|
@ -309,8 +309,8 @@ R_DrawSurfaceBlock8_mip0 (void)
|
|||
prowdest = prowdestbase;
|
||||
|
||||
for (v = 0; v < r_numvblocks; v++) {
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
lightleft = r_lightptr[0];
|
||||
lightright = r_lightptr[1];
|
||||
r_lightptr += r_lightwidth;
|
||||
|
@ -352,8 +352,8 @@ R_DrawSurfaceBlock8_mip1 (void)
|
|||
prowdest = prowdestbase;
|
||||
|
||||
for (v = 0; v < r_numvblocks; v++) {
|
||||
./ FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
lightleft = r_lightptr[0];
|
||||
lightright = r_lightptr[1];
|
||||
r_lightptr += r_lightwidth;
|
||||
|
@ -395,8 +395,8 @@ R_DrawSurfaceBlock8_mip2 (void)
|
|||
prowdest = prowdestbase;
|
||||
|
||||
for (v = 0; v < r_numvblocks; v++) {
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
lightleft = r_lightptr[0];
|
||||
lightright = r_lightptr[1];
|
||||
r_lightptr += r_lightwidth;
|
||||
|
@ -438,8 +438,8 @@ R_DrawSurfaceBlock8_mip3 (void)
|
|||
prowdest = prowdestbase;
|
||||
|
||||
for (v = 0; v < r_numvblocks; v++) {
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
// FIXME: make these locals?
|
||||
// FIXME: use delta rather than both right and left, like ASM?
|
||||
lightleft = r_lightptr[0];
|
||||
lightright = r_lightptr[1];
|
||||
r_lightptr += r_lightwidth;
|
||||
|
|
Loading…
Reference in a new issue