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

📄 p_setup.c

📁 Nxdoom真的满好用的
💻 C
📖 第 1 页 / 共 2 页
字号:
//// 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->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;    }	    Z_Free (data);}//// 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);}//// 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;    }    // count number of lines in each sector    li = lines;    total = 0;    for (i=0 ; i<numlines ; i++, li++)    {	total++;	li->frontsector->linecount++;	if (li->backsector && li->backsector != li->frontsector)	{	    li->backsector->linecount++;	    total++;	}    }	    // build line tables for each sector	    linebuffer = Z_Malloc (total*4, PU_LEVEL, 0);    sector = sectors;    for (i=0 ; i<numsectors ; i++, sector++)    {	M_ClearBox (bbox);	sector->lines = linebuffer;	li = lines;	for (j=0 ; j<numlines ; j++, li++)	{	    if (li->frontsector == sector || li->backsector == sector)	    {		*linebuffer++ = li;		M_AddToBox (bbox, li->v1->x, li->v1->y);		M_AddToBox (bbox, li->v2->x, li->v2->y);	    }	}	if (linebuffer - sector->lines != sector->linecount)	    I_Error ("P_GroupLines: miscounted");				// set the degenmobj_t to the middle of the bounding box	sector->soundorg.x = (bbox[BOXRIGHT]+bbox[BOXLEFT])/2;	sector->soundorg.y = (bbox[BOXTOP]+bbox[BOXBOTTOM])/2;			// adjust bounding box to map blocks	block = (bbox[BOXTOP]-bmaporgy+MAXRADIUS)>>MAPBLOCKSHIFT;	block = block >= bmapheight ? bmapheight-1 : block;	sector->blockbox[BOXTOP]=block;	block = (bbox[BOXBOTTOM]-bmaporgy-MAXRADIUS)>>MAPBLOCKSHIFT;	block = block < 0 ? 0 : block;	sector->blockbox[BOXBOTTOM]=block;	block = (bbox[BOXRIGHT]-bmaporgx+MAXRADIUS)>>MAPBLOCKSHIFT;	block = block >= bmapwidth ? bmapwidth-1 : block;	sector->blockbox[BOXRIGHT]=block;	block = (bbox[BOXLEFT]-bmaporgx-MAXRADIUS)>>MAPBLOCKSHIFT;	block = block < 0 ? 0 : block;	sector->blockbox[BOXLEFT]=block;    }	}//// P_SetupLevel//voidP_SetupLevel( int		episode,  int		map,  int		playermask,  skill_t	skill){    int		i;    char	lumpname[9];    int		lumpnum;	    totalkills = totalitems = totalsecret = wminfo.maxfrags = 0;    wminfo.partime = 180;    for (i=0 ; i<MAXPLAYERS ; i++)    {	players[i].killcount = players[i].secretcount 	    = players[i].itemcount = 0;    }    // Initial height of PointOfView    // will be set by player think.    players[consoleplayer].viewz = 1;     // Make sure all sounds are stopped before Z_FreeTags.    S_Start ();			    #if 0 // UNUSED    if (debugfile)    {	Z_FreeTags (PU_LEVEL, MAXINT);	Z_FileDumpHeap (debugfile);    }    else#endif	Z_FreeTags (PU_LEVEL, PU_PURGELEVEL-1);    // UNUSED W_Profile ();    P_InitThinkers ();    // if working with a devlopment map, reload it    W_Reload ();				       // find map name    if ( gamemode == commercial)    {	if (map<10)	    sprintf (lumpname,"map0%i", map);	else	    sprintf (lumpname,"map%i", map);    }    else    {	lumpname[0] = 'E';	lumpname[1] = '0' + episode;	lumpname[2] = 'M';	lumpname[3] = '0' + map;	lumpname[4] = 0;    }    lumpnum = W_GetNumForName (lumpname);	    leveltime = 0;	    // note: most of this ordering is important	    P_LoadBlockMap (lumpnum+ML_BLOCKMAP);    P_LoadVertexes (lumpnum+ML_VERTEXES);    P_LoadSectors (lumpnum+ML_SECTORS);    P_LoadSideDefs (lumpnum+ML_SIDEDEFS);    P_LoadLineDefs (lumpnum+ML_LINEDEFS);    P_LoadSubsectors (lumpnum+ML_SSECTORS);    P_LoadNodes (lumpnum+ML_NODES);    P_LoadSegs (lumpnum+ML_SEGS);	    rejectmatrix = W_CacheLumpNum (lumpnum+ML_REJECT,PU_LEVEL);    P_GroupLines ();    bodyqueslot = 0;    deathmatch_p = deathmatchstarts;    P_LoadThings (lumpnum+ML_THINGS);        // if deathmatch, randomly spawn the active players    if (deathmatch)    {	for (i=0 ; i<MAXPLAYERS ; i++)	    if (playeringame[i])	    {		players[i].mo = NULL;		G_DeathMatchSpawnPlayer (i);	    }			    }    // clear special respawning que    iquehead = iquetail = 0;			    // set up world state    P_SpawnSpecials ();	    // build subsector connect matrix    //	UNUSED P_ConnectSubsectors ();    // preload graphics    if (precache)	R_PrecacheLevel ();    //printf ("free memory: 0x%x\n", Z_FreeMemory());}//// P_Init//void P_Init (void){    P_InitSwitchList ();    P_InitPicAnims ();    R_InitSprites (sprnames);}

⌨️ 快捷键说明

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