mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
more opaque correctness
This commit is contained in:
parent
fb72aaf082
commit
1442273a8f
3 changed files with 73 additions and 70 deletions
|
@ -174,7 +174,7 @@ Load_Tracklist (void)
|
||||||
Qread (oggfile, buffile, size);
|
Qread (oggfile, buffile, size);
|
||||||
|
|
||||||
tracklist = PL_GetPropertyList (buffile);
|
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");
|
Sys_Printf ("Malformed or empty tracklist file. check mus_ogglist\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -198,16 +198,16 @@ I_OGGMus_SetPlayList (int track)
|
||||||
Sys_Printf ("No Track entry for track #%d.\n", track);
|
Sys_Printf ("No Track entry for track #%d.\n", track);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (play_list->type == QFString)
|
if (PL_Type (play_list) == QFString)
|
||||||
return;
|
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);
|
Sys_Printf ("Track entry for track #%d not string or array.\n", track);
|
||||||
play_list = 0;
|
play_list = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i = 0; i < PL_A_NumObjects (play_list); i++) {
|
for (i = 0; i < PL_A_NumObjects (play_list); i++) {
|
||||||
plitem_t *item = PL_ObjectAtIndex (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);
|
Sys_Printf ("Bad subtract %d in track %d.\n", i, track);
|
||||||
play_list = 0;
|
play_list = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -224,7 +224,7 @@ I_OGGMus_PlayNext (int looping)
|
||||||
|
|
||||||
if (!play_list)
|
if (!play_list)
|
||||||
return;
|
return;
|
||||||
if (play_list->type == QFString) {
|
if (PL_Type (play_list) == QFString) {
|
||||||
track = PL_String (play_list);
|
track = PL_String (play_list);
|
||||||
play_pos = 0;
|
play_pos = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -331,7 +331,7 @@ I_OGGMus_Info (void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sys_Printf (" %s - %s\n", trackstring, (char *) currenttrack->data);
|
Sys_Printf (" %s - %s\n", trackstring, PL_String (currenttrack));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,9 +308,10 @@ qfs_get_gd_params (plitem_t *gdpl, gamedir_t *gamedir, dstring_t *path,
|
||||||
hashtab_t *vars)
|
hashtab_t *vars)
|
||||||
{
|
{
|
||||||
plitem_t *p;
|
plitem_t *p;
|
||||||
|
const char *ps;
|
||||||
|
|
||||||
if ((p = PL_ObjectForKey (gdpl, "Path")) && *(char *) p->data) {
|
if ((p = PL_ObjectForKey (gdpl, "Path")) && *(ps = PL_String (p))) {
|
||||||
char *str = qfs_var_subst (p->data, vars);
|
char *str = qfs_var_subst (ps, vars);
|
||||||
char *e = strchr (str, '"');
|
char *e = strchr (str, '"');
|
||||||
|
|
||||||
if (!e)
|
if (!e)
|
||||||
|
@ -322,45 +323,51 @@ qfs_get_gd_params (plitem_t *gdpl, gamedir_t *gamedir, dstring_t *path,
|
||||||
free (str);
|
free (str);
|
||||||
}
|
}
|
||||||
if (!gamedir->gamecode && (p = PL_ObjectForKey (gdpl, "GameCode")))
|
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")))
|
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")))
|
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")))
|
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")))
|
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
|
static void
|
||||||
qfs_inherit (plitem_t *plist, plitem_t *gdpl, gamedir_t *gamedir,
|
qfs_inherit (plitem_t *plist, plitem_t *gdpl, gamedir_t *gamedir,
|
||||||
dstring_t *path, hashtab_t *dirs, hashtab_t *vars)
|
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;
|
return;
|
||||||
if (base->type == QFString) {
|
switch (PL_Type (base_item)) {
|
||||||
if (Hash_Find (dirs, base->data))
|
case QFString:
|
||||||
|
{
|
||||||
|
const char *base = PL_String (base_item);
|
||||||
|
if (Hash_Find (dirs, base))
|
||||||
return;
|
return;
|
||||||
gdpl = PL_ObjectForKey (plist, base->data);
|
gdpl = PL_ObjectForKey (plist, base);
|
||||||
if (!gdpl) {
|
if (!gdpl) {
|
||||||
Sys_Printf ("base `%s' not found\n", (char *)base->data);
|
Sys_Printf ("base `%s' not found\n", base);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qfs_set_var (vars, "gamedir", base->data);
|
qfs_set_var (vars, "gamedir", base);
|
||||||
Hash_Add (dirs, strdup (base->data));
|
Hash_Add (dirs, strdup (base));
|
||||||
qfs_get_gd_params (gdpl, gamedir, path, vars);
|
qfs_get_gd_params (gdpl, gamedir, path, vars);
|
||||||
qfs_inherit (plist, gdpl, gamedir, path, dirs, vars);
|
qfs_inherit (plist, gdpl, gamedir, path, dirs, vars);
|
||||||
} else if (base->type == QFArray) {
|
}
|
||||||
|
break;
|
||||||
|
case QFArray:
|
||||||
|
{
|
||||||
int i, num_dirs;
|
int i, num_dirs;
|
||||||
plitem_t *basedir_item;
|
plitem_t *basedir_item;
|
||||||
const char *basedir;
|
const char *basedir;
|
||||||
|
|
||||||
num_dirs = PL_A_NumObjects (base);
|
num_dirs = PL_A_NumObjects (base_item);
|
||||||
for (i = 0; i < num_dirs; i++) {
|
for (i = 0; i < num_dirs; i++) {
|
||||||
basedir_item = PL_ObjectAtIndex (base, i);
|
basedir_item = PL_ObjectAtIndex (base_item, i);
|
||||||
if (!basedir_item)
|
if (!basedir_item)
|
||||||
continue;
|
continue;
|
||||||
basedir = PL_String (basedir_item);
|
basedir = PL_String (basedir_item);
|
||||||
|
@ -372,11 +379,15 @@ qfs_inherit (plitem_t *plist, plitem_t *gdpl, gamedir_t *gamedir,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
qfs_set_var (vars, "gamedir", basedir);
|
qfs_set_var (vars, "gamedir", basedir);
|
||||||
Hash_Add (dirs, strdup (base->data));
|
Hash_Add (dirs, strdup (basedir));
|
||||||
qfs_get_gd_params (gdpl, gamedir, path, vars);
|
qfs_get_gd_params (gdpl, gamedir, path, vars);
|
||||||
qfs_inherit (plist, gdpl, gamedir, path, dirs, vars);
|
qfs_inherit (plist, gdpl, gamedir, path, dirs, vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -577,7 +588,7 @@ qfs_load_config (void)
|
||||||
PL_Free (qfs_gd_plist);
|
PL_Free (qfs_gd_plist);
|
||||||
qfs_gd_plist = PL_GetPropertyList (buf);
|
qfs_gd_plist = PL_GetPropertyList (buf);
|
||||||
free (buf);
|
free (buf);
|
||||||
if (qfs_gd_plist && qfs_gd_plist->type == QFDictionary)
|
if (qfs_gd_plist && PL_Type (qfs_gd_plist) == QFDictionary)
|
||||||
return; // done
|
return; // done
|
||||||
Sys_Printf ("not a dictionary\n");
|
Sys_Printf ("not a dictionary\n");
|
||||||
no_config:
|
no_config:
|
||||||
|
|
|
@ -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 *
|
static plitem_t *
|
||||||
get_item (const char *key, plitem_t *d1, plitem_t *d2)
|
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))
|
if ((p = get_item ("light", dict, prop))
|
||||||
|| (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);
|
ent->light = parse_light (str, ent->color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((p = get_item ("style", dict, prop))) {
|
if ((p = get_item ("style", dict, prop))) {
|
||||||
if ((str = plstring (p))) {
|
if ((str = PL_String (p))) {
|
||||||
ent->style = atoi (str);
|
ent->style = atoi (str);
|
||||||
if ((unsigned) ent->style > 254)
|
if ((unsigned) ent->style > 254)
|
||||||
fprintf (stderr, "Bad light style %i (must be 0-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 ((p = get_item ("angle", dict, prop))) {
|
||||||
if ((str = plstring (p))) {
|
if ((str = PL_String (p))) {
|
||||||
ent->angle = parse_float (str);
|
ent->angle = parse_float (str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((p = get_item ("wait", dict, prop))) {
|
if ((p = get_item ("wait", dict, prop))) {
|
||||||
if ((str = plstring (p))) {
|
if ((str = PL_String (p))) {
|
||||||
ent->falloff = parse_float (str);
|
ent->falloff = parse_float (str);
|
||||||
ent->falloff *= ent->falloff; // presquared
|
ent->falloff *= ent->falloff; // presquared
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((p = get_item ("_lightradius", dict, prop))) {
|
if ((p = get_item ("_lightradius", dict, prop))) {
|
||||||
if ((str = plstring (p))) {
|
if ((str = PL_String (p))) {
|
||||||
ent->lightradius = parse_float (str);
|
ent->lightradius = parse_float (str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((p = get_item ("color", dict, prop))
|
if ((p = get_item ("color", dict, prop))
|
||||||
|| (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);
|
parse_color (str, ent->color2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((p = get_item ("_attenuation", dict, prop))) {
|
if ((p = get_item ("_attenuation", dict, prop))) {
|
||||||
if ((str = plstring (p))) {
|
if ((str = PL_String (p))) {
|
||||||
ent->attenuation = parse_attenuation (str);
|
ent->attenuation = parse_attenuation (str);
|
||||||
if (ent->attenuation == -1) {
|
if (ent->attenuation == -1) {
|
||||||
ent->attenuation = options.attenuation;
|
ent->attenuation = options.attenuation;
|
||||||
|
@ -234,27 +226,27 @@ set_properties (entity_t *ent, plitem_t *dict)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((p = get_item ("_radius", dict, prop))) {
|
if ((p = get_item ("_radius", dict, prop))) {
|
||||||
if ((str = plstring (p))) {
|
if ((str = PL_String (p))) {
|
||||||
ent->radius = parse_float (str);
|
ent->radius = parse_float (str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((p = get_item ("_noise", dict, prop))) {
|
if ((p = get_item ("_noise", dict, prop))) {
|
||||||
if ((str = plstring (p))) {
|
if ((str = PL_String (p))) {
|
||||||
ent->noise = parse_float (str);
|
ent->noise = parse_float (str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((p = get_item ("_noisetype", dict, prop))) {
|
if ((p = get_item ("_noisetype", dict, prop))) {
|
||||||
if ((str = plstring (p))) {
|
if ((str = PL_String (p))) {
|
||||||
ent->noisetype = parse_noise (str);
|
ent->noisetype = parse_noise (str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((p = get_item ("_persistence", dict, prop))) {
|
if ((p = get_item ("_persistence", dict, prop))) {
|
||||||
if ((str = plstring (p))) {
|
if ((str = PL_String (p))) {
|
||||||
ent->persistence = parse_float (str);
|
ent->persistence = parse_float (str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((p = get_item ("_resolution", dict, prop))) {
|
if ((p = get_item ("_resolution", dict, prop))) {
|
||||||
if ((str = plstring (p))) {
|
if ((str = PL_String (p))) {
|
||||||
ent->resolution = parse_float (str);
|
ent->resolution = parse_float (str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue