Esempio n. 1
0
void P_LoadNodes(int lump)
{
    byte *data;
    int   i, j, 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     = I_TempBuffer();
    W_ReadLump(lump, data);

    mn = (mapnode_t *)data;
    no = nodes;
    for(i = 0; i < numnodes; i++, no++, mn++)
    {
        no->x  = LITTLESHORT(mn->x ) << FRACBITS;
        no->y  = LITTLESHORT(mn->y ) << FRACBITS;
        no->dx = LITTLESHORT(mn->dx) << FRACBITS;
        no->dy = LITTLESHORT(mn->dy) << FRACBITS;

        for(j = 0; j < 2; j++)
        {
            no->children[j] = (unsigned short)LITTLESHORT(mn->children[j]);
            for(k = 0; k < 4; k++)
                no->bbox[j][k] = LITTLESHORT(mn->bbox[j][k]) << FRACBITS;
        }
    }
}
Esempio n. 2
0
void P_LoadSideDefs(int lump)
{
    byte *data;
    int   i;
    mapsidedef_t *msd;
    side_t       *sd;

    for(i = 0; i < numtextures; i++)
        textures[i].usecount = 0;

    numsides = W_LumpLength(lump) / sizeof(mapsidedef_t);
    sides    = Z_Malloc(numsides * sizeof(side_t), PU_LEVEL, 0);
    D_memset(sides, 0, numsides * sizeof(side_t));
    data     = I_TempBuffer();
    W_ReadLump(lump, data);

    msd = (mapsidedef_t *)data;
    sd  = sides;
    for(i = 0; i < numsides; i++, msd++, sd++)
    {
        sd->textureoffset = LITTLESHORT(msd->textureoffset) << FRACBITS;
        sd->rowoffset     = LITTLESHORT(msd->rowoffset) << FRACBITS;
        sd->toptexture    = R_TextureNumForName(msd->toptexture);
        sd->bottomtexture = R_TextureNumForName(msd->bottomtexture);
        sd->midtexture    = R_TextureNumForName(msd->midtexture);
        sd->sector        = &sectors[LITTLESHORT(msd->sector)];

        textures[sd->toptexture].usecount++;
        textures[sd->bottomtexture].usecount++;
        textures[sd->midtexture].usecount++;
    }
}
Esempio n. 3
0
void P_LoadSectors(int lump)
{
    byte *data;
    int   i;
    mapsector_t *ms;
    sector_t    *ss;

    numsectors = W_LumpLength(lump) / sizeof(mapsector_t);
    sectors    = Z_Malloc(numsectors * sizeof(sector_t), PU_LEVEL, 0);
    D_memset(sectors, 0, numsectors * sizeof(sector_t));
    data = I_TempBuffer();
    W_ReadLump(lump, data);

    ms = (mapsector_t *)data;
    ss = sectors;
    for(i = 0; i < numsectors; i++, ss++, ms++)
    {
        ss->floorheight   = LITTLESHORT(ms->floorheight) << FRACBITS;
        ss->ceilingheight = LITTLESHORT(ms->ceilingheight) << FRACBITS;
        ss->floorpic      = R_FlatNumForName(ms->floorpic);

        if(!D_strncasecmp(ms->ceilingpic,"F_SKY1", 6))
            ss->ceilingpic = -1;
        else
        {
            ss->ceilingpic = R_FlatNumForName(ms->ceilingpic);
        }

        ss->lightlevel = LITTLESHORT(ms->lightlevel);
        ss->special    = LITTLESHORT(ms->special);
        ss->tag        = LITTLESHORT(ms->tag);
        ss->thinglist  = NULL;
    }
}
Esempio n. 4
0
void P_LoadVertexes (int lump)
{
#ifdef MARS
	numvertexes = W_LumpLength (lump) / sizeof(vertex_t);
	vertexes = (vertex_t *)(wadfileptr+BIGLONG(lumpinfo[lump].filepos));
#else
	byte		*data;
	int			i;
	mapvertex_t	*ml;
	vertex_t	*li;
	
	numvertexes = W_LumpLength (lump) / sizeof(mapvertex_t);
	vertexes = Z_Malloc (numvertexes*sizeof(vertex_t),PU_LEVEL,0);	
	data = I_TempBuffer ();	
	W_ReadLump (lump,data);
	
	
	ml = (mapvertex_t *)data;
	li = vertexes;
	for (i=0 ; i<numvertexes ; i++, li++, ml++)
	{
		li->x = LITTLESHORT(ml->x)<<FRACBITS;
		li->y = LITTLESHORT(ml->y)<<FRACBITS;
	}
#endif
}
Esempio n. 5
0
void P_LoadVertexes(int lump)
{
    byte        *data;
    int          i;
    mapvertex_t *ml;
    vertex_t    *li;

    numvertexes = W_LumpLength(lump) / sizeof(mapvertex_t);
    vertexes    = Z_Malloc(numvertexes * sizeof(vertex_t), PU_LEVEL, 0);
    data = I_TempBuffer();
    W_ReadLump(lump, data);

    ml = (mapvertex_t *)data;
    li = vertexes;
    for(i = 0; i < numvertexes; i++, li++, ml++)
    {
        li->x = LITTLESHORT(ml->x) << FRACBITS;
        li->y = LITTLESHORT(ml->y) << FRACBITS;
    }
}
Esempio n. 6
0
void P_LoadSubsectors(int lump)
{
    byte *data;
    int   i;
    mapsubsector_t *ms;
    subsector_t    *ss;

    numsubsectors = W_LumpLength(lump) / sizeof(mapsubsector_t);
    subsectors    = Z_Malloc(numsubsectors * sizeof(subsector_t), PU_LEVEL, 0);
    data = I_TempBuffer();
    W_ReadLump(lump, data);

    ms = (mapsubsector_t *)data;
    D_memset (subsectors,0, numsubsectors * sizeof(subsector_t));
    ss = subsectors;
    for(i = 0; i < numsubsectors; i++, ss++, ms++)
    {
        ss->numlines  = LITTLESHORT(ms->numsegs);
        ss->firstline = LITTLESHORT(ms->firstseg);
    }
}
Esempio n. 7
0
void P_LoadSegs(int lump)
{
    byte     *data;
    int       i;
    mapseg_t *ml;
    seg_t    *li;
    line_t   *ldef;
    int       linedef, side;

    numsegs = W_LumpLength(lump) / sizeof(mapseg_t);
    segs    = Z_Malloc(numsegs * sizeof(seg_t), PU_LEVEL, 0);
    D_memset(segs, 0, numsegs * sizeof(seg_t));
    data = I_TempBuffer();
    W_ReadLump(lump, data);

    ml = (mapseg_t *)data;
    li = segs;
    for(i = 0; i < numsegs; i++, li++, ml++)
    {
        li->v1 = &vertexes[LITTLESHORT(ml->v1)];
        li->v2 = &vertexes[LITTLESHORT(ml->v2)];

        li->angle = (LITTLESHORT(ml->angle)) << 16;
        li->offset = (LITTLESHORT(ml->offset)) << 16;
        linedef = LITTLESHORT(ml->linedef);
        ldef = &lines[linedef];
        li->linedef = ldef;
        side = LITTLESHORT(ml->side);
        li->sidedef = &sides[ldef->sidenum[side]];
        li->frontsector = sides[ldef->sidenum[side]].sector;

        if(ldef-> flags & ML_TWOSIDED)
            li->backsector = sides[ldef->sidenum[side ^ 1]].sector;
        else
            li->backsector = 0;

        if(ldef->v1 == li->v1)
            ldef->fineangle = li->angle >> ANGLETOFINESHIFT;
    }
}
Esempio n. 8
0
void P_LoadThings(int lump)
{
    byte *data;
    int   i;
    mapthing_t *mt;
    int numthings;

    data = I_TempBuffer();
    W_ReadLump(lump, data);
    numthings = W_LumpLength(lump) / sizeof(mapthing_t);

    mt = (mapthing_t *)data;
    for(i = 0; i < numthings; i++, mt++)
    {
        mt->x       = LITTLESHORT(mt->x);
        mt->y       = LITTLESHORT(mt->y);
        mt->angle   = LITTLESHORT(mt->angle);
        mt->type    = LITTLESHORT(mt->type);
        mt->options = LITTLESHORT(mt->options);
        P_SpawnMapThing(mt);
    }
}
Esempio n. 9
0
void P_LoadLineDefs(int lump)
{
    byte *data;
    int   i;
    maplinedef_t *mld;
    line_t       *ld;
    vertex_t     *v1, *v2;

    numlines = W_LumpLength(lump) / sizeof(maplinedef_t);
    lines    = Z_Malloc(numlines * sizeof(line_t), PU_LEVEL, 0);
    D_memset(lines, 0, numlines * sizeof(line_t));
    data     = I_TempBuffer();
    W_ReadLump(lump, data);

    mld = (maplinedef_t *)data;
    ld = lines;
    for(i = 0; i < numlines; i++, mld++, ld++)
    {
        ld->flags   = LITTLESHORT(mld->flags);
        ld->special = LITTLESHORT(mld->special);
        ld->tag     = LITTLESHORT(mld->tag);
        v1 = ld->v1 = &vertexes[LITTLESHORT(mld->v1)];
        v2 = ld->v2 = &vertexes[LITTLESHORT(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] = LITTLESHORT(mld->sidenum[0]);
        ld->sidenum[1] = LITTLESHORT(mld->sidenum[1]);

        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;
    }
}