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; // Make sure primary lumps are used for texture searching W_UsePrimary(); 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 = §ors[SHORT(msd->sector)]; } if(DevMaps) { W_UseAuxiliary(); } Z_Free(data); }
void W_CloseAuxiliary(void) { int i; if(AuxiliaryOpened) { W_UseAuxiliary(); for(i = 0; i < numlumps; i++) { if(lumpcache[i]) { Z_Free(lumpcache[i]); } } Z_Free(AuxiliaryLumpInfo); Z_Free(AuxiliaryLumpCache); W_CloseAuxiliaryFile(); AuxiliaryOpened = false; } W_UsePrimary(); }
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); memset (sectors, 0, numsectors*sizeof(sector_t)); data = W_CacheLumpNum (lump,PU_STATIC); ms = (mapsector_t *)data; ss = sectors; // Make sure primary lumps are used for flat searching W_UsePrimary(); for(i = 0; i < numsectors; i++, ss++, ms++) { ss->floorheight = SHORT(ms->floorheight)<<FRACBITS; ss->ceilingheight = SHORT(ms->ceilingheight)<<FRACBITS; ss->floorpic = R_FlatNumForName(ms->floorpic); ss->ceilingpic = R_FlatNumForName(ms->ceilingpic); ss->lightlevel = SHORT(ms->lightlevel); ss->special = SHORT(ms->special); ss->tag = SHORT(ms->tag); ss->thinglist = NULL; ss->seqType = SEQTYPE_STONE; // default seqType } if(DevMaps) { W_UseAuxiliary(); } Z_Free(data); }
void P_SetupLevel(int episode, int map, int playermask, skill_t skill) { int i; int parm; char lumpname[9]; char auxName[128]; int lumpnum; mobj_t *mobj; for(i = 0; i < MAXPLAYERS; i++) { players[i].killcount = players[i].secretcount = players[i].itemcount = 0; } players[consoleplayer].viewz = 1; // will be set by player think #ifdef __WATCOMC__ if(i_CDMusic == false) { S_StartSongName("chess", true); // Waiting-for-level-load song } #endif Z_FreeTags(PU_LEVEL, PU_PURGELEVEL-1); P_InitThinkers(); leveltime = 0; if(DevMaps) { sprintf(auxName, "%sMAP%02d.WAD", DevMapsDir, map); W_OpenAuxiliary(auxName); } sprintf(lumpname, "MAP%02d", map); lumpnum = W_GetNumForName(lumpname); // // Begin processing map lumps // 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; po_NumPolyobjs = 0; deathmatch_p = deathmatchstarts; P_LoadThings(lumpnum+ML_THINGS); PO_Init(lumpnum+ML_THINGS); // Initialize the polyobjs P_LoadACScripts(lumpnum+ML_BEHAVIOR); // ACS object code // // End of map lump processing // if(DevMaps) { // Close the auxiliary file, but don't free its loaded lumps. // The next call to W_OpenAuxiliary() will do a full shutdown // of the current auxiliary WAD (free lumps and info lists). W_CloseAuxiliaryFile(); W_UsePrimary(); } // If deathmatch, randomly spawn the active players TimerGame = 0; if(deathmatch) { for (i=0 ; i<MAXPLAYERS ; i++) { if (playeringame[i]) { // must give a player spot before deathmatchspawn mobj = P_SpawnMobj (playerstarts[0][i].x<<16, playerstarts[0][i].y<<16,0, MT_PLAYER_FIGHTER); players[i].mo = mobj; G_DeathMatchSpawnPlayer (i); P_RemoveMobj (mobj); } } parm = M_CheckParm("-timer"); if(parm && parm < myargc-1) { TimerGame = atoi(myargv[parm+1])*35*60; } } // set up world state P_SpawnSpecials (); // build subsector connect matrix // P_ConnectSubsectors (); // Load colormap and set the fullbright flag i = P_GetMapFadeTable(gamemap); W_ReadLump(i, colormaps); if(i == W_GetNumForName("COLORMAP")) { LevelUseFullBright = true; } else { // Probably fog ... don't use fullbright sprites LevelUseFullBright = false; } // preload graphics if (precache) R_PrecacheLevel (); // Check if the level is a lightning level P_InitLightning(); S_StopAllSound(); SN_StopAllSequences(); S_StartSong(gamemap, true); //printf ("free memory: 0x%x\n", Z_FreeMemory()); }