[prboom+] 02/03: Imported Upstream version 2.5.1.4~svn4449+dfsg1

Fabian Greffrath fabian at moszumanska.debian.org
Mon Oct 12 11:46:27 UTC 2015


This is an automated email from the git hooks/post-receive script.

fabian pushed a commit to branch master
in repository prboom+.

commit b6f69c5d969cf82005f8a8e3abfdc2f5581bb5d6
Author: Fabian Greffrath <fabian+debian at greffrath.com>
Date:   Mon Oct 12 13:46:00 2015 +0200

    Imported Upstream version 2.5.1.4~svn4449+dfsg1
---
 src/d_main.c  | 15 +++++-----
 src/r_patch.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 80 insertions(+), 29 deletions(-)

diff --git a/src/d_main.c b/src/d_main.c
index 8d3a004..e785d8a 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -704,8 +704,7 @@ void D_AddFile (const char *file, wad_source_t source)
   // No Rest For The Living
   len=strlen(wadfiles[numwadfiles].name);
   if (len>=9 && !strnicmp(wadfiles[numwadfiles].name+len-9,"nerve.wad",9))
-    if (bfgedition)
-      gamemission = pack_nerve;
+    gamemission = pack_nerve;
 
   numwadfiles++;
   // proff: automatically try to add the gwa files
@@ -1733,13 +1732,13 @@ static void D_DoomMainSetup(void)
       {
         ProcessDehFile(NULL, D_dehout(), lump);
       }
-      if (gamemission == pack_nerve)
+    }
+    if (gamemission == pack_nerve)
+    {
+      int lump = (W_CheckNumForName)("NERVEBEX", ns_prboom);
+      if (lump != -1)
       {
-        lump = (W_CheckNumForName)("NERVEBEX", ns_prboom);
-        if (lump != -1)
-        {
-          ProcessDehFile(NULL, D_dehout(), lump);
-        }
+        ProcessDehFile(NULL, D_dehout(), lump);
       }
     }
     if (gamemission == chex)
diff --git a/src/r_patch.c b/src/r_patch.c
index b04992c..3b1dd48 100644
--- a/src/r_patch.c
+++ b/src/r_patch.c
@@ -106,6 +106,9 @@ static rpatch_t *patches = 0;
 
 static rpatch_t *texture_composites = 0;
 
+// indices of two duplicate PLAYPAL entries, second is -1 if none found
+static int playpal_transparent, playpal_duplicate;
+
 //---------------------------------------------------------------------------
 void R_InitPatches(void) {
   if (!patches)
@@ -120,6 +123,43 @@ void R_InitPatches(void) {
     // clear out new patches to signal they're uninitialized
     memset(texture_composites, 0, sizeof(rpatch_t)*numtextures);
   }
+
+  if (!playpal_duplicate)
+  {
+    int lump = W_GetNumForName("PLAYPAL");
+    const byte *playpal = W_CacheLumpNum(lump);
+
+    // find two duplicate palette entries. use one for transparency.
+    // rewrite source pixels in patches to the other on composition.
+
+    int i, j, found = 0;
+
+    for (i = 0; i < 256; i++)
+    {
+      for (j = i+1; j < 256; j++)
+      {
+        if (playpal[3*i+0] == playpal[3*j+0] &&
+            playpal[3*i+1] == playpal[3*j+1] &&
+            playpal[3*i+2] == playpal[3*j+2])
+        {
+          found = 1;
+          break;
+        }
+      }
+      if (found)
+        break;
+    }
+
+    if (found) { // found duplicate
+      playpal_transparent = i;
+      playpal_duplicate   = j;
+    } else { // no duplicate: use 255 for transparency, as done previously
+      playpal_transparent = 255;
+      playpal_duplicate   = -1;
+    }
+
+    W_UnlockLumpNum(lump);
+  }
 }
 
 //---------------------------------------------------------------------------
@@ -255,18 +295,18 @@ static void FillEmptySpace(rpatch_t *patch)
     {
       for (y = 0; y < h; y++)
       {
-        if (*src == 0xff) has_holes = 1;
-
-        if (*src != 0xff) // already a solid pixel, just copy it over
-          *dest = *src;
-        else if (y > 0 && *(src-1) != 0xff) // solid pixel above
-          *dest = *(src - 1);
-        else if (y < h-1 && *(src+1) != 0xff) // solid pixel below
-          *dest = *(src + 1);
-        else if (x > 0 && *prev != 0xff) // solid pixel to left
-          *dest = *prev;
-        else if (x < w-1 && *next != 0xff) // solid pixel to right
-          *dest = *next;
+        if (*src == playpal_transparent) has_holes = 1;
+
+        if (*src != playpal_transparent)
+          *dest = *src; // already a solid pixel, just copy it over
+        else if (y > 0 && *(src-1) != playpal_transparent)
+          *dest = *(src - 1); // solid pixel above
+        else if (y < h-1 && *(src+1) != playpal_transparent)
+          *dest = *(src + 1); // solid pixel below
+        else if (x > 0 && *prev != playpal_transparent)
+          *dest = *prev; // solid pixel to left
+        else if (x < w-1 && *next != playpal_transparent)
+          *dest = *next; // solid pixel to right
         else // transparent pixel with no adjacent solid pixels
           *dest = *src, transparent++; // count unhandled pixels
 
@@ -291,10 +331,10 @@ static void FillEmptySpace(rpatch_t *patch)
 
   for (x = 0, src = orig, dest = src + h-1; x < w; x++, src += h, dest += h)
   {
-    if (*src != 0xff && *dest == 0xff) // bottom transparent, top solid
-      *dest = *src;
-    else if (*src == 0xff && *dest != 0xff) // top transparent, bottom solid
-      *src = *dest;
+    if (*src != playpal_transparent && *dest == playpal_transparent)
+      *dest = *src; // bottom transparent, top solid
+    else if (*src == playpal_transparent && *dest != playpal_transparent)
+      *src = *dest; // top transparent, bottom solid
   }
 
   if (has_holes)
@@ -353,6 +393,15 @@ static dboolean CheckIfPatch(int lump)
 }
 
 //---------------------------------------------------------------------------
+static void StorePixel(rpatch_t *patch, int x, int y, byte color)
+{
+  // write pixel to patch, substituting for playpal_transparent as needed
+  if (color == playpal_transparent && playpal_duplicate >= 0)
+    color = playpal_duplicate;
+  patch->pixels[x * patch->height + y] = color;
+}
+
+//---------------------------------------------------------------------------
 static void createPatch(int id) {
   rpatch_t *patch;
   const int patchNum = id;
@@ -439,7 +488,8 @@ static void createPatch(int id) {
   // sanity check that we've got all the memory allocated we need
   assert((((byte*)patch->posts  + numPostsTotal*sizeof(rpost_t)) - (byte*)patch->data) == dataSize);
 
-  memset(patch->pixels, 0xff, (patch->width*patch->height));
+  if (playpal_transparent != 0)
+    memset(patch->pixels, playpal_transparent, (patch->width*patch->height));
 
   // fill in the pixels, posts, and columns
   numPostsUsedSoFar = 0;
@@ -507,7 +557,7 @@ static void createPatch(int id) {
         // fill in the post's pixels
         oldColumnPixelData = (const byte *)oldColumn + 3;
         for (y=0; y<len; y++) {
-          patch->pixels[x * patch->height + top + y] = oldColumnPixelData[y];
+          StorePixel(patch, x, top + y, oldColumnPixelData[y]);
         }
       }
       oldColumn = (const column_t *)((const byte *)oldColumn + oldColumn->length + 4);
@@ -643,7 +693,9 @@ static void createTextureCompositePatch(int id) {
   // sanity check that we've got all the memory allocated we need
   assert((((byte*)composite_patch->posts + numPostsTotal*sizeof(rpost_t)) - (byte*)composite_patch->data) == dataSize);
 
-  memset(composite_patch->pixels, 0xff, (composite_patch->width*composite_patch->height));
+  if (playpal_transparent != 0)
+    memset(composite_patch->pixels, playpal_transparent,
+           (composite_patch->width*composite_patch->height));
 
   numPostsUsedSoFar = 0;
 
@@ -711,7 +763,7 @@ static void createTextureCompositePatch(int id) {
                 continue;
               if (ty >= composite_patch->height)
                 break;
-              composite_patch->pixels[tx * composite_patch->height + ty] = oldColumnPixelData[y];
+              StorePixel(composite_patch, tx, ty, oldColumnPixelData[y]);
             }
           }
           // do the buggy clipping
@@ -756,7 +808,7 @@ static void createTextureCompositePatch(int id) {
             continue;
           if (ty >= composite_patch->height)
             break;
-          composite_patch->pixels[tx * composite_patch->height + ty] = oldColumnPixelData[y];
+          StorePixel(composite_patch, tx, ty, oldColumnPixelData[y]);
         }
 
         oldColumn = (const column_t *)((const byte *)oldColumn + oldColumn->length + 4);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/prboom+.git



More information about the Pkg-games-commits mailing list