diff --git a/libs/audio/cd_file.c b/libs/audio/cd_file.c index 7130576c2..34c569000 100644 --- a/libs/audio/cd_file.c +++ b/libs/audio/cd_file.c @@ -174,7 +174,7 @@ Load_Tracklist (void) Qread (oggfile, buffile, size); tracklist = PL_GetPropertyList (buffile); - if (!tracklist || tracklist->type != QFDictionary) { + if (!tracklist || PL_Type (tracklist) != QFDictionary) { Sys_Printf ("Malformed or empty tracklist file. check mus_ogglist\n"); return -1; } @@ -198,16 +198,16 @@ I_OGGMus_SetPlayList (int track) Sys_Printf ("No Track entry for track #%d.\n", track); return; } - if (play_list->type == QFString) + if (PL_Type (play_list) == QFString) return; - if (play_list->type != QFArray) { + if (PL_Type (play_list) != QFArray) { Sys_Printf ("Track entry for track #%d not string or array.\n", track); play_list = 0; return; } for (i = 0; i < PL_A_NumObjects (play_list); i++) { plitem_t *item = PL_ObjectAtIndex (play_list, i); - if (!item || item->type != QFString) { + if (!item || PL_Type (item) != QFString) { Sys_Printf ("Bad subtract %d in track %d.\n", i, track); play_list = 0; return; @@ -224,7 +224,7 @@ I_OGGMus_PlayNext (int looping) if (!play_list) return; - if (play_list->type == QFString) { + if (PL_Type (play_list) == QFString) { track = PL_String (play_list); play_pos = 0; } else { @@ -331,7 +331,7 @@ I_OGGMus_Info (void) continue; } - Sys_Printf (" %s - %s\n", trackstring, (char *) currenttrack->data); + Sys_Printf (" %s - %s\n", trackstring, PL_String (currenttrack)); count++; } } diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index e8d0d4721..21e3a382c 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -308,9 +308,10 @@ qfs_get_gd_params (plitem_t *gdpl, gamedir_t *gamedir, dstring_t *path, hashtab_t *vars) { plitem_t *p; + const char *ps; - if ((p = PL_ObjectForKey (gdpl, "Path")) && *(char *) p->data) { - char *str = qfs_var_subst (p->data, vars); + if ((p = PL_ObjectForKey (gdpl, "Path")) && *(ps = PL_String (p))) { + char *str = qfs_var_subst (ps, vars); char *e = strchr (str, '"'); if (!e) @@ -322,60 +323,70 @@ qfs_get_gd_params (plitem_t *gdpl, gamedir_t *gamedir, dstring_t *path, free (str); } if (!gamedir->gamecode && (p = PL_ObjectForKey (gdpl, "GameCode"))) - gamedir->gamecode = qfs_var_subst (p->data, vars); + gamedir->gamecode = qfs_var_subst (PL_String (p), vars); if (!gamedir->dir.skins && (p = PL_ObjectForKey (gdpl, "SkinPath"))) - gamedir->dir.skins = qfs_var_subst (p->data, vars); + gamedir->dir.skins = qfs_var_subst (PL_String (p), vars); if (!gamedir->dir.progs && (p = PL_ObjectForKey (gdpl, "ProgPath"))) - gamedir->dir.progs = qfs_var_subst (p->data, vars); + gamedir->dir.progs = qfs_var_subst (PL_String (p), vars); if (!gamedir->dir.sound && (p = PL_ObjectForKey (gdpl, "SoundPath"))) - gamedir->dir.sound = qfs_var_subst (p->data, vars); + gamedir->dir.sound = qfs_var_subst (PL_String (p), vars); if (!gamedir->dir.maps && (p = PL_ObjectForKey (gdpl, "MapPath"))) - gamedir->dir.maps = qfs_var_subst (p->data, vars); + gamedir->dir.maps = qfs_var_subst (PL_String (p), vars); } static void qfs_inherit (plitem_t *plist, plitem_t *gdpl, gamedir_t *gamedir, dstring_t *path, hashtab_t *dirs, hashtab_t *vars) { - plitem_t *base; + plitem_t *base_item; - if (!(base = PL_ObjectForKey (gdpl, "Inherit"))) + if (!(base_item = PL_ObjectForKey (gdpl, "Inherit"))) return; - if (base->type == QFString) { - if (Hash_Find (dirs, base->data)) - return; - gdpl = PL_ObjectForKey (plist, base->data); - if (!gdpl) { - Sys_Printf ("base `%s' not found\n", (char *)base->data); - return; - } - qfs_set_var (vars, "gamedir", base->data); - Hash_Add (dirs, strdup (base->data)); - qfs_get_gd_params (gdpl, gamedir, path, vars); - qfs_inherit (plist, gdpl, gamedir, path, dirs, vars); - } else if (base->type == QFArray) { - int i, num_dirs; - plitem_t *basedir_item; - const char *basedir; - - num_dirs = PL_A_NumObjects (base); - for (i = 0; i < num_dirs; i++) { - basedir_item = PL_ObjectAtIndex (base, i); - if (!basedir_item) - continue; - basedir = PL_String (basedir_item); - if (!basedir || Hash_Find (dirs, basedir)) - continue; - gdpl = PL_ObjectForKey (plist, basedir); - if (!gdpl) { - Sys_Printf ("base `%s' not found\n", basedir); - continue; + switch (PL_Type (base_item)) { + case QFString: + { + const char *base = PL_String (base_item); + if (Hash_Find (dirs, base)) + return; + gdpl = PL_ObjectForKey (plist, base); + if (!gdpl) { + Sys_Printf ("base `%s' not found\n", base); + return; + } + qfs_set_var (vars, "gamedir", base); + Hash_Add (dirs, strdup (base)); + qfs_get_gd_params (gdpl, gamedir, path, vars); + qfs_inherit (plist, gdpl, gamedir, path, dirs, vars); } - qfs_set_var (vars, "gamedir", basedir); - Hash_Add (dirs, strdup (base->data)); - qfs_get_gd_params (gdpl, gamedir, path, vars); - qfs_inherit (plist, gdpl, gamedir, path, dirs, vars); - } + break; + case QFArray: + { + int i, num_dirs; + plitem_t *basedir_item; + const char *basedir; + + num_dirs = PL_A_NumObjects (base_item); + for (i = 0; i < num_dirs; i++) { + basedir_item = PL_ObjectAtIndex (base_item, i); + if (!basedir_item) + continue; + basedir = PL_String (basedir_item); + if (!basedir || Hash_Find (dirs, basedir)) + continue; + gdpl = PL_ObjectForKey (plist, basedir); + if (!gdpl) { + Sys_Printf ("base `%s' not found\n", basedir); + continue; + } + qfs_set_var (vars, "gamedir", basedir); + Hash_Add (dirs, strdup (basedir)); + qfs_get_gd_params (gdpl, gamedir, path, vars); + qfs_inherit (plist, gdpl, gamedir, path, dirs, vars); + } + } + break; + default: + break; } } @@ -577,7 +588,7 @@ qfs_load_config (void) PL_Free (qfs_gd_plist); qfs_gd_plist = PL_GetPropertyList (buf); free (buf); - if (qfs_gd_plist && qfs_gd_plist->type == QFDictionary) + if (qfs_gd_plist && PL_Type (qfs_gd_plist) == QFDictionary) return; // done Sys_Printf ("not a dictionary\n"); no_config: diff --git a/tools/qflight/source/properties.c b/tools/qflight/source/properties.c index 9ea2cc1ef..2b76469a9 100644 --- a/tools/qflight/source/properties.c +++ b/tools/qflight/source/properties.c @@ -156,14 +156,6 @@ parse_noise (const char *arg) } } -static inline const char * -plstring (plitem_t *pl) -{ - if (pl->type == QFString) - return pl->data; - return 0; -} - static plitem_t * get_item (const char *key, plitem_t *d1, plitem_t *d2) { @@ -189,12 +181,12 @@ set_properties (entity_t *ent, plitem_t *dict) } if ((p = get_item ("light", dict, prop)) || (p = get_item ("_light", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->light = parse_light (str, ent->color); } } if ((p = get_item ("style", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->style = atoi (str); if ((unsigned) ent->style > 254) fprintf (stderr, "Bad light style %i (must be 0-254)", @@ -202,29 +194,29 @@ set_properties (entity_t *ent, plitem_t *dict) } } if ((p = get_item ("angle", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->angle = parse_float (str); } } if ((p = get_item ("wait", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->falloff = parse_float (str); ent->falloff *= ent->falloff; // presquared } } if ((p = get_item ("_lightradius", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->lightradius = parse_float (str); } } if ((p = get_item ("color", dict, prop)) || (p = get_item ("_color", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { parse_color (str, ent->color2); } } if ((p = get_item ("_attenuation", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->attenuation = parse_attenuation (str); if (ent->attenuation == -1) { ent->attenuation = options.attenuation; @@ -234,27 +226,27 @@ set_properties (entity_t *ent, plitem_t *dict) } } if ((p = get_item ("_radius", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->radius = parse_float (str); } } if ((p = get_item ("_noise", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->noise = parse_float (str); } } if ((p = get_item ("_noisetype", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->noisetype = parse_noise (str); } } if ((p = get_item ("_persistence", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->persistence = parse_float (str); } } if ((p = get_item ("_resolution", dict, prop))) { - if ((str = plstring (p))) { + if ((str = PL_String (p))) { ent->resolution = parse_float (str); } }