From 361f855de03f22ab1b3b1b292deb97aec3a51372 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 20 Jul 2006 05:13:39 +0000 Subject: [PATCH] - Added some simple translucency map analysis for BOOM maps to more intelligently pick the value to use for TranslucentLine's second argument. - Added a queryiwad_key cvar to control which key can force the IWAD selection to appear. It can be either "shift" or "control". Any other value will disable its functionality. - Fixed: A_SkullPop() and A_FreezeDeathChunks() did not transfer the player's inventory to the new dismembered head "player". SVN r268 (trunk) --- docs/rh-log.txt | 9 ++++ src/g_heretic/a_hereticplayer.cpp | 1 + src/g_shared/a_action.cpp | 1 + src/p_setup.cpp | 71 ++++++++++++++++++++++++++++--- src/v_palette.cpp | 6 +++ src/v_palette.h | 4 +- src/win32/i_system.cpp | 17 +++++++- 7 files changed, 101 insertions(+), 8 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 77b6a9ba3..0df4971c6 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,12 @@ +July 19, 2006 +- Added some simple translucency map analysis for BOOM maps to more + intelligently pick the value to use for TranslucentLine's second argument. +- Added a queryiwad_key cvar to control which key can force the IWAD selection + to appear. It can be either "shift" or "control". Any other value will + disable its functionality. +- Fixed: A_SkullPop() and A_FreezeDeathChunks() did not transfer the player's + inventory to the new dismembered head "player". + July 18, 2006 - Fixed: C_midPrint() needs a NULL status bar check. diff --git a/src/g_heretic/a_hereticplayer.cpp b/src/g_heretic/a_hereticplayer.cpp index 6acae5890..fe1f223bc 100644 --- a/src/g_heretic/a_hereticplayer.cpp +++ b/src/g_heretic/a_hereticplayer.cpp @@ -212,6 +212,7 @@ void A_SkullPop (AActor *actor) // Attach player mobj to bloody skull player = actor->player; actor->player = NULL; + mo->ObtainInventory (actor); mo->player = player; mo->health = actor->health; mo->angle = actor->angle; diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 77e7ed292..bbbaad0cc 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -284,6 +284,7 @@ void A_FreezeDeathChunks (AActor *actor) head->momy = pr_freeze.Random2 () << (FRACBITS-7); head->player = actor->player; actor->player = NULL; + head->ObtainInventory (actor); head->health = actor->health; head->angle = actor->angle; head->player->mo = head; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 7b47d6c42..f7a340c9c 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -120,6 +120,7 @@ struct sidei_t // [RH] Only keep BOOM sidedef init stuff around for init struct { short tag, special; + short alpha; DWORD map; } a; @@ -1715,12 +1716,18 @@ void P_FinishLoadingLineDefs () switch (ld->special) { // killough 4/11/98: handle special types int j; + int alpha; case TranslucentLine: // killough 4/11/98: translucent 2s textures // [RH] Second arg controls how opaque it is. + alpha = sidetemp[ld->sidenum[0]].a.alpha; + if (alpha < 0) + { + alpha = ld->args[1]; + } if (!ld->args[0]) { - ld->alpha = (byte)ld->args[1]; + ld->alpha = (BYTE)alpha; if (ld->args[2] == 1) { sides[ld->sidenum[0]].Flags |= WALLF_ADDTRANS; @@ -1736,7 +1743,7 @@ void P_FinishLoadingLineDefs () { if (lines[j].id == ld->args[0]) { - lines[j].alpha = (byte)ld->args[1]; + lines[j].alpha = (BYTE)alpha; if (lines[j].args[2] == 1) { sides[lines[j].sidenum[0]].Flags |= WALLF_ADDTRANS; @@ -1930,6 +1937,7 @@ static void P_AllocateSideDefs (int count) for (i = 0; i < count; i++) { sidetemp[i].a.special = sidetemp[i].a.tag = 0; + sidetemp[i].a.alpha = -1; sidetemp[i].a.map = NO_SIDE; } if (count < numsides) @@ -2075,6 +2083,28 @@ static void P_LoopSidedefs () sidetemp = NULL; } +int P_DetermineTranslucency (int lumpnum) +{ + FWadLump tranmap = Wads.OpenLumpNum (lumpnum); + BYTE index; + PalEntry newcolor; + + tranmap.Seek (GPalette.BlackIndex * 256 + GPalette.WhiteIndex, SEEK_SET); + tranmap.Read (&index, 1); + + newcolor = GPalette.BaseColors[GPalette.Remap[index]]; + + if (developer) + { + char lumpname[9]; + lumpname[8] = 0; + Wads.GetLumpName (lumpname, lumpnum); + Printf ("%s appears to be translucency %d (%d%%)\n", lumpname, newcolor.r, + newcolor.r*100/255); + } + return newcolor.r; +} + // killough 4/4/98: delay using texture names until // after linedefs are loaded, to allow overloading. // killough 5/3/98: reformatted, cleaned up @@ -2171,8 +2201,37 @@ void P_LoadSideDefs2 (MapData * map) } break; -/* - case TranslucentLine: // killough 4/11/98: apply translucency to 2s normal texture + case TranslucentLine: // killough 4/11/98: apply translucency to 2s normal texture + if (!map->HasBehavior) + { + int lumpnum; + + if (strnicmp ("TRANMAP", msd->midtexture, 8) == 0) + { + // The translator set the alpha argument already; no reason to do it again. + sd->midtexture = 0; + } + else if ((lumpnum = Wads.CheckNumForName (msd->midtexture)) > 0 && + Wads.LumpLength (lumpnum) == 65536) + { + sidetemp[i].a.alpha = P_DetermineTranslucency (lumpnum); + sd->midtexture = 0; + } + else + { + strncpy (name, msd->midtexture, 8); + sd->midtexture = TexMan.GetTexture (name, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable); + } + + strncpy (name, msd->toptexture, 8); + sd->toptexture = TexMan.GetTexture (name, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable); + + strncpy (name, msd->bottomtexture, 8); + sd->bottomtexture = TexMan.GetTexture (name, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable); + break; + } + // Fallthrough for Hexen maps is intentional +#if 0 sd->midtexture = strncasecmp("TRANMAP", msd->midtexture, 8) ? (sd->special = W_CheckNumForName(msd->midtexture)) < 0 || W_LumpLength(sd->special) != 65536 ? @@ -2180,8 +2239,8 @@ void P_LoadSideDefs2 (MapData * map) (sd->special++, 0) : (sd->special=0); sd->toptexture = R_TextureNumForName(msd->toptexture); sd->bottomtexture = R_TextureNumForName(msd->bottomtexture); - break; -*/ +#endif + default: // normal cases strncpy (name, msd->midtexture, 8); sd->midtexture = TexMan.GetTexture (name, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable); diff --git a/src/v_palette.cpp b/src/v_palette.cpp index 377f7659c..e1a7aec3b 100644 --- a/src/v_palette.cpp +++ b/src/v_palette.cpp @@ -148,6 +148,12 @@ void FPalette::SetPalette (const BYTE *colors) BaseColors[i] = PalEntry (colors[0], colors[1], colors[2]); Remap[i] = i; } + + // Find white and black from the original palette so that they can be + // used to make an educated guess of the translucency % for a BOOM + // translucency map. + WhiteIndex = BestColor ((DWORD *)BaseColors, 255, 255, 255); + BlackIndex = BestColor ((DWORD *)BaseColors, 0, 0, 0); } // In ZDoom's new texture system, color 0 is used as the transparent color. diff --git a/src/v_palette.h b/src/v_palette.h index 78965af25..658ad70a4 100644 --- a/src/v_palette.h +++ b/src/v_palette.h @@ -54,10 +54,12 @@ struct FPalette void MakeGoodRemap (); - //PalEntry Colors[256]; // gamma corrected palette PalEntry BaseColors[256]; // non-gamma corrected palette BYTE Remap[256]; // remap original palette indices to in-game indices + BYTE WhiteIndex; // white in original palette index + BYTE BlackIndex; // black in original palette index + // Given an array of colors, fills in remap with values to remap the // passed array of colors to this palette. void MakeRemap (const DWORD *colors, BYTE *remap, const BYTE *useful, int numcolors) const; diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index c448e358f..fb0125f96 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -616,6 +616,7 @@ void I_PrintStr (const char *cp, bool lineBreak) } EXTERN_CVAR (Bool, queryiwad); +CVAR (String, queryiwad_key, "shift", CVAR_GLOBALCONFIG|CVAR_ARCHIVE); static WadStuff *WadList; static int NumWads; static int DefaultWad; @@ -698,7 +699,21 @@ BOOL CALLBACK IWADBoxCallback (HWND hDlg, UINT message, WPARAM wParam, LPARAM lP int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad) { - if (showwin || GetAsyncKeyState(VK_SHIFT)) + int vkey; + + if (stricmp (queryiwad_key, "shift") == 0) + { + vkey = VK_SHIFT; + } + else if (stricmp (queryiwad_key, "control") == 0 || stricmp (queryiwad_key, "ctrl") == 0) + { + vkey = VK_CONTROL; + } + else + { + vkey = 0; + } + if (showwin || (vkey != 0 && GetAsyncKeyState(vkey))) { WadList = wads; NumWads = numwads;