Show q3 levelshots located in levelshots/ subdirectories
This commit is contained in:
parent
d00be81cb5
commit
8af9f68b5e
14
src/q3maps.c
14
src/q3maps.c
@ -710,14 +710,17 @@ static void process_levelshots(GHashTable* maphash) {
|
|||||||
for (ptr=shotslist;ptr;ptr=g_slist_next(ptr)) {
|
for (ptr=shotslist;ptr;ptr=g_slist_next(ptr)) {
|
||||||
struct q3mapinfo* mi = ptr->data;
|
struct q3mapinfo* mi = ptr->data;
|
||||||
struct q3mapinfo* mih = NULL;
|
struct q3mapinfo* mih = NULL;
|
||||||
|
gchar* levelshot = NULL;
|
||||||
gchar* mapname = NULL;
|
gchar* mapname = NULL;
|
||||||
gchar* mapbase = NULL;
|
|
||||||
char* origkey = NULL;
|
char* origkey = NULL;
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
if (!mi->levelshot || strlen(mi->levelshot) <= 4) { g_free(mi); continue; }
|
if (!mi->levelshot || strlen(mi->levelshot) <= 4) { g_free(mi); continue; }
|
||||||
mapbase = g_path_get_basename(mi->levelshot);
|
levelshot = g_ascii_strdown(mi->levelshot, strlen(mi->levelshot)-4);
|
||||||
mapname = g_ascii_strdown(mapbase, strlen(mapbase)-4); /* g_ascii_strdown does implicit strndup */
|
mapname = g_strrstr(levelshot, "levelshots/");
|
||||||
found = g_hash_table_lookup_extended(maphash, mapname, (gpointer)&origkey, (gpointer)&mih);
|
if (mapname) {
|
||||||
|
mapname += strlen("levelshots/");
|
||||||
|
found = g_hash_table_lookup_extended(maphash, mapname, (gpointer)&origkey, (gpointer)&mih);
|
||||||
|
}
|
||||||
if (found != TRUE || mih != GINT_TO_POINTER(-1)) // not in hash or mapinfo alread defined
|
if (found != TRUE || mih != GINT_TO_POINTER(-1)) // not in hash or mapinfo alread defined
|
||||||
{
|
{
|
||||||
// debug(0, "drop shot %s %p", mapname, mih);
|
// debug(0, "drop shot %s %p", mapname, mih);
|
||||||
@ -727,8 +730,7 @@ static void process_levelshots(GHashTable* maphash) {
|
|||||||
// debug(0, "insert shot %s", mapname);
|
// debug(0, "insert shot %s", mapname);
|
||||||
g_hash_table_insert(maphash, origkey, mi);
|
g_hash_table_insert(maphash, origkey, mi);
|
||||||
}
|
}
|
||||||
g_free(mapbase);
|
g_free(levelshot);
|
||||||
g_free(mapname);
|
|
||||||
}
|
}
|
||||||
g_slist_free(shotslist);
|
g_slist_free(shotslist);
|
||||||
shotslist=NULL;
|
shotslist=NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user