[gamecode] Print array contents in pr_debug_array_view

This makes it much easier to check data in progs files.
This commit is contained in:
Bill Currie 2024-02-18 14:05:06 +09:00
parent 131ad9013c
commit 4576de816d

View file

@ -1572,6 +1572,7 @@ pr_dump_struct (qfot_type_t *type, pr_type_t *value, void *_data,
dstring_appendstr (dstr, "}");
//dasprintf (dstr, "<%s>", struct_type);
}
static void
pr_debug_struct_view (qfot_type_t *type, pr_type_t *value, void *_data)
{
@ -1597,9 +1598,24 @@ static void
pr_debug_array_view (qfot_type_t *type, pr_type_t *value, void *_data)
{
__auto_type data = (pr_debug_data_t *) _data;
progs_t *pr = data->pr;
dstring_t *dstr = data->dstr;
qfot_array_t *array = &type->array;
dstring_appendstr (dstr, "<array>");
qfot_type_t *val_type = &G_STRUCT (pr, qfot_type_t, array->type);
int val_size = pr_debug_type_size (pr, val_type);
dstring_appendstr (dstr, "{");
int offset = 0;
for (int i = 0; i < array->size; i++, offset += val_size) {
pr_type_t *val = value + offset;
dasprintf (dstr, "[%d]=", array->base + i);
value_string (data, val_type, val);
if (i < array->size - 1) {
dstring_appendstr (dstr, ", ");
}
}
dstring_appendstr (dstr, "}");
}
static void