]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sbar.c
added support for GL_ARB_texture_env_combine, currently only used on wall rendering...
[xonotic/darkplaces.git] / sbar.c
diff --git a/sbar.c b/sbar.c
index 2d69abe346c0388766ea0d8d7e4750e2d4c17e29..73e51ca788f97bc38aabc63d90dff25820c0c88e 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -75,7 +75,6 @@ void Sbar_ShowScores (void)
        if (sb_showscores)
                return;
        sb_showscores = true;
-//     sb_updates = 0;
 }
 
 /*
@@ -88,19 +87,8 @@ Tab key up
 void Sbar_DontShowScores (void)
 {
        sb_showscores = false;
-//     sb_updates = 0;
 }
 
-/*
-===============
-Sbar_Changed
-===============
-*/
-//void Sbar_Changed (void)
-//{
-//     sb_updates = 0; // update next frame
-//}
-
 /*
 ===============
 Sbar_Init
@@ -272,19 +260,6 @@ void Sbar_DrawAlphaPic (int x, int y, qpic_t *pic, float alpha)
                Draw_AlphaPic (x + ((vid.width - 320)>>1), y + (vid.height-SBAR_HEIGHT), pic, alpha);
 }
 
-/*
-=============
-Sbar_DrawTransPic
-=============
-*/
-void Sbar_DrawTransPic (int x, int y, qpic_t *pic)
-{
-       if (cl.gametype == GAME_DEATHMATCH)
-               Draw_TransPic (x /*+ ((vid.width - 320)>>1)*/, y + (vid.height-SBAR_HEIGHT), pic);
-       else
-               Draw_TransPic (x + ((vid.width - 320)>>1), y + (vid.height-SBAR_HEIGHT), pic);
-}
-
 /*
 ================
 Sbar_DrawCharacter
@@ -374,7 +349,7 @@ void Sbar_DrawNum (int x, int y, int num, int digits, int color)
                else
                        frame = *ptr -'0';
 
-               Sbar_DrawTransPic (x,y,sb_nums[color][frame]);
+               Sbar_DrawPic (x,y,sb_nums[color][frame]);
                x += 24;
                ptr++;
        }
@@ -420,11 +395,6 @@ void Sbar_SortFrags (void)
                        }
 }
 
-int    Sbar_ColorForMap (int m)
-{
-       return m < 128 ? m + 8 : m + 8;
-}
-
 /*
 ===============
 Sbar_UpdateScoreboard
@@ -449,8 +419,8 @@ void Sbar_UpdateScoreboard (void)
 
                top = s->colors & 0xf0;
                bottom = (s->colors & 15) <<4;
-               scoreboardtop[i] = Sbar_ColorForMap (top);
-               scoreboardbottom[i] = Sbar_ColorForMap (bottom);
+               scoreboardtop[i] = top + 8;
+               scoreboardbottom[i] = bottom + 8;
        }
 }
 
@@ -496,51 +466,6 @@ void Sbar_DrawScoreboard (void)
        Sbar_SoloScoreboard ();
        if (cl.gametype == GAME_DEATHMATCH)
                Sbar_DeathmatchOverlay ();
-#if 0
-       int             i, j, c;
-       int             x, y;
-       int             l;
-       int             top, bottom;
-       scoreboard_t    *s;
-
-       if (cl.gametype != GAME_DEATHMATCH)
-       {
-               Sbar_SoloScoreboard ();
-               return;
-       }
-
-       Sbar_UpdateScoreboard ();
-
-       l = scoreboardlines <= 6 ? scoreboardlines : 6;
-
-       for (i=0 ; i<l ; i++)
-       {
-               x = 20*(i&1);
-               y = i/2 * 8;
-
-               s = &cl.scores[fragsort[i]];
-               if (!s->name[0])
-                       continue;
-
-       // draw background
-               top = s->colors & 0xf0;
-               bottom = (s->colors & 15)<<4;
-               top = Sbar_ColorForMap (top);
-               bottom = Sbar_ColorForMap (bottom);
-
-               Draw_Fill ( x*8+10 + ((vid.width - 320)>>1), y + vid.height - SBAR_HEIGHT, 28, 4, top);
-               Draw_Fill ( x*8+10 + ((vid.width - 320)>>1), y+4 + vid.height - SBAR_HEIGHT, 28, 4, bottom);
-
-       // draw text
-               for (j=0 ; j<20 ; j++)
-               {
-                       c = scoreboardtext[i][j];
-                       if (c == 0 || c == ' ')
-                               continue;
-                       Sbar_DrawCharacter ( (x+j)*8, y, c);
-               }
-       }
-#endif
 }
 
 //=============================================================================
@@ -565,11 +490,9 @@ void Sbar_DrawInventory (void)
                        Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], 0.4);
        }
        else
-       {
                Sbar_DrawAlphaPic (0, -24, sb_ibar, 0.4);
-       }
 
-// weapons
+       // weapons
        for (i=0 ; i<7 ; i++)
        {
                if (cl.items & (IT_SHOTGUN<<i) )
@@ -586,86 +509,69 @@ void Sbar_DrawInventory (void)
                        else
                                flashon = (flashon%5) + 2;
 
-         Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], 0.4);
-
-//                     if (flashon > 1)
-//                             sb_updates = 0;         // force update to remove flash
+                       Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], 0.4);
                }
        }
 
-// MED 01/04/97
-// hipnotic weapons
-    if (hipnotic)
-    {
-      int grenadeflashing=0;
-      for (i=0 ; i<4 ; i++)
-      {
-         if (cl.items & (1<<hipweapons[i]) )
-         {
-            time = cl.item_gettime[hipweapons[i]];
-            flashon = (int)((cl.time - time)*10);
-            if (flashon >= 10)
-            {
-               if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i])  )
-                  flashon = 1;
-               else
-                  flashon = 0;
-            }
-            else
-               flashon = (flashon%5) + 2;
-
-            // check grenade launcher
-            if (i==2)
-            {
-               if (cl.items & HIT_PROXIMITY_GUN)
-               {
-                  if (flashon)
-                  {
-                     grenadeflashing = 1;
-                     Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
-                  }
-               }
-            }
-            else if (i==3)
-            {
-               if (cl.items & (IT_SHOTGUN<<4))
-               {
-                  if (flashon && !grenadeflashing)
-                  {
-                     Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
-                  }
-                  else if (!grenadeflashing)
-                  {
-                     Sbar_DrawPic (96, -16, hsb_weapons[0][3]);
-                  }
-               }
-               else
-                  Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
-            }
-            else
-               Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
-//            if (flashon > 1)
-//               sb_updates = 0;      // force update to remove flash
-         }
-      }
-    }
-
-       if (rogue)
+       // MED 01/04/97
+       // hipnotic weapons
+       if (hipnotic)
        {
-    // check for powered up weapon.
-               if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
+               int grenadeflashing=0;
+               for (i=0 ; i<4 ; i++)
                {
-                       for (i=0;i<5;i++)
+                       if (cl.items & (1<<hipweapons[i]) )
                        {
-                               if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
+                               time = cl.item_gettime[hipweapons[i]];
+                               flashon = (int)((cl.time - time)*10);
+                               if (flashon >= 10)
                                {
-                                       Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
+                                       if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i])  )
+                                               flashon = 1;
+                                       else
+                                               flashon = 0;
                                }
+                               else
+                                       flashon = (flashon%5) + 2;
+
+                               // check grenade launcher
+                               if (i==2)
+                               {
+                                       if (cl.items & HIT_PROXIMITY_GUN)
+                                       {
+                                               if (flashon)
+                                               {
+                                                       grenadeflashing = 1;
+                                                       Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
+                                               }
+                                       }
+                               }
+                               else if (i==3)
+                               {
+                                       if (cl.items & (IT_SHOTGUN<<4))
+                                       {
+                                               if (!grenadeflashing)
+                                                       Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
+                                       }
+                                       else
+                                               Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
+                               }
+                               else
+                                       Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
                        }
                }
        }
 
-// ammo counts
+       if (rogue)
+       {
+               // check for powered up weapon.
+               if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
+                       for (i=0;i<5;i++)
+                               if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
+                                       Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
+       }
+
+       // ammo counts
        for (i=0 ; i<4 ; i++)
        {
                sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
@@ -678,86 +584,53 @@ void Sbar_DrawInventory (void)
        }
 
        flashon = 0;
-   // items
-   for (i=0 ; i<6 ; i++)
-      if (cl.items & (1<<(17+i)))
-      {
-         time = cl.item_gettime[17+i];
-         if (time && time > cl.time - 2 && flashon )
-         {  // flash frame
-//            sb_updates = 0;
-         }
-         else
-         {
-         //MED 01/04/97 changed keys
-            if (!hipnotic || (i>1))
-            {
-               Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
-            }
-         }
-//         if (time && time > cl.time - 2)
-//            sb_updates = 0;
-      }
-   //MED 01/04/97 added hipnotic items
-   // hipnotic items
-   if (hipnotic)
-   {
-      for (i=0 ; i<2 ; i++)
-         if (cl.items & (1<<(24+i)))
-         {
-            time = cl.item_gettime[24+i];
-            if (time && time > cl.time - 2 && flashon )
-            {  // flash frame
-//               sb_updates = 0;
-            }
-            else
-            {
-               Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
-            }
-//            if (time && time > cl.time - 2)
-//               sb_updates = 0;
-         }
-   }
+       // items
+       for (i=0 ; i<6 ; i++)
+               if (cl.items & (1<<(17+i)))
+               {
+                       time = cl.item_gettime[17+i];
+                       if (time && time > cl.time - 2 && flashon )
+                       {  // flash frame
+                       }
+                       else
+                       //MED 01/04/97 changed keys
+                               if (!hipnotic || (i>1))
+                                       Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
+               }
+       //MED 01/04/97 added hipnotic items
+       // hipnotic items
+       if (hipnotic)
+       {
+               for (i=0 ; i<2 ; i++)
+                       if (cl.items & (1<<(24+i)))
+                       {
+                               time = cl.item_gettime[24+i];
+                               if (!time || time <= cl.time - 2 || !flashon)
+                                       Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
+                       }
+       }
 
        if (rogue)
        {
-       // new rogue items
+               // new rogue items
                for (i=0 ; i<2 ; i++)
-               {
                        if (cl.items & (1<<(29+i)))
                        {
                                time = cl.item_gettime[29+i];
-
-                               if (time &&     time > cl.time - 2 && flashon )
-                               {       // flash frame
-//                                     sb_updates = 0;
-                               }
-                               else
-                               {
+                               if (!time || time <= cl.time - 2 || !flashon)
                                        Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
-                               }
-
-//                             if (time &&     time > cl.time - 2)
-//                                     sb_updates = 0;
                        }
-               }
        }
        else
        {
-       // sigils
+               // sigils
                for (i=0 ; i<4 ; i++)
                {
                        if (cl.items & (1<<(28+i)))
                        {
                                time = cl.item_gettime[28+i];
-                               if (time &&     time > cl.time - 2 && flashon )
-                               {       // flash frame
-//                                     sb_updates = 0;
-                               }
-                               else
+                               if (!time || time <= cl.time - 2 || !flashon)
                                        Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
-//                             if (time &&     time > cl.time - 2)
-//                                     sb_updates = 0;
                        }
                }
        }
@@ -799,10 +672,8 @@ void Sbar_DrawFrags (void)
                        continue;
 
        // draw background
-               top = s->colors & 0xf0;
-               bottom = (s->colors & 15)<<4;
-               top = Sbar_ColorForMap (top);
-               bottom = Sbar_ColorForMap (bottom);
+               top = (s->colors & 0xf0) + 8;
+               bottom = ((s->colors & 15)<<4) + 8;
 
                Draw_Fill (xofs + x*8 + 10, y, 28, 4, top);
                Draw_Fill (xofs + x*8 + 10, y+4, 28, 3, bottom);
@@ -850,10 +721,8 @@ void Sbar_DrawFace (void)
                
                s = &cl.scores[cl.viewentity - 1];
                // draw background
-               top = s->colors & 0xf0;
-               bottom = (s->colors & 15)<<4;
-               top = Sbar_ColorForMap (top);
-               bottom = Sbar_ColorForMap (bottom);
+               top = (s->colors & 0xf0) + 8;
+               bottom = ((s->colors & 15)<<4) + 8;
 
                if (cl.gametype == GAME_DEATHMATCH)
                        xofs = 113;
@@ -914,6 +783,9 @@ void Sbar_DrawFace (void)
                f = 4;
        else
                f = cl.stats[STAT_HEALTH] / 20;
+       // LordHavoc: I don't even know how the game didn't crash without this
+       if (f < 0)
+               f = 0;
 
        if (cl.time <= cl.faceanimtime)
        {
@@ -935,8 +807,6 @@ void Sbar_Draw (void)
        if (scr_con_current == vid.height)
                return;         // console is full screen
 
-       scr_copyeverything = 1;
-
 //     sb_updates++;
 
        if (sb_lines > 24)
@@ -1072,7 +942,7 @@ void Sbar_IntermissionNumber (int x, int y, int num, int digits, int color)
                else
                        frame = *ptr -'0';
 
-               Draw_TransPic (x,y,sb_nums[color][frame]);
+               Draw_Pic (x,y,sb_nums[color][frame]);
                x += 24;
                ptr++;
        }
@@ -1091,9 +961,6 @@ void Sbar_DeathmatchOverlay (void)
        char                    num[128];
        scoreboard_t    *s;
 
-       scr_copyeverything = 1;
-       scr_fullupdate = 0;
-
        pic = Draw_CachePic ("gfx/ranking.lmp");
        M_DrawPic ((320-pic->width)/2, 8, pic);
 
@@ -1113,10 +980,8 @@ void Sbar_DeathmatchOverlay (void)
                        continue;
 
        // draw background
-               top = s->colors & 0xf0;
-               bottom = (s->colors & 15)<<4;
-               top = Sbar_ColorForMap (top);
-               bottom = Sbar_ColorForMap (bottom);
+               top = (s->colors & 0xf0) + 8;
+               bottom = ((s->colors & 15)<<4) + 8;
 
                Draw_Fill ( x, y+1, 88, 3, top);
                Draw_Fill ( x, y+4, 88, 3, bottom);
@@ -1154,9 +1019,6 @@ void Sbar_MiniDeathmatchOverlay (void)
        if (vid.width < 512 || !sb_lines)
                return;
 
-       scr_copyeverything = 1;
-       scr_fullupdate = 0;
-
 // scores
        Sbar_SortFrags ();
 
@@ -1191,8 +1053,8 @@ void Sbar_MiniDeathmatchOverlay (void)
                        continue;
 
        // draw background
-               top = Sbar_ColorForMap (s->colors & 0xf0);
-               bottom = Sbar_ColorForMap ((s->colors & 15)<<4);
+               top = (s->colors & 0xf0) + 8;
+               bottom = ((s->colors & 15)<<4) + 8;
 
                Draw_Fill ( x, y+1, 72, 3, top);
                Draw_Fill ( x, y+4, 72, 3, bottom);
@@ -1221,9 +1083,6 @@ void Sbar_IntermissionOverlay (void)
        int             dig;
        int             num;
 
-       scr_copyeverything = 1;
-       scr_fullupdate = 0;
-
        if (cl.gametype == GAME_DEATHMATCH)
        {
                Sbar_DeathmatchOverlay ();
@@ -1234,22 +1093,22 @@ void Sbar_IntermissionOverlay (void)
        Draw_Pic (64, 24, pic);
 
        pic = Draw_CachePic ("gfx/inter.lmp");
-       Draw_TransPic (0, 56, pic);
+       Draw_Pic (0, 56, pic);
 
 // time
        dig = cl.completed_time/60;
        Sbar_IntermissionNumber (160, 64, dig, 3, 0);
        num = cl.completed_time - dig*60;
-       Draw_TransPic (234,64,sb_colon);
-       Draw_TransPic (246,64,sb_nums[0][num/10]);
-       Draw_TransPic (266,64,sb_nums[0][num%10]);
+       Draw_Pic (234,64,sb_colon);
+       Draw_Pic (246,64,sb_nums[0][num/10]);
+       Draw_Pic (266,64,sb_nums[0][num%10]);
 
        Sbar_IntermissionNumber (160, 104, cl.stats[STAT_SECRETS], 3, 0);
-       Draw_TransPic (232,104,sb_slash);
+       Draw_Pic (232,104,sb_slash);
        Sbar_IntermissionNumber (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0);
 
        Sbar_IntermissionNumber (160, 144, cl.stats[STAT_MONSTERS], 3, 0);
-       Draw_TransPic (232,144,sb_slash);
+       Draw_Pic (232,144,sb_slash);
        Sbar_IntermissionNumber (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0);
 
 }
@@ -1265,8 +1124,6 @@ void Sbar_FinaleOverlay (void)
 {
        qpic_t  *pic;
 
-       scr_copyeverything = 1;
-
        pic = Draw_CachePic ("gfx/finale.lmp");
-       Draw_TransPic ( (vid.width-pic->width)/2, 16, pic);
+       Draw_Pic ( (vid.width-pic->width)/2, 16, pic);
 }