Skip to content

Commit

Permalink
Cleanup|Client: DED structures now use de::Uri pointers (removed unne…
Browse files Browse the repository at this point in the history
…cessary casts)
  • Loading branch information
danij-deng committed Jun 24, 2014
1 parent 4ca1547 commit 43dbdaa
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 52 deletions.
2 changes: 1 addition & 1 deletion doomsday/client/src/audio/s_mus.cpp
Expand Up @@ -245,7 +245,7 @@ int Mus_GetExt(ded_music_t *def, ddstring_t *retPath)
}

LOG_AUDIO_WARNING("Music file \"%s\" not found (id '%s')")
<< *reinterpret_cast<de::Uri *>(def->path) << def->id;
<< *def->path << def->id;
}

// Try the resource locator?
Expand Down
67 changes: 33 additions & 34 deletions doomsday/client/src/def_main.cpp
Expand Up @@ -363,7 +363,7 @@ ded_ptcgen_t *Def_GetGenerator(de::Uri const &uri)
if(!def->material) continue;

// Is this suitable?
if(reinterpret_cast<de::Uri const &>(*def->material) == uri)
if(*def->material == uri)
return def;

#if 0 /// @todo $revise-texture-animation
Expand Down Expand Up @@ -821,7 +821,7 @@ static ded_group_t *findGroupDefByFrameTextureUri(de::Uri const &uri)

if(!gm.material) continue;

if(reinterpret_cast<de::Uri const &>(*gm.material) == uri)
if(*gm.material == uri)
{
// Found one.
return &grp;
Expand Down Expand Up @@ -866,7 +866,7 @@ static void rebuildMaterialLayers(Material &material, ded_material_t const &def)
// Determine the start frame.
int startFrame = 0;
while(!grp->members[startFrame].material ||
reinterpret_cast<de::Uri const &>(*grp->members[startFrame].material) != textureUri)
*grp->members[startFrame].material != textureUri)
{
startFrame++;
}
Expand All @@ -887,7 +887,7 @@ static void rebuildMaterialLayers(Material &material, ded_material_t const &def)

try
{
Texture &texture = App_ResourceSystem().texture(reinterpret_cast<de::Uri const &>(*gm.material));
Texture &texture = App_ResourceSystem().texture(*gm.material);
layer0->addStage(Material::Layer::Stage(&texture, gm.tics, gm.randomTics / float( gm.tics )));
}
catch(TextureManifest::MissingTextureError const &)
Expand Down Expand Up @@ -924,7 +924,7 @@ static void rebuildMaterialLayers(Material &material, ded_material_t const &def)
// Add a new stage.
try
{
Texture &texture = App_ResourceSystem().textureScheme("Details").findByResourceUri(*reinterpret_cast<de::Uri const *>(detailDef->stage.texture)).texture();
Texture &texture = App_ResourceSystem().textureScheme("Details").findByResourceUri(*detailDef->stage.texture).texture();
dlayer->addStage(Material::DetailLayer::Stage(&texture, stage->tics, stage->variance,
detailDef->stage.scale, detailDef->stage.strength,
detailDef->stage.maxDistance));
Expand Down Expand Up @@ -974,15 +974,15 @@ static void rebuildMaterialLayers(Material &material, ded_material_t const &def)
try
{
Texture &texture = App_ResourceSystem().textureScheme("Reflections")
.findByResourceUri(reinterpret_cast<de::Uri const &>(*shineDef->stage.texture)).texture();
.findByResourceUri(*shineDef->stage.texture).texture();

Texture *maskTexture = 0;
if(shineDef->stage.maskTexture)
{
try
{
maskTexture = &App_ResourceSystem().textureScheme("Masks")
.findByResourceUri(reinterpret_cast<de::Uri const &>(*shineDef->stage.maskTexture)).texture();
.findByResourceUri(*shineDef->stage.maskTexture).texture();
}
catch(TextureManifest::MissingTextureError const &)
{} // Ignore this error.
Expand Down Expand Up @@ -1037,19 +1037,19 @@ static void rebuildMaterialDecorations(Material &material, ded_material_t const

if(stage->up)
{
defineLightmap(*reinterpret_cast<de::Uri const *>(stage->up));
defineLightmap(*stage->up);
}
if(stage->down)
{
defineLightmap(*reinterpret_cast<de::Uri const *>(stage->down));
defineLightmap(*stage->down);
}
if(stage->sides)
{
defineLightmap(*reinterpret_cast<de::Uri const *>(stage->sides));
defineLightmap(*stage->sides);
}
if(stage->flare)
{
defineFlaremap(*reinterpret_cast<de::Uri const *>(stage->flare));
defineFlaremap(*stage->flare);
}
}

Expand Down Expand Up @@ -1096,8 +1096,7 @@ static void interpretMaterialDef(ded_material_t const &def)
try
{
// Create/retrieve a manifest for the would-be material.
MaterialManifest *manifest =
&App_ResourceSystem().declareMaterial(*reinterpret_cast<de::Uri *>(def.uri));
MaterialManifest *manifest = &App_ResourceSystem().declareMaterial(*def.uri);

// Update manifest classification:
manifest->setFlags(MaterialManifest::AutoGenerated, def.autoGenerated? SetFlags : UnsetFlags);
Expand All @@ -1109,7 +1108,7 @@ static void interpretMaterialDef(ded_material_t const &def)
{
try
{
Texture &texture = App_ResourceSystem().texture(*reinterpret_cast<de::Uri *>(firstLayer.stages[0].texture));
Texture &texture = App_ResourceSystem().texture(*firstLayer.stages[0].texture);
if(texture.isFlagged(Texture::Custom))
{
manifest->setFlags(MaterialManifest::Custom);
Expand All @@ -1119,8 +1118,8 @@ static void interpretMaterialDef(ded_material_t const &def)
{
// Log but otherwise ignore this error.
LOG_RES_WARNING("Ignoring unknown texture \"%s\" in Material \"%s\" (layer %i stage %i): %s")
<< *reinterpret_cast<de::Uri *>(firstLayer.stages[0].texture)
<< *reinterpret_cast<de::Uri *>(def.uri)
<< *firstLayer.stages[0].texture
<< *def.uri
<< 0 << 0
<< er.asText();
}
Expand Down Expand Up @@ -1149,12 +1148,12 @@ static void interpretMaterialDef(ded_material_t const &def)
catch(ResourceSystem::UnknownSchemeError const &er)
{
LOG_RES_WARNING("Failed to declare material \"%s\": %s")
<< *reinterpret_cast<de::Uri *>(def.uri) << er.asText();
<< *def.uri << er.asText();
}
catch(MaterialScheme::InvalidPathError const &er)
{
LOG_RES_WARNING("Failed to declare material \"%s\": %s")
<< *reinterpret_cast<de::Uri *>(def.uri) << er.asText();
<< *def.uri << er.asText();
}
}

Expand Down Expand Up @@ -1315,19 +1314,19 @@ void Def_Read()

if(dl->stage.up)
{
defineLightmap(*reinterpret_cast<de::Uri const *>(dl->stage.up));
defineLightmap(*dl->stage.up);
}
if(dl->stage.down)
{
defineLightmap(*reinterpret_cast<de::Uri const *>(dl->stage.down));
defineLightmap(*dl->stage.down);
}
if(dl->stage.sides)
{
defineLightmap(*reinterpret_cast<de::Uri const *>(dl->stage.sides));
defineLightmap(*dl->stage.sides);
}
if(dl->stage.flare)
{
defineFlaremap(*reinterpret_cast<de::Uri const *>(dl->stage.flare));
defineFlaremap(*dl->stage.flare);
}
}
}
Expand All @@ -1344,7 +1343,7 @@ void Def_Read()

if(!dtl->stage.texture) continue;

App_ResourceSystem().defineTexture("Details", reinterpret_cast<de::Uri &>(*dtl->stage.texture));
App_ResourceSystem().defineTexture("Details", *dtl->stage.texture);
}

// Surface reflections (Define textures).
Expand All @@ -1359,11 +1358,11 @@ void Def_Read()

if(ref->stage.texture)
{
App_ResourceSystem().defineTexture("Reflections", reinterpret_cast<de::Uri &>(*ref->stage.texture));
App_ResourceSystem().defineTexture("Reflections", *ref->stage.texture);
}
if(ref->stage.maskTexture)
{
App_ResourceSystem().defineTexture("Masks", reinterpret_cast<de::Uri &>(*ref->stage.maskTexture),
App_ResourceSystem().defineTexture("Masks", *ref->stage.maskTexture,
Vector2i(ref->stage.maskWidth, ref->stage.maskHeight));
}
}
Expand Down Expand Up @@ -1597,7 +1596,7 @@ static void initMaterialGroup(ded_group_t &def)

try
{
MaterialManifest &manifest = App_ResourceSystem().materialManifest(*reinterpret_cast<de::Uri *>(gm->material));
MaterialManifest &manifest = App_ResourceSystem().materialManifest(*gm->material);

if(def.flags & AGF_PRECACHE) // A precache group.
{
Expand Down Expand Up @@ -1626,7 +1625,7 @@ static void initMaterialGroup(ded_group_t &def)
{
// Log but otherwise ignore this error.
LOG_RES_WARNING("Unknown material \"%s\" in group def %i: %s")
<< *reinterpret_cast<de::Uri *>(gm->material)
<< *gm->material
<< i << er.asText();
}
}
Expand Down Expand Up @@ -1682,23 +1681,23 @@ void Def_PostInit()
// Lights.
for(int i = 0; i < defs.lights.size(); ++i)
{
ded_light_t* lig = &defs.lights[i];
ded_light_t *lig = &defs.lights[i];

if(lig->up)
{
defineLightmap(*reinterpret_cast<de::Uri const *>(lig->up));
defineLightmap(*lig->up);
}
if(lig->down)
{
defineLightmap(*reinterpret_cast<de::Uri const *>(lig->down));
defineLightmap(*lig->down);
}
if(lig->sides)
{
defineLightmap(*reinterpret_cast<de::Uri const *>(lig->sides));
defineLightmap(*lig->sides);
}
if(lig->flare)
{
defineFlaremap(*reinterpret_cast<de::Uri const *>(lig->flare));
defineFlaremap(*lig->flare);
}
}

Expand Down Expand Up @@ -1797,7 +1796,7 @@ void Def_CopyLineType(linetype_t* l, ded_linetype_t* def)
{
try
{
l->actMaterial = App_ResourceSystem().materialManifest(*reinterpret_cast<de::Uri *>(def->actMaterial)).id();
l->actMaterial = App_ResourceSystem().materialManifest(*def->actMaterial).id();
}
catch(ResourceSystem::MissingManifestError const &)
{} // Ignore this error.
Expand All @@ -1807,7 +1806,7 @@ void Def_CopyLineType(linetype_t* l, ded_linetype_t* def)
{
try
{
l->deactMaterial = App_ResourceSystem().materialManifest(*reinterpret_cast<de::Uri *>(def->deactMaterial)).id();
l->deactMaterial = App_ResourceSystem().materialManifest(*def->deactMaterial).id();
}
catch(ResourceSystem::MissingManifestError const &)
{} // Ignore this error.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/r_things.cpp
Expand Up @@ -517,7 +517,7 @@ void R_ProjectSprite(mobj_t *mo)

if(def && def->flare)
{
de::Uri const &flaremapResourceUri = *reinterpret_cast<de::Uri const *>(def->flare);
de::Uri const &flaremapResourceUri = *def->flare;
if(flaremapResourceUri.path().toStringRef().compareWithoutCase("-"))
{
vis->data.flare.tex = GL_PrepareFlaremap(flaremapResourceUri);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/sky.cpp
Expand Up @@ -571,7 +571,7 @@ void Sky::configure(ded_sky_t *def)
.setFadeoutLimit(lyrDef.colorLimit)
.enable();

if(de::Uri *matUri = reinterpret_cast<de::Uri *>(lyrDef.material))
if(de::Uri *matUri = lyrDef.material)
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/resource/compositebitmapfont.cpp
Expand Up @@ -222,7 +222,7 @@ CompositeBitmapFont *CompositeBitmapFont::fromDef(FontManifest &manifest,
if(!def.charMap[i].path) continue;
try
{
String glyphPatchPath = reinterpret_cast<de::Uri &>(*def.charMap[i].path).resolved();
String glyphPatchPath = def.charMap[i].path->resolved();
font->glyphSetPatch(def.charMap[i].ch, glyphPatchPath);
}
catch(de::Uri::ResolveError const &er)
Expand Down Expand Up @@ -259,7 +259,7 @@ void CompositeBitmapFont::rebuildFromDef(ded_compositefont_t const &newDef)

try
{
String glyphPatchPath = reinterpret_cast<de::Uri &>(*d->def->charMap[i].path).resolved();
String glyphPatchPath = d->def->charMap[i].path->resolved();
glyphSetPatch(d->def->charMap[i].ch, glyphPatchPath);
}
catch(de::Uri::ResolveError const& er)
Expand Down
16 changes: 8 additions & 8 deletions doomsday/client/src/resource/material.cpp
Expand Up @@ -46,7 +46,7 @@ static Texture *findTextureForLayerStage(ded_material_layer_stage_t const &def)
{
if(def.texture)
{
return &App_ResourceSystem().texture(*reinterpret_cast<de::Uri *>(def.texture));
return &App_ResourceSystem().texture(*def.texture);
}
}
catch(TextureManifest::MissingTextureError const &)
Expand Down Expand Up @@ -104,7 +104,7 @@ static Texture *findTextureForDetailLayerStage(ded_detail_stage_t const &def)
if(def.texture)
{
return &App_ResourceSystem().textureScheme("Details")
.findByResourceUri(*reinterpret_cast<de::Uri *>(def.texture)).texture();
.findByResourceUri(*def.texture).texture();
}
}
catch(TextureManifest::MissingTextureError const &)
Expand Down Expand Up @@ -163,15 +163,15 @@ static Texture *findTextureForShineLayerStage(ded_shine_stage_t const &def, bool
if(def.maskTexture)
{
return &App_ResourceSystem().textureScheme("Masks")
.findByResourceUri(*reinterpret_cast<de::Uri *>(def.maskTexture)).texture();
.findByResourceUri(*def.maskTexture).texture();
}
}
else
{
if(def.texture)
{
return &App_ResourceSystem().textureScheme("Reflections")
.findByResourceUri(*reinterpret_cast<de::Uri *>(def.texture)).texture();
.findByResourceUri(*def.texture).texture();
}
}
}
Expand Down Expand Up @@ -220,16 +220,16 @@ Material::ShineLayer::Stages const &Material::ShineLayer::stages() const

Material::Decoration::Stage *Material::Decoration::Stage::fromDef(ded_decorlight_stage_t const &def)
{
Texture *upTexture = App_ResourceSystem().texture("Lightmaps", reinterpret_cast<de::Uri *>(def.up));
Texture *downTexture = App_ResourceSystem().texture("Lightmaps", reinterpret_cast<de::Uri *>(def.down));
Texture *sidesTexture = App_ResourceSystem().texture("Lightmaps", reinterpret_cast<de::Uri *>(def.sides));
Texture *upTexture = App_ResourceSystem().texture("Lightmaps", def.up);
Texture *downTexture = App_ResourceSystem().texture("Lightmaps", def.down);
Texture *sidesTexture = App_ResourceSystem().texture("Lightmaps", def.sides);

Texture *flareTexture = 0;
int sysFlareIdx = def.sysFlareIdx;

if(def.flare && !def.flare->isEmpty())
{
de::Uri const *resourceUri = reinterpret_cast<de::Uri *>(def.flare);
de::Uri const *resourceUri = def.flare;

// Select a system flare by numeric identifier?
if(resourceUri->path().length() == 1 &&
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/resource/resourcesystem.cpp
Expand Up @@ -3104,7 +3104,7 @@ AbstractFont *ResourceSystem::newFontFromDef(ded_compositefont_t const &def)
LOG_AS("ResourceSystem::newFontFromDef");

if(!def.uri) return 0;
de::Uri const &uri = *reinterpret_cast<de::Uri *>(def.uri);
de::Uri const &uri = *def.uri;

try
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/world/map.cpp
Expand Up @@ -1450,7 +1450,7 @@ DENG2_OBSERVES(bsp::Partitioner, UnclosedSectorFound)
{
try
{
Material *defMat = &App_ResourceSystem().material(*reinterpret_cast<de::Uri const *>(def->material));
Material *defMat = &App_ResourceSystem().material(*def->material);

Material *mat = gen->plane->surface().materialPtr();
if(def->flags & Generator::SpawnFloor)
Expand Down
8 changes: 5 additions & 3 deletions doomsday/libdoomsday/src/defs/ded.cpp
Expand Up @@ -371,10 +371,12 @@ ded_material_t *ded_s::findMaterialDef(de::Uri const &uri) const
for(int i = materials.size() - 1; i >= 0; i--)
{
ded_material_t *def = &materials[i];
if(!def->uri || uri != reinterpret_cast<de::Uri &>(*def->uri)) continue;
return def;
if(def->uri && uri == *def->uri)
{
return def;
}
}
return NULL;
return 0; // Not found.
}

ded_material_t* ded_s::getMaterial(char const *uriCString) const
Expand Down

0 comments on commit 43dbdaa

Please sign in to comment.