Skip to content

Commit

Permalink
Fixed: "listmaps" printed [null] as the source file for missing maps
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Nov 12, 2012
1 parent 5daabbb commit 99331b0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/doomsday.def
Expand Up @@ -306,7 +306,7 @@ EXPORTS
Uri_SetUri @328 NONAME
Uri_SetUri2 @332 NONAME
Uri_Resolved @405 NONAME
; Uri_ResolvedConst @760 NONAME
Uri_IsEmpty @760 NONAME
Uri_Clear @406 NONAME
Uri_Scheme @486 NONAME
Uri_Path @487 NONAME
Expand Down
8 changes: 7 additions & 1 deletion doomsday/engine/api/uri.h
Expand Up @@ -379,12 +379,18 @@ Uri* Uri_FromReader(Reader* reader);
*/
void Uri_Delete(Uri* uri);

/**
* Returns true if the path component of the URI is empty; otherwise false.
* @param uri Uri instance.
*/
boolean Uri_IsEmpty(Uri const* uri);

/**
* Clears the uri, returning it to an empty state.
* @param uri Uri instance.
* @return Same as @a uri, for caller convenience.
*/
Uri* Uri_Clear(Uri* uri);
Uri* Uri_Clear(Uri const* uri);

/**
* Copy the contents of @a other into this uri.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/p_data.cpp
Expand Up @@ -136,7 +136,7 @@ AutoStr* P_MapSourceFile(char const* uriCString)
{
de::Uri uri = de::Uri(uriCString, RC_NULL);
lumpnum_t lumpNum = W_CheckLumpNumForName2(Str_Text(uri.path()), true/*quiet please*/);
if(lumpNum < 0) return NULL;
if(lumpNum < 0) return AutoStr_NewStd();
return W_LumpSourceFile(lumpNum);
}

Expand Down
6 changes: 6 additions & 0 deletions doomsday/engine/portable/src/uri.cpp
Expand Up @@ -835,6 +835,12 @@ boolean Uri_Equality(Uri const* uri, Uri const* other)
return *self == (*(TOINTERNAL_CONST(other)));
}

boolean Uri_IsEmpty(Uri const* uri)
{
SELF_CONST(uri);
return self->isEmpty();
}

Uri* Uri_Clear(Uri* uri)
{
SELF(uri);
Expand Down
13 changes: 8 additions & 5 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -3494,9 +3494,9 @@ const char* P_GetMapName(uint episode, uint map)
/**
* Print a list of maps and the WAD files where they are from.
*/
void G_PrintFormattedMapList(uint episode, const char** files, uint count)
void G_PrintFormattedMapList(uint episode, char const** files, uint count)
{
const char* current = NULL;
char const* current = NULL;
uint i, k, rangeStart = 0, len;

for(i = 0; i < count; ++i)
Expand All @@ -3517,7 +3517,7 @@ void G_PrintFormattedMapList(uint episode, const char** files, uint count)
{
Uri* mapUri = G_ComposeMapUri(episode, k);
AutoStr* path = Uri_ToString(mapUri);
Con_Printf("%s%s", Str_Text(path), (k != i-1) ? "," : "");
Con_Printf("%s%s", Str_Text(path), (k != i - 1) ? "," : "");
Uri_Delete(mapUri);
}
}
Expand Down Expand Up @@ -3589,8 +3589,11 @@ void G_PrintMapList(void)
for(map = 0; map < maxMapsPerEpisode; ++map)
{
Uri* uri = G_ComposeMapUri(episode, map);
AutoStr* path = Uri_Compose(uri);
sourceList[map] = Str_Text(P_MapSourceFile(Str_Text(path)));
AutoStr* path = P_MapSourceFile(Str_Text(Uri_Compose(uri)));
if(!Str_IsEmpty(path))
{
sourceList[map] = Str_Text(path);
}
Uri_Delete(uri);
}
G_PrintFormattedMapList(episode, sourceList, 99);
Expand Down

0 comments on commit 99331b0

Please sign in to comment.