Skip to content

Commit

Permalink
Changed: Removed requirement of one (or more) texture definitions dur…
Browse files Browse the repository at this point in the history
…ing engine start up (PNAMES and TEXTURE1/2 lumps are no longer required).
  • Loading branch information
danij committed Dec 3, 2008
1 parent e139c32 commit e10e101
Showing 1 changed file with 37 additions and 20 deletions.
57 changes: 37 additions & 20 deletions doomsday/engine/portable/src/r_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,24 +996,19 @@ typedef struct {
return texDefs;
}

/**
* Reads in the texture defs and creates materials for them.
*/
void R_InitTextures(void)
static void loadTextureDefs(void)
{
int i;
float startTime = Sys_GetSeconds();
lumpnum_t* patchLumpList;
lumpnum_t i, pnamesLump, *patchLumpList;
size_t numPatches;
int count = 0, countCustom = 0, *eCount;
texturedef_t** list = NULL, **listCustom = NULL, ***eList;
boolean firstNull;

numTextureDefs = 0;
textureDefs = NULL;
if((pnamesLump = W_CheckNumForName("PNAMES")) == -1)
return;

// Load the patch names from the PNAMES lump.
patchLumpList = loadPatchList(W_GetNumForName("PNAMES"), &numPatches);
patchLumpList = loadPatchList(pnamesLump, &numPatches);
if(!patchLumpList)
Con_Error("R_InitTextures: Error loading PNAMES.");

Expand Down Expand Up @@ -1162,20 +1157,42 @@ void R_InitTextures(void)

// We're finished with the patch lump list now.
M_Free(patchLumpList);
}

/**
* Reads in the texture defs and creates materials for them.
*/
void R_InitTextures(void)
{
int i;
float startTime = Sys_GetSeconds();

numTextureDefs = 0;
textureDefs = NULL;

// Load texture definitions from TEXTURE1/2 lumps.
loadTextureDefs();

// Create materials for the defined textures.
for(i = 0; i < numTextureDefs; ++i)
if(numTextureDefs > 0)
{
texturedef_t* texDef = textureDefs[i];
material_t* mat;
materialtex_t* mTex;
// Create materials for the defined textures.
for(i = 0; i < numTextureDefs; ++i)
{
texturedef_t* texDef = textureDefs[i];
material_t* mat;
materialtex_t* mTex;

mTex = R_MaterialTexCreate(i, MTT_TEXTURE);
mTex = R_MaterialTexCreate(i, MTT_TEXTURE);

// Create a material for this texture.
mat = R_MaterialCreate(texDef->name, texDef->width, texDef->height,
((texDef->flags & TXDF_NODRAW)? MATF_NO_DRAW : 0),
mTex, MG_TEXTURES);
// Create a material for this texture.
mat = R_MaterialCreate(texDef->name, texDef->width, texDef->height,
((texDef->flags & TXDF_NODRAW)? MATF_NO_DRAW : 0),
mTex, MG_TEXTURES);
}
}
else
{
Con_Message("R_InitTextures: Warning, no textures found.\n");
}

VERBOSE(Con_Message("R_InitTextures: Done in %.2f seconds.\n",
Expand Down

0 comments on commit e10e101

Please sign in to comment.