sw_ralias.c and gl_rmain.c are now client clean. this involved a bit of a

revamp of skins. keep an eye out for broken skins (especially in nq)
This commit is contained in:
Bill Currie 2001-05-21 22:25:35 +00:00
parent ddceaf78b3
commit da8715f27d
23 changed files with 202 additions and 100 deletions

View file

@ -86,6 +86,7 @@ typedef struct entity_s
int frame;
byte *colormap;
int skinnum; // for Alias models
struct skin_s *skin;
struct player_info_s *scoreboard; // identify player

View file

@ -41,12 +41,19 @@ typedef struct skin_s
{
char name[16];
qboolean failedload; // the name isn't a valid skin
union {
cache_user_t cache;
struct tex_s *texels;
} data;
int texture;
int fb_texture;
} skin_t;
extern byte player_8bit_texels[320 * 200];
extern skin_t skin_cache[MAX_CACHED_SKINS];
extern int skin_textures;
extern int skin_fb_textures;
struct tex_s;
struct player_info_s;
struct model_s;
@ -54,12 +61,16 @@ struct model_s;
void Skin_Find (struct player_info_s *sc);
struct tex_s *Skin_Cache (skin_t *skin);
void Skin_Flush (void);
int Skin_Init_Textures (int base);
void Skin_Init (void);
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_Do_Translation (skin_t *player_skin, int slot, skin_t *skin);
void Skin_Do_Translation_Model (struct model_s *model, int skinnum, int slot, skin_t *skin);
void Skin_Process (skin_t *skin, struct tex_s *);
skin_t *Skin_NewTempSkin (void);
void Skin_ClearTempSkins (void);
#endif

View file

@ -91,8 +91,6 @@ extern int cnttextures[2];
extern int particletexture;
extern int netgraphtexture;
extern int netgraphtexture; // netgraph texture
extern int playertextures;
extern int player_fb_textures;
extern int skytexturenum; // index in cl.loadmodel, not gl texture object

View file

@ -327,8 +327,9 @@ void CL_TimeDemo_f (void);
/*
cl_parse.c
*/
struct skin_s;
void CL_ParseServerMessage (void);
void CL_NewTranslation (int slot);
void CL_NewTranslation (int slot, struct skin_s *skin);
/*

View file

@ -37,7 +37,9 @@
#include "QF/input.h"
#include "QF/keys.h"
#include "QF/msg.h"
#include "QF/render.h"
#include "QF/screen.h"
#include "QF/skin.h"
#include "QF/va.h"
#include "client.h"
@ -45,7 +47,6 @@
#include "host.h"
#include "host.h"
#include "r_dynamic.h"
#include "QF/render.h"
#include "server.h"
byte *vid_colormap;
@ -571,6 +572,12 @@ CL_RelinkEntities (void)
}
if (i <= cl.maxclients) {
ent->skin = Skin_NewTempSkin ();
if (ent->skin)
CL_NewTranslation (i - 1, ent->skin);
}
// rotate binary objects locally
if (ent->model->flags & EF_ROTATE)
ent->angles[1] = bobjrotate;
@ -692,6 +699,7 @@ CL_ReadFromServer (void)
Con_Printf ("\n");
R_ClearEnts ();
Skin_ClearTempSkins ();
CL_RelinkEntities ();
CL_UpdateTEnts ();

View file

@ -400,8 +400,8 @@ CL_ParseUpdate (int bits)
ent->syncbase = 0.0;
} else
forcelink = true; // hack to make null model players work
if (num > 0 && num <= cl.maxclients)
CL_NewTranslation (num - 1);
//XXX if (num > 0 && num <= cl.maxclients)
//XXX CL_NewTranslation (num - 1);
}
if (bits & U_FRAME)
@ -427,8 +427,8 @@ CL_ParseUpdate (int bits)
skin = ent->baseline->skin;
if (skin != ent->skinnum) {
ent->skinnum = skin;
if (num > 0 && num <= cl.maxclients)
CL_NewTranslation (num - 1);
//XXX if (num > 0 && num <= cl.maxclients)
//XXX CL_NewTranslation (num - 1);
}
if (bits & U_EFFECTS)
@ -803,7 +803,7 @@ CL_ParseServerMessage (void)
Host_Error
("CL_ParseServerMessage: svc_updatecolors > MAX_SCOREBOARD");
cl.scores[i].colors = MSG_ReadByte (net_message);
CL_NewTranslation (i);
//XXX CL_NewTranslation (i);
break;
case svc_particle:

View file

@ -51,7 +51,6 @@
#include "QF/sys.h"
#include "QF/vid.h"
#include "client.h"
#include "glquake.h"
#include "r_cvar.h"
#include "r_dynamic.h"
@ -73,9 +72,6 @@ int c_brush_polys, c_alias_polys;
qboolean envmap; // true during envmap command capture
int playertextures; // up to 16 color translated skins
int player_fb_textures; // up to 128 skin fullbright maps
int mirrortexturenum; // quake texturenum, not gltexturenum
qboolean mirror;
mplane_t *mirror_plane;
@ -595,7 +591,6 @@ R_SetupAliasBlendedFrame (int frame, aliashdr_t *paliashdr, entity_t *e, qboolea
static void
R_DrawAliasModel (entity_t *e)
{
int i;
int lnum;
vec3_t dist;
float add;
@ -710,10 +705,13 @@ R_DrawAliasModel (entity_t *e)
// we can't dynamically colormap textures, so they are cached
// seperately for the players. Heads are just uncolored.
if (currententity->colormap != vid.colormap && !gl_nocolors->int_val) {
i = currententity - cl_entities;
if (i >= 1 && i <= cl.maxclients)
texture = playertextures - 1 + i;
if (currententity->skin && !gl_nocolors->int_val) {
skin_t *skin = currententity->skin;
texture = skin->texture;
if (gl_fb_models->int_val) {
fb_texture = skin->fb_texture;
}
}
glBindTexture (GL_TEXTURE_2D, texture);

View file

@ -158,10 +158,7 @@ R_Init (void)
netgraphtexture = texture_extension_number;
texture_extension_number++;
playertextures = texture_extension_number;
texture_extension_number += MAX_CLIENTS;
player_fb_textures = texture_extension_number;
texture_extension_number += MAX_CACHED_SKINS;
texture_extension_number = Skin_Init_Textures (texture_extension_number);
glEnableClientState (GL_COLOR_ARRAY);
glEnableClientState (GL_VERTEX_ARRAY);

View file

@ -163,31 +163,30 @@ build_skin (int texnum, byte *ptexels, int width, int height,
}
void
Skin_Do_Translation (skin_t *player_skin, int slot)
Skin_Do_Translation (skin_t *player_skin, int slot, skin_t *skin)
{
int texnum;
int texnum = skin->texture;
int inwidth, inheight;
byte *original;
tex_t *skin;
tex_t *skin_texels;
if ((skin = (tex_t*)Skin_Cache (player_skin)) != NULL) {
if ((skin_texels = (tex_t*)Skin_Cache (player_skin)) != NULL) {
// skin data width
inwidth = 320;
inheight = 200;
original = skin->data;
original = skin_texels->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)
Skin_Do_Translation_Model (model_t *model, int skinnum, int slot, skin_t *skin)
{
int texnum;
int texnum = skin->texture;
int inwidth, inheight;
aliashdr_t *paliashdr;
byte *original;
@ -211,7 +210,6 @@ Skin_Do_Translation_Model (model_t *model, int skinnum, int slot)
inwidth = paliashdr->mdl.skinwidth;
inheight = paliashdr->mdl.skinheight;
texnum = playertextures + slot;
build_skin (texnum, original, inwidth, inheight, inwidth, inheight, false);
}
@ -233,8 +231,8 @@ Skin_Process (skin_t *skin, tex_t *tex)
byte *ptexels = Hunk_TempAlloc (pixels);
if (Mod_CalcFullbright (tex->data, ptexels, pixels)) {
skin->fb_texture = player_fb_textures + (skin - skin_cache);
skin->fb_texture = skin_fb_textures + (skin - skin_cache);
build_skin (skin->fb_texture, ptexels, tex->width, tex->height,
296, 194, true);
}
}
}

View file

@ -120,7 +120,7 @@ Host_Skin_Init_Cvars (void)
void
CL_NewTranslation (int slot)
CL_NewTranslation (int slot, skin_t *skin)
{
scoreboard_t *player;
int top, bottom;
@ -139,5 +139,8 @@ CL_NewTranslation (int slot)
skinnum = cl_entities[1 + slot].skinnum;
Skin_Set_Translate (top, bottom, dest);
Skin_Do_Translation_Model (model, skinnum, slot);
memset (skin, 0, sizeof (*skin));
skin->texture = skin_textures + slot; //FIXME
skin->data.texels = 0; //FIXME
Skin_Do_Translation_Model (model, skinnum, slot, skin);
}

View file

@ -47,6 +47,8 @@
#include "client.h"
#define MAX_TEMP_SKINS 64 //XXX dynamic?
extern cvar_t *noskins; // XXX FIXME, this shouldn't be here?
cvar_t *baseskin;
@ -60,6 +62,11 @@ skin_t skin_cache[MAX_CACHED_SKINS];
hashtab_t *skin_hash;
int numskins;
skin_t temp_skins[MAX_TEMP_SKINS];
int num_temp_skins;
int skin_textures;
int skin_fb_textures;
static char *
skin_get_key (void *_skin, void *unused)
@ -120,7 +127,6 @@ Skin_Find (player_info_t *sc)
}
#endif
/*
Skin_Cache
@ -148,7 +154,7 @@ Skin_Cache (skin_t *skin)
if (skin->failedload)
return NULL;
out = Cache_Check (&skin->cache);
out = Cache_Check (&skin->data.cache);
if (out)
return out;
@ -174,7 +180,7 @@ Skin_Cache (skin_t *skin)
}
pixels = 320 * 200;
out = Cache_Alloc (&skin->cache, sizeof (tex_t) + pixels, skin->name);
out = Cache_Alloc (&skin->data.cache, sizeof (tex_t) + pixels, skin->name);
if (!out)
Sys_Error ("Skin_Cache: couldn't allocate");
opix = out->data;
@ -200,13 +206,39 @@ Skin_Flush (void)
int i;
for (i = 0; i < numskins; i++) {
if (skin_cache[i].cache.data)
Cache_Free (&skin_cache[i].cache);
if (skin_cache[i].data.cache.data)
Cache_Free (&skin_cache[i].data.cache);
}
numskins = 0;
Hash_FlushTable (skin_hash);
}
skin_t *
Skin_NewTempSkin (void)
{
if (num_temp_skins == MAX_TEMP_SKINS)
return 0; // ran out
return &temp_skins[num_temp_skins++];
}
void
Skin_ClearTempSkins (void)
{
num_temp_skins = 0;
}
int
Skin_Init_Textures (int base)
{
skin_textures = base;
base += MAX_TEMP_SKINS;
skin_fb_textures = base;
base += MAX_TEMP_SKINS;
return base;
}
void
Skin_Init (void)
{

View file

@ -36,7 +36,6 @@
#include "QF/sys.h"
#include "QF/texture.h"
#include "client.h"
#include "d_ifacea.h"
#include "r_local.h"
@ -559,6 +558,17 @@ R_AliasSetupSkin (void)
r_affinetridesc.skinwidth = a_skinwidth;
r_affinetridesc.seamfixupX16 = (a_skinwidth >> 1) << 16;
r_affinetridesc.skinheight = pmdl->skinheight;
if (currententity->skin) {
tex_t *base;
base = currententity->skin->data.texels;
if (base) {
r_affinetridesc.pskin = base->data;
r_affinetridesc.skinwidth = base->width;
r_affinetridesc.skinheight = base->height;
}
}
}
@ -676,7 +686,7 @@ R_AliasDrawModel (alight_t *plighting)
acolormap = currententity->colormap;
if (currententity != &cl.viewent)
if (currententity != r_view_model)
ziscale = (float) 0x8000 *(float) 0x10000;
else
ziscale = (float) 0x8000 *(float) 0x10000 *3.0;

View file

@ -73,13 +73,13 @@ Skin_Set_Translate (int top, int bottom, byte *dest)
void
Skin_Do_Translation (skin_t *player_skin, int slot)
Skin_Do_Translation (skin_t *player_skin, int slot, skin_t *skin)
{
}
void
Skin_Do_Translation_Model (model_t *model, int skinnum, int slot)
Skin_Do_Translation_Model (model_t *model, int skinnum, int slot, skin_t *skin)
{
}

View file

@ -33,10 +33,13 @@
#define NET_TIMINGS 256
#define NET_TIMINGSMASK 255
struct skin_s;
extern int packet_latency[NET_TIMINGS];
int CL_CalcNet (void);
void CL_ParseServerMessage (void);
void CL_NewTranslation (int slot);
void CL_NewTranslation (int slot, struct skin_s *skin);
qboolean CL_CheckOrDownloadFile (char *filename);
qboolean CL_IsUploading(void);
void CL_NextUpload(void);

View file

@ -40,10 +40,12 @@
#include "QF/console.h"
#include "QF/msg.h"
#include "QF/render.h"
#include "QF/skin.h"
#include "cl_cam.h"
#include "cl_ents.h"
#include "cl_main.h"
#include "cl_parse.h"
#include "cl_pred.h"
#include "cl_tent.h"
#include "d_iface.h"
@ -452,6 +454,18 @@ CL_LinkPacketEntities (void)
(*ent)->scoreboard = NULL;
}
if ((*ent)->scoreboard && !(*ent)->scoreboard->skin)
Skin_Find ((*ent)->scoreboard);
if ((*ent)->scoreboard && (*ent)->scoreboard->skin) {
(*ent)->skin = Skin_NewTempSkin ();
if ((*ent)->skin) {
i = s1->colormap - 1;
CL_NewTranslation (i, (*ent)->skin);
}
} else {
(*ent)->skin = NULL;
}
// LordHavoc: cleaned up Endy's coding style, and fixed Endy's bugs
// Ender: Extend (Colormod) [QSG - Begin]
// N.B: All messy code below is the sole fault of LordHavoc and
@ -599,6 +613,7 @@ CL_LinkProjectiles (void)
(*ent)->frame = 0;
(*ent)->colormap = vid.colormap;
(*ent)->scoreboard = NULL;
(*ent)->skin = NULL;
// LordHavoc: Endy had neglected to do this as part of the QSG
// VERSION 2 stuff
(*ent)->glow_size = 0;
@ -829,6 +844,17 @@ CL_LinkPlayers (void)
else
(*ent)->scoreboard = NULL;
if ((*ent)->scoreboard && !(*ent)->scoreboard->skin)
Skin_Find ((*ent)->scoreboard);
if ((*ent)->scoreboard && (*ent)->scoreboard->skin) {
(*ent)->skin = Skin_NewTempSkin ();
if ((*ent)->skin) {
CL_NewTranslation (j, (*ent)->skin);
}
} else {
(*ent)->skin = NULL;
}
// LordHavoc: more QSG VERSION 2 stuff, FIXME: players don't have
// extend stuff
(*ent)->glow_size = 0;
@ -1031,6 +1057,7 @@ CL_EmitEntities (void)
return;
R_ClearEnts ();
Skin_ClearTempSkins ();
CL_LinkPlayers ();
CL_LinkPacketEntities ();

View file

@ -970,7 +970,7 @@ CL_ProcessUserInfo (int slot, player_info_t *player)
Skin_Find (player);
Sbar_Changed ();
CL_NewTranslation (slot);
//XXX CL_NewTranslation (slot);
}

View file

@ -193,7 +193,7 @@ CL_Skin_Init_Cvars (void)
void
CL_NewTranslation (int slot)
CL_NewTranslation (int slot, skin_t *skin)
{
player_info_t *player;
char s[512];
@ -219,6 +219,13 @@ CL_NewTranslation (int slot)
player->translations);
if (!player->skin)
Skin_Find (player);
Skin_Do_Translation (player->skin, slot);
memcpy (skin, player->skin, sizeof (*skin));
skin->texture = skin_textures + slot; //FIXME
skin->data.texels = Skin_Cache(player->skin); //FIXME the breaks cache ownership
Skin_Do_Translation (player->skin, slot, skin);
} else {
memcpy (skin, player->skin, sizeof (*skin));
skin->texture = skin_textures + slot; //FIXME
skin->data.texels = Skin_Cache(player->skin); //FIXME the breaks cache ownership
}
}

View file

@ -51,8 +51,6 @@
#include "QF/sys.h"
#include "QF/vid.h"
#include "cl_parse.h"
#include "client.h"
#include "glquake.h"
#include "r_cvar.h"
#include "r_dynamic.h"
@ -74,9 +72,6 @@ int c_brush_polys, c_alias_polys;
qboolean envmap; // true during envmap command capture
int playertextures; // up to 16 color translated skins
int player_fb_textures; // up to 128 skin fullbright maps
int mirrortexturenum; // quake texturenum, not gltexturenum
qboolean mirror;
mplane_t *mirror_plane;
@ -596,7 +591,6 @@ R_SetupAliasBlendedFrame (int frame, aliashdr_t *paliashdr, entity_t *e, qboolea
static void
R_DrawAliasModel (entity_t *e)
{
int i;
int lnum;
vec3_t dist;
float add;
@ -711,21 +705,11 @@ R_DrawAliasModel (entity_t *e)
// we can't dynamically colormap textures, so they are cached
// seperately for the players. Heads are just uncolored.
if (currententity->scoreboard && !gl_nocolors->int_val) {
skin_t *skin;
if (currententity->skin && !gl_nocolors->int_val) {
skin_t *skin = currententity->skin;
i = currententity->scoreboard - cl.players;
if (!currententity->scoreboard->skin) {
Skin_Find (currententity->scoreboard);
CL_NewTranslation (i);
}
skin = currententity->scoreboard->skin;
if (skin && i >= 0 && i < MAX_CLIENTS)
texture = playertextures + i;
else
skin = 0;
texture = skin->texture;
if (gl_fb_models->int_val) {
if (skin)
fb_texture = skin->fb_texture;
}
}

View file

@ -158,10 +158,7 @@ R_Init (void)
netgraphtexture = texture_extension_number;
texture_extension_number++;
playertextures = texture_extension_number;
texture_extension_number += MAX_CLIENTS;
player_fb_textures = texture_extension_number;
texture_extension_number += MAX_CACHED_SKINS;
texture_extension_number = Skin_Init_Textures (texture_extension_number);
glEnableClientState (GL_COLOR_ARRAY);
glEnableClientState (GL_VERTEX_ARRAY);

View file

@ -163,31 +163,30 @@ build_skin (int texnum, byte *ptexels, int width, int height,
}
void
Skin_Do_Translation (skin_t *player_skin, int slot)
Skin_Do_Translation (skin_t *player_skin, int slot, skin_t *skin)
{
int texnum;
int texnum = skin->texture;
int inwidth, inheight;
byte *original;
tex_t *skin;
tex_t *skin_texels;
if ((skin = (tex_t*)Skin_Cache (player_skin)) != NULL) {
if ((skin_texels = (tex_t*)Skin_Cache (player_skin)) != NULL) {
// skin data width
inwidth = 320;
inheight = 200;
original = skin->data;
original = skin_texels->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)
Skin_Do_Translation_Model (model_t *model, int skinnum, int slot, skin_t *skin)
{
int texnum;
int texnum = skin->texture;
int inwidth, inheight;
aliashdr_t *paliashdr;
byte *original;
@ -211,7 +210,6 @@ Skin_Do_Translation_Model (model_t *model, int skinnum, int slot)
inwidth = paliashdr->mdl.skinwidth;
inheight = paliashdr->mdl.skinheight;
texnum = playertextures + slot;
build_skin (texnum, original, inwidth, inheight, inwidth, inheight, false);
}
@ -233,8 +231,8 @@ Skin_Process (skin_t *skin, tex_t *tex)
byte *ptexels = Hunk_TempAlloc (pixels);
if (Mod_CalcFullbright (tex->data, ptexels, pixels)) {
skin->fb_texture = player_fb_textures + (skin - skin_cache);
skin->fb_texture = skin_fb_textures + (skin - skin_cache);
build_skin (skin->fb_texture, ptexels, tex->width, tex->height,
296, 194, true);
}
}
}

View file

@ -47,6 +47,8 @@
#include "client.h"
#define MAX_TEMP_SKINS 64 //XXX dynamic?
extern cvar_t *noskins; // XXX FIXME, this shouldn't be here?
cvar_t *baseskin;
@ -60,6 +62,11 @@ skin_t skin_cache[MAX_CACHED_SKINS];
hashtab_t *skin_hash;
int numskins;
skin_t temp_skins[MAX_TEMP_SKINS];
int num_temp_skins;
int skin_textures;
int skin_fb_textures;
static char *
skin_get_key (void *_skin, void *unused)
@ -145,7 +152,7 @@ Skin_Cache (skin_t *skin)
if (skin->failedload)
return NULL;
out = Cache_Check (&skin->cache);
out = Cache_Check (&skin->data.cache);
if (out)
return out;
@ -171,7 +178,7 @@ Skin_Cache (skin_t *skin)
}
pixels = 320 * 200;
out = Cache_Alloc (&skin->cache, sizeof (tex_t) + pixels, skin->name);
out = Cache_Alloc (&skin->data.cache, sizeof (tex_t) + pixels, skin->name);
if (!out)
Sys_Error ("Skin_Cache: couldn't allocate");
opix = out->data;
@ -197,13 +204,38 @@ Skin_Flush (void)
int i;
for (i = 0; i < numskins; i++) {
if (skin_cache[i].cache.data)
Cache_Free (&skin_cache[i].cache);
if (skin_cache[i].data.cache.data)
Cache_Free (&skin_cache[i].data.cache);
}
numskins = 0;
Hash_FlushTable (skin_hash);
}
skin_t *
Skin_NewTempSkin (void)
{
if (num_temp_skins == MAX_TEMP_SKINS)
return 0; // ran out
return &temp_skins[num_temp_skins++];
}
void
Skin_ClearTempSkins (void)
{
num_temp_skins = 0;
}
int
Skin_Init_Textures (int base)
{
skin_textures = base;
base += MAX_TEMP_SKINS;
skin_fb_textures = base;
base += MAX_TEMP_SKINS;
return base;
}
void
Skin_Init (void)

View file

@ -36,7 +36,6 @@
#include "QF/sys.h"
#include "QF/texture.h"
#include "client.h"
#include "d_ifacea.h"
#include "r_local.h"
@ -560,16 +559,14 @@ R_AliasSetupSkin (void)
r_affinetridesc.seamfixupX16 = (a_skinwidth >> 1) << 16;
r_affinetridesc.skinheight = pmdl->skinheight;
if (currententity->scoreboard) {
if (currententity->skin) {
tex_t *base;
if (!currententity->scoreboard->skin)
Skin_Find (currententity->scoreboard);
base = Skin_Cache (currententity->scoreboard->skin);
base = currententity->skin->data.texels;
if (base) {
r_affinetridesc.pskin = base->data;
r_affinetridesc.skinwidth = 320;
r_affinetridesc.skinheight = 200;
r_affinetridesc.skinwidth = base->width;
r_affinetridesc.skinheight = base->height;
}
}
}
@ -689,7 +686,7 @@ R_AliasDrawModel (alight_t *plighting)
acolormap = currententity->colormap;
if (currententity != &cl.viewent)
if (currententity != r_view_model)
ziscale = (float) 0x8000 *(float) 0x10000;
else
ziscale = (float) 0x8000 *(float) 0x10000 *3.0;

View file

@ -73,13 +73,13 @@ Skin_Set_Translate (int top, int bottom, byte *dest)
void
Skin_Do_Translation (skin_t *player_skin, int slot)
Skin_Do_Translation (skin_t *player_skin, int slot, skin_t *skin)
{
}
void
Skin_Do_Translation_Model (model_t *model, int skinnum, int slot)
Skin_Do_Translation_Model (model_t *model, int skinnum, int slot, skin_t *skin)
{
}