Skip to content

Commit

Permalink
The symbolic name of a material, is that of the material itself and n…
Browse files Browse the repository at this point in the history
…ot the texture resource it wraps.
  • Loading branch information
danij committed Apr 1, 2008
1 parent 456dd0f commit 7a85ef8
Showing 1 changed file with 11 additions and 38 deletions.
49 changes: 11 additions & 38 deletions doomsday/engine/portable/src/r_materials.c
Expand Up @@ -394,56 +394,29 @@ const ded_ptcgen_t* P_GetMaterialPtcGen(const material_t* mat)

int R_CheckMaterialNumForName(const char* name, materialtype_t type)
{
int i;
uint i;

switch(type)
for(i = 0; i < numMaterials; ++i)
{
case MAT_FLAT:
if(name[0] == '-') // No flat marker.
return 0;

for(i = 0; i < numFlats; ++i)
if(!strncasecmp(flats[i]->name, name, 8))
{
return i;
}
break;

case MAT_TEXTURE:
if(name[0] == '-') // No texture marker.
return 0;
material_t *mat = materials[i];

for(i = 0; i < numTextures; ++i)
if(!strncasecmp(textures[i]->name, name, 8))
{
return i;
}
break;

default:
Con_Error("R_CheckMaterialNumForName: Unknown material type %i.",
type);
if(mat->type == type && !strncasecmp(mat->name, name, 8))
return mat->ofTypeID;
}

return -1;
}

const char *R_MaterialNameForNum(int ofTypeID, materialtype_t type)
{
switch(type)
{
case MAT_FLAT:
if(ofTypeID < 0 || ofTypeID > numFlats - 1)
return NULL;
return flats[ofTypeID]->name;
uint i;

case MAT_TEXTURE:
if(ofTypeID < 0 || ofTypeID > numTextures - 1)
return NULL;
return textures[ofTypeID]->name;
for(i = 0; i < numMaterials; ++i)
{
material_t *mat = materials[i];

default:
Con_Error("R_MaterialNameForNum: Unknown material type %i.", type);
if(mat->type == type && mat->ofTypeID == ofTypeID)
return mat->name;
}

return NULL;
Expand Down

0 comments on commit 7a85ef8

Please sign in to comment.