mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-25 13:51:36 +00:00
[gamecode] Clean up progs data access
pr_type_t now contains only the one "value" field, and all the access macros now use their PACKED variant for base access, making access to larger types more consistent with the smaller types.
This commit is contained in:
parent
7ef9aab7f3
commit
6d62e91ce7
24 changed files with 248 additions and 232 deletions
|
@ -403,16 +403,6 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
*/
|
||||
///@{
|
||||
|
||||
/** \internal
|
||||
\param p pointer to ::progs_t VM struct
|
||||
\param o offset into global data space
|
||||
\param t typename prefix (see pr_type_u)
|
||||
\return lvalue of the appropriate type
|
||||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define G_var(p,o,t) ((p)->pr_globals[o].t##_var)
|
||||
|
||||
/** Access a global as an arbitray type.
|
||||
|
||||
More direct than G_STRUCT
|
||||
|
@ -428,6 +418,16 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
*/
|
||||
#define G_PACKED(p,t,o) (*(t *) &(p)->pr_globals[o])
|
||||
|
||||
/** \internal
|
||||
\param p pointer to ::progs_t VM struct
|
||||
\param o offset into global data space
|
||||
\param t typename prefix (see pr_type_u)
|
||||
\return lvalue of the appropriate type
|
||||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define G_var(p,o,t) G_PACKED(p, pr_##t##_t, o)
|
||||
|
||||
/** Access a float global. Can be assigned to.
|
||||
|
||||
\par QC type:
|
||||
|
@ -450,7 +450,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define G_DOUBLE(p,o) (*(double *) ((p)->pr_globals + o))
|
||||
#define G_DOUBLE(p,o) G_var (p, o, double)
|
||||
|
||||
/** Access an int global. Can be assigned to.
|
||||
|
||||
|
@ -486,7 +486,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define G_VECTOR(p,o) (&G_var (p, o, vector))
|
||||
#define G_VECTOR(p,o) (&G_var (p, o, float))
|
||||
|
||||
/** Access a quaternion global. Can be assigned to.
|
||||
|
||||
|
@ -498,7 +498,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define G_QUAT(p,o) (&G_var (p, o, quat))
|
||||
#define G_QUAT(p,o) (&G_var (p, o, float))
|
||||
|
||||
/** Access a string index global. Can be assigned to.
|
||||
|
||||
|
@ -534,8 +534,31 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define G_POINTER(p,o) G_var (p, o, pointer)
|
||||
#define G_POINTER(p,o) G_var (p, o, ptr)
|
||||
|
||||
/** Access a field global.
|
||||
|
||||
\par QC type:
|
||||
\c field
|
||||
\param p pointer to ::progs_t VM struct
|
||||
\param o offset into global data space
|
||||
\return field offset
|
||||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define G_FIELD(p,o) G_var (p, o, field)
|
||||
|
||||
/** Access an entity global.
|
||||
|
||||
\par QC type:
|
||||
\c entity
|
||||
\param p pointer to ::progs_t VM struct
|
||||
\param o offset into global data space
|
||||
\return entity "pointer"
|
||||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define G_ENTITY(p,o) G_var (p, o, entity)
|
||||
|
||||
/** Access an entity global.
|
||||
|
||||
|
@ -620,16 +643,6 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
*/
|
||||
///@{
|
||||
|
||||
/** \internal
|
||||
\param p pointer to ::progs_t VM struct
|
||||
\param n parameter number (0-7)
|
||||
\param t typename prefix (see pr_type_u)
|
||||
\return lvalue of the appropriate type
|
||||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define P_var(p,n,t) ((p)->pr_params[n]->t##_var)
|
||||
|
||||
/** Access a parameter as an arbitray type.
|
||||
|
||||
\par QC type:
|
||||
|
@ -644,6 +657,16 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
*/
|
||||
#define P_PACKED(p,t,n) (*(t *) (p)->pr_params[n])
|
||||
|
||||
/** \internal
|
||||
\param p pointer to ::progs_t VM struct
|
||||
\param n parameter number (0-7)
|
||||
\param t typename prefix (see pr_type_u)
|
||||
\return lvalue of the appropriate type
|
||||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define P_var(p,n,t) P_PACKED(p, pr_##t##_t, n)
|
||||
|
||||
/** Access a float parameter. Can be assigned to.
|
||||
|
||||
\par QC type:
|
||||
|
@ -666,7 +689,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define P_DOUBLE(p,n) P_PACKED(p, double, n)
|
||||
#define P_DOUBLE(p,n) P_var (p, n, double)
|
||||
|
||||
/** Access an int parameter. Can be assigned to.
|
||||
|
||||
|
@ -702,7 +725,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define P_VECTOR(p,n) (&P_var (p, n, vector))
|
||||
#define P_VECTOR(p,n) (&P_var (p, n, float))
|
||||
|
||||
/** Access a quaterion parameter. Can be used any way a quat_t variable can.
|
||||
|
||||
|
@ -714,7 +737,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define P_QUAT(p,n) (&P_var (p, n, quat))
|
||||
#define P_QUAT(p,n) (&P_var (p, n, float))
|
||||
|
||||
/** Access a string index parameter. Can be assigned to.
|
||||
|
||||
|
@ -750,7 +773,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define P_POINTER(p,n) P_var (p, n, pointer)
|
||||
#define P_POINTER(p,n) P_var (p, n, ptr)
|
||||
|
||||
/** Access an entity parameter.
|
||||
|
||||
|
@ -839,16 +862,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
*/
|
||||
///@{
|
||||
|
||||
/** \internal
|
||||
\param p pointer to ::progs_t VM struct
|
||||
\param t typename prefix (see pr_type_u)
|
||||
\return lvalue of the appropriate type
|
||||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define R_var(p,t) ((p)->pr_return->t##_var)
|
||||
|
||||
/** Access the VM function return value parameter as an arbitray type.
|
||||
/** Access the VM function return value as an arbitray type.
|
||||
|
||||
\par QC type:
|
||||
\c struct etc small enough to fit in the return slot
|
||||
|
@ -861,6 +875,15 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
*/
|
||||
#define R_PACKED(p,t) (*(t *) (p)->pr_return)
|
||||
|
||||
/** \internal
|
||||
\param p pointer to ::progs_t VM struct
|
||||
\param t typename prefix (see pr_type_u)
|
||||
\return lvalue of the appropriate type
|
||||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define R_var(p,t) R_PACKED(p, pr_##t##_t)
|
||||
|
||||
/** Access the VM function return value as a \c float
|
||||
|
||||
\par QC type:
|
||||
|
@ -881,7 +904,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define R_DOUBLE(p) R_PACKED (p, double)
|
||||
#define R_DOUBLE(p) R_var (p, double)
|
||||
|
||||
/** Access the VM function return value as a \c ::pr_int_t (AKA int32_t)
|
||||
|
||||
|
@ -914,7 +937,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define R_VECTOR(p) (&R_var (p, vector))
|
||||
#define R_VECTOR(p) (&R_var (p, float))
|
||||
|
||||
/** Access the VM function return value as a \c ::quat_t quaternion.
|
||||
|
||||
|
@ -925,7 +948,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define R_QUAT(p) (&R_var (p, quat))
|
||||
#define R_QUAT(p) (&R_var (p, float))
|
||||
|
||||
/** Access the VM function return value as a ::pr_string_t (a VM string reference).
|
||||
|
||||
|
@ -958,7 +981,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define R_POINTER(p) R_var (p, pointer)
|
||||
#define R_POINTER(p) R_var (p, ptr)
|
||||
|
||||
|
||||
/** Set the return value to the given C string. The returned string will
|
||||
|
@ -1036,6 +1059,19 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
*/
|
||||
#define E_fld(e,o) ((e)->pr->pr_edict_area[(e)->edict + (o)])
|
||||
|
||||
/** Access an entity field as an arbitray type.
|
||||
|
||||
\par QC type:
|
||||
\c struct etc small enough to fit in a single parameter
|
||||
\param e pointer to the entity
|
||||
\param t C type of the structure
|
||||
\param o field offset into entity data space
|
||||
\return structure lvalue. use & to make a pointer of the
|
||||
appropriate type.
|
||||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define E_PACKED(e,t,o) (*(t *) &E_fld (e, o))
|
||||
|
||||
/** \internal
|
||||
\param e pointer to the entity
|
||||
|
@ -1045,7 +1081,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define E_var(e,o,t) (E_fld (e,o).t##_var)
|
||||
#define E_var(e,o,t) E_PACKED (e, pr_##t##_t,o)
|
||||
|
||||
|
||||
/** Access a float entity field. Can be assigned to.
|
||||
|
@ -1070,7 +1106,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define E_DOUBLE(e,o) (*(double *) ((e)->v + o))
|
||||
#define E_DOUBLE(e,o) E_var (e, o, double)
|
||||
|
||||
/** Access an int entity field. Can be assigned to.
|
||||
|
||||
|
@ -1106,7 +1142,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define E_VECTOR(e,o) (&E_var (e, o, vector))
|
||||
#define E_VECTOR(e,o) (&E_var (e, o, float))
|
||||
|
||||
/** Access a quaternion entity field. Can be used any way a quat_t variable
|
||||
can.
|
||||
|
@ -1119,7 +1155,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define E_QUAT(e,o) E_var (e, o, quat)
|
||||
#define E_QUAT(e,o) E_var (e, o, float)
|
||||
|
||||
/** Access a string index entity field. Can be assigned to.
|
||||
|
||||
|
@ -1155,7 +1191,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define E_POINTER(e,o) E_var (e, o, pointer)
|
||||
#define E_POINTER(e,o) E_var (e, o, ptr)
|
||||
|
||||
|
||||
/** Access a string entity field, converting it to a C string. Kills the
|
||||
|
|
|
@ -39,6 +39,8 @@ typedef int64_t pr_long_t __attribute__((aligned(8)));
|
|||
typedef uint64_t pr_ulong_t __attribute__((aligned(8)));
|
||||
typedef uint16_t pr_ushort_t __attribute__((aligned(2)));;
|
||||
|
||||
#define PR_PTR(t, p) (*(pr_##t##_t *) (p))
|
||||
|
||||
#define PR_VEC_TYPE(t,n,s) \
|
||||
typedef t n __attribute__ ((vector_size (s*sizeof (t))))
|
||||
|
||||
|
@ -538,16 +540,12 @@ typedef struct dfunction_s {
|
|||
dparmsize_t param_size[PR_MAX_PARAMS];
|
||||
} dfunction_t;
|
||||
|
||||
typedef union pr_type_u {
|
||||
float float_var;
|
||||
pr_string_t string_var;
|
||||
pr_func_t func_var;
|
||||
pr_uint_t entity_var;
|
||||
float vector_var; // really [3], but this structure must be 32 bits
|
||||
float quat_var; // really [4], but this structure must be 32 bits
|
||||
pr_int_t int_var;
|
||||
pr_ptr_t pointer_var;
|
||||
pr_uint_t uint_var;
|
||||
typedef struct pr_type_s {
|
||||
union {
|
||||
pr_int_t value;
|
||||
pr_uint_t uint_value;
|
||||
pr_float_t float_value;
|
||||
};
|
||||
} pr_type_t;
|
||||
|
||||
typedef pr_type_t pr_void_t; // so size of void is 1
|
||||
|
|
|
@ -337,11 +337,11 @@ parse_expression (progs_t *pr, const char *expr, int conditional)
|
|||
goto error;
|
||||
if (!Script_GetToken (es, 1))
|
||||
goto error;
|
||||
pr->wp_val.int_var = strtol (es->token->str, &e, 0);
|
||||
PR_PTR (int, &pr->wp_val) = strtol (es->token->str, &e, 0);
|
||||
if (e == es->token->str)
|
||||
goto error;
|
||||
if (*e == '.' || *e == 'e' || *e == 'E')
|
||||
pr->wp_val.float_var = strtod (es->token->str, &e);
|
||||
PR_PTR (float, &pr->wp_val) = strtod (es->token->str, &e);
|
||||
pr->wp_conditional = 1;
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ pr_debug_clear (progs_t *pr, void *data)
|
|||
|
||||
pr->watch = 0;
|
||||
pr->wp_conditional = 0;
|
||||
pr->wp_val.int_var = 0;
|
||||
PR_PTR (int, &pr->wp_val) = 0;
|
||||
|
||||
for (int i = 0; i < ev_type_count; i++ ) {
|
||||
res->type_encodings[i] = &res->void_type;
|
||||
|
@ -612,7 +612,7 @@ PR_LoadDebug (progs_t *pr)
|
|||
|
||||
if (!str)
|
||||
return 1;
|
||||
res->debugfile = PR_GetString (pr, str->string_var);
|
||||
res->debugfile = PR_GetString (pr, PR_PTR (string, str));
|
||||
sym_file = QFS_SkipPath (res->debugfile);
|
||||
path_end = QFS_SkipPath (pr->progs_name);
|
||||
sym_path = malloc (strlen (sym_file) + (path_end - pr->progs_name) + 1);
|
||||
|
@ -1152,7 +1152,7 @@ pr_debug_string_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
{
|
||||
__auto_type data = (pr_debug_data_t *) _data;
|
||||
dstring_t *dstr = data->dstr;
|
||||
pr_string_t string = value->string_var;
|
||||
pr_string_t string = PR_PTR (string, value);
|
||||
if (PR_StringValid (data->pr, string)) {
|
||||
const char *str = PR_GetString (data->pr, string);
|
||||
|
||||
|
@ -1196,11 +1196,11 @@ pr_debug_float_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
dstring_t *dstr = data->dstr;
|
||||
|
||||
if (data->pr->progs->version == PROG_ID_VERSION
|
||||
&& ISDENORM (value->int_var)
|
||||
&& value->uint_var != 0x80000000) {
|
||||
dasprintf (dstr, "<%08x>", value->int_var);
|
||||
&& ISDENORM (PR_PTR (int, value))
|
||||
&& PR_PTR (uint, value) != 0x80000000) {
|
||||
dasprintf (dstr, "<%08x>", PR_PTR (int, value));
|
||||
} else {
|
||||
dasprintf (dstr, "%.9g", value->float_var);
|
||||
dasprintf (dstr, "%.9g", PR_PTR (float, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1210,7 +1210,7 @@ pr_debug_vector_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
__auto_type data = (pr_debug_data_t *) _data;
|
||||
dstring_t *dstr = data->dstr;
|
||||
|
||||
dasprintf (dstr, "'%.9g %.9g %.9g'", VectorExpand (&value->vector_var));
|
||||
dasprintf (dstr, "'%.9g %.9g %.9g'", VectorExpand (&PR_PTR (float, value)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1221,15 +1221,15 @@ pr_debug_entity_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
dstring_t *dstr = data->dstr;
|
||||
|
||||
if (pr->pr_edicts
|
||||
&& value->entity_var < pr->max_edicts
|
||||
&& !(value->entity_var % pr->pr_edict_size)) {
|
||||
edict_t *edict = PROG_TO_EDICT (pr, value->entity_var);
|
||||
&& PR_PTR (entity, value) < pr->max_edicts
|
||||
&& !(PR_PTR (entity, value) % pr->pr_edict_size)) {
|
||||
edict_t *edict = PROG_TO_EDICT (pr, PR_PTR (entity, value));
|
||||
if (edict) {
|
||||
dasprintf (dstr, "entity %d", NUM_FOR_BAD_EDICT (pr, edict));
|
||||
return;
|
||||
}
|
||||
}
|
||||
dasprintf (dstr, "entity [%x]", value->entity_var);
|
||||
dasprintf (dstr, "entity [%x]", PR_PTR (entity, value));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1238,12 +1238,12 @@ pr_debug_field_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;
|
||||
pr_def_t *def = PR_FieldAtOfs (pr, value->int_var);
|
||||
pr_def_t *def = PR_FieldAtOfs (pr, PR_PTR (int, value));
|
||||
|
||||
if (def) {
|
||||
dasprintf (dstr, ".%s", PR_GetString (pr, def->name));
|
||||
} else {
|
||||
dasprintf (dstr, ".<$%04x>", value->int_var);
|
||||
dasprintf (dstr, ".<$%04x>", PR_PTR (int, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1254,12 +1254,12 @@ pr_debug_func_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
progs_t *pr = data->pr;
|
||||
dstring_t *dstr = data->dstr;
|
||||
|
||||
if (value->func_var >= pr->progs->functions.count) {
|
||||
dasprintf (dstr, "INVALID:%d", value->func_var);
|
||||
} else if (!value->func_var) {
|
||||
if (PR_PTR (func, value) >= pr->progs->functions.count) {
|
||||
dasprintf (dstr, "INVALID:%d", PR_PTR (func, value));
|
||||
} else if (!PR_PTR (func, value)) {
|
||||
dstring_appendstr (dstr, "NULL");
|
||||
} else {
|
||||
dfunction_t *f = pr->pr_functions + value->func_var;
|
||||
dfunction_t *f = pr->pr_functions + PR_PTR (func, value);
|
||||
dasprintf (dstr, "%s()", PR_GetString (pr, f->name));
|
||||
}
|
||||
}
|
||||
|
@ -1270,7 +1270,7 @@ pr_debug_ptr_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;
|
||||
pr_ptr_t offset = value->int_var;
|
||||
pr_ptr_t offset = PR_PTR (int, value);
|
||||
pr_ptr_t offs = offset;
|
||||
pr_def_t *def = 0;
|
||||
|
||||
|
@ -1292,7 +1292,7 @@ pr_debug_quaternion_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
__auto_type data = (pr_debug_data_t *) _data;
|
||||
dstring_t *dstr = data->dstr;
|
||||
|
||||
dasprintf (dstr, "'%.9g %.9g %.9g %.9g'", QuatExpand (&value->quat_var));
|
||||
dasprintf (dstr, "'%.9g %.9g %.9g %.9g'", QuatExpand (&PR_PTR (float, value)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1301,7 +1301,7 @@ pr_debug_int_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
__auto_type data = (pr_debug_data_t *) _data;
|
||||
dstring_t *dstr = data->dstr;
|
||||
|
||||
dasprintf (dstr, "%d", value->int_var);
|
||||
dasprintf (dstr, "%d", PR_PTR (int, value));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1310,7 +1310,7 @@ pr_debug_uint_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
__auto_type data = (pr_debug_data_t *) _data;
|
||||
dstring_t *dstr = data->dstr;
|
||||
|
||||
dasprintf (dstr, "$%08x", value->uint_var);
|
||||
dasprintf (dstr, "$%08x", PR_PTR (uint, value));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1319,7 +1319,7 @@ pr_debug_short_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
__auto_type data = (pr_debug_data_t *) _data;
|
||||
dstring_t *dstr = data->dstr;
|
||||
|
||||
dasprintf (dstr, "%04x", (short)value->int_var);
|
||||
dasprintf (dstr, "%04x", (short)PR_PTR (int, value));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1355,7 +1355,7 @@ pr_debug_ushort_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
__auto_type data = (pr_debug_data_t *) _data;
|
||||
dstring_t *dstr = data->dstr;
|
||||
|
||||
dasprintf (dstr, "%04x", (pr_ushort_t)value->int_var);
|
||||
dasprintf (dstr, "%04x", (pr_ushort_t)PR_PTR (int, value));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1431,7 +1431,7 @@ PR_Debug_Watch (progs_t *pr, const char *expr)
|
|||
(int) (intptr_t) (pr->watch - pr->pr_globals));
|
||||
if (pr->wp_conditional)
|
||||
Sys_Printf (" if new val == %d\n",
|
||||
pr->wp_val.int_var);
|
||||
PR_PTR (int, &pr->wp_val));
|
||||
} else { Sys_Printf (" none active\n");
|
||||
}
|
||||
return;
|
||||
|
@ -1444,7 +1444,7 @@ PR_Debug_Watch (progs_t *pr, const char *expr)
|
|||
if (pr->watch) {
|
||||
Sys_Printf ("watchpoint set to [%d]\n", PR_SetPointer (pr, pr->watch));
|
||||
if (pr->wp_conditional)
|
||||
Sys_Printf (" if new val == %d\n", pr->wp_val.int_var);
|
||||
Sys_Printf (" if new val == %d\n", PR_PTR (int, &pr->wp_val));
|
||||
} else {
|
||||
Sys_Printf ("watchpoint cleared\n");
|
||||
}
|
||||
|
@ -1683,8 +1683,8 @@ PR_PrintStatement (progs_t *pr, dstatement_t *s, int contents)
|
|||
case 'E':
|
||||
{
|
||||
edict_t *ed = 0;
|
||||
opval = pr->pr_globals[s->a].entity_var;
|
||||
param_ind = pr->pr_globals[s->b].uint_var;
|
||||
opval = G_ENTITY (pr, s->a);
|
||||
param_ind = G_FIELD (pr, s->b);
|
||||
if (param_ind < pr->progs->entityfields
|
||||
&& opval > 0
|
||||
&& opval < pr->pr_edict_area_size) {
|
||||
|
|
|
@ -287,7 +287,7 @@ PR_EnterFunction (progs_t *pr, bfunction_t *f)
|
|||
if (pr_deadbeef_locals) {
|
||||
for (pr_uint_t i = f->params_start;
|
||||
i < f->params_start + f->locals; i++) {
|
||||
pr->pr_globals[i].int_var = 0xdeadbeef;
|
||||
pr->pr_globals[i].value = 0xdeadbeef;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,8 +304,8 @@ PR_EnterFunction (progs_t *pr, bfunction_t *f)
|
|||
copy_param (dstParams[i], pr->pr_params[i], f->param_size[i].size);
|
||||
}
|
||||
copy_args = pr->pr_argc - i;
|
||||
argc->int_var = copy_args;
|
||||
argv->int_var = dstParams[i] - pr->pr_globals;
|
||||
PR_PTR (int, argc) = copy_args;
|
||||
PR_PTR (ptr, argv) = PR_SetPointer (pr, dstParams[i]);
|
||||
if (i < PR_MAX_PARAMS) {
|
||||
memcpy (dstParams[i], pr->pr_params[i],
|
||||
(copy_args * pr->pr_param_size) * sizeof (pr_type_t));
|
||||
|
@ -517,7 +517,7 @@ static inline void
|
|||
pr_memset (pr_type_t *dst, int val, pr_uint_t count)
|
||||
{
|
||||
while (count-- > 0) {
|
||||
(*dst++).int_var = val;
|
||||
(*dst++).value = val;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -839,7 +839,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
ptr->int_var = OPA(int);
|
||||
ptr->value = OPA(int);
|
||||
break;
|
||||
case OP_STOREP_V_v6p:
|
||||
pointer = OPB(ptr);
|
||||
|
@ -847,7 +847,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_vector);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
VectorCopy (&OPA(float), &ptr->vector_var);
|
||||
VectorCopy (&OPA(float), &PR_PTR (float, ptr));
|
||||
break;
|
||||
case OP_STOREP_Q_v6p:
|
||||
pointer = OPB(ptr);
|
||||
|
@ -855,7 +855,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
QuatCopy (&OPA(float), &ptr->quat_var);
|
||||
QuatCopy (&OPA(float), &PR_PTR (float, ptr));
|
||||
break;
|
||||
case OP_STOREP_D_v6p:
|
||||
pointer = OPB(ptr);
|
||||
|
@ -910,7 +910,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
"field in an edict");
|
||||
}
|
||||
fldofs = OPA(entity) + OPB(field);
|
||||
OPC(int) = pr->pr_edict_area[fldofs].int_var;
|
||||
OPC(int) = PR_PTR (int, &pr->pr_edict_area[fldofs]);
|
||||
break;
|
||||
case OP_LOAD_V_v6p:
|
||||
if (pr_boundscheck) {
|
||||
|
@ -961,23 +961,21 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
OPC(int) = ptr->int_var;
|
||||
OPC(int) = ptr->value;
|
||||
break;
|
||||
case OP_LOADB_V_v6p:
|
||||
pointer = OPA(entity) + OPB(field);
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_vector);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
VectorCopy (&ptr->vector_var, &OPC(float));
|
||||
VectorCopy (G_VECTOR (pr, pointer), &OPC(float));
|
||||
break;
|
||||
case OP_LOADB_Q_v6p:
|
||||
pointer = OPA(entity) + OPB(field);
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
QuatCopy (&ptr->quat_var, &OPC(float));
|
||||
QuatCopy (G_QUAT (pr, pointer), &OPC(float));
|
||||
break;
|
||||
case OP_LOADB_D_v6p:
|
||||
pointer = OPA(entity) + OPB(field);
|
||||
|
@ -1000,7 +998,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
OPC(int) = ptr->int_var;
|
||||
OPC(int) = ptr->value;
|
||||
break;
|
||||
case OP_LOADBI_V_v6p:
|
||||
pointer = OPA(ptr) + (short) st->b;
|
||||
|
@ -1008,7 +1006,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_vector);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
VectorCopy (&ptr->vector_var, &OPC(float));
|
||||
VectorCopy (G_VECTOR (pr, pointer), &OPC(float));
|
||||
break;
|
||||
case OP_LOADBI_Q_v6p:
|
||||
pointer = OPA(ptr) + (short) st->b;
|
||||
|
@ -1016,7 +1014,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
QuatCopy (&ptr->quat_var, &OPC(float));
|
||||
QuatCopy (G_QUAT (pr, pointer), &OPC(float));
|
||||
break;
|
||||
case OP_LOADBI_D_v6p:
|
||||
pointer = OPA(ptr) + (short) st->b;
|
||||
|
@ -1049,7 +1047,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
ptr->int_var = OPA(int);
|
||||
ptr->value = OPA(int);
|
||||
break;
|
||||
case OP_STOREB_V_v6p:
|
||||
pointer = OPB(ptr) + OPC(int);
|
||||
|
@ -1057,7 +1055,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_vector);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
VectorCopy (&OPA(float), &ptr->vector_var);
|
||||
VectorCopy (&OPA(float), G_VECTOR (pr, pointer));
|
||||
break;
|
||||
case OP_STOREB_Q_v6p:
|
||||
pointer = OPB(ptr) + OPC(int);
|
||||
|
@ -1065,7 +1063,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
QuatCopy (&OPA(float), &ptr->quat_var);
|
||||
QuatCopy (&OPA(float), G_QUAT (pr, pointer));
|
||||
break;
|
||||
case OP_STOREB_D_v6p:
|
||||
pointer = OPB(ptr) + OPC(int);
|
||||
|
@ -1088,7 +1086,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
ptr->int_var = OPA(int);
|
||||
ptr->value = OPA(int);
|
||||
break;
|
||||
case OP_STOREBI_V_v6p:
|
||||
pointer = OPB(ptr) + (short) st->c;
|
||||
|
@ -1096,7 +1094,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_vector);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
VectorCopy (&OPA(float), &ptr->vector_var);
|
||||
VectorCopy (&OPA(float), G_VECTOR (pr, pointer));
|
||||
break;
|
||||
case OP_STOREBI_Q_v6p:
|
||||
pointer = OPB(ptr) + (short) st->c;
|
||||
|
@ -1104,7 +1102,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
QuatCopy (&OPA(float), &ptr->quat_var);
|
||||
QuatCopy (&OPA(float), G_QUAT (pr, pointer));
|
||||
break;
|
||||
case OP_STOREBI_D_v6p:
|
||||
pointer = OPB(ptr) + (short) st->c;
|
||||
|
@ -1128,7 +1126,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 1);
|
||||
}
|
||||
stk->int_var = OPA(int);
|
||||
stk->value = OPA(int);
|
||||
*pr->globals.stack = stack;
|
||||
}
|
||||
break;
|
||||
|
@ -1174,14 +1172,13 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
||||
stk->int_var = ptr->int_var;
|
||||
stk->value = ptr->value;
|
||||
*pr->globals.stack = stack;
|
||||
}
|
||||
break;
|
||||
case OP_PUSHB_V_v6p:
|
||||
{
|
||||
pr_ptr_t stack = *pr->globals.stack - 3;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
|
||||
pointer = OPA(ptr) + OPB(int);
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1191,14 +1188,13 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
||||
VectorCopy (&ptr->vector_var, &stk->vector_var);
|
||||
VectorCopy (G_VECTOR (pr, pointer), G_VECTOR (pr, stack));
|
||||
*pr->globals.stack = stack;
|
||||
}
|
||||
break;
|
||||
case OP_PUSHB_Q_v6p:
|
||||
{
|
||||
pr_ptr_t stack = *pr->globals.stack - 4;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
|
||||
pointer = OPA(ptr) + OPB(int);
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1208,7 +1204,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
|
||||
QuatCopy (&ptr->quat_var, &stk->quat_var);
|
||||
QuatCopy (G_QUAT (pr, pointer), G_QUAT (pr, stack));
|
||||
*pr->globals.stack = stack;
|
||||
}
|
||||
break;
|
||||
|
@ -1232,14 +1228,13 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
||||
stk->int_var = ptr->int_var;
|
||||
stk->value = ptr->value;
|
||||
*pr->globals.stack = stack;
|
||||
}
|
||||
break;
|
||||
case OP_PUSHBI_V_v6p:
|
||||
{
|
||||
pr_ptr_t stack = *pr->globals.stack - 3;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
|
||||
pointer = OPA(ptr) + st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1249,14 +1244,13 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
||||
VectorCopy (&ptr->vector_var, &stk->vector_var);
|
||||
VectorCopy (G_VECTOR (pr, pointer), G_VECTOR (pr, stack));
|
||||
*pr->globals.stack = stack;
|
||||
}
|
||||
break;
|
||||
case OP_PUSHBI_Q_v6p:
|
||||
{
|
||||
pr_ptr_t stack = *pr->globals.stack - 4;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
|
||||
pointer = OPA(ptr) + st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1266,7 +1260,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
|
||||
QuatCopy (&ptr->quat_var, &stk->quat_var);
|
||||
QuatCopy (G_QUAT (pr, pointer), G_QUAT (pr, stack));
|
||||
*pr->globals.stack = stack;
|
||||
}
|
||||
break;
|
||||
|
@ -1284,7 +1278,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 1);
|
||||
}
|
||||
OPA(int) = stk->int_var;
|
||||
OPA(int) = stk->value;
|
||||
*pr->globals.stack = stack + 1;
|
||||
}
|
||||
break;
|
||||
|
@ -1330,14 +1324,13 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
||||
ptr->int_var = stk->int_var;
|
||||
ptr->value = stk->value;
|
||||
*pr->globals.stack = stack + 1;
|
||||
}
|
||||
break;
|
||||
case OP_POPB_V_v6p:
|
||||
{
|
||||
pr_ptr_t stack = *pr->globals.stack;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
|
||||
pointer = OPA(ptr) + OPB(int);
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1347,14 +1340,13 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
||||
VectorCopy (&stk->vector_var, &ptr->vector_var);
|
||||
VectorCopy (G_VECTOR (pr, stack), G_VECTOR (pr, pointer));
|
||||
*pr->globals.stack = stack + 3;
|
||||
}
|
||||
break;
|
||||
case OP_POPB_Q_v6p:
|
||||
{
|
||||
pr_ptr_t stack = *pr->globals.stack;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
|
||||
pointer = OPA(ptr) + OPB(int);
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1364,7 +1356,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
|
||||
QuatCopy (&stk->quat_var, &ptr->quat_var);
|
||||
QuatCopy (G_QUAT (pr, stack), G_QUAT (pr, pointer));
|
||||
*pr->globals.stack = stack + 4;
|
||||
}
|
||||
break;
|
||||
|
@ -1388,14 +1380,13 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
||||
ptr->int_var = stk->int_var;
|
||||
ptr->value = stk->value;
|
||||
*pr->globals.stack = stack + 1;
|
||||
}
|
||||
break;
|
||||
case OP_POPBI_V_v6p:
|
||||
{
|
||||
pr_ptr_t stack = *pr->globals.stack;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
|
||||
pointer = OPA(ptr) + st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1405,14 +1396,13 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
||||
VectorCopy (&stk->vector_var, &ptr->vector_var);
|
||||
VectorCopy (G_VECTOR (pr, stack), G_VECTOR (pr, pointer));
|
||||
*pr->globals.stack = stack + 3;
|
||||
}
|
||||
break;
|
||||
case OP_POPBI_Q_v6p:
|
||||
{
|
||||
pr_ptr_t stack = *pr->globals.stack;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
|
||||
pointer = OPA(ptr) + st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1422,7 +1412,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
|
||||
QuatCopy (&stk->quat_var, &ptr->quat_var);
|
||||
QuatCopy (G_QUAT (pr, stack), G_QUAT (pr, pointer));
|
||||
*pr->globals.stack = stack + 4;
|
||||
}
|
||||
break;
|
||||
|
@ -1481,8 +1471,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
pointer = ptr->int_var;
|
||||
pointer = G_POINTER (pr, pointer);
|
||||
if (pr_boundscheck
|
||||
&& (pointer >= pr->progs->statements.count)) {
|
||||
PR_RunError (pr, "Invalid jump destination");
|
||||
|
@ -1551,9 +1540,9 @@ op_call:
|
|||
int frame = pr->fields.frame + self;
|
||||
int think = pr->fields.think + self;
|
||||
float time = *pr->globals.ftime + 0.1;
|
||||
pr->pr_edict_area[nextthink].float_var = time;
|
||||
pr->pr_edict_area[frame].float_var = OPA(float);
|
||||
pr->pr_edict_area[think].func_var = OPB(func);
|
||||
PR_PTR (float, &pr->pr_edict_area[nextthink]) = time;
|
||||
PR_PTR (float, &pr->pr_edict_area[frame]) = OPA(float);
|
||||
PR_PTR (func, &pr->pr_edict_area[think]) = OPB(func);
|
||||
}
|
||||
break;
|
||||
case OP_STATE_F_v6p:
|
||||
|
@ -1563,9 +1552,9 @@ op_call:
|
|||
int frame = pr->fields.frame + self;
|
||||
int think = pr->fields.think + self;
|
||||
float time = *pr->globals.ftime + OPC(float);
|
||||
pr->pr_edict_area[nextthink].float_var = time;
|
||||
pr->pr_edict_area[frame].float_var = OPA(float);
|
||||
pr->pr_edict_area[think].func_var = OPB(func);
|
||||
PR_PTR (float, &pr->pr_edict_area[nextthink]) = time;
|
||||
PR_PTR (float, &pr->pr_edict_area[frame]) = OPA(float);
|
||||
PR_PTR (func, &pr->pr_edict_area[think]) = OPB(func);
|
||||
}
|
||||
break;
|
||||
case OP_ADD_I_v6p:
|
||||
|
@ -1748,8 +1737,7 @@ op_call:
|
|||
OPC(float) = OPA(double) < OPB(double);
|
||||
break;
|
||||
case OP_NOT_D_v6p:
|
||||
OPC(int) = (op_a[0].int_var
|
||||
|| (op_a[1].int_var & ~0x80000000u));
|
||||
OPC(int) = (op_a[0].value || (op_a[1].value & ~0x80000000u));
|
||||
break;
|
||||
case OP_EQ_D_v6p:
|
||||
OPC(int) = OPA(double) == OPB(double);
|
||||
|
@ -1783,17 +1771,17 @@ op_call:
|
|||
default:
|
||||
PR_RunError (pr, "Bad opcode %i", st->op & ~OP_BREAK);
|
||||
}
|
||||
if (pr->watch && pr->watch->int_var != old_val.int_var) {
|
||||
if (pr->watch && pr->watch->value != old_val.value) {
|
||||
if (!pr->wp_conditional
|
||||
|| pr->watch->int_var == pr->wp_val.int_var) {
|
||||
|| pr->watch->value == pr->wp_val.value) {
|
||||
if (pr->debug_handler) {
|
||||
pr->debug_handler (prd_watchpoint, 0, pr->debug_data);
|
||||
} else {
|
||||
PR_RunError (pr, "watchpoint hit: %d -> %d",
|
||||
old_val.int_var, pr->watch->int_var);
|
||||
old_val.value, pr->watch->value);
|
||||
}
|
||||
}
|
||||
old_val.int_var = pr->watch->int_var;
|
||||
old_val.value = pr->watch->value;
|
||||
}
|
||||
}
|
||||
exit_program:
|
||||
|
@ -1877,7 +1865,7 @@ pr_jump_mode (progs_t *pr, const dstatement_t *st, int jump_ind)
|
|||
break;
|
||||
case 1:
|
||||
// variable indexed array: a + *b (only +ve)
|
||||
jump_offs = (op_a + OPB(uint))->uint_var;
|
||||
jump_offs = PR_PTR (uint, op_a + OPB(uint));
|
||||
break;
|
||||
case 2:
|
||||
// constant indexed pointer: *a + b (supports -ve offset)
|
||||
|
@ -1963,7 +1951,7 @@ pr_with (progs_t *pr, const dstatement_t *st)
|
|||
|
||||
case 4:
|
||||
// hard-0 base
|
||||
pr->pr_bases[st->c & 3] = pr->pr_globals[st->b].pointer_var;
|
||||
pr->pr_bases[st->c & 3] = G_POINTER (pr, st->b);;
|
||||
return;
|
||||
case 5:
|
||||
pr->pr_bases[st->c & 3] = OPB(ptr);
|
||||
|
@ -2571,7 +2559,7 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
|||
case OP_CALL_C:
|
||||
case OP_CALL_D:
|
||||
mm = pr_call_mode (pr, st, st_op - OP_CALL_B + 1);
|
||||
function = mm->func_var;
|
||||
function = PR_PTR (func, mm);
|
||||
pr->pr_argc = 0;
|
||||
// op_c specifies the location for the return value if any
|
||||
pr->pr_xfunction->profile += profile - startprofile;
|
||||
|
@ -2714,9 +2702,9 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
|||
int frame = pr->fields.frame + self;
|
||||
int think = pr->fields.think + self;
|
||||
float time = *pr->globals.ftime + 0.1;
|
||||
pr->pr_edict_area[nextthink].float_var = time;
|
||||
pr->pr_edict_area[frame].float_var = OPA(float);
|
||||
pr->pr_edict_area[think].func_var = op_b->func_var;
|
||||
PR_PTR (float, &pr->pr_edict_area[nextthink]) = time;
|
||||
PR_PTR (float, &pr->pr_edict_area[frame]) = OPA(float);
|
||||
PR_PTR (func, &pr->pr_edict_area[think]) = OPB(func);
|
||||
}
|
||||
break;
|
||||
OP_cmp_T (GE, U, long, lvec2, lvec4, >=, ulong, ulvec2, ulvec4);
|
||||
|
@ -2736,9 +2724,9 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
|||
int frame = pr->fields.frame + self;
|
||||
int think = pr->fields.think + self;
|
||||
float time = *pr->globals.ftime + OPC(float);
|
||||
pr->pr_edict_area[nextthink].float_var = time;
|
||||
pr->pr_edict_area[frame].float_var = OPA(float);
|
||||
pr->pr_edict_area[think].func_var = op_b->func_var;
|
||||
PR_PTR (float, &pr->pr_edict_area[nextthink]) = time;
|
||||
PR_PTR (float, &pr->pr_edict_area[frame]) = OPA(float);
|
||||
PR_PTR (func, &pr->pr_edict_area[think]) = OPB(func);
|
||||
}
|
||||
break;
|
||||
// 1 1110
|
||||
|
@ -2768,9 +2756,9 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
|||
int frame = pr->fields.frame + self;
|
||||
int think = pr->fields.think + self;
|
||||
double time = *pr->globals.dtime + 0.1;
|
||||
*(double *) (&pr->pr_edict_area[nextthink]) = time;
|
||||
pr->pr_edict_area[frame].int_var = OPA(int);
|
||||
pr->pr_edict_area[think].func_var = op_b->func_var;
|
||||
PR_PTR (double, &pr->pr_edict_area[nextthink]) = time;
|
||||
PR_PTR (int, &pr->pr_edict_area[frame]) = OPA(int);
|
||||
PR_PTR (func, &pr->pr_edict_area[think]) = OPB(func);
|
||||
}
|
||||
break;
|
||||
OP_cmp_T (LE, U, long, lvec2, lvec4, <=, ulong, ulvec2, ulvec4);
|
||||
|
@ -2799,9 +2787,9 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
|||
int frame = pr->fields.frame + self;
|
||||
int think = pr->fields.think + self;
|
||||
double time = *pr->globals.dtime + OPC(double);
|
||||
*(double *) (&pr->pr_edict_area[nextthink]) = time;
|
||||
pr->pr_edict_area[frame].int_var = OPA(int);
|
||||
pr->pr_edict_area[think].func_var = op_b->func_var;
|
||||
PR_PTR (double, &pr->pr_edict_area[nextthink]) = time;
|
||||
PR_PTR (int, &pr->pr_edict_area[frame]) = OPA(int);
|
||||
PR_PTR (func, &pr->pr_edict_area[think]) = OPB(func);
|
||||
}
|
||||
break;
|
||||
// 1 1111
|
||||
|
@ -2810,7 +2798,7 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
|||
case OP_LEA_C:
|
||||
case OP_LEA_D:
|
||||
mm = pr_address_mode (pr, st, (st_op - OP_LEA_A));
|
||||
op_c->pointer_var = mm - pr->pr_globals;
|
||||
OPC(ptr) = mm - pr->pr_globals;
|
||||
break;
|
||||
case OP_QV4MUL_F:
|
||||
OPC(vec4) = qvmulf (OPA(vec4), OPB(vec4));
|
||||
|
@ -2862,17 +2850,17 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
|||
default:
|
||||
PR_RunError (pr, "Bad opcode o%03o", st->op & OP_MASK);
|
||||
}
|
||||
if (pr->watch && pr->watch->int_var != old_val.int_var) {
|
||||
if (pr->watch && pr->watch->value != old_val.value) {
|
||||
if (!pr->wp_conditional
|
||||
|| pr->watch->int_var == pr->wp_val.int_var) {
|
||||
|| pr->watch->value == pr->wp_val.value) {
|
||||
if (pr->debug_handler) {
|
||||
pr->debug_handler (prd_watchpoint, 0, pr->debug_data);
|
||||
} else {
|
||||
PR_RunError (pr, "watchpoint hit: %d -> %d",
|
||||
old_val.int_var, pr->watch->int_var);
|
||||
old_val.value, pr->watch->value);
|
||||
}
|
||||
}
|
||||
old_val.int_var = pr->watch->int_var;
|
||||
old_val.value = pr->watch->value;
|
||||
}
|
||||
}
|
||||
exit_program:
|
||||
|
|
|
@ -68,34 +68,34 @@ PR_UglyValueString (progs_t *pr, etype_t type, pr_type_t *val, dstring_t *line)
|
|||
|
||||
switch (type) {
|
||||
case ev_string:
|
||||
dsprintf (line, "%s", PR_GetString (pr, val->string_var));
|
||||
dsprintf (line, "%s", PR_GetString (pr, PR_PTR (string, val)));
|
||||
break;
|
||||
case ev_entity:
|
||||
dsprintf (line, "%d",
|
||||
NUM_FOR_BAD_EDICT (pr, PROG_TO_EDICT (pr, val->entity_var)));
|
||||
NUM_FOR_BAD_EDICT (pr, PROG_TO_EDICT (pr, PR_PTR (entity, val))));
|
||||
break;
|
||||
case ev_func:
|
||||
f = pr->pr_functions + val->func_var;
|
||||
f = pr->pr_functions + PR_PTR (func, val);
|
||||
dsprintf (line, "%s", PR_GetString (pr, f->name));
|
||||
break;
|
||||
case ev_field:
|
||||
def = PR_FieldAtOfs (pr, val->int_var);
|
||||
def = PR_FieldAtOfs (pr, PR_PTR (int, val));
|
||||
dsprintf (line, "%s", PR_GetString (pr, def->name));
|
||||
break;
|
||||
case ev_void:
|
||||
dstring_copystr (line, "void");
|
||||
break;
|
||||
case ev_float:
|
||||
dsprintf (line, "%.9g", val->float_var);
|
||||
dsprintf (line, "%.9g", PR_PTR (float, val));
|
||||
break;
|
||||
case ev_int:
|
||||
dsprintf (line, "%d", val->int_var);
|
||||
dsprintf (line, "%d", PR_PTR (int, val));
|
||||
break;
|
||||
case ev_vector:
|
||||
dsprintf (line, "%.9g %.9g %.9g", VectorExpand (&val->vector_var));
|
||||
dsprintf (line, "%.9g %.9g %.9g", VectorExpand (&PR_PTR (float, val)));
|
||||
break;
|
||||
case ev_quaternion:
|
||||
dsprintf (line, "%.9g %.9g %.9g %.9g", QuatExpand (&val->quat_var));
|
||||
dsprintf (line, "%.9g %.9g %.9g %.9g", QuatExpand (&PR_PTR (float, val)));
|
||||
break;
|
||||
default:
|
||||
dsprintf (line, "bad type %i", type);
|
||||
|
@ -132,7 +132,7 @@ ED_EntityDict (progs_t *pr, edict_t *ed)
|
|||
// if the value is still all 0, skip the field
|
||||
type = d->type & ~DEF_SAVEGLOBAL;
|
||||
for (j = 0; j < pr_type_size[type]; j++)
|
||||
if (v[j].int_var)
|
||||
if (v[j].value)
|
||||
break;
|
||||
if (j == pr_type_size[type])
|
||||
continue;
|
||||
|
@ -226,11 +226,11 @@ ED_ParseEpair (progs_t *pr, pr_type_t *base, pr_def_t *key, const char *s)
|
|||
|
||||
switch (key->type & ~DEF_SAVEGLOBAL) {
|
||||
case ev_string:
|
||||
d->string_var = ED_NewString (pr, s);
|
||||
PR_PTR (string, d) = ED_NewString (pr, s);
|
||||
break;
|
||||
|
||||
case ev_float:
|
||||
d->float_var = atof (s);
|
||||
PR_PTR (float, d) = atof (s);
|
||||
break;
|
||||
|
||||
case ev_vector:
|
||||
|
@ -241,14 +241,14 @@ ED_ParseEpair (progs_t *pr, pr_type_t *base, pr_def_t *key, const char *s)
|
|||
while (*v && *v != ' ')
|
||||
v++;
|
||||
*v = 0;
|
||||
(&d->vector_var)[i] = atof (w);
|
||||
(&PR_PTR (float, d))[i] = atof (w);
|
||||
w = v = v + 1;
|
||||
}
|
||||
free (string);
|
||||
break;
|
||||
|
||||
case ev_entity:
|
||||
d->entity_var = EDICT_TO_PROG (pr, EDICT_NUM (pr, atoi (s)));
|
||||
PR_PTR (entity, d) = EDICT_TO_PROG (pr, EDICT_NUM (pr, atoi (s)));
|
||||
break;
|
||||
|
||||
case ev_field:
|
||||
|
@ -257,7 +257,7 @@ ED_ParseEpair (progs_t *pr, pr_type_t *base, pr_def_t *key, const char *s)
|
|||
Sys_Printf ("Can't find field %s\n", s);
|
||||
return false;
|
||||
}
|
||||
d->int_var = G_INT (pr, def->ofs);
|
||||
PR_PTR (int, d) = G_INT (pr, def->ofs);
|
||||
break;
|
||||
|
||||
case ev_func:
|
||||
|
@ -266,7 +266,7 @@ ED_ParseEpair (progs_t *pr, pr_type_t *base, pr_def_t *key, const char *s)
|
|||
Sys_Printf ("Can't find function %s\n", s);
|
||||
return false;
|
||||
}
|
||||
d->func_var = func - pr->pr_functions;
|
||||
PR_PTR (func, d) = func - pr->pr_functions;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -860,9 +860,7 @@ fmt_append_item (fmt_state_t *state)
|
|||
}
|
||||
|
||||
#undef P_var
|
||||
#define P_var(p,n,t) (state->args[n]->t##_var)
|
||||
#undef P_DOUBLE
|
||||
#define P_DOUBLE(p,n) (*(double *) (state->args[n]))
|
||||
#define P_var(p,n,t) PR_PTR (t, state->args[n])
|
||||
|
||||
/** State machine for PR_Sprintf
|
||||
*
|
||||
|
|
|
@ -86,7 +86,8 @@ bi_gib_builtin_f (void)
|
|||
pr_list = PR_Zone_Malloc (builtin->pr, GIB_Argc() * sizeof (pr_type_t));
|
||||
|
||||
for (i = 0; i < GIB_Argc(); i++)
|
||||
pr_list[i].int_var = PR_SetTempString (builtin->pr, GIB_Argv(i));
|
||||
PR_PTR (string, &pr_list[i]) = PR_SetTempString (builtin->pr,
|
||||
GIB_Argv(i));
|
||||
|
||||
PR_RESET_PARAMS (builtin->pr);
|
||||
P_INT (builtin->pr, 0) = GIB_Argc();
|
||||
|
|
|
@ -62,10 +62,10 @@ PF_VarString (progs_t *pr, int first, int argc)
|
|||
pr_type_t **argv = pr->pr_params;
|
||||
|
||||
for (len = 0, i = first; i < argc; i++)
|
||||
len += strlen (PR_GetString (pr, argv[i]->string_var));
|
||||
len += strlen (PR_GetString (pr, *(pr_string_t *) argv[i]));
|
||||
dst = out = Hunk_TempAlloc (0, len + 1);
|
||||
for (i = first; i < argc; i++) {
|
||||
src = PR_GetString (pr, argv[i]->string_var);
|
||||
src = PR_GetString (pr, PR_PTR (string, argv[i]));
|
||||
while (*src)
|
||||
*dst++ = *src++;
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ bi_Hash_FindList (progs_t *pr, void *_res)
|
|||
pr_list = PR_Zone_Malloc (pr, count * sizeof (pr_type_t));
|
||||
// the hash tables stores progs pointers...
|
||||
for (count = 0, l = list; *l; l++)
|
||||
pr_list[count++].int_var = (intptr_t) *l;
|
||||
PR_PTR (ptr, &pr_list[count++]) = (intptr_t) *l;
|
||||
free (list);
|
||||
RETURN_POINTER (pr, pr_list);
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ bi_Hash_FindElementList (progs_t *pr, void *_res)
|
|||
pr_list = PR_Zone_Malloc (pr, count * sizeof (pr_type_t));
|
||||
// the hash tables stores progs pointers...
|
||||
for (count = 0, l = list; *l; l++)
|
||||
pr_list[count++].int_var = (intptr_t) *l;
|
||||
PR_PTR (ptr, &pr_list[count++]) = (intptr_t) *l;
|
||||
free (list);
|
||||
RETURN_POINTER (pr, pr_list);
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ bi_Hash_GetList (progs_t *pr, void *_res)
|
|||
pr_list = PR_Zone_Malloc (pr, count * sizeof (pr_type_t));
|
||||
// the hash tables stores progs pointers...
|
||||
for (count = 0, l = list; *l; l++)
|
||||
pr_list[count++].int_var = (intptr_t) *l;
|
||||
PR_PTR(ptr, &pr_list[count++]) = (intptr_t) *l;
|
||||
free (list);
|
||||
RETURN_POINTER (pr, pr_list);
|
||||
}
|
||||
|
|
|
@ -1507,25 +1507,27 @@ rua_obj_msg_sendv (progs_t *pr, void *data)
|
|||
RUA_CALL_END (pr, imp)
|
||||
}
|
||||
|
||||
#define RETAIN_COUNT(obj) PR_PTR (int, &(obj)[-1])
|
||||
|
||||
static void
|
||||
rua_obj_increment_retaincount (progs_t *pr, void *data)
|
||||
{
|
||||
pr_type_t *obj = &P_STRUCT (pr, pr_type_t, 0);
|
||||
R_INT (pr) = ++(*--obj).int_var;
|
||||
R_INT (pr) = ++RETAIN_COUNT (obj);
|
||||
}
|
||||
|
||||
static void
|
||||
rua_obj_decrement_retaincount (progs_t *pr, void *data)
|
||||
{
|
||||
pr_type_t *obj = &P_STRUCT (pr, pr_type_t, 0);
|
||||
R_INT (pr) = --(*--obj).int_var;
|
||||
R_INT (pr) = --RETAIN_COUNT (obj);
|
||||
}
|
||||
|
||||
static void
|
||||
rua_obj_get_retaincount (progs_t *pr, void *data)
|
||||
{
|
||||
pr_type_t *obj = &P_STRUCT (pr, pr_type_t, 0);
|
||||
R_INT (pr) = (*--obj).int_var;
|
||||
R_INT (pr) = RETAIN_COUNT (obj);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -186,13 +186,9 @@ extern progs_t sv_pr_state;
|
|||
#define SVstring(e,f) SVFIELD (e, f, string)
|
||||
#define SVfunc(e,f) SVFIELD (e, f, func)
|
||||
#define SVentity(e,f) SVFIELD (e, f, entity)
|
||||
#define SVvector(e,f) (&SVFIELD (e, f, vector))
|
||||
#define SVvector(e,f) (&SVFIELD (e, f, float))
|
||||
#define SVint(e,f) SVFIELD (e, f, int)
|
||||
#if TYPECHECK_PROGS
|
||||
#define SVdouble(e,f) E_DOUBLE (e, PR_AccessField (&sv_pr_state, #f, ev_##t, __FILE__, __LINE__))
|
||||
#else
|
||||
#define SVdouble(e,f) E_DOUBLE (e, sv_fields.f)
|
||||
#endif
|
||||
#define SVdouble(e,f) SVFIELD (e, f, double)
|
||||
|
||||
typedef struct edict_leaf_s {
|
||||
struct edict_leaf_s *next;
|
||||
|
|
|
@ -1139,7 +1139,7 @@ PF_WriteBytes (progs_t *pr, void *data)
|
|||
}
|
||||
}
|
||||
for (i = 0; i < argc; i++) {
|
||||
p = argv[i]->float_var;
|
||||
p = PR_PTR (float, &argv[i]);
|
||||
MSG_WriteByte (msg, p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,13 +193,9 @@ extern progs_t sv_pr_state;
|
|||
#define SVstring(e,f) SVFIELD (e, f, string)
|
||||
#define SVfunc(e,f) SVFIELD (e, f, func)
|
||||
#define SVentity(e,f) SVFIELD (e, f, entity)
|
||||
#define SVvector(e,f) (&SVFIELD (e, f, vector))
|
||||
#define SVvector(e,f) (&SVFIELD (e, f, float))
|
||||
#define SVint(e,f) SVFIELD (e, f, int)
|
||||
#if TYPECHECK_PROGS
|
||||
#define SVdouble(e,f) E_DOUBLE (e, PR_AccessField (&sv_pr_state, #f, ev_##t, __FILE__, __LINE__))
|
||||
#else
|
||||
#define SVdouble(e,f) E_DOUBLE (e, sv_fields.f)
|
||||
#endif
|
||||
#define SVdouble(e,f) SVFIELD (e, f, double)
|
||||
|
||||
typedef struct edict_leaf_s {
|
||||
struct edict_leaf_s *next;
|
||||
|
|
|
@ -1130,7 +1130,7 @@ PF_WriteBytes (progs_t *pr, void *data)
|
|||
}
|
||||
}
|
||||
for (i = 0; i < argc; i++) {
|
||||
p = argv[i]->float_var;
|
||||
p = PR_PTR (float, argv[i]);
|
||||
buf[i] = p;
|
||||
}
|
||||
|
||||
|
|
|
@ -181,16 +181,16 @@ static void
|
|||
free_edict (progs_t *pr, edict_t *ent)
|
||||
{
|
||||
if (sv_old_entity_free) {
|
||||
E_fld (ent, sv_fields.model).entity_var = 0;
|
||||
E_fld (ent, sv_fields.takedamage).float_var = 0;
|
||||
E_fld (ent, sv_fields.modelindex).float_var = 0;
|
||||
E_fld (ent, sv_fields.colormap).float_var = 0;
|
||||
E_fld (ent, sv_fields.skin).float_var = 0;
|
||||
E_fld (ent, sv_fields.frame).float_var = 0;
|
||||
E_fld (ent, sv_fields.nextthink).float_var = -1;
|
||||
E_fld (ent, sv_fields.solid).float_var = 0;
|
||||
memset (&E_fld (ent, sv_fields.origin).vector_var, 0, 3*sizeof (float));
|
||||
memset (&E_fld (ent, sv_fields.angles).vector_var, 0, 3*sizeof (float));
|
||||
E_STRING (ent, sv_fields.model) = 0;
|
||||
E_FLOAT (ent, sv_fields.takedamage) = 0;
|
||||
E_FLOAT (ent, sv_fields.modelindex) = 0;
|
||||
E_FLOAT (ent, sv_fields.colormap) = 0;
|
||||
E_FLOAT (ent, sv_fields.skin) = 0;
|
||||
E_FLOAT (ent, sv_fields.frame) = 0;
|
||||
E_FLOAT (ent, sv_fields.nextthink) = -1;
|
||||
E_FLOAT (ent, sv_fields.solid) = 0;
|
||||
VectorZero (E_VECTOR (ent, sv_fields.origin));
|
||||
VectorZero (E_VECTOR (ent, sv_fields.angles));
|
||||
} else {
|
||||
ED_ClearEdict (pr, ent, 0);
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ enum {
|
|||
|
||||
\hideinitializer
|
||||
*/
|
||||
#define QFO_var(q, s, t, o) ((q)->spaces[s].data[o].t##_var)
|
||||
#define QFO_var(q, s, t, o) (*(pr_##t##_t *) &(q)->spaces[s].data[o])
|
||||
|
||||
/** Access a double variable in the object file. Can be assigned to.
|
||||
|
||||
|
|
|
@ -97,16 +97,17 @@ typedef struct pr_info_s {
|
|||
extern pr_info_t pr;
|
||||
|
||||
#define GETSTR(s) (pr.strings->strings + (s))
|
||||
#define D_var(t, d) ((d)->space->data[(d)->offset].t##_var)
|
||||
#define D_DOUBLE(d) (*(double *) ((d)->space->data + (d)->offset))
|
||||
#define D_PACKED(t,d) (*(t *) &(d)->space->data[(d)->offset])
|
||||
#define D_var(t, d) D_PACKED (pr_##t##_t, d)
|
||||
#define D_DOUBLE(d) D_var (double, d)
|
||||
#define D_FLOAT(d) D_var (float, d)
|
||||
#define D_INT(d) D_var (int, d)
|
||||
#define D_VECTOR(d) (&D_var (vector, d))
|
||||
#define D_QUAT(d) (&D_var (quat, d))
|
||||
#define D_VECTOR(d) (&D_var (float, d))
|
||||
#define D_QUAT(d) (&D_var (float, d))
|
||||
#define D_STRING(d) D_var (string, d)
|
||||
#define D_GETSTR(d) GETSTR (D_STRING (d))
|
||||
#define D_FUNCTION(d) D_var (func, d)
|
||||
#define D_POINTER(t,d) ((t *)((d)->space->data + (d)->offset))
|
||||
#define D_POINTER(t,d) (&D_PACKED (t, d))
|
||||
#define D_STRUCT(t,d) (*D_POINTER (t, d))
|
||||
|
||||
#define G_POINTER(s,t,o) ((t *)((s)->data + o))
|
||||
|
|
|
@ -401,7 +401,7 @@ init_elements (struct def_s *def, expr_t *eles)
|
|||
internal_error (c, "bogus expression type in init_elements()");
|
||||
}
|
||||
if (c->e.value->lltype == ev_string) {
|
||||
EMIT_STRING (def->space, g->string_var,
|
||||
EMIT_STRING (def->space, *(pr_string_t *) g,
|
||||
c->e.value->v.string_val);
|
||||
} else {
|
||||
memcpy (g, &c->e.value->v, type_size (get_type (c)) * 4);
|
||||
|
@ -636,7 +636,7 @@ initialize_def (symbol_t *sym, expr_t *init, defspace_t *space,
|
|||
EMIT_STRING (sym->s.def->space, D_STRING (sym->s.def),
|
||||
v->v.string_val);
|
||||
} else {
|
||||
memcpy (D_POINTER (void, sym->s.def), &v->v,
|
||||
memcpy (D_POINTER (pr_type_t, sym->s.def), &v->v,
|
||||
type_size (sym->type) * sizeof (pr_type_t));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ qfo_globals (qfo_t *qfo)
|
|||
QFO_TYPESTR (qfo, def->type));
|
||||
if (!(def->flags & QFOD_EXTERNAL) && qfo->spaces[space].data)
|
||||
printf (" %d",
|
||||
qfo->spaces[space].data[def->offset].int_var);
|
||||
qfo->spaces[space].data[def->offset].value);
|
||||
puts ("");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -433,7 +433,7 @@ qfo_byteswap_space (void *space, int size, qfos_type_t type)
|
|||
case qfos_type:
|
||||
case qfos_debug:
|
||||
for (val = (pr_type_t *) space, c = 0; c < size; c++, val++)
|
||||
val->int_var = LittleLong (val->int_var);
|
||||
val->value = LittleLong (val->value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ WriteProgs (dprograms_t *progs, int size)
|
|||
fielddefs[i].name = LittleLong (fielddefs[i].name);
|
||||
}
|
||||
for (i = 0; i < progs->globals.count; i++)
|
||||
globals[i].int_var = LittleLong (globals[i].int_var);
|
||||
globals[i].value = LittleLong (globals[i].value);
|
||||
|
||||
if (!(h = Qopen (options.output_file, "wb")))
|
||||
Sys_Error ("%s: %s\n", options.output_file, strerror(errno));
|
||||
|
@ -307,7 +307,7 @@ WriteSym (pr_debug_header_t *sym, int size)
|
|||
debug_defs[i].type_encoding = LittleLong (debug_defs[i].type_encoding);
|
||||
}
|
||||
for (i = 0; i < sym->debug_data_size; i++) {
|
||||
debug_data[i].int_var = LittleLong (debug_data[i].int_var);
|
||||
debug_data[i].value = LittleLong (debug_data[i].value);
|
||||
}
|
||||
|
||||
if (!(h = Qopen (options.debug_file, "wb")))
|
||||
|
|
|
@ -73,7 +73,7 @@ static const char *reloc_name[] = {
|
|||
"rel_def_field_ofs",
|
||||
};
|
||||
|
||||
#define RELOC(r) (r)->space->data[(r)->offset].int_var
|
||||
#define RELOC(r) (r)->space->data[(r)->offset].value
|
||||
|
||||
void
|
||||
relocate_refs (reloc_t *reloc, int offset)
|
||||
|
@ -169,7 +169,7 @@ relocate_refs (reloc_t *reloc, int offset)
|
|||
case rel_def_field_ofs:
|
||||
//FIXME what is correct here?
|
||||
//RELOC (reloc) += pr.data->data[offset].int_var;
|
||||
RELOC (reloc) += pr.near_data->data[offset].int_var;
|
||||
RELOC (reloc) += PR_PTR (int, &pr.near_data->data[offset]);
|
||||
break;
|
||||
}
|
||||
reloc = reloc->next;
|
||||
|
|
|
@ -365,7 +365,7 @@ emit_structure (const char *name, int su, struct_def_t *defs, type_t *type,
|
|||
if (!defs[i].emit) {
|
||||
//FIXME relocs? arrays? structs?
|
||||
pr_type_t *val = (pr_type_t *) data;
|
||||
memcpy (D_POINTER (void, &field_def), val,
|
||||
memcpy (D_POINTER (pr_type_t, &field_def), val,
|
||||
type_size (field_def.type) * sizeof (pr_type_t));
|
||||
data = &val[type_size (field_def.type)];
|
||||
} else {
|
||||
|
|
|
@ -614,7 +614,7 @@ emit_value (ex_value_t *value, def_t *def)
|
|||
break;
|
||||
}
|
||||
|
||||
memcpy (D_POINTER (void, cn), &val.v, 4 * type_size (type));
|
||||
memcpy (D_POINTER (pr_type_t, cn), &val.v, 4 * type_size (type));
|
||||
|
||||
make_def_imm (cn, tab, &val);
|
||||
|
||||
|
|
Loading…
Reference in a new issue