Removed some unused variables.

Added support for 32bit player skins (with pants/shirt overlays).
Updated spectating name tags to not lag, and be centered. Also visible by default.
Smoothed out viewweapons slightly in certain cases (when they're not animating at 10fps).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3290 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2009-07-17 22:28:16 +00:00
parent 4b2c4ed77a
commit 4671892cce
10 changed files with 140 additions and 35 deletions

View File

@ -2764,6 +2764,8 @@ Create visible entities in the correct position
for all current players for all current players
============= =============
*/ */
vec3_t nametagorg[MAX_CLIENTS];
qboolean nametagseen[MAX_CLIENTS];
void CL_LinkPlayers (void) void CL_LinkPlayers (void)
{ {
int pnum; int pnum;
@ -2793,6 +2795,8 @@ void CL_LinkPlayers (void)
for (j=0, info=cl.players, state=frame->playerstate ; j < MAX_CLIENTS for (j=0, info=cl.players, state=frame->playerstate ; j < MAX_CLIENTS
; j++, info++, state++) ; j++, info++, state++)
{ {
nametagseen[j] = false;
if (state->messagenum != cl.validsequence) if (state->messagenum != cl.validsequence)
{ {
#ifdef CSQC_DAT #ifdef CSQC_DAT
@ -2992,6 +2996,9 @@ void CL_LinkPlayers (void)
VectorCopy (exact.origin, ent->origin); VectorCopy (exact.origin, ent->origin);
} }
VectorCopy(ent->origin, nametagorg[j]);
nametagseen[j] = true;
if (state->effects & QWEF_FLAG1) if (state->effects & QWEF_FLAG1)
CL_AddFlagModels (ent, 0); CL_AddFlagModels (ent, 0);
else if (state->effects & QWEF_FLAG2) else if (state->effects & QWEF_FLAG2)
@ -3021,6 +3028,7 @@ void CL_LinkViewModel(void)
static struct model_s *oldmodel[MAX_SPLITS]; static struct model_s *oldmodel[MAX_SPLITS];
static float lerptime[MAX_SPLITS]; static float lerptime[MAX_SPLITS];
static float frameduration[MAX_SPLITS];
static int prevframe[MAX_SPLITS]; static int prevframe[MAX_SPLITS];
static int oldframe[MAX_SPLITS]; static int oldframe[MAX_SPLITS];
float alpha; float alpha;
@ -3094,6 +3102,12 @@ void CL_LinkViewModel(void)
if (ent.framestate.g[FS_REG].frame[0] != prevframe[r_refdef.currentplayernum]) if (ent.framestate.g[FS_REG].frame[0] != prevframe[r_refdef.currentplayernum])
{ {
oldframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[1] = prevframe[r_refdef.currentplayernum]; oldframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[1] = prevframe[r_refdef.currentplayernum];
frameduration[r_refdef.currentplayernum] = (realtime - lerptime[r_refdef.currentplayernum]);
if (frameduration[r_refdef.currentplayernum] < 0.01)//no faster than 100 times a second... to avoid divide by zero
frameduration[r_refdef.currentplayernum] = 0.01;
if (frameduration[r_refdef.currentplayernum] > 0.2) //no slower than 5 times a second
frameduration[r_refdef.currentplayernum] = 0.2;
lerptime[r_refdef.currentplayernum] = realtime; lerptime[r_refdef.currentplayernum] = realtime;
} }
prevframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[0]; prevframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[0];
@ -3102,9 +3116,10 @@ void CL_LinkViewModel(void)
{ {
oldmodel[r_refdef.currentplayernum] = ent.model; oldmodel[r_refdef.currentplayernum] = ent.model;
oldframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[1] = ent.framestate.g[FS_REG].frame[0]; oldframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[1] = ent.framestate.g[FS_REG].frame[0];
frameduration[r_refdef.currentplayernum] = 0.1;
lerptime[r_refdef.currentplayernum] = realtime; lerptime[r_refdef.currentplayernum] = realtime;
} }
ent.framestate.g[FS_REG].lerpfrac = 1-(realtime-lerptime[r_refdef.currentplayernum])*10; ent.framestate.g[FS_REG].lerpfrac = 1-(realtime-lerptime[r_refdef.currentplayernum])/frameduration[r_refdef.currentplayernum];
ent.framestate.g[FS_REG].lerpfrac = bound(0, ent.framestate.g[FS_REG].lerpfrac, 1); ent.framestate.g[FS_REG].lerpfrac = bound(0, ent.framestate.g[FS_REG].lerpfrac, 1);
} }
#define Q2RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors #define Q2RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors

View File

@ -26,7 +26,12 @@ typedef struct
char name[64]; char name[64];
int width; int width;
int height; int height;
int cachedbpp;
//for hardware 32bit texture overrides
int tex_base;
int tex_lower;
int tex_upper;
qboolean failedload; // the name isn't a valid skin qboolean failedload; // the name isn't a valid skin
cache_user_t cache; cache_user_t cache;
} skin_t; } skin_t;

View File

@ -1,3 +1,22 @@
/*
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 included (GNU.txt) 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" #include "quakedef.h"
#ifdef PSET_CLASSIC #ifdef PSET_CLASSIC

View File

@ -1,3 +1,22 @@
/*
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 included (GNU.txt) 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" #include "quakedef.h"
#define NUMVERTEXNORMALS 162 #define NUMVERTEXNORMALS 162

View File

@ -99,13 +99,8 @@ cvar_t r_floortexture = SCVARF ("r_floortexture", "",
CVAR_RENDERERCALLBACK); CVAR_RENDERERCALLBACK);
cvar_t r_fullbright = SCVARF ("r_fullbright", "0", cvar_t r_fullbright = SCVARF ("r_fullbright", "0",
CVAR_CHEAT); CVAR_CHEAT);
#ifdef MINIMAL
cvar_t r_fullbrightSkins = SCVARF ("r_fullbrightSkins", "1", cvar_t r_fullbrightSkins = SCVARF ("r_fullbrightSkins", "1",
CVAR_SEMICHEAT); CVAR_SEMICHEAT);
#else
cvar_t r_fullbrightSkins = SCVARF ("r_fullbrightSkins", "0",
CVAR_SEMICHEAT);
#endif
cvar_t r_lightmap_saturation = SCVAR ("r_lightmap_saturation", "1"); cvar_t r_lightmap_saturation = SCVAR ("r_lightmap_saturation", "1");
cvar_t r_lightstylesmooth = SCVAR ("r_lightstylesmooth", "0"); cvar_t r_lightstylesmooth = SCVAR ("r_lightstylesmooth", "0");
cvar_t r_lightstylespeed = SCVAR ("r_lightstylespeed", "10"); cvar_t r_lightstylespeed = SCVAR ("r_lightstylespeed", "10");

View File

@ -222,6 +222,10 @@ qbyte *Skin_Cache8 (skin_t *skin)
if (skin->failedload) if (skin->failedload)
return NULL; return NULL;
skin->tex_base = 0;
skin->tex_lower = 0;
skin->tex_upper = 0;
out = Cache_Check (&skin->cache); out = Cache_Check (&skin->cache);
if (out) if (out)
return out; return out;
@ -250,7 +254,6 @@ qbyte *Skin_Cache8 (skin_t *skin)
skin->width = 320; skin->width = 320;
skin->height = 200; skin->height = 200;
skin->cachedbpp = 8;
out = Cache_Alloc (&skin->cache, 320*200, skin->name); out = Cache_Alloc (&skin->cache, 320*200, skin->name);
@ -272,6 +275,22 @@ qbyte *Skin_Cache8 (skin_t *skin)
{ {
if (strcmp(skin->name, baseskin.string)) if (strcmp(skin->name, baseskin.string))
{ {
#if defined(RGLQUAKE) || defined(D3DQUAKE)
if (qrenderer == QR_OPENGL || qrenderer == QR_DIRECT3D)
{
skin->tex_base = Mod_LoadReplacementTexture(skin->name, "skins", true, false, true);
if (skin->tex_base)
{
sprintf (name, "%s_shirt", skin->name);
skin->tex_upper = Mod_LoadReplacementTexture(name, "skins", true, true, true);
sprintf (name, "%s_pants", skin->name);
skin->tex_lower = Mod_LoadReplacementTexture(name, "skins", true, true, true);
skin->failedload = true;
return NULL;
}
}
#endif
//if its not already the base skin, try the base (and warn if anything not base couldn't load). //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); Con_Printf ("Couldn't load skin %s\n", name);
sprintf (name, "skins/%s.pcx", baseskin.string); sprintf (name, "skins/%s.pcx", baseskin.string);
@ -301,8 +320,6 @@ qbyte *Skin_Cache8 (skin_t *skin)
return NULL; return NULL;
} }
skin->cachedbpp = 8;
pcx->xmax = (unsigned short)LittleShort(pcx->xmax); pcx->xmax = (unsigned short)LittleShort(pcx->xmax);
pcx->ymax = (unsigned short)LittleShort(pcx->ymax); pcx->ymax = (unsigned short)LittleShort(pcx->ymax);
pcx->xmin = (unsigned short)LittleShort(pcx->xmin); pcx->xmin = (unsigned short)LittleShort(pcx->xmin);
@ -416,8 +433,6 @@ qbyte *Skin_Cache32 (skin_t *skin)
else else
path = "skins/"; path = "skins/";
skin->cachedbpp = 32;
// //
// load the pic from disk // load the pic from disk
// //

View File

@ -94,7 +94,7 @@ cvar_t v_gunkick = SCVAR("v_gunkick", "0");
cvar_t v_viewheight = SCVAR("v_viewheight", "0"); cvar_t v_viewheight = SCVAR("v_viewheight", "0");
cvar_t scr_autoid = SCVAR("scr_autoid", "0"); cvar_t scr_autoid = SCVAR("scr_autoid", "1");
extern cvar_t cl_chasecam; extern cvar_t cl_chasecam;
@ -1234,19 +1234,24 @@ void SCR_VRectForPlayer(vrect_t *vrect, int pnum)
} }
} }
void Draw_ExpandedString(int x, int y, conchar_t *str);
extern vec3_t nametagorg[MAX_CLIENTS];
extern qboolean nametagseen[MAX_CLIENTS];
void R_DrawNameTags(void) void R_DrawNameTags(void)
{ {
conchar_t buffer[256];
int i; int i;
int len;
vec3_t center; vec3_t center;
vec3_t tagcenter; vec3_t tagcenter;
vec3_t waste, waste2; vec3_t waste, waste2;
frame_t *frame;
player_state_t *state;
if (!cl.spectator && !cls.demoplayback) if (!cl.spectator && !cls.demoplayback)
return; return;
if (!scr_autoid.value) if (!scr_autoid.value)
return; return;
if (cls.state != ca_active || !cl.validsequence)
return;
#ifdef RGLQUAKE #ifdef RGLQUAKE
if (qrenderer == QR_OPENGL) if (qrenderer == QR_OPENGL)
@ -1256,26 +1261,23 @@ void R_DrawNameTags(void)
} }
#endif #endif
frame = &cl.frames[cl.parsecount&UPDATE_MASK]; for (i = 0; i < MAX_CLIENTS; i++)
state = frame->playerstate;
for (i = 0; i < MAX_CLIENTS; i++, state++)
{ {
if (state->messagenum != cl.parsecount) if (!nametagseen[i])
continue; // not present this frame continue;
if (i == cl.playernum[r_refdef.currentplayernum]) if (i == cl.playernum[r_refdef.currentplayernum])
continue; // Don't draw tag for the local player continue; // Don't draw tag for the local player
if (Cam_DrawPlayer(r_refdef.currentplayernum, i) == false)
continue; // Don't draw tag for players not drawn on the map if (TP_IsPlayerVisible(nametagorg[i]))
if (view_frame && view_frame->playerstate[i].flags & PF_DEAD)
continue; // Don't draw tag for dead people
if (!TraceLineN(r_refdef.vieworg, state->origin, waste, waste2))
{ {
VectorCopy(state->origin, tagcenter); VectorCopy(nametagorg[i], tagcenter);
tagcenter[2] += 32; tagcenter[2] += 32;
Matrix4_Project(tagcenter, center, r_refdef.viewangles, r_refdef.vieworg, r_refdef.fov_x, r_refdef.fov_y); Matrix4_Project(tagcenter, center, r_refdef.viewangles, r_refdef.vieworg, r_refdef.fov_x, r_refdef.fov_y);
if (center[2] > 1) if (center[2] > 1)
continue; continue;
Draw_FunString(center[0]*r_refdef.vrect.width+r_refdef.vrect.x, (1-center[1])*r_refdef.vrect.height+r_refdef.vrect.y, cl.players[i].name);
len = COM_ParseFunString(CON_WHITEMASK, cl.players[i].name, buffer, sizeof(buffer), false) - buffer;
Draw_ExpandedString(center[0]*r_refdef.vrect.width+r_refdef.vrect.x - len*4, (1-center[1])*r_refdef.vrect.height+r_refdef.vrect.y, buffer);
} }
} }
} }

View File

@ -2746,6 +2746,25 @@ static qboolean TP_IsItemVisible(item_vis_t *visitem)
return false; return false;
} }
//checks to see if a point at org the size of a player is visible or not
qboolean TP_IsPlayerVisible(vec3_t origin)
{
item_vis_t visitem;
VectorCopy(vpn, visitem.forward);
VectorCopy(vright, visitem.right);
VectorCopy(vup, visitem.up);
VectorCopy(r_origin, visitem.vieworg);
VectorCopy (origin, visitem.entorg);
visitem.entorg[2] += 27;
VectorSubtract (visitem.entorg, visitem.vieworg, visitem.dir);
visitem.dist = DotProduct (visitem.dir, visitem.forward);
visitem.radius = 25;
return TP_IsItemVisible(&visitem);
}
static float TP_RankPoint(item_vis_t *visitem) static float TP_RankPoint(item_vis_t *visitem)
{ {
vec3_t v2, v3; vec3_t v2, v3;

View File

@ -367,6 +367,15 @@ static galiastexnum_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, int sur
} }
} }
if (e->scoreboard->skin->tex_base)
{
texnums = &cm->texnum;
texnums->loweroverlay = e->scoreboard->skin->tex_lower;
texnums->upperoverlay = e->scoreboard->skin->tex_upper;
texnums->base = e->scoreboard->skin->tex_base;
return texnums;
}
cm->texnum.base = Mod_LoadHiResTexture(e->scoreboard->skin->name, "skins", true, false, true); cm->texnum.base = Mod_LoadHiResTexture(e->scoreboard->skin->name, "skins", true, false, true);
return &cm->texnum; return &cm->texnum;
} }
@ -379,6 +388,15 @@ static galiastexnum_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, int sur
original = Skin_Cache8(e->scoreboard->skin); original = Skin_Cache8(e->scoreboard->skin);
inwidth = e->scoreboard->skin->width; inwidth = e->scoreboard->skin->width;
inheight = e->scoreboard->skin->height; inheight = e->scoreboard->skin->height;
if (!original && e->scoreboard->skin->tex_base)
{
texnums = &cm->texnum;
texnums->loweroverlay = e->scoreboard->skin->tex_lower;
texnums->upperoverlay = e->scoreboard->skin->tex_upper;
texnums->base = e->scoreboard->skin->tex_base;
return texnums;
}
} }
else else
{ {

View File

@ -2193,8 +2193,6 @@ void PF_centerprint (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
char *s; char *s;
int entnum; int entnum;
client_t *cl, *sp;
int slen;
entnum = G_EDICTNUM(prinst, OFS_PARM0); entnum = G_EDICTNUM(prinst, OFS_PARM0);
s = PF_VarString(prinst, 1, pr_globals); s = PF_VarString(prinst, 1, pr_globals);