mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-03-13 03:33:28 +00:00
more skin cleanups
This commit is contained in:
parent
45bacc2b60
commit
aab3c199a2
5 changed files with 170 additions and 167 deletions
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
|
extern byte player_8bit_texels[320 * 200];
|
||||||
|
|
||||||
void Skin_Find (player_info_t *sc);
|
void Skin_Find (player_info_t *sc);
|
||||||
byte *Skin_Cache (skin_t *skin);
|
byte *Skin_Cache (skin_t *skin);
|
||||||
void Skin_Skins_f (void);
|
void Skin_Skins_f (void);
|
||||||
|
@ -38,6 +40,9 @@ void Skin_AllSkins_f (void);
|
||||||
void Skin_NextDownload (void);
|
void Skin_NextDownload (void);
|
||||||
void Skin_Init (void);
|
void Skin_Init (void);
|
||||||
void Skin_Init_Cvars (void);
|
void Skin_Init_Cvars (void);
|
||||||
|
void Skin_Init_Translation (void);
|
||||||
|
void Skin_Set_Translate (player_info_t *player);
|
||||||
|
void Skin_Do_Translation (player_info_t *player);
|
||||||
|
|
||||||
#define RSSHOT_WIDTH 320
|
#define RSSHOT_WIDTH 320
|
||||||
#define RSSHOT_HEIGHT 200
|
#define RSSHOT_HEIGHT 200
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "qendian.h"
|
#include "qendian.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
#include "skin.h"
|
||||||
|
|
||||||
extern model_t *loadmodel;
|
extern model_t *loadmodel;
|
||||||
|
|
||||||
|
@ -66,8 +67,6 @@ extern mtriangle_t triangles[MAXALIASTRIS];
|
||||||
extern trivertx_t *poseverts[MAXALIASFRAMES];
|
extern trivertx_t *poseverts[MAXALIASFRAMES];
|
||||||
extern int posenum;
|
extern int posenum;
|
||||||
|
|
||||||
byte player_8bit_texels[320 * 200];
|
|
||||||
|
|
||||||
//=========================================================
|
//=========================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
222
source/gl_skin.c
222
source/gl_skin.c
|
@ -36,149 +36,133 @@
|
||||||
#include "skin.h"
|
#include "skin.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
||||||
/*
|
byte player_8bit_texels[320 * 200];
|
||||||
=====================
|
static byte translate[256];
|
||||||
CL_NewTranslation
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
CL_NewTranslation (int slot)
|
Skin_Set_Translate (player_info_t *player)
|
||||||
|
{
|
||||||
|
int top;
|
||||||
|
int bottom;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
top = bound (0, player->topcolor, 13) * 16;
|
||||||
|
bottom = bound (0, player->bottomcolor, 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Skin_Do_Translation (player_info_t *player)
|
||||||
{
|
{
|
||||||
int top, bottom;
|
|
||||||
byte translate[256];
|
|
||||||
unsigned int translate32[256];
|
|
||||||
int i, j;
|
int i, j;
|
||||||
byte *original;
|
|
||||||
unsigned int pixels[512 * 256], *out;
|
|
||||||
unsigned int scaled_width, scaled_height;
|
|
||||||
int inwidth, inheight;
|
int inwidth, inheight;
|
||||||
int tinwidth, tinheight;
|
int tinwidth, tinheight;
|
||||||
byte *inrow;
|
unsigned int scaled_width, scaled_height;
|
||||||
unsigned int frac, fracstep;
|
unsigned int frac, fracstep;
|
||||||
player_info_t *player;
|
unsigned int translate32[256];
|
||||||
extern byte player_8bit_texels[320 * 200];
|
byte *original;
|
||||||
char s[512];
|
unsigned int pixels[512 * 256], *out;
|
||||||
int playernum = slot;
|
byte *inrow;
|
||||||
|
|
||||||
if (slot > MAX_CLIENTS)
|
// locate the original skin pixels
|
||||||
Host_EndGame ("CL_NewTranslation: slot > MAX_CLIENTS");
|
tinwidth = 296; // real model width
|
||||||
|
tinheight = 194; // real model height
|
||||||
|
|
||||||
player = &cl.players[playernum];
|
if (!player->skin)
|
||||||
if (!player->name[0])
|
Skin_Find (player);
|
||||||
return;
|
if ((original = Skin_Cache (player->skin)) != NULL) {
|
||||||
|
// skin data width
|
||||||
|
inwidth = 320;
|
||||||
|
inheight = 200;
|
||||||
|
} else {
|
||||||
|
original = player_8bit_texels;
|
||||||
|
inwidth = 296;
|
||||||
|
inheight = 194;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy (s, Info_ValueForKey (player->userinfo, "skin"));
|
// because this happens during gameplay, do it fast
|
||||||
COM_StripExtension (s, s);
|
// instead of sending it through GL_Upload8()
|
||||||
if (player->skin && !strequal (s, player->skin->name))
|
glBindTexture (GL_TEXTURE_2D, playertextures + (player - cl.players));
|
||||||
player->skin = NULL;
|
|
||||||
|
|
||||||
if (player->_topcolor != player->topcolor ||
|
// FIXME deek: This 512x256 limit sucks!
|
||||||
player->_bottomcolor != player->bottomcolor || !player->skin) {
|
scaled_width = min (gl_max_size->int_val, 512);
|
||||||
player->_topcolor = player->topcolor;
|
scaled_height = min (gl_max_size->int_val, 256);
|
||||||
player->_bottomcolor = player->bottomcolor;
|
|
||||||
|
|
||||||
top = player->topcolor;
|
// allow users to crunch sizes down even more if they want
|
||||||
bottom = player->bottomcolor;
|
scaled_width >>= gl_playermip->int_val;
|
||||||
top = (top < 0) ? 0 : ((top > 13) ? 13 : top);
|
scaled_height >>= gl_playermip->int_val;
|
||||||
bottom = (bottom < 0) ? 0 : ((bottom > 13) ? 13 : bottom);
|
|
||||||
top *= 16;
|
|
||||||
bottom *= 16;
|
|
||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
if (VID_Is8bit ()) { // 8bit texture upload
|
||||||
translate[i] = i;
|
byte *out2;
|
||||||
|
|
||||||
for (i = 0; i < 16; i++) {
|
out2 = (byte *) pixels;
|
||||||
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
|
|
||||||
tinwidth = 296; // real model width
|
|
||||||
tinheight = 194; // real model height
|
|
||||||
|
|
||||||
if (!player->skin)
|
|
||||||
Skin_Find (player);
|
|
||||||
if ((original = Skin_Cache (player->skin)) != NULL) {
|
|
||||||
// skin data width
|
|
||||||
inwidth = 320;
|
|
||||||
inheight = 200;
|
|
||||||
} else {
|
|
||||||
original = player_8bit_texels;
|
|
||||||
inwidth = 296;
|
|
||||||
inheight = 194;
|
|
||||||
}
|
|
||||||
|
|
||||||
// because this happens during gameplay, do it fast
|
|
||||||
// instead of sending it through GL_Upload8()
|
|
||||||
glBindTexture (GL_TEXTURE_2D, playertextures + playernum);
|
|
||||||
|
|
||||||
// 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
|
|
||||||
byte *out2;
|
|
||||||
|
|
||||||
out2 = (byte *) pixels;
|
|
||||||
memset (pixels, 0, sizeof (pixels));
|
|
||||||
fracstep = tinwidth * 0x10000 / scaled_width;
|
|
||||||
for (i = 0; i < scaled_height; i++, out2 += scaled_width) {
|
|
||||||
inrow = original + inwidth * (i * tinheight / 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;
|
|
||||||
memset (pixels, 0, sizeof (pixels));
|
memset (pixels, 0, sizeof (pixels));
|
||||||
fracstep = tinwidth * 0x10000 / scaled_width;
|
fracstep = tinwidth * 0x10000 / scaled_width;
|
||||||
for (i = 0; i < scaled_height; i++, out += scaled_width) {
|
for (i = 0; i < scaled_height; i++, out2 += scaled_width) {
|
||||||
inrow = original + inwidth * (i * tinheight / scaled_height);
|
inrow = original + inwidth * (i * tinheight / scaled_height);
|
||||||
frac = fracstep >> 1;
|
frac = fracstep >> 1;
|
||||||
for (j = 0; j < scaled_width; j += 4) {
|
for (j = 0; j < scaled_width; j += 4) {
|
||||||
out[j] = translate32[inrow[frac >> 16]];
|
out2[j] = translate[inrow[frac >> 16]];
|
||||||
frac += fracstep;
|
frac += fracstep;
|
||||||
out[j + 1] = translate32[inrow[frac >> 16]];
|
out2[j + 1] = translate[inrow[frac >> 16]];
|
||||||
frac += fracstep;
|
frac += fracstep;
|
||||||
out[j + 2] = translate32[inrow[frac >> 16]];
|
out2[j + 2] = translate[inrow[frac >> 16]];
|
||||||
frac += fracstep;
|
frac += fracstep;
|
||||||
out[j + 3] = translate32[inrow[frac >> 16]];
|
out2[j + 3] = translate[inrow[frac >> 16]];
|
||||||
frac += fracstep;
|
frac += fracstep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format,
|
GL_Upload8_EXT ((byte *) pixels, scaled_width, scaled_height, false,
|
||||||
scaled_width, scaled_height, 0, GL_RGBA,
|
false);
|
||||||
GL_UNSIGNED_BYTE, pixels);
|
return;
|
||||||
|
|
||||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
translate32[i] = d_8to24table[translate[i]];
|
||||||
|
|
||||||
|
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, gl_solid_format,
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Skin_Init_Translation (void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < 256; i++)
|
||||||
|
translate [i] = i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "cl_parse.h"
|
#include "cl_parse.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
#include "host.h"
|
||||||
#include "msg.h"
|
#include "msg.h"
|
||||||
#include "pcx.h"
|
#include "pcx.h"
|
||||||
#include "qendian.h"
|
#include "qendian.h"
|
||||||
|
@ -366,6 +367,7 @@ Skin_Init (void)
|
||||||
Cmd_AddCommand ("skins", Skin_Skins_f, "No Description");
|
Cmd_AddCommand ("skins", Skin_Skins_f, "No Description");
|
||||||
Cmd_AddCommand ("allskins", Skin_AllSkins_f, "No Description");
|
Cmd_AddCommand ("allskins", Skin_AllSkins_f, "No Description");
|
||||||
Cmd_AddCommand ("color", CL_Color_f, "No Description");
|
Cmd_AddCommand ("color", CL_Color_f, "No Description");
|
||||||
|
Skin_Init_Translation ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -381,3 +383,34 @@ Skin_Init_Cvars (void)
|
||||||
bottomcolor = Cvar_Get ("bottomcolor", "0", CVAR_ARCHIVE | CVAR_USERINFO,
|
bottomcolor = Cvar_Get ("bottomcolor", "0", CVAR_ARCHIVE | CVAR_USERINFO,
|
||||||
"Players color on bottom");
|
"Players color on bottom");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
CL_NewTranslation
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
CL_NewTranslation (int slot)
|
||||||
|
{
|
||||||
|
player_info_t *player;
|
||||||
|
char s[512];
|
||||||
|
|
||||||
|
if (slot > MAX_CLIENTS)
|
||||||
|
Host_EndGame ("CL_NewTranslation: slot > MAX_CLIENTS");
|
||||||
|
|
||||||
|
player = &cl.players[slot];
|
||||||
|
if (!player->name[0])
|
||||||
|
return;
|
||||||
|
|
||||||
|
strcpy (s, Info_ValueForKey (player->userinfo, "skin"));
|
||||||
|
COM_StripExtension (s, s);
|
||||||
|
if (player->skin && !strequal (s, player->skin->name))
|
||||||
|
player->skin = NULL;
|
||||||
|
|
||||||
|
if (player->_topcolor != player->topcolor ||
|
||||||
|
player->_bottomcolor != player->bottomcolor || !player->skin) {
|
||||||
|
player->_topcolor = player->topcolor;
|
||||||
|
player->_bottomcolor = player->bottomcolor;
|
||||||
|
|
||||||
|
Skin_Set_Translate (player);
|
||||||
|
Skin_Do_Translation (player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -42,60 +42,42 @@
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
CL_NewTranslation
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
CL_NewTranslation (int slot)
|
Skin_Set_Translate (player_info_t *player)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int top, bottom;
|
int top, bottom;
|
||||||
byte *dest, *source;
|
byte *dest, *source;
|
||||||
player_info_t *player;
|
|
||||||
char s[512];
|
|
||||||
|
|
||||||
if (slot > MAX_CLIENTS)
|
top = bound (0, player->topcolor, 13) * 16;
|
||||||
Host_EndGame ("CL_NewTranslation: slot > MAX_CLIENTS");
|
bottom = bound (0, player->bottomcolor, 13) * 16;
|
||||||
|
|
||||||
player = &cl.players[slot];
|
dest = player->translations;
|
||||||
|
source = vid.colormap;
|
||||||
|
memcpy (dest, vid.colormap, sizeof (player->translations));
|
||||||
|
|
||||||
strcpy (s, Info_ValueForKey (player->userinfo, "skin"));
|
for (i = 0; i < VID_GRADES; i++, dest += 256, source += 256) {
|
||||||
COM_StripExtension (s, s);
|
if (top < 128) // the artists made some backwards
|
||||||
if (player->skin && !strequal (s, player->skin->name))
|
// ranges. sigh.
|
||||||
player->skin = NULL;
|
memcpy (dest + TOP_RANGE, source + top, 16);
|
||||||
|
else
|
||||||
|
for (j = 0; j < 16; j++)
|
||||||
|
dest[TOP_RANGE + j] = source[top + 15 - j];
|
||||||
|
|
||||||
if (player->_topcolor != player->topcolor ||
|
if (bottom < 128)
|
||||||
player->_bottomcolor != player->bottomcolor || !player->skin) {
|
memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
|
||||||
player->_topcolor = player->topcolor;
|
else
|
||||||
player->_bottomcolor = player->bottomcolor;
|
for (j = 0; j < 16; j++)
|
||||||
|
dest[BOTTOM_RANGE + j] = source[bottom + 15 - j];
|
||||||
dest = player->translations;
|
|
||||||
source = vid.colormap;
|
|
||||||
memcpy (dest, vid.colormap, sizeof (player->translations));
|
|
||||||
top = player->topcolor;
|
|
||||||
if (top > 13 || top < 0)
|
|
||||||
top = 13;
|
|
||||||
top *= 16;
|
|
||||||
bottom = player->bottomcolor;
|
|
||||||
if (bottom > 13 || bottom < 0)
|
|
||||||
bottom = 13;
|
|
||||||
bottom *= 16;
|
|
||||||
|
|
||||||
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 (player_info_t *player)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Skin_Init_Translation (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue