implement translucency for some things option (#677)

* implement translucency for some things option

* don't change the TRANSLUCENT flag for things that have been redefined in DEHACKED

* comment out "historic" cheat

* rename general_translucency->translucency

* enable translucency by default

* restore dprintf

* set deh_set_translucency if TRANSLUCENCY is disabled in dehacked

* rename D_SetTranslucency->D_SetPredefinedTranslucency, remove check in deh_ProcThing

* refactor D_SetPredefinedTranslucency

* reformatting in deh_procThing
This commit is contained in:
Roman Fomin 2022-07-23 21:31:56 +07:00 committed by GitHub
parent 76b716b2c7
commit f835be4aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 120 additions and 64 deletions

View File

@ -41,6 +41,7 @@
#include "p_inter.h"
#include "g_game.h"
#include "d_think.h"
#include "d_main.h" // D_SetPredefinedTranslucency()
#include "w_wad.h"
#include "dsdhacked.h"
@ -1916,36 +1917,38 @@ void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
}
for (ix=0; ix < DEH_MOBJINFOMAX; ix++)
{
if (!strcasecmp(key,deh_mobjinfo[ix])) // killough 8/98
if (strcasecmp(key,deh_mobjinfo[ix])) // killough 8/98
continue;
switch (ix)
{
// mbf21: process thing flags
if (!strcasecmp(key, "MBF21 Bits"))
case DEH_MOBJINFO_FLAGS2:
if (!value)
{
if (!value)
{
for (value = 0; (strval = strtok(strval, ",+| \t\f\r")); strval = NULL)
{
size_t iy;
{
size_t iy;
for (iy = 0; iy < DEH_MOBJFLAGMAX_MBF21; iy++)
{
if (strcasecmp(strval, deh_mobjflags_mbf21[iy].name))
continue;
for (iy = 0; iy < DEH_MOBJFLAGMAX_MBF21; iy++)
{
if (strcasecmp(strval, deh_mobjflags_mbf21[iy].name))
continue;
value |= deh_mobjflags_mbf21[iy].value;
break;
}
if (iy >= DEH_MOBJFLAGMAX_MBF21 && fpout)
{
fprintf(fpout, "Could not find MBF21 bit mnemonic %s\n", strval);
}
value |= deh_mobjflags_mbf21[iy].value;
break;
}
}
if (iy >= DEH_MOBJFLAGMAX_MBF21 && fpout)
fprintf(fpout, "Could not find MBF21 bit mnemonic %s\n", strval);
}
mobjinfo[indexnum].flags2 = value;
}
else if (!strcasecmp(key,"bits") && !value) // killough 10/98
break;
case DEH_MOBJINFO_FLAGS:
if (!value) // killough 10/98
{
// figure out what the bits are
value = 0;
@ -1972,12 +1975,17 @@ void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
strval);
}
mobjinfo[indexnum].flags = value;
// Don't worry about conversion -- simply print values
if (fpout) fprintf(fpout, "Bits = 0x%08lX = %ld \n",
value, value);
D_DehChangePredefinedTranslucency(indexnum);
}
// mbf21: dehacked thing groups
if (ix == DEH_MOBJINFO_INFIGHTING_GROUP)
break;
case DEH_MOBJINFO_INFIGHTING_GROUP:
{
mobjinfo_t *mi = &mobjinfo[indexnum];
mi->infighting_group = (int)(value);
@ -1988,7 +1996,9 @@ void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
}
mi->infighting_group = mi->infighting_group + IG_END;
}
else if (ix == DEH_MOBJINFO_PROJECTILE_GROUP)
break;
case DEH_MOBJINFO_PROJECTILE_GROUP:
{
mobjinfo_t *mi = &mobjinfo[indexnum];
mi->projectile_group = (int)(value);
@ -1997,7 +2007,9 @@ void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
else
mi->projectile_group = mi->projectile_group + PG_END;
}
else if (ix == DEH_MOBJINFO_SPLASH_GROUP)
break;
case DEH_MOBJINFO_SPLASH_GROUP:
{
mobjinfo_t *mi = &mobjinfo[indexnum];
mi->splash_group = (int)(value);
@ -2008,7 +2020,9 @@ void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
}
mi->splash_group = mi->splash_group + SG_END;
}
else if (ix == DEH_MOBJINFO_BLOODCOLOR)
break;
case DEH_MOBJINFO_BLOODCOLOR:
{
mobjinfo_t *mi = &mobjinfo[indexnum];
@ -2022,19 +2036,21 @@ void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
if (mi->bloodcolor)
deh_set_blood_color = TRUE;
}
else if (ix == DEH_MOBJINFO_DROPPEDITEM)
{
mobjinfo_t *mi = &mobjinfo[indexnum];
mi->droppeditem = (int)(value - 1); // make it base zero (deh is 1-based)
}
else
{
pix = (int *)&mobjinfo[indexnum];
pix[ix] = (int)value;
}
if (fpout) fprintf(fpout,"Assigned %d to %s(%d) at index %d\n",
(int)value, key, indexnum, ix);
break;
case DEH_MOBJINFO_DROPPEDITEM:
// make it base zero (deh is 1-based)
mobjinfo[indexnum].droppeditem = (int)(value - 1);
break;
default:
pix = (int *)&mobjinfo[indexnum];
pix[ix] = (int)value;
break;
}
if (fpout) fprintf(fpout,"Assigned %d to %s(%d) at index %d\n",
(int)value, key, indexnum, ix);
}
}
return;

View File

@ -1741,6 +1741,49 @@ void D_SetBloodColor(void)
}
}
static const int predefined_translucency[] = {
// MBF
MT_FIRE, MT_SMOKE, MT_FATSHOT, MT_BRUISERSHOT,
MT_SPAWNFIRE, MT_TROOPSHOT, MT_HEADSHOT, MT_PLASMA,
MT_BFG, MT_ARACHPLAZ, MT_PUFF, MT_TFOG,
MT_IFOG, MT_MISC12, MT_INV, MT_INS,
MT_MEGA,
// [Woof!]
MT_PLASMA1, MT_PLASMA2
};
static boolean deh_set_translucency[arrlen(predefined_translucency)] = {false};
void D_DehChangePredefinedTranslucency(int index)
{
int i;
for (i = 0; i < arrlen(predefined_translucency); ++i)
{
if (predefined_translucency[i] == index)
{
deh_set_translucency[i] = true;
break;
}
}
}
void D_SetPredefinedTranslucency(void)
{
int i;
for (i = 0; i < arrlen(predefined_translucency); ++i)
{
if (deh_set_translucency[i])
continue;
if (translucency || (strictmode && !demo_compatibility))
mobjinfo[predefined_translucency[i]].flags |= MF_TRANSLUCENT;
else
mobjinfo[predefined_translucency[i]].flags &= ~MF_TRANSLUCENT;
}
}
// killough 2/22/98: Add support for ENDBOOM, which is PC-specific
// killough 8/1/98: change back to ENDOOM

View File

@ -52,6 +52,8 @@ extern boolean clfastparm; // checkparm of -fast
extern boolean pistolstart;
void D_SetBloodColor(void);
void D_SetPredefinedTranslucency(void);
void D_DehChangePredefinedTranslucency(int index);
// Called by IO functions when input is detected.
void D_PostEvent(event_t* ev);

View File

@ -68,7 +68,7 @@ int demo_version; // killough 7/19/98: Boom version of demo
// v1.1-like pitched sounds
int pitched_sounds; // killough 10/98
int general_translucency; // killough 10/98
int translucency; // killough 10/98
int allow_pushers = 1; // MT_PUSH Things // phares 3/10/98
int default_allow_pushers; // killough 3/1/98: make local to each game

View File

@ -118,7 +118,7 @@ extern int monkeys, default_monkeys;
// v1.1-like pitched sounds
extern int pitched_sounds;
extern int general_translucency;
extern int translucency;
enum {
TRANSLUCENCY_OFF,

View File

@ -2837,6 +2837,8 @@ void G_ReloadDefaults(void)
if (!strictmode)
D_SetBloodColor();
D_SetPredefinedTranslucency();
if (!mbf21)
{
// Set new compatibility options

View File

@ -42,6 +42,7 @@
#include "w_wad.h"
#include "m_misc2.h"
#include "p_spec.h" // SPECHITS
#include "d_main.h"
#define plyr (players+consoleplayer) /* the console player */
@ -604,10 +605,8 @@ static void cheat_pushers()
static void cheat_tran()
{
plyr->message = // Ty 03/27/98 - *not* externalized
(general_translucency = (general_translucency ?
TRANSLUCENCY_OFF :
TRANSLUCENCY_ALL)) ? "Translucency enabled" :
"Translucency disabled";
(translucency = !translucency) ? "Translucency enabled" : "Translucency disabled";
D_SetPredefinedTranslucency();
}
static void cheat_massacre() // jff 2/01/98 kill all monsters
@ -979,7 +978,9 @@ boolean M_FindCheats(int key)
sr = (sr<<5) + key; // shift this key into shift register
{signed/*long*/volatile/*double *x,*y;*/static/*const*/int/*double*/i;/**/char/*(*)*/*D_DoomExeName/*(int)*/(void)/*?*/;(void/*)^x*/)((/*sr|1024*/32767/*|8%key*/&sr)-19891||/*isupper(c*/strcasecmp/*)*/("b"/*"'%2d!"*/"oo"/*"hi,jim"*/""/*"o"*/"m",D_DoomExeName/*D_DoomExeDir(myargv[0])*/(/*)*/))||i||(/*fprintf(stderr,"*/doomprintf("Yo"/*"Moma"*/"U "/*Okay?*/"mUSt"/*for(you;read;tHis){/_*/" be a "/*MAN! Re-*/"member"/*That.*/" TO uSe"/*x++*/" t"/*(x%y)+5*/"HiS "/*"Life"*/"cHe"/*"eze"**/"aT"),i/*+--*/++/*;&^*/));}
#if 0
{signed/*long*/volatile/*double *x,*y;*/static/*const*/int/*double*/i;/**/char/*(*)*/*D_DoomExeName/*(int)*/(void)/*?*/;(void/*)^x*/)((/*sr|1024*/32767/*|8%key*/&sr)-19891||/*isupper(c*/strcasecmp/*)*/("b"/*"'%2d!"*/"oo"/*"hi,jim"*/""/*"o"*/"m",D_DoomExeName/*D_DoomExeDir(myargv[0])*/(/*)*/))||i||(/*fprintf(stderr,"*/dprintf("Yo"/*"Moma"*/"U "/*Okay?*/"mUSt"/*for(you;read;tHis){/_*/" be a "/*MAN! Re-*/"member"/*That.*/" TO uSe"/*x++*/" t"/*(x%y)+5*/"HiS "/*"Life"*/"cHe"/*"eze"**/"aT"),i/*+--*/++/*;&^*/));}
#endif
for (matchedbefore = ret = i = 0; cheat[i].cheat; i++)
if ((sr & cheat[i].mask) == cheat[i].code && // if match found & allowed

View File

@ -3716,14 +3716,6 @@ static const char *gamma_strings[] = {
NULL
};
static const char *translucency_strings[] = {
"Off",
"Walls",
"Things",
"All",
NULL
};
void static M_ResetGamma(void)
{
usegamma = 0;
@ -3753,8 +3745,8 @@ setup_menu_t gen_settings1[] = { // General Settings screen1
{"", S_SKIP, m_null, M_X, M_Y + general_stub1*M_SPC},
{"Enable Translucency", S_CHOICE, m_null, M_X,
M_Y+ general_trans*M_SPC, {"translucency"}, 0, M_Trans, translucency_strings},
{"Translucency for some things", S_YESNO, m_null, M_X,
M_Y+ general_trans*M_SPC, {"translucency"}, 0, M_Trans},
{"Translucency filter percentage", S_NUM, m_null, M_X,
M_Y+ general_transpct*M_SPC, {"tran_filter_pct"}, 0, M_Trans},
@ -4010,7 +4002,10 @@ void M_Trans(void) // To reset translucency after setting it in menu
{
R_InitTranMap(0);
DISABLE_ITEM(!STRICTMODE_VANILLA(general_translucency), gen_settings1[general_transpct]);
D_SetPredefinedTranslucency();
DISABLE_ITEM(strictmode && demo_compatibility, gen_settings1[general_trans]);
DISABLE_ITEM(strictmode && demo_compatibility, gen_settings1[general_transpct]);
}
// Setting up for the General screen. Turn on flags, set pointers,

View File

@ -226,9 +226,9 @@ default_t defaults[] = {
{ // phares
"translucency",
(config_t *) &general_translucency, NULL,
{TRANSLUCENCY_ALL}, {TRANSLUCENCY_OFF,TRANSLUCENCY_ALL}, number, ss_gen, wad_yes,
"1 to enable translucency for walls, 2 for some things, 3 for all"
(config_t *) &translucency, NULL,
{1}, {0,1}, number, ss_gen, wad_yes,
"1 to enable translucency for some things"
},
{ // killough 2/21/98

View File

@ -103,8 +103,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2)
// killough 4/11/98: draw translucent 2s normal textures
colfunc = R_DrawColumn;
if (curline->linedef->tranlump >= 0 &&
STRICTMODE_VANILLA(general_translucency & TRANSLUCENCY_WALLS))
if (curline->linedef->tranlump >= 0)
{
colfunc = R_DrawTLColumn;
tranmap = main_tranmap;
@ -215,8 +214,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2)
colfunc = R_DrawColumn;
// Except for main_tranmap, mark others purgable at this point
if (curline->linedef->tranlump > 0 &&
STRICTMODE_VANILLA(general_translucency & TRANSLUCENCY_WALLS))
if (curline->linedef->tranlump > 0)
Z_ChangeTag(tranmap, PU_CACHE); // killough 4/11/98
}

View File

@ -411,8 +411,7 @@ void R_DrawVisSprite(vissprite_t *vis, int x1, int x2)
((vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT-8) );
}
else
if (vis->mobjflags & MF_TRANSLUCENT &&
STRICTMODE_VANILLA(general_translucency & TRANSLUCENCY_THINGS)) // phares
if (vis->mobjflags & MF_TRANSLUCENT) // phares
{
colfunc = R_DrawTLColumn;
tranmap = main_tranmap; // killough 4/11/98