]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into martin-t/globals
authorMartin Taibr <taibr.martin@gmail.com>
Mon, 1 Jul 2019 16:22:58 +0000 (18:22 +0200)
committerMartin Taibr <taibr.martin@gmail.com>
Mon, 1 Jul 2019 16:22:58 +0000 (18:22 +0200)
1  2 
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/view.qc
qcsrc/common/debug.qh
qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc
qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc
qcsrc/common/weapons/weapon/shockwave.qc
qcsrc/lib/_all.inc
qcsrc/lib/deglobalization.qh
qcsrc/lib/warpzone/anglestransform.qh
qcsrc/lib/warpzone/server.qc
qcsrc/server/weapons/weaponsystem.qc

Simple merge
Simple merge
Simple merge
Simple merge
index bd43ab1194197eddc8ea4a7c37b3eb9aa647c4a1,0000000000000000000000000000000000000000..55dbbe525d14127bb868840d42fdc42036aa894e
mode 100644,000000..100644
--- /dev/null
@@@ -1,90 -1,0 +1,90 @@@
- #define MAKE_VECTORS(angles, forward, right, up) MACRO_BEGIN { \
 +#include "lib/float.qh"
 +#include "lib/misc.qh"
 +#include "lib/static.qh"
 +#include "lib/vector.qh"
 +
 +// These macros wrap functions which use globals so mutation only occurs inside them and is not visible from outside.
 +// Functions for which all usages are replaced with these macros can be hidden by #defines inside our `*defs.qh` files
 +// to prevent anyone from using them accidentally in the future
 +
 +// TODO stuff in the engine that uses the v_forward/v_right/v_up globals and is not wrapped yet:
 +//  - RF_USEAXIS, addentities, predraw,
 +//    - CL_GetEntityMatrix (in engine but is called from other functions so transitively any of them can use the globals - e.g. V_CalcRefdef, maybe others)
 +//    - however RF_USEAXIS is only used if MF_ROTATE is used which is only set in one place
 +//  - e.camera_transform / CL_VM_TransformView (in engine)
 +//    - this is the only used function that both sets and gets the globals (aim does too but isn't used in our code)
 +
 +// convenience for deglobalization code - don't use these just to hide that globals are still used
 +#define CLEAR_V_GLOBALS() v_forward = VEC_NAN; v_right = VEC_NAN; v_up = VEC_NAN
 +#define GET_V_GLOBALS(forward, right, up) forward = v_forward; right = v_right; up = v_up
 +#define SET_V_GLOBALS(forward, right, up) v_forward = forward; v_right = right; v_up = up
 +
 +#ifdef GAMEQC
 +STATIC_INIT(globals) {
 +      // set to NaN to more easily detect uninitialized use
 +      // TODO when all functions are wrapped and the raw functions are not used anymore,
 +      // uncomment the defines in *progs.qh files that hide the raw functions
 +      // and assert that the global vectors are NaN before calling the raw functions here
 +      // to make sure nobody (even builtins) is accidentally using them - NaN is the most likely value to expose remaining usages
 +
 +      CLEAR_V_GLOBALS();
 +}
 +#endif
 +
 +/// Same as the `makevectors` builtin but uses the provided locals instead of the `v_*` globals.
 +/// Always use this instead of raw `makevectors` to make the data flow clear.
 +/// Note that you might prefer `FIXED_MAKE_VECTORS` for new code.
- } MACRO_END
++#define MAKE_VECTORS(angles, forward, right, up) MACRO_BEGIN \
 +      _makevectors_hidden(angles); \
 +      GET_V_GLOBALS(forward, right, up); \
 +      CLEAR_V_GLOBALS(); \
- #define SKEL_GET_BONE_ABS(skel, bonenum, forward, right, up, origin) MACRO_BEGIN { \
++MACRO_END
 +
 +/// Same as `MAKE_VECTORS` but also creates the locals for convenience.
 +#define MAKE_VECTORS_NEW(angles, forward, right, up) \
 +      vector forward = '0 0 0', right = '0 0 0', up = '0 0 0'; \
 +      MAKE_VECTORS(angles, forward, right, up);
 +
 +/// Returns all 4 vectors by assigning to them (instead of returning a value) for consistency (and sanity)
- } MACRO_END
++#define SKEL_GET_BONE_ABS(skel, bonenum, forward, right, up, origin) MACRO_BEGIN \
 +      origin = _skel_get_boneabs_hidden(skel, bonenum) \
 +      GET_V_GLOBALS(forward, right, up); \
 +      CLEAR_V_GLOBALS(); \
- #define SKEL_SET_BONE(skel, bonenum, org, forward, right, up) MACRO_BEGIN { \
++MACRO_END
 +
 +#define SKEL_GET_BONE_ABS_NEW(skel, bonenum, forward, right, up, origin) \
 +      vector forward = '0 0 0', right = '0 0 0', up = '0 0 0', origin = '0 0 0'; \
 +      SKEL_GET_BONE_ABS(skel, bonenum, forward, right, up, origin)
 +
- } MACRO_END
++#define SKEL_SET_BONE(skel, bonenum, org, forward, right, up) MACRO_BEGIN \
 +      SET_V_GLOBALS(forward, right, up); \
 +      _skel_set_bone_hidden(skel, bonenum, org); \
 +      CLEAR_V_GLOBALS(); \
- #define ADD_DYNAMIC_LIGHT(org, radius, lightcolours, forward, right, up) MACRO_BEGIN { \
++MACRO_END
 +
- } MACRO_END
++#define ADD_DYNAMIC_LIGHT(org, radius, lightcolours, forward, right, up) MACRO_BEGIN \
 +      SET_V_GLOBALS(forward, right, up); \
 +      _adddynamiclight_hidden(org, radius, lightcolours); \
 +      CLEAR_V_GLOBALS(); \
- #define VECTOR_VECTORS(forward_in, forward, right, up) MACRO_BEGIN { \
++MACRO_END
 +
- } MACRO_END
++#define VECTOR_VECTORS(forward_in, forward, right, up) MACRO_BEGIN \
 +      _vectorvectors_hidden(forward_in); \
 +      GET_V_GLOBALS(forward, right, up); \
 +      CLEAR_V_GLOBALS(); \
- #define GET_TAG_INFO(ent, tagindex, forward, right, up, origin) MACRO_BEGIN {  \
++MACRO_END
 +
 +#define VECTOR_VECTORS_NEW(forward_in, forward, right, up) \
 +      vector forward = '0 0 0', right = '0 0 0', up = '0 0 0'; \
 +      VECTOR_VECTORS(forward_in, forward, right, up);
 +
 +/// Note that this only avoids the v_* globals, not the gettaginfo_* ones
- } MACRO_END
++#define GET_TAG_INFO(ent, tagindex, forward, right, up, origin) MACRO_BEGIN \
 +      origin = _gettaginfo_hidden(ent, tagindex); \
 +      GET_V_GLOBALS(forward, right, up); \
 +      CLEAR_V_GLOBALS(); \
++MACRO_END
 +
 +#define GET_TAG_INFO_NEW(ent, tagindex, forward, right, up, origin) \
 +      vector forward = '0 0 0', right = '0 0 0', up = '0 0 0', origin = '0 0 0'; \
 +      GET_TAG_INFO(ent, tagindex, forward, right, up, origin);
index 070c81a53f0bb9cfe5ac1f17589bbc34b07b591e,b287651a10a4fb868acdfeca18d2c0dfaf77b4d0..c11a63185f8090d3348d1cc7e720f30751cc2d4e
          a.x = -a.x;
          makevectors(a);
      }
-     #define FIXED_MAKE_VECTORS(angles, forward, right, up) MACRO_BEGIN { \
++    #define FIXED_MAKE_VECTORS(angles, forward, right, up) MACRO_BEGIN \
 +        fixedmakevectors(angles); \
 +        GET_V_GLOBALS(forward, right, up); \
 +        CLEAR_V_GLOBALS(); \
-     } MACRO_END
++    MACRO_END
 +    #define FIXED_MAKE_VECTORS_NEW(angles, forward, right, up) \
 +        VECS_NEW(forward, right, up); \
 +        FIXED_MAKE_VECTORS(angles, forward, right, up);
      #define fixedvectoangles2 vectoangles2
      #define fixedvectoangles vectoangles
  #endif
Simple merge
Simple merge