2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
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 the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "quakedef.h"
|
|
|
|
|
2018-03-04 14:41:16 +00:00
|
|
|
#ifdef QWSKINS
|
2020-08-24 07:52:55 +00:00
|
|
|
cvar_t baseskin = CVARD("baseskin", "", "The name of the player skin to use as a fallback.");
|
2016-09-08 19:04:35 +00:00
|
|
|
cvar_t noskins = CVAR("noskins", "0");
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2004-12-29 03:24:21 +00:00
|
|
|
extern cvar_t cl_teamskin;
|
|
|
|
extern cvar_t cl_enemyskin;
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
extern cvar_t r_fb_models;
|
|
|
|
|
|
|
|
char allskins[128];
|
2014-09-08 23:47:19 +00:00
|
|
|
#define MAX_CACHED_SKINS 256 //max_clients is 255. hopefully this will not be reached, but hey.
|
|
|
|
qwskin_t skins[MAX_CACHED_SKINS];
|
2004-08-23 00:15:46 +00:00
|
|
|
int numskins;
|
|
|
|
|
2004-12-29 03:24:21 +00:00
|
|
|
//returns the name
|
|
|
|
char *Skin_FindName (player_info_t *sc)
|
|
|
|
{
|
|
|
|
int tracknum;
|
|
|
|
char *s;
|
|
|
|
static char name[MAX_OSPATH];
|
|
|
|
|
|
|
|
char *skinforcing_team;
|
|
|
|
|
|
|
|
if (allskins[0])
|
|
|
|
{
|
|
|
|
Q_strncpyz(name, allskins, sizeof(name));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-05 16:21:44 +00:00
|
|
|
s = InfoBuf_ValueForKey(&sc->userinfo, "skin");
|
2004-12-29 03:24:21 +00:00
|
|
|
if (s && s[0])
|
|
|
|
Q_strncpyz(name, s, sizeof(name));
|
|
|
|
else
|
|
|
|
Q_strncpyz(name, baseskin.string, sizeof(name));
|
|
|
|
}
|
|
|
|
|
2015-07-03 02:07:41 +00:00
|
|
|
if (cl.playerview[0].cam_state == CAM_FREECAM)
|
|
|
|
tracknum = cl.playerview[0].playernum;
|
|
|
|
else
|
|
|
|
tracknum = cl.playerview[0].cam_spec_track;
|
|
|
|
|
|
|
|
if (cl.players[tracknum].spectator)
|
2004-12-29 03:24:21 +00:00
|
|
|
skinforcing_team = "spec";
|
|
|
|
else
|
2015-07-03 02:07:41 +00:00
|
|
|
skinforcing_team = cl.players[tracknum].team;
|
2004-12-29 03:24:21 +00:00
|
|
|
|
|
|
|
//Don't force skins in splitscreen (it's probable that the new skin would be wrong).
|
2015-07-03 02:07:41 +00:00
|
|
|
//Don't force skins in TF (where skins are already forced on a class basis by the mod).
|
2004-12-29 03:24:21 +00:00
|
|
|
//Don't force skins on servers that have it disabled.
|
2015-07-03 02:07:41 +00:00
|
|
|
//Don't force the local player's skin
|
2004-12-29 03:24:21 +00:00
|
|
|
if (cl.splitclients<2 && !cl.teamfortress && !(cl.fpd & FPD_NO_FORCE_SKIN))
|
2015-07-03 02:07:41 +00:00
|
|
|
if (&cl.players[tracknum] != sc)
|
2004-12-29 03:24:21 +00:00
|
|
|
{
|
|
|
|
char *skinname = NULL;
|
|
|
|
qboolean teammate;
|
|
|
|
|
|
|
|
teammate = (cl.teamplay && !strcmp(sc->team, skinforcing_team)) ? true : false;
|
|
|
|
/*
|
2015-07-03 02:07:41 +00:00
|
|
|
if (cl.validsequence)
|
|
|
|
{
|
|
|
|
player_state_t *state = cl.frames[cl.parsecount & UPDATE_MASK].playerstate + (sc - cl.players);
|
|
|
|
if (state->messagenum == cl.parsecount)
|
|
|
|
{
|
|
|
|
if ((state->effects & (EF_BLUE | EF_RED)) == (EF_BLUE | EF_RED))
|
|
|
|
skinname = teammate ? cl_teambothskin.string : cl_enemybothskin.string;
|
|
|
|
else if (state->effects & EF_BLUE)
|
|
|
|
skinname = teammate ? cl_teamquadskin.string : cl_enemyquadskin.string;
|
|
|
|
else if (state->effects & EF_RED)
|
|
|
|
skinname = teammate ? cl_teampentskin.string : cl_enemypentskin.string;
|
|
|
|
}
|
|
|
|
}
|
2004-12-29 03:24:21 +00:00
|
|
|
*/
|
|
|
|
if (!skinname || !skinname[0])
|
|
|
|
skinname = teammate ? cl_teamskin.string : cl_enemyskin.string;
|
2008-06-05 07:45:34 +00:00
|
|
|
|
|
|
|
//per-player skin forcing
|
|
|
|
if (teammate && sc->colourised && *sc->colourised->skin)
|
|
|
|
skinname = sc->colourised->skin;
|
|
|
|
|
2004-12-29 03:24:21 +00:00
|
|
|
if (skinname[0] && !strchr(skinname, '/')) // a '/' in a skin name is deemed as a model name, so we ignore it.
|
|
|
|
Q_strncpyz(name, skinname, sizeof(name));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strstr(name, "..") || *name == '.')
|
|
|
|
Q_strncpyz(name, baseskin.string, sizeof(name));
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2014-09-08 23:47:19 +00:00
|
|
|
qwskin_t *Skin_Lookup (char *fullname)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
qwskin_t *skin;
|
|
|
|
char cleanname[sizeof(skin->name)];
|
|
|
|
COM_StripExtension (fullname, cleanname, sizeof(cleanname));
|
|
|
|
for (i=0 ; i<numskins ; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp (cleanname, skins[i].name))
|
|
|
|
{
|
|
|
|
skin = &skins[i];
|
2020-08-13 08:39:48 +00:00
|
|
|
Skin_TryCache8 (skin);
|
2014-09-08 23:47:19 +00:00
|
|
|
return skin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//FIXME: this is stupid.
|
|
|
|
if (numskins == MAX_CACHED_SKINS)
|
|
|
|
{ // ran out of spots, so flush everything
|
|
|
|
Skin_Skins_f ();
|
|
|
|
}
|
|
|
|
|
|
|
|
skin = &skins[numskins];
|
|
|
|
numskins++;
|
|
|
|
|
|
|
|
memset (skin, 0, sizeof(*skin));
|
|
|
|
Q_strncpyz(skin->name, cleanname, sizeof(skin->name));
|
2020-08-13 08:39:48 +00:00
|
|
|
Skin_TryCache8 (skin);
|
2014-09-08 23:47:19 +00:00
|
|
|
return skin;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Skin_Find
|
|
|
|
|
|
|
|
Determines the best skin for the given scoreboard
|
|
|
|
slot, and sets scoreboard->skin
|
|
|
|
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void Skin_Find (player_info_t *sc)
|
|
|
|
{
|
2014-09-08 23:47:19 +00:00
|
|
|
qwskin_t *skin;
|
2004-08-23 00:15:46 +00:00
|
|
|
int i;
|
2014-05-10 13:42:13 +00:00
|
|
|
char name[128], *s;
|
2004-11-27 08:16:25 +00:00
|
|
|
|
|
|
|
|
2014-09-08 23:47:19 +00:00
|
|
|
sc->model = NULL;
|
|
|
|
sc->skinid = 0;
|
|
|
|
sc->qwskin = NULL;
|
|
|
|
|
2014-10-06 17:55:39 +00:00
|
|
|
s = Skin_FindName(sc);
|
2004-12-22 18:58:54 +00:00
|
|
|
if (!*s)
|
2014-09-08 23:47:19 +00:00
|
|
|
return;
|
2014-05-10 13:42:13 +00:00
|
|
|
COM_StripExtension (s, name, sizeof(name));
|
2004-11-27 08:16:25 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
for (i=0 ; i<numskins ; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp (name, skins[i].name))
|
|
|
|
{
|
2014-09-08 23:47:19 +00:00
|
|
|
sc->qwskin = &skins[i];
|
2004-08-23 00:15:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numskins == MAX_CACHED_SKINS)
|
|
|
|
{ // ran out of spots, so flush everything
|
|
|
|
Skin_Skins_f ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
skin = &skins[numskins];
|
2014-09-08 23:47:19 +00:00
|
|
|
sc->qwskin = skin;
|
2004-08-23 00:15:46 +00:00
|
|
|
numskins++;
|
|
|
|
|
|
|
|
memset (skin, 0, sizeof(*skin));
|
|
|
|
Q_strncpyz(skin->name, name, sizeof(skin->name));
|
|
|
|
}
|
|
|
|
|
2020-08-13 08:39:48 +00:00
|
|
|
|
|
|
|
qbyte *Skin_ParsePCX(const char *name, const pcx_t *pcx, size_t pcxsize, int *pcxheight, int *pcxwidth)
|
2014-10-06 17:55:39 +00:00
|
|
|
{
|
2020-08-13 08:39:48 +00:00
|
|
|
const qbyte *raw;
|
2004-08-23 00:15:46 +00:00
|
|
|
qbyte *out, *pix;
|
2008-01-16 03:19:14 +00:00
|
|
|
int x, y, srcw, srch;
|
2004-08-23 00:15:46 +00:00
|
|
|
int dataByte;
|
|
|
|
int runLength;
|
|
|
|
int fbremap[256];
|
2020-08-13 08:39:48 +00:00
|
|
|
|
|
|
|
unsigned short xmax, ymax, xmin, ymin;
|
|
|
|
|
|
|
|
*pcxheight = *pcxwidth = 0;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// parse the PCX file
|
|
|
|
//
|
2020-08-13 08:39:48 +00:00
|
|
|
raw = (const qbyte *)(pcx+1);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2008-01-16 03:19:14 +00:00
|
|
|
//check format (sizes are checked later)
|
2004-08-23 00:15:46 +00:00
|
|
|
if (pcx->manufacturer != 0x0a
|
|
|
|
|| pcx->version != 5
|
|
|
|
|| pcx->encoding != 1
|
2008-01-16 03:19:14 +00:00
|
|
|
|| pcx->bits_per_pixel != 8)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2008-01-16 03:19:14 +00:00
|
|
|
Con_Printf ("Bad skin %s (unsupported format)\n", name);
|
2020-08-13 08:39:48 +00:00
|
|
|
return NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2005-04-19 21:09:29 +00:00
|
|
|
|
2020-08-13 08:39:48 +00:00
|
|
|
xmax = (unsigned short)LittleShort(pcx->xmax);
|
|
|
|
ymax = (unsigned short)LittleShort(pcx->ymax);
|
|
|
|
xmin = (unsigned short)LittleShort(pcx->xmin);
|
|
|
|
ymin = (unsigned short)LittleShort(pcx->ymin);
|
2005-04-19 21:09:29 +00:00
|
|
|
|
2020-08-13 08:39:48 +00:00
|
|
|
srcw = xmax-xmin+1;
|
|
|
|
srch = ymax-ymin+1;
|
2008-01-16 03:19:14 +00:00
|
|
|
|
|
|
|
if (srcw < 1 || srch < 1 || srcw > 320 || srch > 200)
|
2005-03-20 02:57:11 +00:00
|
|
|
{
|
2008-01-16 03:19:14 +00:00
|
|
|
Con_Printf ("Bad skin %s (unsupported size)\n", name);
|
2020-08-13 08:39:48 +00:00
|
|
|
return NULL;
|
2008-01-16 03:19:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-13 08:39:48 +00:00
|
|
|
*pcxheight = srcw;
|
|
|
|
*pcxwidth = srch;
|
|
|
|
|
|
|
|
out = BZ_Malloc(srcw*srch);
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!out)
|
|
|
|
Sys_Error ("Skin_Cache: couldn't allocate");
|
|
|
|
|
2014-10-05 20:04:11 +00:00
|
|
|
// TODO: we build a fullbright remap.. can we get rid of this?
|
|
|
|
for (x = 0; x < vid.fullbright; x++)
|
|
|
|
fbremap[x] = x + (256-vid.fullbright); //fullbrights don't exist, so don't loose palette info.
|
|
|
|
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
pix = out;
|
2008-01-16 03:19:14 +00:00
|
|
|
// memset (out, 0, skin->width*skin->height);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2008-01-16 03:19:14 +00:00
|
|
|
dataByte = 0; //typically black (this is in case a 0*0 file is loaded... which won't happen anyway)
|
2020-08-13 08:39:48 +00:00
|
|
|
for (y=0 ; y < srch ; y++, pix += srcw)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2008-01-16 03:19:14 +00:00
|
|
|
for (x=0 ; x < srcw ; )
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2020-08-13 08:39:48 +00:00
|
|
|
if (raw - (const qbyte*)pcx > pcxsize)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2014-10-06 17:55:39 +00:00
|
|
|
BZ_Free(out);
|
2004-08-23 00:15:46 +00:00
|
|
|
Con_Printf ("Skin %s was malformed. You should delete it.\n", name);
|
2020-08-13 08:39:48 +00:00
|
|
|
return NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
dataByte = *raw++;
|
|
|
|
|
|
|
|
if((dataByte & 0xC0) == 0xC0)
|
|
|
|
{
|
|
|
|
runLength = dataByte & 0x3F;
|
2020-08-13 08:39:48 +00:00
|
|
|
if (raw - (const qbyte*)pcx > pcxsize)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2014-10-06 17:55:39 +00:00
|
|
|
BZ_Free(out);
|
2004-08-23 00:15:46 +00:00
|
|
|
Con_Printf ("Skin %s was malformed. You should delete it.\n", name);
|
2020-08-13 08:39:48 +00:00
|
|
|
return NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
dataByte = *raw++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
runLength = 1;
|
|
|
|
|
|
|
|
// skin sanity check
|
2020-08-13 08:39:48 +00:00
|
|
|
if (runLength + x > xmax + 2)
|
2014-10-06 17:55:39 +00:00
|
|
|
{
|
|
|
|
BZ_Free(out);
|
2004-08-23 00:15:46 +00:00
|
|
|
Con_Printf ("Skin %s was malformed. You should delete it.\n", name);
|
2020-08-13 08:39:48 +00:00
|
|
|
return NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dataByte >= 256-vid.fullbright) //kill the fb componant
|
2009-11-04 21:16:50 +00:00
|
|
|
if (!r_fb_models.ival)
|
2004-08-23 00:15:46 +00:00
|
|
|
dataByte = fbremap[dataByte + vid.fullbright-256];
|
|
|
|
|
|
|
|
while(runLength-- > 0)
|
|
|
|
pix[x++] = dataByte;
|
|
|
|
}
|
|
|
|
|
2008-01-16 03:19:14 +00:00
|
|
|
//pad the end of the scan line with the trailing pixel
|
2020-08-13 08:39:48 +00:00
|
|
|
for ( ; x < srcw ; )
|
2008-01-16 03:19:14 +00:00
|
|
|
pix[x++] = dataByte;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2008-01-16 03:19:14 +00:00
|
|
|
//pad the bottom of the skin with that final pixel
|
2020-08-13 08:39:48 +00:00
|
|
|
for ( ; y < srch; y++, pix += srcw)
|
|
|
|
for (x = 0; x < srcw; )
|
2008-01-16 03:19:14 +00:00
|
|
|
pix[x++] = dataByte;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2020-08-13 08:39:48 +00:00
|
|
|
if ( raw - (const qbyte *)pcx > pcxsize)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2014-10-06 17:55:39 +00:00
|
|
|
BZ_Free(out);
|
2004-08-23 00:15:46 +00:00
|
|
|
Con_Printf ("Skin %s was malformed. You should delete it.\n", name);
|
2020-08-13 08:39:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Skin_WorkerDone(void *skinptr, void *skindata, size_t width, size_t height)
|
|
|
|
{
|
|
|
|
qwskin_t *skin = skinptr;
|
|
|
|
skin->width = width;
|
|
|
|
skin->height = height;
|
|
|
|
skin->skindata = skindata;
|
2021-05-19 04:49:24 +00:00
|
|
|
if (skindata || TEXLOADED(skin->textures.base))
|
2020-08-13 08:39:48 +00:00
|
|
|
skin->loadstate = SKIN_LOADED;
|
|
|
|
else
|
|
|
|
skin->loadstate = SKIN_FAILED;
|
|
|
|
}
|
|
|
|
void Skin_WorkerLoad(void *skinptr, void *data, size_t a, size_t b)
|
|
|
|
{
|
|
|
|
qwskin_t *skin = skinptr;
|
|
|
|
char name[MAX_QPATH];
|
|
|
|
qbyte *out;
|
2021-05-19 04:49:24 +00:00
|
|
|
int srcw = 0, srch = 0;
|
2020-08-13 08:39:48 +00:00
|
|
|
|
2021-05-19 04:49:24 +00:00
|
|
|
size_t pcxsize = 0;
|
|
|
|
void *pcxfiledata = NULL;
|
|
|
|
|
|
|
|
const char *skinpath = "skins";
|
|
|
|
|
|
|
|
skin->textures.base = r_nulltex;
|
|
|
|
if (gl_load24bit.ival)
|
|
|
|
skin->textures.base = R_LoadHiResTexture(skin->name, skinpath, IF_LOADNOW|IF_NOALPHA|IF_NOPCX);
|
2020-08-13 08:39:48 +00:00
|
|
|
|
2021-05-19 04:49:24 +00:00
|
|
|
if (skin->textures.base && skin->textures.base->width) //result was already posted and will be handled before Skin_WorkerDone.
|
2020-08-13 08:39:48 +00:00
|
|
|
{
|
2021-05-19 04:49:24 +00:00
|
|
|
if (!skin->textures.upperoverlay)
|
2020-08-13 08:39:48 +00:00
|
|
|
{
|
2021-05-19 04:49:24 +00:00
|
|
|
Q_snprintfz (name, sizeof(name), "%s_shirt", skin->name);
|
|
|
|
TEXASSIGN(skin->textures.upperoverlay, R_LoadHiResTexture(name, skinpath, IF_LOADNOW));
|
|
|
|
}
|
|
|
|
if (!skin->textures.loweroverlay)
|
|
|
|
{
|
|
|
|
Q_snprintfz (name, sizeof(name), "%s_pants", skin->name);
|
|
|
|
TEXASSIGN(skin->textures.loweroverlay, R_LoadHiResTexture(name, skinpath, IF_LOADNOW));
|
|
|
|
}
|
|
|
|
if (!skin->textures.fullbright)
|
|
|
|
{
|
|
|
|
Q_snprintfz (name, sizeof(name), "%s_luma", skin->name);
|
|
|
|
TEXASSIGN(skin->textures.fullbright, R_LoadHiResTexture(skin->name, skinpath, IF_LOADNOW));
|
|
|
|
}
|
|
|
|
if (!skin->textures.specular)
|
|
|
|
{
|
|
|
|
Q_snprintfz (name, sizeof(name), "%s_gloss", skin->name);
|
|
|
|
TEXASSIGN(skin->textures.specular, R_LoadHiResTexture(skin->name, skinpath, IF_LOADNOW));
|
2020-08-13 08:39:48 +00:00
|
|
|
}
|
2021-05-19 04:49:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Q_snprintfz (name, sizeof(name), "skins/%s.pcx", skin->name);
|
|
|
|
pcxfiledata = FS_LoadMallocFileFlags (name, FSLF_IGNOREPURE, &pcxsize);
|
2020-08-13 08:39:48 +00:00
|
|
|
if (!pcxfiledata)
|
|
|
|
{
|
2021-05-19 04:49:24 +00:00
|
|
|
//use 24bit skins even if gl_load24bit is failed
|
|
|
|
if (strcmp(skin->name, baseskin.string))
|
|
|
|
{
|
|
|
|
//if its not already the base skin, try the base (and warn if anything not base couldn't load).
|
|
|
|
Con_Printf ("Couldn't load skin %s\n", name);
|
|
|
|
if (*baseskin.string)
|
|
|
|
{
|
|
|
|
Q_snprintfz (name, sizeof(name), "skins/%s.pcx", baseskin.string);
|
|
|
|
pcxfiledata = FS_LoadMallocFileFlags (name, FSLF_IGNOREPURE, &pcxsize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!pcxfiledata)
|
|
|
|
{
|
|
|
|
Skin_WorkerDone(skin, NULL, 0, 0);
|
|
|
|
return;
|
|
|
|
}
|
2020-08-13 08:39:48 +00:00
|
|
|
}
|
2014-10-06 17:55:39 +00:00
|
|
|
}
|
|
|
|
|
2020-08-13 08:39:48 +00:00
|
|
|
if (pcxfiledata)
|
|
|
|
{
|
|
|
|
out = Skin_ParsePCX(name, pcxfiledata, pcxsize, &srcw, &srch);
|
|
|
|
FS_FreeFile(pcxfiledata);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out = NULL;
|
|
|
|
srcw = srch = 0;
|
|
|
|
}
|
|
|
|
if (!out)
|
|
|
|
COM_AddWork(WG_MAIN, Skin_WorkerDone, skin, NULL, 0, 0);
|
|
|
|
else
|
|
|
|
COM_AddWork(WG_MAIN, Skin_WorkerDone, skin, out, srcw, srch);
|
2014-10-06 17:55:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==========
|
|
|
|
Skin_Cache
|
|
|
|
|
|
|
|
Returns a pointer to the skin bitmap, or NULL to use the default
|
|
|
|
==========
|
|
|
|
*/
|
2020-08-13 08:39:48 +00:00
|
|
|
qbyte *Skin_TryCache8 (qwskin_t *skin)
|
2014-10-06 17:55:39 +00:00
|
|
|
{
|
|
|
|
if (noskins.value==1) // JACK: So NOSKINS > 1 will show skins, but
|
|
|
|
return NULL; // not download new ones.
|
|
|
|
|
|
|
|
if (skin->loadstate==SKIN_LOADING)
|
2004-08-23 00:15:46 +00:00
|
|
|
return NULL;
|
2014-10-06 17:55:39 +00:00
|
|
|
if (skin->loadstate==SKIN_LOADED)
|
|
|
|
return skin->skindata;
|
|
|
|
|
|
|
|
//
|
|
|
|
// load the pic from disk
|
|
|
|
//
|
|
|
|
if (strchr(skin->name, ' ')) //see if it's actually three colours
|
|
|
|
{
|
|
|
|
qbyte bv;
|
|
|
|
int col[3];
|
|
|
|
char *s;
|
|
|
|
qbyte *out;
|
|
|
|
|
|
|
|
s = COM_Parse(skin->name);
|
|
|
|
col[0] = atof(com_token);
|
|
|
|
s = COM_Parse(s);
|
|
|
|
col[1] = atof(com_token);
|
|
|
|
s = COM_Parse(s);
|
|
|
|
col[2] = atof(com_token);
|
|
|
|
|
|
|
|
bv = GetPaletteIndex(col[0], col[1], col[2]);
|
|
|
|
|
|
|
|
skin->width = 320;
|
|
|
|
skin->height = 200;
|
|
|
|
|
2018-07-24 13:59:42 +00:00
|
|
|
skin->skindata = out = BZ_Malloc(skin->width*skin->height);
|
2014-10-06 17:55:39 +00:00
|
|
|
|
2018-07-24 13:59:42 +00:00
|
|
|
memset (out, bv, skin->width*skin->height);
|
2014-10-06 17:55:39 +00:00
|
|
|
|
|
|
|
skin->loadstate = SKIN_LOADED;
|
|
|
|
|
|
|
|
return out;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2014-10-06 17:55:39 +00:00
|
|
|
if (skin->loadstate == SKIN_FAILED)
|
|
|
|
return NULL;
|
|
|
|
skin->loadstate = SKIN_LOADING;
|
2020-08-13 08:39:48 +00:00
|
|
|
COM_AddWork(WG_LOADER, Skin_WorkerLoad, skin, NULL,0,0);
|
|
|
|
return NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Skin_NextDownload
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void Skin_NextDownload (void)
|
|
|
|
{
|
|
|
|
player_info_t *sc;
|
|
|
|
int i;
|
|
|
|
|
2009-03-03 01:52:30 +00:00
|
|
|
//Con_Printf ("Checking skins...\n");
|
2014-09-08 23:47:19 +00:00
|
|
|
if (cls.protocol == CP_QUAKE2)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2014-09-08 23:47:19 +00:00
|
|
|
int j;
|
|
|
|
char *slash;
|
|
|
|
char *skinname;
|
2023-09-11 09:31:09 +00:00
|
|
|
char *dogtag;
|
2014-09-08 23:47:19 +00:00
|
|
|
for (i = 0; i != MAX_CLIENTS; i++)
|
2010-11-10 03:32:47 +00:00
|
|
|
{
|
2014-09-08 23:47:19 +00:00
|
|
|
sc = &cl.players[i];
|
|
|
|
if (!sc->name[0])
|
|
|
|
continue;
|
2018-07-05 16:21:44 +00:00
|
|
|
skinname = InfoBuf_ValueForKey(&sc->userinfo, "skin");
|
2014-09-08 23:47:19 +00:00
|
|
|
slash = strchr(skinname, '/');
|
2010-11-10 03:32:47 +00:00
|
|
|
if (slash)
|
|
|
|
{
|
|
|
|
*slash = 0;
|
2023-09-11 09:31:09 +00:00
|
|
|
|
|
|
|
dogtag = strchr(slash+1, '\\'); //q2e
|
|
|
|
if (dogtag)
|
|
|
|
*dogtag++ = 0;
|
|
|
|
|
2014-09-08 23:47:19 +00:00
|
|
|
CL_CheckOrEnqueDownloadFile(va("players/%s/tris.md2", skinname), NULL, 0);
|
2014-09-17 03:04:08 +00:00
|
|
|
for (j = 1; j < MAX_PRECACHE_MODELS; j++)
|
2010-11-10 03:32:47 +00:00
|
|
|
{
|
|
|
|
if (cl.model_name[j][0] == '#')
|
2014-09-08 23:47:19 +00:00
|
|
|
CL_CheckOrEnqueDownloadFile(va("players/%s/%s", skinname, cl.model_name[j]+1), NULL, 0);
|
2014-09-17 03:04:08 +00:00
|
|
|
if (!*cl.model_name[j])
|
|
|
|
break;
|
2010-11-10 03:32:47 +00:00
|
|
|
}
|
2014-09-17 03:04:08 +00:00
|
|
|
for (j = 1; j < MAX_PRECACHE_SOUNDS; j++)
|
2010-11-10 03:32:47 +00:00
|
|
|
{
|
|
|
|
if (cl.sound_name[j][0] == '*')
|
2014-09-08 23:47:19 +00:00
|
|
|
CL_CheckOrEnqueDownloadFile(va("players/%s/%s", skinname, cl.sound_name[j]+1), NULL, 0);
|
2014-09-17 03:04:08 +00:00
|
|
|
if (!*cl.sound_name[j])
|
|
|
|
break;
|
2010-11-10 03:32:47 +00:00
|
|
|
}
|
|
|
|
*slash = '/';
|
2014-09-08 23:47:19 +00:00
|
|
|
CL_CheckOrEnqueDownloadFile(va("players/%s.pcx", skinname), NULL, 0);
|
2010-11-10 03:32:47 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-08 23:47:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-10-06 17:55:39 +00:00
|
|
|
for (i = 0; i < MAX_CLIENTS; i++)
|
2014-09-08 23:47:19 +00:00
|
|
|
{
|
|
|
|
sc = &cl.players[i];
|
2014-10-06 17:55:39 +00:00
|
|
|
sc->lastskin = NULL; //invalidate any 'safe' skins
|
2014-09-08 23:47:19 +00:00
|
|
|
if (!sc->name[0])
|
|
|
|
continue;
|
|
|
|
Skin_Find (sc);
|
|
|
|
if (noskins.ival || !sc->qwskin)
|
|
|
|
continue;
|
|
|
|
if (strchr(sc->qwskin->name, ' ')) //skip over skins using a space
|
|
|
|
continue;
|
|
|
|
if (!*sc->qwskin->name)
|
|
|
|
continue;
|
2014-10-06 17:55:39 +00:00
|
|
|
|
2014-09-08 23:47:19 +00:00
|
|
|
CL_CheckOrEnqueDownloadFile(va("skins/%s.pcx", sc->qwskin->name), NULL, 0);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// now load them in for real
|
|
|
|
for (i=0 ; i<MAX_CLIENTS ; i++)
|
|
|
|
{
|
|
|
|
sc = &cl.players[i];
|
2014-09-08 23:47:19 +00:00
|
|
|
if (!sc->name[0] || !sc->qwskin)
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
2020-08-13 08:39:48 +00:00
|
|
|
Skin_TryCache8 (sc->qwskin);
|
2014-09-08 23:47:19 +00:00
|
|
|
//sc->qwskin = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-23 17:49:42 +00:00
|
|
|
//called from a few places when some skin cheat is applied.
|
|
|
|
//flushes all player skins.
|
|
|
|
void Skin_FlushPlayers(void)
|
|
|
|
{ //wipe the skin info
|
|
|
|
int i;
|
2015-02-09 03:37:41 +00:00
|
|
|
for (i = 0; i < MAX_CLIENTS; i++)
|
2014-09-08 23:47:19 +00:00
|
|
|
cl.players[i].qwskin = NULL;
|
2009-04-01 22:03:56 +00:00
|
|
|
|
2013-10-29 17:38:22 +00:00
|
|
|
for (i = 0; i < cl.allocated_client_slots; i++)
|
2009-04-01 22:03:56 +00:00
|
|
|
CL_NewTranslation(i);
|
2005-01-23 17:49:42 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2015-02-09 03:37:41 +00:00
|
|
|
//call on shutdown. does not refresh any skins at all.
|
2013-03-12 22:53:23 +00:00
|
|
|
void Skin_FlushAll(void)
|
|
|
|
{ //wipe the skin info
|
|
|
|
int i;
|
|
|
|
for (i=0 ; i<numskins ; i++)
|
2014-10-29 05:03:03 +00:00
|
|
|
{
|
|
|
|
if (skins[i].loadstate==SKIN_LOADING)
|
|
|
|
COM_WorkerPartialSync(&skins[i], &skins[i].loadstate, SKIN_LOADING);
|
2013-07-14 12:22:51 +00:00
|
|
|
if (skins[i].skindata)
|
|
|
|
BZ_Free(skins[i].skindata);
|
2014-10-29 05:03:03 +00:00
|
|
|
}
|
2013-03-12 22:53:23 +00:00
|
|
|
numskins = 0;
|
2014-10-06 17:55:39 +00:00
|
|
|
for (i = 0; i < MAX_CLIENTS; i++)
|
2015-02-09 03:37:41 +00:00
|
|
|
{
|
|
|
|
cl.players[i].qwskin = NULL;
|
2014-10-06 17:55:39 +00:00
|
|
|
cl.players[i].lastskin = NULL;
|
2015-02-09 03:37:41 +00:00
|
|
|
}
|
2013-03-12 22:53:23 +00:00
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
==========
|
|
|
|
Skin_Skins_f
|
|
|
|
|
|
|
|
Refind all skins, downloading if needed.
|
|
|
|
==========
|
|
|
|
*/
|
|
|
|
void Skin_Skins_f (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2004-12-22 18:58:54 +00:00
|
|
|
if (cls.state == ca_disconnected)
|
|
|
|
{
|
2020-08-13 08:39:48 +00:00
|
|
|
Con_TPrintf ("Can't \"%s\", not connected\n", Cmd_Argv(0));
|
2004-12-22 18:58:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-08 23:47:19 +00:00
|
|
|
R_GAliasFlushSkinCache(false);
|
2004-08-23 00:15:46 +00:00
|
|
|
for (i=0 ; i<numskins ; i++)
|
2014-10-29 05:03:03 +00:00
|
|
|
{
|
|
|
|
if (skins[i].loadstate==SKIN_LOADING)
|
|
|
|
COM_WorkerPartialSync(&skins[i], &skins[i].loadstate, SKIN_LOADING);
|
2013-07-14 12:22:51 +00:00
|
|
|
if (skins[i].skindata)
|
|
|
|
BZ_Free(skins[i].skindata);
|
2014-10-29 05:03:03 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
numskins = 0;
|
2014-10-06 17:55:39 +00:00
|
|
|
for (i = 0; i < MAX_CLIENTS; i++)
|
|
|
|
cl.players[i].lastskin = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
Skin_NextDownload ();
|
|
|
|
|
2006-01-04 00:44:34 +00:00
|
|
|
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
// if (Cmd_FromServer())
|
|
|
|
{
|
|
|
|
SCR_SetLoadingStage(LS_NONE);
|
2009-04-06 00:34:32 +00:00
|
|
|
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
CL_SendClientCommand(true, "begin %i", cl.servercount);
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==========
|
|
|
|
Skin_AllSkins_f
|
|
|
|
|
|
|
|
Sets all skins to one specific one
|
|
|
|
==========
|
|
|
|
*/
|
|
|
|
void Skin_AllSkins_f (void)
|
|
|
|
{
|
|
|
|
strcpy (allskins, Cmd_Argv(1));
|
|
|
|
Skin_Skins_f ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Skin_FlushSkin(char *name)
|
|
|
|
{
|
2014-10-06 17:55:39 +00:00
|
|
|
int i;
|
2004-08-23 00:15:46 +00:00
|
|
|
char sname[16]="";
|
|
|
|
if (strncmp(name, "skins/", 6))
|
|
|
|
return;
|
|
|
|
Q_strncpyz(sname, (name + 6), strlen(name+6)-3);
|
|
|
|
for (i=0 ; i<numskins ; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp(skins[i].name, sname))
|
2014-10-06 17:55:39 +00:00
|
|
|
{
|
|
|
|
skins[i].loadstate = SKIN_NOTLOADED;
|
|
|
|
memset(&skins[i].textures, 0, sizeof(skins[i].textures));
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-04 14:41:16 +00:00
|
|
|
#else
|
|
|
|
void Skin_FlushPlayers(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
//required for the qw protocol (server stuffcmds 'skins' to get the client to send 'begin'. *sigh*
|
|
|
|
void Skin_Skins_f (void)
|
|
|
|
{
|
|
|
|
if (cls.state == ca_disconnected)
|
|
|
|
{
|
2020-08-13 08:39:48 +00:00
|
|
|
Con_TPrintf ("Can't \"%s\", not connected\n", Cmd_Argv(0));
|
2018-03-04 14:41:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2018-03-04 14:41:16 +00:00
|
|
|
R_GAliasFlushSkinCache(false);
|
|
|
|
|
|
|
|
// if (Cmd_FromServer())
|
|
|
|
{
|
|
|
|
SCR_SetLoadingStage(LS_NONE);
|
|
|
|
|
|
|
|
CL_SendClientCommand(true, "begin %i", cl.servercount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2008-05-25 22:23:43 +00:00
|
|
|
|