Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Nov 26, 2010
1 parent dc63884 commit f3b23a8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/doomsday.h
Expand Up @@ -99,7 +99,7 @@ extern "C" {
/**
* Registers a new resource for the specified game.
*
* \note Resource registration order defines the load order of resources (among those of the same class).
* \note Resource registration order defines the load order of resources (among those of the same type).
*
* @param game Unique identifier/name of the game.
* @param type Type of resource being added.
Expand Down
42 changes: 23 additions & 19 deletions doomsday/engine/portable/src/dd_main.c
Expand Up @@ -555,24 +555,28 @@ static boolean allGameResourcesFound(gameinfo_t* info)

static void loadGameResources(gameinfo_t* info, resourcetype_t type, const char* searchPath)
{
assert(info && VALID_RESOURCE_TYPE(type) && searchPath && searchPath[0]);
assert(info && VALID_RESOURCE_TYPE(type) && searchPath);
{
resourcenamespaceid_t rni = F_ParseResourceNamespace(searchPath);
gameresource_record_t* const* records = GameInfo_Resources(info, rni, 0);
if(!records)
return;
do
{
switch((*records)->type)
resourcenamespaceid_t rni;

if((rni = F_ParseResourceNamespace(searchPath)) == 0)
rni = F_DefaultResourceNamespaceForType(type);

{gameresource_record_t* const* records;
if((records = GameInfo_Resources(info, rni, 0)))
do
{
case RT_PACKAGE:
if(Str_Length(&(*records)->path) != 0)
W_AddFile(Str_Text(&(*records)->path), false);
break;
default:
Con_Error("loadGameResources: Error, no resource loader found for %s.", F_ResourceTypeStr((*records)->type));
};
} while(*(++records));
switch((*records)->type)
{
case RT_PACKAGE:
if(Str_Length(&(*records)->path) != 0)
W_AddFile(Str_Text(&(*records)->path), false);
break;
default:
Con_Error("loadGameResources: Error, no resource loader found for %s.", F_ResourceTypeStr((*records)->type));
};
} while(*(++records));
}
}
}

Expand Down Expand Up @@ -780,10 +784,10 @@ static int DD_ChangeGameWorker(void* parm)

/**
* Phase 1: Add game-resource files.
* First ZIPs then WADs (they may contain virtual WAD files).
* \fixme dj: First ZIPs then WADs (they may contain virtual WAD files).
*/
loadGameResources(info, RT_PACKAGE, "packages:");
loadGameResources(info, RT_PACKAGE, "packages:");
#pragma message("!!!WARNING: Phase 1 of game resource loading does not presently prioritize ZIP!!!")
loadGameResources(info, RT_PACKAGE, "");

/**
* Phase 2: Add additional game-startup files.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/def_main.c
Expand Up @@ -779,7 +779,7 @@ static void readAllDefinitions(void)

// Now any extra definition files required by the game.
{ gameresource_record_t* const* records;
if((records = GameInfo_Resources(DD_GameInfo(), F_ParseResourceNamespace("defs:"), 0)))
if((records = GameInfo_Resources(DD_GameInfo(), F_ResourceNamespaceForName("defs:"), 0)))
do
{
if(Str_Length(&(*records)->path) != 0)
Expand Down Expand Up @@ -821,7 +821,7 @@ void Def_Read(void)
// Get rid of everything.
// \fixme dj: This is not correct. We do not want to clear all paths
// we should instead re-init to the default path set.
DD_ClearResourceSearchPathList(F_ParseResourceNamespace("models:"));
DD_ClearResourceSearchPathList(F_ResourceNamespaceForName("models:"));
Def_Destroy();
}

Expand Down
26 changes: 13 additions & 13 deletions doomsday/engine/portable/src/gameinfo.c
Expand Up @@ -52,7 +52,7 @@ typedef enum {
* @param overrideFlag2 Takes precendence.
*/
static void formResourceSearchPaths(gameinfo_t* info, resourcenamespaceid_t rni, ddstring_t* pathList,
searchpathid_t* searchOrder, const char* defaultNamespace, const char* overrideFlag,
searchpathid_t* searchOrder, const char* defaultPath, const char* overrideFlag,
const char* overrideFlag2)
{
assert(info && F_IsValidResourceNamespaceId(rni) && pathList && searchOrder);
Expand Down Expand Up @@ -83,10 +83,10 @@ static void formResourceSearchPaths(gameinfo_t* info, resourcenamespaceid_t rni,
}
case SPI_BASEPATH_DATA:
{ filename_t newPath;
if(defaultNamespace && defaultNamespace[0])
if(defaultPath && defaultPath[0])
{
filename_t other;
dd_snprintf(other, FILENAME_T_MAXLEN, DD_BASEPATH_DATA"%s", defaultNamespace);
dd_snprintf(other, FILENAME_T_MAXLEN, DD_BASEPATH_DATA"%s", defaultPath);
M_TranslatePath(newPath, other, FILENAME_T_MAXLEN);
}
else
Expand All @@ -98,10 +98,10 @@ static void formResourceSearchPaths(gameinfo_t* info, resourcenamespaceid_t rni,
}
case SPI_BASEPATH_DEFS:
{ filename_t newPath;
if(defaultNamespace && defaultNamespace[0])
if(defaultPath && defaultPath[0])
{
filename_t other;
dd_snprintf(other, FILENAME_T_MAXLEN, DD_BASEPATH_DEFS"%s", defaultNamespace);
dd_snprintf(other, FILENAME_T_MAXLEN, DD_BASEPATH_DEFS"%s", defaultPath);
M_TranslatePath(newPath, other, FILENAME_T_MAXLEN);
}
else
Expand All @@ -112,10 +112,10 @@ static void formResourceSearchPaths(gameinfo_t* info, resourcenamespaceid_t rni,
break;
}
case SPI_GAMEPATH_DATA:
if(defaultNamespace && defaultNamespace[0])
if(defaultPath && defaultPath[0])
{
filename_t newPath;
dd_snprintf(newPath, FILENAME_T_MAXLEN, "%s%s", Str_Text(&info->_dataPath), defaultNamespace);
dd_snprintf(newPath, FILENAME_T_MAXLEN, "%s%s", Str_Text(&info->_dataPath), defaultPath);
GameInfo_AddResourceSearchPath(info, rni, newPath, false);
}
else
Expand All @@ -124,10 +124,10 @@ static void formResourceSearchPaths(gameinfo_t* info, resourcenamespaceid_t rni,
}
break;
case SPI_GAMEPATH_DEFS:
if(defaultNamespace && defaultNamespace[0])
if(defaultPath && defaultPath[0])
{
filename_t newPath;
dd_snprintf(newPath, FILENAME_T_MAXLEN, "%s%s", Str_Text(&info->_defsPath), defaultNamespace);
dd_snprintf(newPath, FILENAME_T_MAXLEN, "%s%s", Str_Text(&info->_defsPath), defaultPath);
GameInfo_AddResourceSearchPath(info, rni, newPath, false);
}
else
Expand All @@ -137,18 +137,18 @@ static void formResourceSearchPaths(gameinfo_t* info, resourcenamespaceid_t rni,
break;
case SPI_GAMEMODEPATH_DATA:
usingGameModePathData = true;
if(defaultNamespace && defaultNamespace[0] && Str_Length(&info->_identityKey))
if(defaultPath && defaultPath[0] && Str_Length(&info->_identityKey))
{
filename_t newPath;
dd_snprintf(newPath, FILENAME_T_MAXLEN, "%s%s%s", Str_Text(&info->_dataPath), defaultNamespace, Str_Text(&info->_identityKey));
dd_snprintf(newPath, FILENAME_T_MAXLEN, "%s%s%s", Str_Text(&info->_dataPath), defaultPath, Str_Text(&info->_identityKey));
GameInfo_AddResourceSearchPath(info, rni, newPath, false);
}
break;
case SPI_GAMEMODEPATH_DEFS:
usingGameModePathDefs = true;
if(Str_Length(&info->_identityKey))
{
if(defaultNamespace && defaultNamespace[0])
if(defaultPath && defaultPath[0])
{
filename_t newPath;
dd_snprintf(newPath, FILENAME_T_MAXLEN, "%s%s", Str_Text(&info->_defsPath), Str_Text(&info->_identityKey));
Expand All @@ -157,7 +157,7 @@ static void formResourceSearchPaths(gameinfo_t* info, resourcenamespaceid_t rni,
else
{
filename_t newPath;
dd_snprintf(newPath, FILENAME_T_MAXLEN, "%s%s%s", Str_Text(&info->_defsPath), defaultNamespace, Str_Text(&info->_identityKey));
dd_snprintf(newPath, FILENAME_T_MAXLEN, "%s%s%s", Str_Text(&info->_defsPath), defaultPath, Str_Text(&info->_identityKey));
GameInfo_AddResourceSearchPath(info, rni, newPath, false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/r_extres.c
Expand Up @@ -324,7 +324,7 @@ resourcenamespace_t* F_ToResourceNamespace(resourcenamespaceid_t rni)

resourcenamespaceid_t F_SafeResourceNamespaceForName(const char* name)
{
if(name && name)
if(name && name[0])
{
uint i, numResourceNamespaces = F_NumResourceNamespaces();
for(i = 1; i < numResourceNamespaces+1; ++i)
Expand Down

0 comments on commit f3b23a8

Please sign in to comment.