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

📄 p_setup.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 3 页
字号:
    ms = (mapsector_t *)data;    ss = sectors;    for (i=0 ; i<numsectors ; i++, ss++, ms++)    {        ss->floorheight = SHORT(ms->floorheight)<<FRACBITS;        ss->ceilingheight = SHORT(ms->ceilingheight)<<FRACBITS;        //        //  flats        //        if( strnicmp(ms->floorpic,"FWATER",6)==0 ||             strnicmp(ms->floorpic,"FLTWAWA1",8)==0 ||            strnicmp(ms->floorpic,"FLTFLWW1",8)==0 )            ss->floortype = FLOOR_WATER;        else        if( strnicmp(ms->floorpic,"FLTLAVA1",8)==0 ||            strnicmp(ms->floorpic,"FLATHUH1",8)==0 )            ss->floortype = FLOOR_LAVA;        else        if( strnicmp(ms->floorpic,"FLTSLUD1",8)==0 )            ss->floortype = FLOOR_SLUDGE;        else            ss->floortype = FLOOR_SOLID;        ss->floorpic = P_AddLevelFlat (ms->floorpic,foundflats);        ss->ceilingpic = P_AddLevelFlat (ms->ceilingpic,foundflats);        ss->lightlevel = SHORT(ms->lightlevel);        ss->special = SHORT(ms->special);        ss->tag = SHORT(ms->tag);        //added:31-03-98: quick hack to test water with DCK/*        if (ss->tag < 0)            CONS_Printf("Level uses dck-water-hack\n");*/        ss->thinglist = NULL;        ss->touching_thinglist = NULL; //SoM: 4/7/2000        ss->stairlock = 0;        ss->nextsec = -1;        ss->prevsec = -1;        ss->heightsec = -1; //SoM: 3/17/2000: This causes some real problems        ss->altheightsec = 0; //SoM: 3/20/2000        ss->floorlightsec = -1;        ss->ceilinglightsec = -1;        ss->ffloors = NULL;        ss->lightlist = NULL;        ss->numlights = 0;        ss->attached = NULL;        ss->numattached = 0;        ss->moved = true;        ss->ceilingportal = ss->floorportal = NULL;        ss->floor_xoffs = ss->ceiling_xoffs = ss->floor_yoffs = ss->ceiling_yoffs = 0;        ss->bottommap = ss->midmap = ss->topmap = -1;        // ----- for special tricks with HW renderer -----        ss->pseudoSector = false;        ss->sectorLines = NULL;        ss->stackList = NULL;        ss->lineoutLength = -1.0;                // ----- end special tricks -----            }    Z_Free (data);    // whoa! there is usually no more than 25 different flats used per level!!    //I_Error ("%d flats found\n", numlevelflats);    // set the sky flat num    skyflatnum = P_AddLevelFlat ("F_SKY1",foundflats);    // copy table for global usage    levelflats = Z_Malloc (numlevelflats*sizeof(levelflat_t),PU_LEVEL,0);    memcpy (levelflats, foundflats, numlevelflats*sizeof(levelflat_t));    // search for animated flats and set up    P_SetupLevelFlatAnims ();}//// P_LoadNodes//void P_LoadNodes (int lump){    byte*       data;    int         i;    int         j;    int         k;    mapnode_t*  mn;    node_t*     no;    numnodes = W_LumpLength (lump) / sizeof(mapnode_t);    nodes = Z_Malloc (numnodes*sizeof(node_t),PU_LEVEL,0);    data = W_CacheLumpNum (lump,PU_STATIC);    mn = (mapnode_t *)data;    no = nodes;    for (i=0 ; i<numnodes ; i++, no++, mn++)    {        no->x = SHORT(mn->x)<<FRACBITS;        no->y = SHORT(mn->y)<<FRACBITS;        no->dx = SHORT(mn->dx)<<FRACBITS;        no->dy = SHORT(mn->dy)<<FRACBITS;        for (j=0 ; j<2 ; j++)        {            no->children[j] = SHORT(mn->children[j]);            for (k=0 ; k<4 ; k++)                no->bbox[j][k] = SHORT(mn->bbox[j][k])<<FRACBITS;        }    }    Z_Free (data);}//// P_LoadThings//void P_LoadThings (int lump){    int                 i;    mapthing_t*         mt;    boolean             spawn;    char                *data, *datastart;    data = datastart = W_CacheLumpNum (lump,PU_LEVEL);    nummapthings     = W_LumpLength (lump) / (5 * sizeof(short));    mapthings        = Z_Malloc(nummapthings * sizeof(mapthing_t), PU_LEVEL, NULL);    //SoM: Because I put a new member into the mapthing_t for use with    //fragglescript, the format has changed and things won't load correctly    //using the old method.    mt = mapthings;    for (i=0 ; i<nummapthings ; i++, mt++)    {        spawn = true;        // Do spawn all other stuff.        // SoM: Do this first so all the mapthing slots are filled!        mt->x = SHORT(READSHORT(data));        mt->y = SHORT(READSHORT(data));        mt->angle = SHORT(READSHORT(data));        mt->type = SHORT(READSHORT(data));        mt->options = SHORT(READSHORT(data));        mt->mobj = NULL; //SoM:        P_SpawnMapThing (mt);    }    Z_Free(datastart);}//// P_LoadLineDefs// Also counts secret lines for intermissions.//void P_LoadLineDefs (int lump){    byte*               data;    int                 i;    maplinedef_t*       mld;    line_t*             ld;    vertex_t*           v1;    vertex_t*           v2;    numlines = W_LumpLength (lump) / sizeof(maplinedef_t);    lines = Z_Malloc (numlines*sizeof(line_t),PU_LEVEL,0);    memset (lines, 0, numlines*sizeof(line_t));    data = W_CacheLumpNum (lump,PU_STATIC);    mld = (maplinedef_t *)data;    ld = lines;    for (i=0 ; i<numlines ; i++, mld++, ld++)    {        ld->flags = SHORT(mld->flags);        ld->special = SHORT(mld->special);        ld->tag = SHORT(mld->tag);        v1 = ld->v1 = &vertexes[SHORT(mld->v1)];        v2 = ld->v2 = &vertexes[SHORT(mld->v2)];        ld->dx = v2->x - v1->x;        ld->dy = v2->y - v1->y;        if (!ld->dx)            ld->slopetype = ST_VERTICAL;        else if (!ld->dy)            ld->slopetype = ST_HORIZONTAL;        else        {            if (FixedDiv (ld->dy , ld->dx) > 0)                ld->slopetype = ST_POSITIVE;            else                ld->slopetype = ST_NEGATIVE;        }        if (v1->x < v2->x)        {            ld->bbox[BOXLEFT] = v1->x;            ld->bbox[BOXRIGHT] = v2->x;        }        else        {            ld->bbox[BOXLEFT] = v2->x;            ld->bbox[BOXRIGHT] = v1->x;        }        if (v1->y < v2->y)        {            ld->bbox[BOXBOTTOM] = v1->y;            ld->bbox[BOXTOP] = v2->y;        }        else        {            ld->bbox[BOXBOTTOM] = v2->y;            ld->bbox[BOXTOP] = v1->y;        }        ld->sidenum[0] = SHORT(mld->sidenum[0]);        ld->sidenum[1] = SHORT(mld->sidenum[1]);        if (ld->sidenum[0] != -1 && ld->special)          sides[ld->sidenum[0]].special = ld->special;        ld->wallportals = NULL;    }    Z_Free (data);}void P_LoadLineDefs2(){  int i;  line_t* ld = lines;  for(i = 0; i < numlines; i++, ld++)  {  if (ld->sidenum[0] != -1)    ld->frontsector = sides[ld->sidenum[0]].sector;  else    ld->frontsector = 0;  if (ld->sidenum[1] != -1)    ld->backsector = sides[ld->sidenum[1]].sector;  else    ld->backsector = 0;  }}//// P_LoadSideDefs///*void P_LoadSideDefs (int lump){    byte*               data;    int                 i;    mapsidedef_t*       msd;    side_t*             sd;    numsides = W_LumpLength (lump) / sizeof(mapsidedef_t);    sides = Z_Malloc (numsides*sizeof(side_t),PU_LEVEL,0);    memset (sides, 0, numsides*sizeof(side_t));    data = W_CacheLumpNum (lump,PU_STATIC);    msd = (mapsidedef_t *)data;    sd = sides;    for (i=0 ; i<numsides ; i++, msd++, sd++)    {        sd->textureoffset = SHORT(msd->textureoffset)<<FRACBITS;        sd->rowoffset = SHORT(msd->rowoffset)<<FRACBITS;        sd->toptexture = R_TextureNumForName(msd->toptexture);        sd->bottomtexture = R_TextureNumForName(msd->bottomtexture);        sd->midtexture = R_TextureNumForName(msd->midtexture);        sd->sector = &sectors[SHORT(msd->sector)];    }    Z_Free (data);}*/void P_LoadSideDefs (int lump){  numsides = W_LumpLength(lump) / sizeof(mapsidedef_t);  sides = Z_Malloc(numsides*sizeof(side_t),PU_LEVEL,0);  memset(sides, 0, numsides*sizeof(side_t));}// SoM: 3/22/2000: Delay loading texture names until after loaded linedefs.//Hurdler: 04/04/2000: proto addedint R_ColormapNumForName(char *name);void P_LoadSideDefs2(int lump){  byte *data = W_CacheLumpNum(lump,PU_STATIC);  int  i;  int  num;  int  mapnum;  for (i=0; i<numsides; i++)    {      register mapsidedef_t *msd = (mapsidedef_t *) data + i;      register side_t *sd = sides + i;      register sector_t *sec;      sd->textureoffset = SHORT(msd->textureoffset)<<FRACBITS;      sd->rowoffset = SHORT(msd->rowoffset)<<FRACBITS;      // refined to allow colormaps to work as wall      // textures if invalid as colormaps but valid as textures.      sd->sector = sec = &sectors[SHORT(msd->sector)];      switch (sd->special)        {        case 242:                       // variable colormap via 242 linedef        case 280:                       //SoM: 3/22/2000: New water type.#ifdef HWRENDER          if(rendermode == render_soft)          {#endif            num = R_CheckTextureNumForName(msd->toptexture);            if(num == -1)            {              sec->topmap = mapnum = R_ColormapNumForName(msd->toptexture);              sd->toptexture = 0;            }            else              sd->toptexture = num;            num = R_CheckTextureNumForName(msd->midtexture);            if(num == -1)            {              sec->midmap = mapnum = R_ColormapNumForName(msd->midtexture);              sd->midtexture = 0;            }            else              sd->midtexture = num;            num = R_CheckTextureNumForName(msd->bottomtexture);            if(num == -1)            {              sec->bottommap = mapnum = R_ColormapNumForName(msd->bottomtexture);              sd->bottomtexture = 0;            }            else              sd->bottomtexture = num;            break;#ifdef HWRENDER          }          else          {            if((num = R_CheckTextureNumForName(msd->toptexture)) == -1)              sd->toptexture = 0;            else              sd->toptexture = num;            if((num = R_CheckTextureNumForName(msd->midtexture)) == -1)              sd->midtexture = 0;            else              sd->midtexture = num;            if((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1)              sd->bottomtexture = 0;            else              sd->bottomtexture = num;            break;          }#endif        case 282:                       //SoM: 4/4/2000: Just colormap transfer#ifdef HWRENDER          if(rendermode == render_soft)          {#endif            if(msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')            {              sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, msd->bottomtexture);              sd->toptexture = sd->bottomtexture = 0;            }            else            {              if((num = R_CheckTextureNumForName(msd->toptexture)) == -1)                sd->toptexture = 0;              else                sd->toptexture = num;              if((num = R_CheckTextureNumForName(msd->midtexture)) == -1)                sd->midtexture = 0;              else                sd->midtexture = num;              if((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1)                sd->bottomtexture = 0;              else                sd->bottomtexture = num;            }#ifdef HWRENDER          }          else          {            if((num = R_CheckTextureNumForName(msd->toptexture)) == -1)              sd->toptexture = 0;            else              sd->toptexture = num;            if((num = R_CheckTextureNumForName(msd->midtexture)) == -1)              sd->midtexture = 0;            else              sd->midtexture = num;            if((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1)              sd->bottomtexture = 0;            else              sd->bottomtexture = num;            break;          }#endif        case 260:          num = R_CheckTextureNumForName(msd->midtexture);          if(num == -1)            sd->midtexture = 1;          else            sd->midtexture = num;          num = R_CheckTextureNumForName(msd->toptexture);          if(num == -1)            sd->toptexture = 1;          else            sd->toptexture = num;          num = R_CheckTextureNumForName(msd->bottomtexture);          if(num == -1)            sd->bottomtexture = 1;          else            sd->bottomtexture = num;          break;/*        case 260: // killough 4/11/98: apply translucency to 2s normal texture          sd->midtexture = strncasecmp("TRANMAP", msd->midtexture, 8) ?            (sd->special = W_CheckNumForName(msd->midtexture)) < 0 ||            W_LumpLength(sd->special) != 65536 ?            sd->special=0, R_TextureNumForName(msd->midtexture) :              (sd->special++, 0) : (sd->special=0);          sd->toptexture = R_TextureNumForName(msd->toptexture);          sd->bottomtexture = R_TextureNumForName(msd->bottomtexture);          break;*/ //This code is replaced.. I need to fix this though        default:                        // normal cases          sd->midtexture = R_TextureNumForName(msd->midtexture);          sd->toptexture = R_TextureNumForName(msd->toptexture);          sd->bottomtexture = R_TextureNumForName(msd->bottomtexture);          break;        }    }  Z_Free (data);}//// P_LoadBlockMap//void P_LoadBlockMap (int lump){    int         i;    int         count;    blockmaplump = W_CacheLumpNum (lump,PU_LEVEL);    blockmap = blockmaplump+4;    count = W_LumpLength (lump)/2;    for (i=0 ; i<count ; i++)        blockmaplump[i] = SHORT(blockmaplump[i]);    bmaporgx = blockmaplump[0]<<FRACBITS;    bmaporgy = blockmaplump[1]<<FRACBITS;    bmapwidth = blockmaplump[2];    bmapheight = blockmaplump[3];    // clear out mobj chains    count = sizeof(*blocklinks)* bmapwidth*bmapheight;    blocklinks = Z_Malloc (count,PU_LEVEL, 0);    memset (blocklinks, 0, count);}//// P_GroupLines// Builds sector line lists and subsector sector numbers.// Finds block bounding boxes for sectors.//void P_GroupLines (void){    line_t**            linebuffer;    int                 i;    int                 j;    int                 total;    line_t*             li;    sector_t*           sector;    subsector_t*        ss;    seg_t*              seg;    fixed_t             bbox[4];    int                 block;    // look up sector number for each subsector    ss = subsectors;    for (i=0 ; i<numsubsectors ; i++, ss++)    {        seg = &segs[ss->firstline];        ss->sector = seg->sidedef->sector;

⌨️ 快捷键说明

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