diff --git a/polymer/eduke32/build/include/tracker.hpp b/polymer/eduke32/build/include/tracker.hpp new file mode 100644 index 000000000..90afddef8 --- /dev/null +++ b/polymer/eduke32/build/include/tracker.hpp @@ -0,0 +1,39 @@ + + +template +class __TRACKER_NAME +{ + TrackedType TrackedValue; + + public: + TrackedType operator = (TrackedType); + TrackedType operator = (__TRACKER_NAME); + TrackedType operator += (TrackedType); + TrackedType operator += (__TRACKER_NAME); + + operator TrackedType(); +}; + +enum { + __TRACKER_NOOP_RIGHTHAND_EQUAL = 0, + __TRACKER_NOOP_RIGHTHAND_ZERO, + __TRACKER_NEVER, +}; + +#define __TRACKER_RIGHTHAND_TYPE __TRACKER_NAME rightHand +#define __TRACKER_RIGHTHAND rightHand.TrackedValue +#include "tracker_operators.hpp" +#undef __TRACKER_RIGHTHAND_TYPE +#undef __TRACKER_RIGHTHAND + +#define __TRACKER_RIGHTHAND_TYPE TrackedType rightHand +#define __TRACKER_RIGHTHAND rightHand +#include "tracker_operators.hpp" +#undef __TRACKER_RIGHTHAND_TYPE +#undef __TRACKER_RIGHTHAND + +template +__TRACKER_NAME::operator TrackedType() +{ + return this->TrackedValue; +} diff --git a/polymer/eduke32/build/include/tracker_operator.hpp b/polymer/eduke32/build/include/tracker_operator.hpp new file mode 100644 index 000000000..04860f461 --- /dev/null +++ b/polymer/eduke32/build/include/tracker_operator.hpp @@ -0,0 +1,28 @@ + +template +TrackedType __TRACKER_NAME::operator __TRACKER_OPERATOR (__TRACKER_RIGHTHAND_TYPE) +{ + bool isNoop; + + switch (__TRACKER_NOOP) { + case __TRACKER_NOOP_RIGHTHAND_EQUAL: + isNoop = this->TrackedValue == __TRACKER_RIGHTHAND; + break; + case __TRACKER_NOOP_RIGHTHAND_ZERO: + isNoop = __TRACKER_RIGHTHAND == 0; + break; + default: + case __TRACKER_NEVER: + isNoop = false; + break; + } + + if (!isNoop) { + + // hook here + int TrackedAddress = (int)&this->TrackedValue; + TrackedAddress += __TRACKER_GLOBAL_OFFSET; + *((TrackedType*)TrackedAddress) = 1; + return (this->TrackedValue __TRACKER_OPERATOR __TRACKER_RIGHTHAND); + } +} \ No newline at end of file diff --git a/polymer/eduke32/build/include/tracker_operators.hpp b/polymer/eduke32/build/include/tracker_operators.hpp new file mode 100644 index 000000000..6432f6070 --- /dev/null +++ b/polymer/eduke32/build/include/tracker_operators.hpp @@ -0,0 +1,11 @@ +#define __TRACKER_OPERATOR = +#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_EQUAL +#include "tracker_operator.hpp" +#undef __TRACKER_OPERATOR +#undef __TRACKER_NOOP + +#define __TRACKER_OPERATOR += +#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_ZERO +#include "tracker_operator.hpp" +#undef __TRACKER_OPERATOR +#undef __TRACKER_NOOP \ No newline at end of file