1
0
Fork 0
forked from fte/fteqw

stains are multiplicative instead of additive

get rid of infokey usage in cl_ignore
reduce sw stainmaps from int to unsigned char


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1657 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2005-12-01 22:36:01 +00:00
parent 79d122b3cf
commit bc44aaf54b
4 changed files with 46 additions and 78 deletions

View file

@ -63,7 +63,7 @@ int Player_NametoSlot(char *name) {
int i; int i;
for (i = 0; i < MAX_CLIENTS; i++) { for (i = 0; i < MAX_CLIENTS; i++) {
if (cl.players[i].name[0] && !strncmp(Info_ValueForKey(cl.players[i].userinfo, "name"), name, 31)) if (cl.players[i].name[0] && !strncmp(cl.players[i].name, name, MAX_SCOREBOARDNAME - 1))
return i; return i;
} }
return PLAYER_NAME_NOMATCH; return PLAYER_NAME_NOMATCH;
@ -74,7 +74,7 @@ int Player_SlottoId (int slot) {
} }
char *Player_MyName (void) { char *Player_MyName (void) {
return Info_ValueForKey(cls.demoplayback ? cls.userinfo : cl.players[cl.playernum[0]].userinfo, "name"); return cl.players[cl.playernum[0]].name;
} }
@ -395,7 +395,7 @@ void Ignore_Flood_Add(char *s) {
qboolean Ignore_Message(char *s, int flags, int offset) { qboolean Ignore_Message(char *s, int flags, int offset) {
int slot, i, p, q, len; int slot, i, p, q, len;
char name[32]; char name[MAX_SCOREBOARDNAME];
if (!ignore_mode.value && (flags & 2)) if (!ignore_mode.value && (flags & 2))
return false; return false;

View file

@ -84,25 +84,9 @@ void GLR_StainSurf (msurface_t *surf, float *parms)
#define stain(x) \ #define stain(x) \
\ \
change = amm*parms[4+x]; \ change = stainbase[(s)*3+x] + amm*parms[4+x]; \
if (change < 0) \ stainbase[(s)*3+x] = bound(0, change, 255);
{ if(change<-128)change=-128; \
if (stainbase[(s)*3+x] < change) \
{} \
else if (stainbase[(s)*3+x] < 0) \
stainbase[(s)*3+x] = change; \
else \
stainbase[(s)*3+x] += change; \
} \
else \
{ if(change>127)change=127; \
if (stainbase[(s)*3+x] > change) \
{} \
else if (stainbase[(s)*3+x] > 0) \
stainbase[(s)*3+x] = change; \
else \
stainbase[(s)*3+x] += change; \
}
@ -292,7 +276,7 @@ void GLR_WipeStains(void)
{ {
if (!lightmap[i]) if (!lightmap[i])
break; break;
memset(lightmap[i]->stainmaps, 0, sizeof(lightmap[i]->stainmaps)); memset(lightmap[i]->stainmaps, 255, sizeof(lightmap[i]->stainmaps));
} }
} }
@ -317,7 +301,7 @@ void GLR_LessenStains(void)
return; return;
time-=r_stainfadetime.value; time-=r_stainfadetime.value;
ammount = r_stainfadeammount.value; ammount = 255 - r_stainfadeammount.value;
surf = cl.worldmodel->surfaces; surf = cl.worldmodel->surfaces;
for (i=0 ; i<cl.worldmodel->numsurfaces ; i++, surf++) for (i=0 ; i<cl.worldmodel->numsurfaces ; i++, surf++)
@ -342,18 +326,13 @@ void GLR_LessenStains(void)
{ {
for (s=0 ; s<smax ; s++) for (s=0 ; s<smax ; s++)
{ {
if (*stain < -ammount) //negative values increase to 0 if (*stain < ammount) //eventually decay to 255
{ {
*stain += ammount; *stain += ammount;
surf->stained=true; surf->stained=true;
} }
else if (*stain > ammount) //positive values reduce to 0 else //reset to 255
{ *stain = 255;
*stain -= ammount;
surf->stained=true;
}
else //close to 0 or 0 already.
*stain = 0;
stain++; stain++;
} }
@ -1030,11 +1009,11 @@ store:
b = *blb++; b = *blb++;
b >>= 7; b >>= 7;
if (isstained) //do we need to add the stain? if (isstained) // merge in stain
{ {
r += *stain++; r = (128+r*(*stain++)) >> 8;
g += *stain++; g = (128+g*(*stain++)) >> 8;
b += *stain++; b = (128+b*(*stain++)) >> 8;
} }
cr = 0; cr = 0;
@ -1188,11 +1167,11 @@ store:
b = *blb++; b = *blb++;
b >>= 7; b >>= 7;
if (isstained) //do we need to add the stain? if (isstained) // merge in stain
{ {
r += *stain++; r = (128+r*(*stain++)) >> 8;
g += *stain++; g = (128+g*(*stain++)) >> 8;
b += *stain++; b = (128+b*(*stain++)) >> 8;
} }
cr = 0; cr = 0;
@ -1383,11 +1362,11 @@ store:
b = *blb++; b = *blb++;
b >>= 7; b >>= 7;
if (isstained) //do we need to add the stain? if (isstained) // merge in stain
{ {
r += *stain++; r = (128+r*(*stain++)) >> 8;
g += *stain++; g = (128+g*(*stain++)) >> 8;
b += *stain++; b = (128+b*(*stain++)) >> 8;
} }
cr = 0; cr = 0;
@ -1541,11 +1520,11 @@ store:
b = *blb++; b = *blb++;
b >>= 7; b >>= 7;
if (isstained) //do we need to add the stain? if (isstained) // merge in stain
{ {
r += *stain++; r = (128+r*(*stain++)) >> 8;
g += *stain++; g = (128+g*(*stain++)) >> 8;
b += *stain++; b = (128+b*(*stain++)) >> 8;
} }
cr = 0; cr = 0;

View file

@ -349,7 +349,7 @@ int Mod_LoadBumpmapTexture(char *name, char *subpath);
typedef struct glRect_s { typedef struct glRect_s {
unsigned char l,t,w,h; unsigned char l,t,w,h;
} glRect_t; } glRect_t;
typedef char stmap; typedef unsigned char stmap;
typedef struct { typedef struct {
qboolean modified; qboolean modified;
qboolean deluxmodified; qboolean deluxmodified;

View file

@ -87,7 +87,8 @@ extern cvar_t r_stainfadeammount;
#define LMBLOCK_HEIGHT 128 #define LMBLOCK_HEIGHT 128
#define MAX_LIGHTMAPS 64 #define MAX_LIGHTMAPS 64
int stainmaps[MAX_LIGHTMAPS*LMBLOCK_WIDTH*LMBLOCK_HEIGHT]; //added to lightmap for added (hopefully) speed. typedef unsigned char stmap;
stmap stainmaps[MAX_LIGHTMAPS*LMBLOCK_WIDTH*LMBLOCK_HEIGHT]; //added to lightmap for added (hopefully) speed.
int allocated[MAX_LIGHTMAPS][LMBLOCK_WIDTH]; int allocated[MAX_LIGHTMAPS][LMBLOCK_WIDTH];
//radius, x y z, a //radius, x y z, a
@ -102,7 +103,7 @@ void SWR_StainSurf (msurface_t *surf, float *parms)
float amm; float amm;
mtexinfo_t *tex; mtexinfo_t *tex;
int *stainbase; stmap *stainbase;
smax = (surf->extents[0]>>4)+1; smax = (surf->extents[0]>>4)+1;
tmax = (surf->extents[1]>>4)+1; tmax = (surf->extents[1]>>4)+1;
@ -148,12 +149,8 @@ void SWR_StainSurf (msurface_t *surf, float *parms)
dist = td + (sd>>1); dist = td + (sd>>1);
if (dist < minlight) if (dist < minlight)
{ {
amm = (rad - dist); amm = stainbase[(s)] + (dist - rad)*parms[4];
if (stainbase[(s)]>0) stainbase[(s)] = bound(0, amm, 255);
amm *= (255-stainbase[(s)])/255.0;
else
amm *= (255+stainbase[(s)])/255.0;
stainbase[(s)] += amm*parms[4];
surf->stained = true; surf->stained = true;
} }
@ -246,7 +243,7 @@ void SWR_AddStain(vec3_t org, float red, float green, float blue, float radius)
void SWR_WipeStains(void) void SWR_WipeStains(void)
{ {
memset(stainmaps, 0, sizeof(stainmaps)); memset(stainmaps, 255, sizeof(stainmaps));
} }
void SWR_LessenStains(void) void SWR_LessenStains(void)
@ -256,7 +253,7 @@ void SWR_LessenStains(void)
int smax, tmax; int smax, tmax;
int s, t; int s, t;
int *stain; stmap *stain;
int stride; int stride;
int ammount; int ammount;
@ -273,7 +270,7 @@ void SWR_LessenStains(void)
return; return;
time-=r_stainfadetime.value; time-=r_stainfadetime.value;
ammount = r_stainfadeammount.value; ammount = 255 - r_stainfadeammount.value;
surf = cl.worldmodel->surfaces; surf = cl.worldmodel->surfaces;
for (i=0 ; i<cl.worldmodel->numsurfaces ; i++, surf++) for (i=0 ; i<cl.worldmodel->numsurfaces ; i++, surf++)
@ -298,18 +295,13 @@ void SWR_LessenStains(void)
{ {
for (s=0 ; s<smax ; s++) for (s=0 ; s<smax ; s++)
{ {
if (*stain < -ammount) //negative values increase to 0 if (*stain < ammount)
{ {
*stain += ammount; *stain += ammount;
surf->stained=true; surf->stained=true;
} }
else if (*stain > ammount) //positive values reduce to 0 else //reset to 255.
{ *stain = 255;
*stain -= ammount;
surf->stained=true;
}
else //close to 0 or 0 already.
*stain = 0;
stain++; stain++;
} }
@ -812,10 +804,9 @@ void SWR_BuildLightMap (void)
#ifdef SWSTAINS #ifdef SWSTAINS
if (surf->stained) if (surf->stained)
{ {
int *stain; stmap *stain;
int sstride; int sstride;
int x, y; int x, y;
int quant;
stain = stainmaps + surf->lightmaptexturenum*LMBLOCK_WIDTH*LMBLOCK_HEIGHT; stain = stainmaps + surf->lightmaptexturenum*LMBLOCK_WIDTH*LMBLOCK_HEIGHT;
stain += (surf->light_t * LMBLOCK_WIDTH + surf->light_s); stain += (surf->light_t * LMBLOCK_WIDTH + surf->light_s);
@ -828,10 +819,7 @@ void SWR_BuildLightMap (void)
{ {
for (y = 0; y < smax; y++, i++, stain++) for (y = 0; y < smax; y++, i++, stain++)
{ {
quant = (int)blocklights[i]+*stain*128; t = (255*256*256-128*256-(int)blocklights[i]*(*stain)) >> (16 - VID_CBITS);
if (quant < 0)
quant = 0;
t = (255*256 - (quant)) >> (8 - VID_CBITS);
if (t < (1 << 6)) if (t < (1 << 6))
t = (1 << 6); t = (1 << 6);
@ -904,7 +892,7 @@ void SWR_BuildLightMapRGB (void)
#ifdef SWSTAINS #ifdef SWSTAINS
if (surf->stained) if (surf->stained)
{ {
int *stain; stmap *stain;
int sstride; int sstride;
int x, y; int x, y;
@ -919,9 +907,10 @@ void SWR_BuildLightMapRGB (void)
{ {
for (y = 0; y < smax; y++, i+=3, stain++) for (y = 0; y < smax; y++, i+=3, stain++)
{ {
r = (255*256-(int)blocklights[i]-*stain*128) >> (8 - VID_CBITS); r = (255*256*256-128*256-(int)blocklights[i]*(*stain)) >> 16 - VID_CBITS;
g = (255*256-(int)blocklights[i+1]-*stain*128) >> (8 - VID_CBITS); g = (255*256*256-128*256-(int)blocklights[i+1]*(*stain)) >> 16 - VID_CBITS;
b = (255*256-(int)blocklights[i+2]-*stain*128) >> (8 - VID_CBITS); b = (255*256*256-128*256-(int)blocklights[i+2]*(*stain)) >> 16 - VID_CBITS;
#define MINL (1<<6) #define MINL (1<<6)
#define MAXL ((255*256) >> (8 - VID_CBITS)) #define MAXL ((255*256) >> (8 - VID_CBITS))