Skip to content

Commit

Permalink
Refactor|Resources: Moved map resource manifests to libdoomsday
Browse files Browse the repository at this point in the history
MapDef was renamed and relocated to libdoomsday as res::MapManifest,
which means this data is now visible to plugins via libdoomsday.

res::System manages and has ownership of map manifests.
  • Loading branch information
danij-deng committed Jul 29, 2015
1 parent 7c2cc21 commit 2659264
Show file tree
Hide file tree
Showing 32 changed files with 257 additions and 255 deletions.
1 change: 0 additions & 1 deletion doomsday/apps/client/include/MapDef

This file was deleted.

30 changes: 1 addition & 29 deletions doomsday/apps/client/include/resource/resourcesystem.h
Expand Up @@ -30,11 +30,11 @@
#include <doomsday/filesys/wad.h>
#include <doomsday/filesys/zip.h>
#include <doomsday/uri.h>
#include <doomsday/resource/mapmanifest.h>
#include <doomsday/resource/system.h>

#include "resource/animgroup.h"
#include "resource/colorpalette.h"
#include "MapDef"
#ifdef __CLIENT__
# include "AbstractFont"
# include "BitmapFont"
Expand Down Expand Up @@ -89,9 +89,6 @@ class ResourceSystem : public res::System
/// An unknown resource scheme was referenced. @ingroup errors
DENG2_ERROR(UnknownSchemeError);

/// The referenced manifest was not found. @ingroup errors
DENG2_ERROR(MissingManifestError);

/// The referenced resource was not found. @ingroup errors
DENG2_ERROR(MissingResourceError);

Expand Down Expand Up @@ -122,7 +119,6 @@ class ResourceSystem : public res::System
#endif

typedef QMap<de::dint, de::Record> SpriteSet; ///< frame => Sprite
typedef de::PathTreeT<MapDef> MapDefs;

public:
/**
Expand Down Expand Up @@ -717,27 +713,6 @@ class ResourceSystem : public res::System

#endif // __CLIENT__

/**
* Convenient method of locating a MapDef for the given @a mapUri.
*/
MapDef *mapDef(de::Uri const &mapUri) const;

/**
* Provides immutable access to a list containing all MapDefs in the system,
* for efficient traversal.
*/
MapDefs const &allMapDefs() const;

/**
* @overload
*/
MapDefs &allMapDefs();

/**
* Returns the total number of MapDefs in the system.
*/
inline de::dint mapDefCount() const { return allMapDefs().size(); }

/**
* Returns the total number of animation/precache groups.
*/
Expand Down Expand Up @@ -874,14 +849,11 @@ class ResourceSystem : public res::System
public: /// @todo Should be private:
void initTextures();
void initSystemTextures();

void initMapDefs();
void initSprites();
#ifdef __CLIENT__
void initModels();
#endif

void clearAllMapDefs();
void clearAllRawTextures();

void clearAllTextureSpecs();
Expand Down
16 changes: 2 additions & 14 deletions doomsday/apps/client/include/world/map.h
Expand Up @@ -49,8 +49,6 @@
# include "Lumobj"
#endif

class MapDef;

class BspLeaf;
class ConvexSubspace;
class LineBlockmap;
Expand Down Expand Up @@ -150,19 +148,9 @@ class Map : public world::Map
* constructed dynamically. When done editing @ref endEditing() should be
* called to switch the map into a non-editable (i.e., playable) state.
*
* @param mapDefinition Definition for the map (Can be set later, @ref setDef).
*/
explicit Map(MapDef *mapDefinition = nullptr);

/**
* Returns the definition for the map.
*/
MapDef *def() const;

/**
* Change the definition associated with the map to @a newMapDefinition.
* @param manifest Resource manifest for the map, if any (Can be set later).
*/
void setDef(MapDef *newMapDefinition);
explicit Map(res::MapManifest *manifest = nullptr);

/**
* Returns the effective map-info definition Record for the map.
Expand Down
8 changes: 3 additions & 5 deletions doomsday/apps/client/src/clientapp.cpp
Expand Up @@ -169,12 +169,10 @@ DENG2_PIMPL(ClientApp)
if((entry.metadata() & LogEntry::Map) &&
ClientApp::worldSystem().hasMap())
{
if(MapDef *mapDef = ClientApp::worldSystem().map().def())
Map const &map = ClientApp::worldSystem().map();
if(map.hasManifest() && !map.manifest().sourceFile()->hasCustom())
{
if(!mapDef->sourceFile()->hasCustom())
{
return *this;
}
return *this;
}
}

Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -1080,7 +1080,7 @@ static dint DD_ActivateGameWorker(void *context)
resSys.initTextures();
resSys.textureScheme("Lightmaps").clear();
resSys.textureScheme("Flaremaps").clear();
resSys.initMapDefs();
resSys.initMapManifests();

if(parms.initiatedBusyMode)
{
Expand Down Expand Up @@ -1949,7 +1949,7 @@ static void initialize()
App_ResourceSystem().initTextures();
App_ResourceSystem().textureScheme("Lightmaps").clear();
App_ResourceSystem().textureScheme("Flaremaps").clear();
App_ResourceSystem().initMapDefs();
App_ResourceSystem().initMapManifests();

Def_Read();

Expand Down Expand Up @@ -2225,7 +2225,7 @@ void DD_UpdateEngineState()
App_FileSystem().resetAllSchemes();

App_ResourceSystem().initTextures();
App_ResourceSystem().initMapDefs();
App_ResourceSystem().initMapManifests();

if(App_GameLoaded() && gx.UpdateState)
{
Expand Down
18 changes: 9 additions & 9 deletions doomsday/apps/client/src/def_main.cpp
Expand Up @@ -785,7 +785,7 @@ static void redecorateMaterial(Material &material, Record const &def)
}
}
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{} // Ignore this error
}

Expand Down Expand Up @@ -978,7 +978,7 @@ static void configureMaterial(Material &mat, Record const &definition)
dstage0.variance = stage0.variance;
}
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{} // Ignore this error.
}
}
Expand Down Expand Up @@ -1016,7 +1016,7 @@ static void configureMaterial(Material &mat, Record const &definition)
maskTexture = &resSys().textureScheme("Masks")
.findByResourceUri(*shineDef->stage.maskTexture);
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{} // Ignore this error.
}

Expand All @@ -1036,7 +1036,7 @@ static void configureMaterial(Material &mat, Record const &definition)
sstage0.variance = stage0.variance;
}
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{} // Ignore this error.
}
}
Expand Down Expand Up @@ -1078,7 +1078,7 @@ static void interpretMaterialDef(Record const &definition)
manifest->setFlags(MaterialManifest::Custom);
}
}
catch(ResourceSystem::MissingManifestError const &er)
catch(res::System::MissingResourceManifestError const &er)
{
// Log but otherwise ignore this error.
LOG_RES_WARNING("Ignoring unknown texture \"%s\" in Material \"%s\" (layer 0 stage 0): %s")
Expand Down Expand Up @@ -1539,7 +1539,7 @@ static void initMaterialGroup(ded_group_t &def)
}
#endif
}
catch(ResourceSystem::MissingManifestError const &er)
catch(res::System::MissingResourceManifestError const &er)
{
// Log but otherwise ignore this error.
LOG_RES_WARNING("Unknown material \"%s\" in group def %i: %s")
Expand Down Expand Up @@ -1693,7 +1693,7 @@ void Def_CopyLineType(linetype_t *l, ded_linetype_t *def)
{
l->actMaterial = resSys().materialManifest(*def->actMaterial).id();
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{} // Ignore this error.
}

Expand All @@ -1703,7 +1703,7 @@ void Def_CopyLineType(linetype_t *l, ded_linetype_t *def)
{
l->deactMaterial = resSys().materialManifest(*def->deactMaterial).id();
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{} // Ignore this error.
}

Expand Down Expand Up @@ -1742,7 +1742,7 @@ void Def_CopyLineType(linetype_t *l, ded_linetype_t *def)
{
l->iparm[k] = resSys().materialManifest(de::Uri(def->iparmStr[k], RC_NULL)).id();
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{} // Ignore this error.
}
}
Expand Down
8 changes: 4 additions & 4 deletions doomsday/apps/client/src/edit_bias.cpp
Expand Up @@ -268,7 +268,7 @@ static void SBE_SetLock(int which, bool enable = true)
}
}

static bool SBE_Save(char const *name = 0)
static bool SBE_Save(char const *name = nullptr)
{
DENG2_ASSERT(editActive);

Expand All @@ -279,7 +279,7 @@ static bool SBE_Save(char const *name = 0)
ddstring_t fileName; Str_Init(&fileName);
if(!name || !name[0])
{
Str_Set(&fileName, String(map.def()? map.def()->composeUri().path() : "unknownmap").toUtf8().constData());
Str_Set(&fileName, String(map.hasManifest() ? map.manifest().composeUri().path() : "unknownmap").toUtf8().constData());
}
else
{
Expand All @@ -306,7 +306,7 @@ static bool SBE_Save(char const *name = 0)
LOG_RES_VERBOSE("Saving to \"%s\"...")
<< NativePath(Str_Text(&fileName)).pretty();

String uid = (map.def()? map.def()->composeUniqueId(App_CurrentGame()) : "(unknown map)");
String uid = (map.hasManifest() ? map.manifest().composeUniqueId(App_CurrentGame()) : "(unknown map)");
fprintf(file, "# %i Bias Lights for %s", map.biasSourceCount(), uid.toUtf8().constData());

// Since there can be quite a lot of these, make sure we'll skip
Expand Down Expand Up @@ -714,7 +714,7 @@ void SBE_DrawGui()
origin.y = top - size.y / 2;

// The map ID.
String label = (map.def()? map.def()->composeUniqueId(App_CurrentGame()) : "(unknown map)");
String label = (map.hasManifest() ? map.manifest().composeUniqueId(App_CurrentGame()) : "(unknown map)");
drawText(label, origin, UI_Color(UIC_TITLE), opacity);

glDisable(GL_TEXTURE_2D);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/render/r_main.cpp
Expand Up @@ -191,7 +191,7 @@ void Rend_Draw2DPlayerSprites()
rendpspriteparams_t parm; setupPSpriteParams(parm, vs);
Rend_DrawPSprite(parm);
}
catch(ResourceSystem::MissingManifestError const &er)
catch(res::System::MissingResourceManifestError const &er)
{
// Log but otherwise ignore this error.
state_t const &state = *vs.psp->statePtr;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/render/r_things.cpp
Expand Up @@ -555,7 +555,7 @@ void R_ProjectSprite(mobj_t &mob)
LOG_GL_WARNING("Projecting flare source for sprite '%i' frame '%i': %s")
<< mob.sprite << mob.frame << er.asText();
}
catch(ResourceSystem::MissingManifestError const &er)
catch(res::System::MissingResourceManifestError const &er)
{
// Log but otherwise ignore this error.
LOG_GL_WARNING("Projecting flare source for sprite '%i' frame '%i': %s")
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/render/rend_font.cpp
Expand Up @@ -1038,7 +1038,7 @@ static void parseParamaterBlock(char** strPtr, drawtextstate_t* state, int* numB
state->fontNum = App_ResourceSystem().fontManifest(de::Uri(buf, RC_NULL)).uniqueId();
continue;
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{}
}

Expand Down Expand Up @@ -1556,7 +1556,7 @@ DENG_EXTERN_C fontid_t Fonts_ResolveUri(uri_s const *uri)
{
return App_ResourceSystem().fontManifest(*reinterpret_cast<de::Uri const *>(uri)).uniqueId();
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{}
return NOFONTID;
}
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/resource/api_material.cpp
Expand Up @@ -45,7 +45,7 @@ DENG_EXTERN_C Material *DD_MaterialForTextureUri(uri_s const *textureUri)
// Log but otherwise ignore this error.
LOG_RES_WARNING(er.asText() + ", ignoring.");
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{} // Ignore this error.

return nullptr; // Not found.
Expand All @@ -65,7 +65,7 @@ DENG_EXTERN_C materialid_t Materials_ResolveUri(struct uri_s const *uri)
{
return App_ResourceSystem().materialManifest(*reinterpret_cast<de::Uri const *>(uri)).id();
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{} // Ignore this error.
return NOMATERIALID;
}
Expand All @@ -79,7 +79,7 @@ DENG_EXTERN_C materialid_t Materials_ResolveUriCString(char const *uriCString)
{
return App_ResourceSystem().materialManifest(de::Uri(uriCString, RC_NULL)).id();
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{} // Ignore this error.
}
return NOMATERIALID;
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/resource/api_resource.cpp
@@ -1,7 +1,7 @@
/** @file api_resource.cpp Public API of the resource subsystem.
*
* @authors Copyright © 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2013-2015 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand Down Expand Up @@ -40,7 +40,7 @@ DENG_EXTERN_C int Textures_UniqueId2(uri_s const *_uri, dd_bool quiet)
{
return App_ResourceSystem().textureManifest(uri).uniqueId();
}
catch(ResourceSystem::MissingManifestError const &)
catch(res::System::MissingResourceManifestError const &)
{
// Log but otherwise ignore this error.
if(!quiet)
Expand Down Expand Up @@ -82,7 +82,7 @@ DENG_EXTERN_C void R_AddAnimGroupFrame(int groupId, uri_s const *textureUri_, in
LOG_DEBUG("Unknown anim group #%i, ignoring.") << groupId;
}
}
catch(ResourceSystem::MissingManifestError const &er)
catch(res::System::MissingResourceManifestError const &er)
{
// Log but otherwise ignore this error.
LOG_RES_WARNING(er.asText() + ". Failed adding texture \"%s\" to group #%i, ignoring.")
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/resource/material.cpp
@@ -1,6 +1,6 @@
/** @file material.cpp Logical material resource.
*
* @authors Copyright © 2009-2014 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2009-2015 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand Down Expand Up @@ -240,7 +240,7 @@ DENG2_PIMPL(Material)
}
catch(TextureManifest::MissingTextureError &)
{}
catch(ResourceSystem::MissingManifestError &)
catch(res::System::MissingResourceManifestError &)
{}
}
}
Expand Down Expand Up @@ -597,7 +597,7 @@ D_CMD(InspectMaterial)
}
return true;
}
catch(ResourceSystem::MissingManifestError const &er)
catch(res::System::MissingResourceManifestError const &er)
{
LOG_SCR_WARNING("%s") << er.asText();
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/resource/materialanimator.cpp
Expand Up @@ -260,7 +260,7 @@ static Texture *findTextureForAnimationStage(MaterialTextureLayer::AnimationStag
}
catch(TextureManifest::MissingTextureError &)
{}
catch(ResourceSystem::MissingManifestError &)
catch(res::System::MissingResourceManifestError &)
{}
return nullptr;
}
Expand Down

0 comments on commit 2659264

Please sign in to comment.