⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r_things.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 5 页
字号:
// Emacs style mode select   -*- C++ -*-//-----------------------------------------------------------------------------//// $Id: r_things.c,v 1.34 2001/05/07 20:27:16 stroggonmeth Exp $//// Copyright (C) 1993-1996 by id Software, Inc.// Portions Copyright (C) 1998-2000 by DooM Legacy Team.//// This program is free software; you can redistribute it and/or// modify it under the terms of the GNU General Public License// as published by the Free Software Foundation; either version 2// of the License, or (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.////// $Log: r_things.c,v $// Revision 1.34  2001/05/07 20:27:16  stroggonmeth// no message//// Revision 1.33  2001/04/27 13:32:14  bpereira// no message//// Revision 1.32  2001/04/17 21:12:08  stroggonmeth// Little commit. Re-enables colormaps for trans columns in C and fixes some sprite bugs.//// Revision 1.31  2001/03/30 17:12:51  bpereira// no message//// Revision 1.30  2001/03/21 18:24:56  stroggonmeth// Misc changes and fixes. Code cleanup//// Revision 1.29  2001/03/13 22:14:20  stroggonmeth// Long time no commit. 3D floors, FraggleScript, portals, ect.//// Revision 1.28  2001/02/24 13:35:21  bpereira// no message//// Revision 1.27  2001/01/25 22:15:44  bpereira// added heretic support//// Revision 1.26  2000/11/21 21:13:18  stroggonmeth// Optimised 3D floors and fixed crashing bug in high resolutions.//// Revision 1.25  2000/11/12 14:15:46  hurdler// Removed unecessary code//// Revision 1.24  2000/11/09 17:56:20  stroggonmeth// Hopefully fixed a few bugs and did a few optimizations.//// Revision 1.23  2000/11/03 02:37:36  stroggonmeth// Fix a few warnings when compiling.//// Revision 1.22  2000/11/02 17:50:10  stroggonmeth// Big 3Dfloors & FraggleScript commit!!//// Revision 1.21  2000/10/04 16:19:24  hurdler// Change all those "3dfx names" to more appropriate names//// Revision 1.20  2000/10/02 18:25:45  bpereira// no message//// Revision 1.19  2000/10/01 10:18:19  bpereira// no message//// Revision 1.18  2000/09/30 16:33:08  metzgermeister// fixed compilation//// Revision 1.17  2000/09/28 20:57:18  bpereira// no message//// Revision 1.16  2000/09/21 16:45:08  bpereira// no message//// Revision 1.15  2000/08/31 14:30:56  bpereira// no message//// Revision 1.14  2000/08/11 21:37:17  hurdler// fix win32 compilation problem//// Revision 1.13  2000/08/11 19:10:13  metzgermeister// *** empty log message ***//// Revision 1.12  2000/04/30 10:30:10  bpereira// no message//// Revision 1.11  2000/04/24 20:24:38  bpereira// no message//// Revision 1.10  2000/04/20 21:47:24  stroggonmeth// no message//// Revision 1.9  2000/04/18 17:39:40  stroggonmeth// Bug fixes and performance tuning.//// Revision 1.8  2000/04/11 19:07:25  stroggonmeth// Finished my logs, fixed a crashing bug.//// Revision 1.7  2000/04/09 02:30:57  stroggonmeth// Fixed missing sprite def//// Revision 1.6  2000/04/08 17:29:25  stroggonmeth// no message//// Revision 1.5  2000/04/06 21:06:20  stroggonmeth// Optimized extra_colormap code...// Added #ifdefs for older water code.//// Revision 1.4  2000/04/04 19:28:43  stroggonmeth// Global colormaps working. Added a new linedef type 272.//// Revision 1.3  2000/04/04 00:32:48  stroggonmeth// Initial Boom compatability plus few misc changes all around.//// Revision 1.2  2000/02/27 00:42:11  hurdler// fix CR+LF problem//// Revision 1.1.1.1  2000/02/22 20:32:32  hurdler// Initial import into CVS (v1.29 pr3)////// DESCRIPTION://      Refresh of things, i.e. objects represented by sprites.////-----------------------------------------------------------------------------#include "doomdef.h"#include "console.h"#include "g_game.h"#include "r_local.h"#include "sounds.h"             //skin sounds#include "st_stuff.h"#include "w_wad.h"#include "z_zone.h"#include "i_video.h"            //rendermode#ifdef LINUXint strupr(char *n); // from dosstr.cint strlwr(char *n); // from dosstr.c#endifstatic void R_InitSkins (void);#define MINZ                  (FRACUNIT*4)#define BASEYCENTER           (BASEVIDHEIGHT/2)// put this in transmap of visprite to draw a shade#define VIS_SMOKESHADE        ((void*)-1)       typedef struct{    int         x1;    int         x2;    int         column;    int         topclip;    int         bottomclip;} maskdraw_t;// SoM: A drawnode is something that points to a 3D floor, 3D side or masked// middle texture. This is used for sorting with sprites.typedef struct drawnode_s{  visplane_t*   plane;  drawseg_t*    seg;  drawseg_t*    thickseg;  ffloor_t*     ffloor;  vissprite_t*  sprite;  struct drawnode_s* next;  struct drawnode_s* prev;} drawnode_t;typedef struct visgroup_s{  int          ds_start, ds_end, vs_start, vs_end;  drawnode_t   nodehead;  lvlportal_t* lvl;  struct visgroup_s* next;  struct visgroup_s* prev;} visgroup_t;// SoM: Portals require that masked items be set in groups (one group for// each portal and a group for the main level architecture). ds_* and vs_*// mark the beginning and end of the drawsegs and vissprites for the group// currently being processed.drawseg_t* ds_start;drawseg_t* ds_end;vissprite_t* vs_start;vissprite_t* vs_end;short      *portalcliptop = NULL;short      *portalclipbot = NULL;//// Sprite rotation 0 is facing the viewer,//  rotation 1 is one angle turn CLOCKWISE around the axis.// This is not the same as the angle,//  which increases counter clockwise (protractor).// There was a lot of stuff grabbed wrong, so I changed it...//fixed_t         pspritescale;fixed_t         pspriteyscale;  //added:02-02-98:aspect ratio for pspritesfixed_t         pspriteiscale;lighttable_t**  spritelights;// constant arrays//  used for psprite clipping and initializing clippingshort           negonearray[MAXVIDWIDTH];short           screenheightarray[MAXVIDWIDTH];//// INITIALIZATION FUNCTIONS//// variables used to look up//  and range check thing_t sprites patchesspritedef_t*    sprites;int             numsprites;spriteframe_t   sprtemp[29];int             maxframe;char*           spritename;// ==========================================================================////  New sprite loading routines for Legacy : support sprites in pwad,//  dehacked sprite renaming, replacing not all frames of an existing//  sprite, add sprites at run-time, add wads at run-time.//// ==========================================================================//////void R_InstallSpriteLump ( int           lumppat,     // graphics patch                           int           lumpid,      // identifier                           unsigned      frame,                           unsigned      rotation,                           boolean       flipped ){    int         r;    if (frame >= 29 || rotation > 8)        I_Error("R_InstallSpriteLump: "                "Bad frame characters in lump %i", lumpid);    if ((int)frame > maxframe)        maxframe = frame;    if (rotation == 0)    {        // the lump should be used for all rotations        if (sprtemp[frame].rotate == 0 && devparm)            CONS_Printf ("R_InitSprites: Sprite %s frame %c has "                        "multiple rot=0 lump\n", spritename, 'A'+frame);        if (sprtemp[frame].rotate == 1 && devparm)            CONS_Printf ("R_InitSprites: Sprite %s frame %c has rotations "                        "and a rot=0 lump\n", spritename, 'A'+frame);        sprtemp[frame].rotate = 0;        for (r=0 ; r<8 ; r++)        {            sprtemp[frame].lumppat[r] = lumppat;            sprtemp[frame].lumpid[r]  = lumpid;            sprtemp[frame].flip[r] = (byte)flipped;        }        return;    }    // the lump is only used for one rotation    if (sprtemp[frame].rotate == 0 && devparm)        CONS_Printf ("R_InitSprites: Sprite %s frame %c has rotations "                     "and a rot=0 lump\n", spritename, 'A'+frame);    sprtemp[frame].rotate = 1;    // make 0 based    rotation--;    if (sprtemp[frame].lumpid[rotation] != -1 && devparm)        CONS_Printf ("R_InitSprites: Sprite %s : %c : %c "                     "has two lumps mapped to it\n",                     spritename, 'A'+frame, '1'+rotation);    // lumppat & lumpid are the same for original Doom, but different    // when using sprites in pwad : the lumppat points the new graphics    sprtemp[frame].lumppat[rotation] = lumppat;    sprtemp[frame].lumpid[rotation] = lumpid;    sprtemp[frame].flip[rotation] = (byte)flipped;}// Install a single sprite, given its identifying name (4 chars)//// (originally part of R_AddSpriteDefs)//// Pass: name of sprite : 4 chars//       spritedef_t//       wadnum         : wad number, indexes wadfiles[], where patches//                        for frames are found//       startlump      : first lump to search for sprite frames//       endlump        : AFTER the last lump to search//// Returns true if the sprite was succesfully added//boolean R_AddSingleSpriteDef (char* sprname, spritedef_t* spritedef, int wadnum, int startlump, int endlump){    int         l;    int         intname;    int         frame;    int         rotation;    lumpinfo_t* lumpinfo;    patch_t     patch;    intname = *(int *)sprname;    memset (sprtemp,-1, sizeof(sprtemp));    maxframe = -1;    // are we 'patching' a sprite already loaded ?    // if so, it might patch only certain frames, not all    if (spritedef->numframes) // (then spriteframes is not null)    {        // copy the already defined sprite frames        memcpy (sprtemp, spritedef->spriteframes,                spritedef->numframes * sizeof(spriteframe_t));        maxframe = spritedef->numframes - 1;    }    // scan the lumps,    //  filling in the frames for whatever is found    lumpinfo = wadfiles[wadnum]->lumpinfo;    for (l=startlump ; l<endlump ; l++)    {        if (*(int *)lumpinfo[l].name == intname)        {            frame = lumpinfo[l].name[4] - 'A';            rotation = lumpinfo[l].name[5] - '0';            // skip NULL sprites from very old dmadds pwads            if (W_LumpLength( (wadnum<<16)+l )<=8)                continue;            // store sprite info in lookup tables            //FIXME:numspritelumps do not duplicate sprite replacements            W_ReadLumpHeader ((wadnum<<16)+l, &patch, sizeof(patch_t));            spritewidth[numspritelumps] = SHORT(patch.width)<<FRACBITS;            spriteoffset[numspritelumps] = SHORT(patch.leftoffset)<<FRACBITS;            spritetopoffset[numspritelumps] = SHORT(patch.topoffset)<<FRACBITS;            spriteheight[numspritelumps] = SHORT(patch.height)<<FRACBITS;#ifdef HWRENDER            //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer            if( rendermode != render_soft && SHORT(patch.topoffset)>0 // not for psprite                && SHORT(patch.topoffset)<SHORT(patch.height))                // perfect is patch.height but sometime it is too high                spritetopoffset[numspritelumps] = min(SHORT(patch.topoffset+4),SHORT(patch.height))<<FRACBITS;            #endif            //----------------------------------------------------            R_InstallSpriteLump ((wadnum<<16)+l, numspritelumps, frame, rotation, false);            if (lumpinfo[l].name[6])            {                frame = lumpinfo[l].name[6] - 'A';                rotation = lumpinfo[l].name[7] - '0';                R_InstallSpriteLump ((wadnum<<16)+l, numspritelumps, frame, rotation, true);            }            if (++numspritelumps>=MAXSPRITELUMPS)                I_Error("R_AddSingleSpriteDef: too much sprite replacements (numspritelumps)\n");        }    }    //    // if no frames found for this sprite    //    if (maxframe == -1)    {        // the first time (which is for the original wad),        // all sprites should have their initial frames        // and then, patch wads can replace it        // we will skip non-replaced sprite frames, only if        // they have already have been initially defined (original wad)        //check only after all initial pwads added        //if (spritedef->numframes == 0)        //    I_Error ("R_AddSpriteDefs: no initial frames found for sprite %s\n",        //             namelist[i]);        // sprite already has frames, and is not replaced by this wad        return false;    }    maxframe++;    //    //  some checks to help development    //    for (frame = 0 ; frame < maxframe ; frame++)    {        switch ((int)sprtemp[frame].rotate)        {          case -1:            // no rotations were found for that frame at all            I_Error ("R_InitSprites: No patches found "                     "for %s frame %c", sprname, frame+'A');            break;          case 0:            // only the first rotation is needed            break;          case 1:            // must have all 8 frames            for (rotation=0 ; rotation<8 ; rotation++)                // we test the patch lump, or the id lump whatever                // if it was not loaded the two are -1                if (sprtemp[frame].lumppat[rotation] == -1)                    I_Error ("R_InitSprites: Sprite %s frame %c "                             "is missing rotations",                             sprname, frame+'A');            break;        }    }    // allocate space for the frames present and copy sprtemp to it    if (spritedef->numframes &&             // has been allocated        spritedef->numframes < maxframe)   // more frames are defined ?    {        Z_Free (spritedef->spriteframes);        spritedef->spriteframes = NULL;    }    // allocate this sprite's frames

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -