mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
split out the qw client specific skin code from skin.c
This commit is contained in:
parent
f62ecbe90d
commit
559aa4485b
7 changed files with 282 additions and 165 deletions
|
@ -52,9 +52,7 @@ struct player_info_s;
|
|||
|
||||
void Skin_Find (struct player_info_s *sc);
|
||||
struct tex_s *Skin_Cache (skin_t *skin);
|
||||
void Skin_Skins_f (void);
|
||||
void Skin_AllSkins_f (void);
|
||||
void Skin_NextDownload (void);
|
||||
void Skin_Flush (void);
|
||||
void Skin_Init (void);
|
||||
void Skin_Init_Cvars (void);
|
||||
void Skin_Init_Translation (void);
|
||||
|
|
41
qw/include/cl_skin.h
Normal file
41
qw/include/cl_skin.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
cl_skin.h
|
||||
|
||||
Client skin definitions
|
||||
|
||||
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$
|
||||
*/
|
||||
|
||||
#ifndef _CL_SKIN_H
|
||||
#define _CL_SKIN_H
|
||||
|
||||
#include "QF/qtypes.h"
|
||||
#include "QF/skin.h"
|
||||
|
||||
void CL_Skins_f (void);
|
||||
void CL_AllSkins_f (void);
|
||||
void Skin_NextDownload (void);
|
||||
void CL_Skin_Init (void);
|
||||
void CL_Skin_Init_Cvars (void);
|
||||
|
||||
#endif
|
|
@ -94,8 +94,8 @@ client_POST_LIBS= $(top_builddir)/libs/video/targets/libQFjs.la
|
|||
# libQFjs is seperate because it needs to be linked after when building statically
|
||||
|
||||
client_SOURCES= cl_cam.c cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c cl_input.c \
|
||||
cl_main.c cl_misc.c cl_parse.c cl_pred.c cl_slist.c cl_tent.c \
|
||||
console.c keys.c locs.c nonintel.c \
|
||||
cl_main.c cl_misc.c cl_parse.c cl_pred.c cl_skin.c cl_slist.c \
|
||||
cl_tent.c console.c keys.c locs.c nonintel.c \
|
||||
pcx.c r_cvar.c r_efrag.c r_view.c sbar.c skin.c teamplay.c tga.c wad.c cl_math.S $(syscl_SRC)
|
||||
|
||||
# Software-rendering clients
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
#include "QF/quakefs.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/screen.h"
|
||||
#include "QF/skin.h"
|
||||
#include "QF/sound.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/teamplay.h"
|
||||
|
@ -89,6 +88,7 @@
|
|||
#include "cl_main.h"
|
||||
#include "cl_parse.h"
|
||||
#include "cl_pred.h"
|
||||
#include "cl_skin.h"
|
||||
#include "cl_slist.h"
|
||||
#include "cl_tent.h"
|
||||
#include "client.h"
|
||||
|
@ -1600,7 +1600,7 @@ Host_Init (void)
|
|||
|
||||
CL_Cam_Init_Cvars ();
|
||||
CL_Input_Init_Cvars ();
|
||||
Skin_Init_Cvars ();
|
||||
CL_Skin_Init_Cvars ();
|
||||
CL_Init_Cvars ();
|
||||
CL_Prediction_Init_Cvars ();
|
||||
COM_Init_Cvars ();
|
||||
|
@ -1655,7 +1655,7 @@ Host_Init (void)
|
|||
|
||||
cls.state = ca_disconnected;
|
||||
Sbar_Init ();
|
||||
Skin_Init ();
|
||||
CL_Skin_Init ();
|
||||
CL_Init ();
|
||||
#else
|
||||
VID_Init (vid_basepal);
|
||||
|
@ -1668,7 +1668,7 @@ Host_Init (void)
|
|||
cls.state = ca_disconnected;
|
||||
CDAudio_Init ();
|
||||
Sbar_Init ();
|
||||
Skin_Init ();
|
||||
CL_Skin_Init ();
|
||||
CL_Init ();
|
||||
IN_Init ();
|
||||
#endif
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include "QF/compat.h"
|
||||
#include "QF/console.h"
|
||||
#include "QF/msg.h"
|
||||
#include "QF/skin.h"
|
||||
#include "QF/screen.h"
|
||||
#include "QF/sound.h"
|
||||
#include "QF/teamplay.h"
|
||||
|
@ -59,6 +58,7 @@
|
|||
#include "cl_input.h"
|
||||
#include "cl_main.h"
|
||||
#include "cl_parse.h"
|
||||
#include "cl_skin.h"
|
||||
#include "cl_tent.h"
|
||||
#include "client.h"
|
||||
#include "host.h"
|
||||
|
|
228
qw/source/cl_skin.c
Normal file
228
qw/source/cl_skin.c
Normal file
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
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/hash.h"
|
||||
#include "QF/info.h"
|
||||
#include "QF/msg.h"
|
||||
#include "QF/pcx.h"
|
||||
#include "QF/qendian.h"
|
||||
#include "QF/quakefs.h"
|
||||
#include "QF/screen.h"
|
||||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/texture.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "cl_parse.h"
|
||||
#include "client.h"
|
||||
#include "host.h"
|
||||
|
||||
cvar_t *noskins; //XXX FIXME
|
||||
cvar_t *skin;
|
||||
cvar_t *topcolor;
|
||||
cvar_t *bottomcolor;
|
||||
|
||||
char allskins[128];
|
||||
|
||||
/*
|
||||
Skin_NextDownload
|
||||
*/
|
||||
void
|
||||
Skin_NextDownload (void)
|
||||
{
|
||||
player_info_t *sc;
|
||||
int i;
|
||||
|
||||
if (cls.downloadnumber == 0) {
|
||||
Con_Printf ("Checking skins...\n");
|
||||
SCR_UpdateScreen ();
|
||||
}
|
||||
cls.downloadtype = dl_skin;
|
||||
|
||||
for (; cls.downloadnumber != MAX_CLIENTS; cls.downloadnumber++) {
|
||||
sc = &cl.players[cls.downloadnumber];
|
||||
if (!sc->name[0])
|
||||
continue;
|
||||
Skin_Find (sc);
|
||||
if (noskins->int_val) //XXX FIXME
|
||||
continue;
|
||||
if (!CL_CheckOrDownloadFile (va ("skins/%s.pcx", sc->skin->name)))
|
||||
return; // started a download
|
||||
}
|
||||
|
||||
cls.downloadtype = dl_none;
|
||||
|
||||
// now load them in for real
|
||||
for (i = 0; i < MAX_CLIENTS; i++) {
|
||||
sc = &cl.players[i];
|
||||
if (!sc->name[0])
|
||||
continue;
|
||||
Skin_Find (sc);
|
||||
Skin_Cache (sc->skin);
|
||||
sc->skin = NULL;
|
||||
}
|
||||
|
||||
if (cls.state != ca_active) { // get next signon phase
|
||||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.netchan.message, va ("begin %i", cl.servercount));
|
||||
Cache_Report (); // print remaining memory
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
CL_Skins_f
|
||||
|
||||
Refind all skins, downloading if needed.
|
||||
*/
|
||||
void
|
||||
CL_Skins_f (void)
|
||||
{
|
||||
Skin_Flush ();
|
||||
cls.downloadnumber = 0;
|
||||
cls.downloadtype = dl_skin;
|
||||
Skin_NextDownload ();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
CL_AllSkins_f
|
||||
|
||||
Sets all skins to one specific one
|
||||
*/
|
||||
void
|
||||
CL_AllSkins_f (void)
|
||||
{
|
||||
strcpy (allskins, Cmd_Argv (1));
|
||||
CL_Skins_f ();
|
||||
}
|
||||
|
||||
void
|
||||
CL_Color_f (void)
|
||||
{
|
||||
// just for quake compatability...
|
||||
int top, bottom;
|
||||
char num[16];
|
||||
|
||||
if (Cmd_Argc () == 1) {
|
||||
Con_Printf ("\"color\" is \"%s %s\"\n",
|
||||
Info_ValueForKey (cls.userinfo, "topcolor"),
|
||||
Info_ValueForKey (cls.userinfo, "bottomcolor"));
|
||||
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;
|
||||
|
||||
snprintf (num, sizeof (num), "%i", top);
|
||||
Cvar_Set (topcolor, num);
|
||||
snprintf (num, sizeof (num), "%i", bottom);
|
||||
Cvar_Set (bottomcolor, num);
|
||||
}
|
||||
|
||||
void
|
||||
CL_Skin_Init (void)
|
||||
{
|
||||
Skin_Init ();
|
||||
Cmd_AddCommand ("skins", CL_Skins_f, "Download all skins that are currently in use");
|
||||
Cmd_AddCommand ("allskins", CL_AllSkins_f, "Force all player skins to one skin");
|
||||
Cmd_AddCommand ("color", CL_Color_f, "The pant and shirt color (color shirt pants) Note that if only shirt color is given, pants will match");
|
||||
}
|
||||
|
||||
void
|
||||
CL_Skin_Init_Cvars (void)
|
||||
{
|
||||
Skin_Init_Cvars ();
|
||||
noskins = Cvar_Get ("noskins", "0", CVAR_NONE, NULL, //XXX FIXME
|
||||
"set to 1 to not download new skins");
|
||||
skin = Cvar_Get ("skin", "", CVAR_ARCHIVE | CVAR_USERINFO, Cvar_Info,
|
||||
"Players skin");
|
||||
topcolor = Cvar_Get ("topcolor", "0", CVAR_ARCHIVE | CVAR_USERINFO,
|
||||
Cvar_Info, "Players color on top");
|
||||
bottomcolor = Cvar_Get ("bottomcolor", "0", CVAR_ARCHIVE | CVAR_USERINFO,
|
||||
Cvar_Info, "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->topcolor, player->bottomcolor,
|
||||
player->translations);
|
||||
if (!player->skin)
|
||||
Skin_Find (player);
|
||||
Skin_Do_Translation (player->skin, slot);
|
||||
}
|
||||
}
|
160
qw/source/skin.c
160
qw/source/skin.c
|
@ -51,12 +51,11 @@
|
|||
#include "QF/texture.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "cl_parse.h"
|
||||
#include "client.h"
|
||||
#include "host.h"
|
||||
|
||||
extern cvar_t *noskins; //XXX FIXME, this shouldn't be here?
|
||||
|
||||
cvar_t *baseskin;
|
||||
cvar_t *noskins;
|
||||
cvar_t *skin;
|
||||
cvar_t *topcolor;
|
||||
cvar_t *bottomcolor;
|
||||
|
@ -110,7 +109,7 @@ Skin_Find (player_info_t *sc)
|
|||
|
||||
if (numskins == MAX_CACHED_SKINS) { // ran out of spots, so flush
|
||||
// everything
|
||||
Skin_Skins_f ();
|
||||
Skin_Flush ();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -144,7 +143,7 @@ Skin_Cache (skin_t *skin)
|
|||
if (cls.downloadtype == dl_skin) // use base until downloaded
|
||||
return NULL;
|
||||
// NOSKINS > 1 will show skins, but not download new ones.
|
||||
if (noskins->int_val == 1)
|
||||
if (noskins->int_val == 1) //XXX FIXME
|
||||
return NULL;
|
||||
|
||||
if (skin->failedload)
|
||||
|
@ -195,60 +194,8 @@ Skin_Cache (skin_t *skin)
|
|||
return out;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Skin_NextDownload
|
||||
*/
|
||||
void
|
||||
Skin_NextDownload (void)
|
||||
{
|
||||
player_info_t *sc;
|
||||
int i;
|
||||
|
||||
if (cls.downloadnumber == 0) {
|
||||
Con_Printf ("Checking skins...\n");
|
||||
SCR_UpdateScreen ();
|
||||
}
|
||||
cls.downloadtype = dl_skin;
|
||||
|
||||
for (; cls.downloadnumber != MAX_CLIENTS; cls.downloadnumber++) {
|
||||
sc = &cl.players[cls.downloadnumber];
|
||||
if (!sc->name[0])
|
||||
continue;
|
||||
Skin_Find (sc);
|
||||
if (noskins->int_val)
|
||||
continue;
|
||||
if (!CL_CheckOrDownloadFile (va ("skins/%s.pcx", sc->skin->name)))
|
||||
return; // started a download
|
||||
}
|
||||
|
||||
cls.downloadtype = dl_none;
|
||||
|
||||
// now load them in for real
|
||||
for (i = 0; i < MAX_CLIENTS; i++) {
|
||||
sc = &cl.players[i];
|
||||
if (!sc->name[0])
|
||||
continue;
|
||||
Skin_Find (sc);
|
||||
Skin_Cache (sc->skin);
|
||||
sc->skin = NULL;
|
||||
}
|
||||
|
||||
if (cls.state != ca_active) { // get next signon phase
|
||||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.netchan.message, va ("begin %i", cl.servercount));
|
||||
Cache_Report (); // print remaining memory
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Skin_Skins_f
|
||||
|
||||
Refind all skins, downloading if needed.
|
||||
*/
|
||||
void
|
||||
Skin_Skins_f (void)
|
||||
Skin_Flush (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -258,67 +205,12 @@ Skin_Skins_f (void)
|
|||
}
|
||||
numskins = 0;
|
||||
Hash_FlushTable (skin_hash);
|
||||
|
||||
cls.downloadnumber = 0;
|
||||
cls.downloadtype = dl_skin;
|
||||
Skin_NextDownload ();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Skin_AllSkins_f
|
||||
|
||||
Sets all skins to one specific one
|
||||
*/
|
||||
void
|
||||
Skin_AllSkins_f (void)
|
||||
{
|
||||
strcpy (allskins, Cmd_Argv (1));
|
||||
Skin_Skins_f ();
|
||||
}
|
||||
|
||||
void
|
||||
CL_Color_f (void)
|
||||
{
|
||||
// just for quake compatability...
|
||||
int top, bottom;
|
||||
char num[16];
|
||||
|
||||
if (Cmd_Argc () == 1) {
|
||||
Con_Printf ("\"color\" is \"%s %s\"\n",
|
||||
Info_ValueForKey (cls.userinfo, "topcolor"),
|
||||
Info_ValueForKey (cls.userinfo, "bottomcolor"));
|
||||
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;
|
||||
|
||||
snprintf (num, sizeof (num), "%i", top);
|
||||
Cvar_Set (topcolor, num);
|
||||
snprintf (num, sizeof (num), "%i", bottom);
|
||||
Cvar_Set (bottomcolor, num);
|
||||
}
|
||||
|
||||
void
|
||||
Skin_Init (void)
|
||||
{
|
||||
skin_hash = Hash_NewTable (1021, skin_get_key, 0, 0);
|
||||
Cmd_AddCommand ("skins", Skin_Skins_f, "Download all skins that are currently in use");
|
||||
Cmd_AddCommand ("allskins", Skin_AllSkins_f, "Force all player skins to one skin");
|
||||
Cmd_AddCommand ("color", CL_Color_f, "The pant and shirt color (color shirt pants) Note that if only shirt color is given, pants will match");
|
||||
Skin_Init_Translation ();
|
||||
}
|
||||
|
||||
|
@ -327,46 +219,4 @@ Skin_Init_Cvars (void)
|
|||
{
|
||||
baseskin = Cvar_Get ("baseskin", "base", CVAR_NONE, NULL,
|
||||
"default base skin name");
|
||||
noskins = Cvar_Get ("noskins", "0", CVAR_NONE, NULL,
|
||||
"set to 1 to not download new skins");
|
||||
skin = Cvar_Get ("skin", "", CVAR_ARCHIVE | CVAR_USERINFO, Cvar_Info,
|
||||
"Players skin");
|
||||
topcolor = Cvar_Get ("topcolor", "0", CVAR_ARCHIVE | CVAR_USERINFO,
|
||||
Cvar_Info, "Players color on top");
|
||||
bottomcolor = Cvar_Get ("bottomcolor", "0", CVAR_ARCHIVE | CVAR_USERINFO,
|
||||
Cvar_Info, "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->topcolor, player->bottomcolor,
|
||||
player->translations);
|
||||
if (!player->skin)
|
||||
Skin_Find (player);
|
||||
Skin_Do_Translation (player->skin, slot);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue