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

📄 r_things.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 5 页
字号:
                if (cliptop[x] == -2)                    cliptop[x] = ds->sprtopclip[x];            }        }    }    //SoM: 3/17/2000: Clip sprites in water.    if (spr->heightsec != -1)  // only things in specially marked sectors    {        fixed_t h,mh;        int phs = viewplayer->mo->subsector->sector->heightsec;        if ((mh = sectors[spr->heightsec].floorheight) > spr->gz &&           (h = centeryfrac - FixedMul(mh-=viewz, spr->scale)) >= 0 &&           (h >>= FRACBITS) < viewheight)        {            if (mh <= 0 || (phs != -1 && viewz > sectors[phs].floorheight))            {                          // clip bottom              for (x=spr->x1 ; x<=spr->x2 ; x++)                if (clipbot[x] == -2 || h < clipbot[x])                  clipbot[x] = h;            }            else                        // clip top            {              for (x=spr->x1 ; x<=spr->x2 ; x++)                if (cliptop[x] == -2 || h > cliptop[x])                  cliptop[x] = h;            }        }        if ((mh = sectors[spr->heightsec].ceilingheight) < spr->gzt &&           (h = centeryfrac - FixedMul(mh-viewz, spr->scale)) >= 0 &&           (h >>= FRACBITS) < viewheight)        {            if (phs != -1 && viewz >= sectors[phs].ceilingheight)            {                         // clip bottom              for (x=spr->x1 ; x<=spr->x2 ; x++)                if (clipbot[x] == -2 || h < clipbot[x])                  clipbot[x] = h;            }            else                       // clip top            {              for (x=spr->x1 ; x<=spr->x2 ; x++)                if (cliptop[x] == -2 || h > cliptop[x])                  cliptop[x] = h;            }        }    }    if(spr->cut & SC_TOP && spr->cut & SC_BOTTOM)    {      fixed_t   h;      for(x = spr->x1; x <= spr->x2; x++)      {        h = spr->szt;        if(cliptop[x] == -2 || h > cliptop[x])          cliptop[x] = h;        h = spr->sz;        if(clipbot[x] == -2 || h < clipbot[x])          clipbot[x] = h;      }    }    else if(spr->cut & SC_TOP)    {      fixed_t   h;      for(x = spr->x1; x <= spr->x2; x++)      {        h = spr->szt;        if(cliptop[x] == -2 || h > cliptop[x])          cliptop[x] = h;      }    }    else if(spr->cut & SC_BOTTOM)    {      fixed_t   h;      for(x = spr->x1; x <= spr->x2; x++)      {        h = spr->sz;        if(clipbot[x] == -2 || h < clipbot[x])          clipbot[x] = h;      }    }    // SoM: STILL NOT FINISHED    if(portalcliptop && portalclipbot)    {      for(x = spr->x1; x <= spr->x2; x++)      {        if(clipbot[x] == -2 || portalclipbot[x] <= clipbot[x])          clipbot[x] = portalclipbot[x] + 1;        if(cliptop[x] == -2 || portalcliptop[x] >= cliptop[x])          cliptop[x] = portalcliptop[x] - 1;      }    }        // all clipping has been performed, so draw the sprite    // check for unclipped columns    for (x = spr->x1 ; x<=spr->x2 ; x++)    {        if (clipbot[x] == -2)            clipbot[x] = viewheight;        if (cliptop[x] == -2)            //Fab:26-04-98: was -1, now clips against console bottom            cliptop[x] = con_clipviewtop;    }    mfloorclip = clipbot;    mceilingclip = cliptop;    R_DrawVisSprite (spr, spr->x1, spr->x2);}//// R_DrawMasked//void R_DrawMasked (void){    drawnode_t*           r2;    drawnode_t*           next;    visgroup_t*           group;    R_CreateDrawNodes();    for(group = grouphead.prev; group != &grouphead; group = group->prev)    {      ds_start = &drawsegs[group->ds_start];      ds_end = &drawsegs[group->ds_end];      if(group->lvl)      {        portalcliptop = group->lvl->topclip;        portalclipbot = group->lvl->botclip;      }      else        portalcliptop = portalclipbot = NULL;      for(r2 = group->nodehead.next; r2 != &group->nodehead; r2 = r2->next)      {        if(r2->plane)        {          next = r2->prev;          R_DrawSinglePlane(r2->plane, true);          R_DoneWithNode(r2);          r2 = next;        }        else if(r2->seg && r2->seg->maskedtexturecol != NULL)        {          next = r2->prev;          R_RenderMaskedSegRange(r2->seg, r2->seg->x1, r2->seg->x2);          r2->seg->maskedtexturecol = NULL;          R_DoneWithNode(r2);          r2 = next;        }        else if(r2->thickseg)        {          next = r2->prev;          R_RenderThickSideRange(r2->thickseg, r2->thickseg->x1, r2->thickseg->x2, r2->ffloor);          R_DoneWithNode(r2);          r2 = next;        }        else if(r2->sprite)        {          next = r2->prev;          R_DrawSprite(r2->sprite);          R_DoneWithNode(r2);          r2 = next;        }      }    }    R_ClearDrawNodes();}// ==========================================================================////                              SKINS CODE//// ==========================================================================int         numskins=0;skin_t      skins[MAXSKINS];// don't work because it must be inistilised before the config load//#define SKINVALUES#ifdef SKINVALUESCV_PossibleValue_t skin_cons_t[MAXSKINS+1];#endifvoid Sk_SetDefaultValue(skin_t *skin){    int   i;    //    // setup the 'marine' as default skin    //    memset (skin, 0, sizeof(skin_t));    strcpy (skin->name, DEFAULTSKIN);    strcpy (skin->faceprefix, "STF");    for (i=0;i<sfx_freeslot0;i++)        if (S_sfx[i].skinsound!=-1)        {            skin->soundsid[S_sfx[i].skinsound] = i;        }    memcpy(&skins[0].spritedef, &sprites[SPR_PLAY], sizeof(spritedef_t));}//// Initialize the basic skins//void R_InitSkins (void){#ifdef SKINVALUES    int i;    for(i=0;i<=MAXSKINS;i++)    {        skin_cons_t[i].value=0;        skin_cons_t[i].strvalue=NULL;    }#endif    // initialize free sfx slots for skin sounds    S_InitRuntimeSounds ();    Sk_SetDefaultValue(&skins[0]);#ifdef SKINVALUES    skin_cons_t[0].strvalue=skins[0].name;#endif    // make the standard Doom2 marine as the default skin    numskins = 1;}// returns true if the skin name is found (loaded from pwad)int R_SkinAvailable (char* name){    int  i;    for (i=0;i<numskins;i++)    {        if (stricmp(skins[i].name,name)==0)            return i;    }    return 0;}// network code calls this when a 'skin change' is receivedvoid SetPlayerSkin (int playernum, char *skinname){    int   i;    for(i=0;i<numskins;i++)    {        if (stricmp(skins[i].name,skinname)==0)        {            // change the face graphics            if (playernum==statusbarplayer &&            // for save time test it there is a real change                strcmp (skins[players[playernum].skin].faceprefix, skins[i].faceprefix) )            {                ST_unloadFaceGraphics ();                ST_loadFaceGraphics (skins[i].faceprefix);            }            players[playernum].skin = i;            if (players[playernum].mo)                players[playernum].mo->skin = &skins[i];            return;        }    }    CONS_Printf("Skin %s not found\n",skinname);    players[playernum].skin = 0;  // not found put the old marine skin    // a copy of the skin value    // so that dead body detached from respawning player keeps the skin    if (players[playernum].mo)        players[playernum].mo->skin = &skins[0];}//// Add skins from a pwad, each skin preceded by 'S_SKIN' marker//// Does the same is in w_wad, but check only for// the first 6 characters (this is so we can have S_SKIN1, S_SKIN2..// for wad editors that don't like multiple resources of the same name)//int W_CheckForSkinMarkerInPwad (int wadid, int startlump){    int         i;    int         v1;    lumpinfo_t* lump_p;    union {                char    s[4];                int             x;    } name4;    strncpy (name4.s, "S_SK", 4);    v1 = name4.x;    // scan forward, start at <startlump>    if (startlump < wadfiles[wadid]->numlumps)    {        lump_p = wadfiles[wadid]->lumpinfo + startlump;        for (i = startlump; i<wadfiles[wadid]->numlumps; i++,lump_p++)        {            if ( *(int *)lump_p->name == v1 &&                 lump_p->name[4] == 'I'     &&                 lump_p->name[5] == 'N')            {                return ((wadid<<16)+i);            }        }    }    return -1; // not found}//// Find skin sprites, sounds & optional status bar face, & add them//void R_AddSkins (int wadnum){    int         lumpnum;    int         lastlump;    lumpinfo_t* lumpinfo;    char*       sprname;    int         intname;    char*       buf;    char*       buf2;    char*       token;    char*       value;    int         i,size;    //    // search for all skin markers in pwad    //    lastlump = 0;    while ( (lumpnum=W_CheckForSkinMarkerInPwad (wadnum, lastlump))!=-1 )    {        if (numskins>MAXSKINS)        {            CONS_Printf ("ignored skin (%d skins maximum)\n",MAXSKINS);            lastlump++;            continue; //faB:so we know how many skins couldn't be added        }        buf  = W_CacheLumpNum (lumpnum, PU_CACHE);        size = W_LumpLength (lumpnum);        // for strtok        buf2 = (char *) malloc (size+1);        if(!buf2)             I_Error("R_AddSkins: No more free memory\n");        memcpy (buf2,buf,size);        buf2[size] = '\0';        // set defaults        Sk_SetDefaultValue(&skins[numskins]);        sprintf (skins[numskins].name,"skin %d",numskins);        // parse        token = strtok (buf2, "\r\n= ");        while (token)        {            if(token[0]=='/' && token[1]=='/') // skip comments            {                token = strtok (NULL, "\r\n"); // skip end of line                goto next_token;               // find the real next token            }            value = strtok (NULL, "\r\n= ");//            CONS_Printf("token = %s, value = %s",token,value);//            CONS_Error("ga");            if (!value)                I_Error ("R_AddSkins: syntax error in S_SKIN lump# %d in WAD %s\n", lumpnum&0xFFFF, wadfiles[wadnum]->filename);            if (!stricmp(token,"name"))            {                // the skin name must uniquely identify a single skin                // I'm lazy so if name is already used I leave the 'skin x'                // default skin name set above                if (!R_SkinAvailable (value))                {                    strncpy (skins[numskins].name, value, SKINNAMESIZE);                    strlwr (skins[numskins].name);                }            }            else            if (!stricmp(token,"face"))            {                strncpy (skins[numskins].faceprefix, value, 3);                strupr (skins[numskins].faceprefix);            }            else            {                int found=false;                // copy name of sounds that are remapped for this skin                for (i=0;i<sfx_freeslot0;i++)                {                    if (!S_sfx[i].name)                      continue;                    if (S_sfx[i].skinsound!=-1 &&                        !stricmp(S_sfx[i].name, token+2) )                    {                        skins[numskins].soundsid[S_sfx[i].skinsound]=                            S_AddSoundFx(value+2,S_sfx[i].singularity);                        found=true;                    }                }                if(!found)                    I_Error("R_AddSkins: Unknow keyword '%s' in S_SKIN lump# %d (WAD %s)\n",token,lumpnum&0xFFFF,wadfiles[wadnum]->filename);            }next_token:            token = strtok (NULL,"\r\n= ");        }        free(buf2);        lumpnum &= 0xFFFF;      // get rid of wad number        // get the base name of this skin's sprite (4 chars)        lumpnum++;        lumpinfo = wadfiles[wadnum]->lumpinfo;        sprname = lumpinfo[lumpnum].name;        intname = *(int *)sprname;        // skip to end of this skin's frames        lastlump = lumpnum;        while (*(int *)lumpinfo[lastlump].name == intname)            lastlump++;        // allocate (or replace) sprite frames, and set spritedef        R_AddSingleSpriteDef (sprname, &skins[numskins].spritedef, wadnum, lumpnum, lastlump);        CONS_Printf ("added skin '%s'\n", skins[numskins].name);#ifdef SKINVALUES        skin_cons_t[numskins].value=numskins;        skin_cons_t[numskins].strvalue=skins[numskins].name;#endif        numskins++;    }    return;}

⌨️ 快捷键说明

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