diff --git a/python-mtheall/CarState.cpp b/python-mtheall/CarState.cpp index 52041c3..bfb0326 100644 --- a/python-mtheall/CarState.cpp +++ b/python-mtheall/CarState.cpp @@ -3,11 +3,22 @@ #include #include #include +#include namespace RocketSim::Python { constexpr unsigned NUM_WHEELS = std::extent_v; +std::once_flag lastRelDodgeTorqueWarnOnce; + +void warnLastRelDodgeTorque () +{ + std::call_once (lastRelDodgeTorqueWarnOnce, + &std::fprintf, + stderr, + "last_rel_dodge_torque is a deprecated alias of flip_rel_torque\n"); +} + PyTypeObject *CarState::Type = nullptr; PyMemberDef CarState::Members[] = { @@ -167,6 +178,7 @@ PyGetSetDef CarState::GetSet[] = { GETSET_ENTRY (CarState, rot_mat, "Rotation matrix"), GETSET_ENTRY (CarState, vel, "Velocity"), GETSET_ENTRY (CarState, ang_vel, "Angular velocity"), + GETSET_ENTRY (CarState, last_rel_dodge_torque, "Deprecated alias of flip_rel_torque"), GETSET_ENTRY (CarState, flip_rel_torque, "Flip relative torque"), GETSET_ENTRY (CarState, last_controls, "Last controls"), GETSET_ENTRY (CarState, world_contact_normal, "World contact normal"), @@ -336,6 +348,7 @@ int CarState::Init (CarState *self_, PyObject *args_, PyObject *kwds_) noexcept static char ballHitInfoKwd[] = "ball_hit_info"; static char lastControlsKwd[] = "last_controls"; static char updateCounterKwd[] = "update_counter"; + static char lastRelDodgeTorqueKwd[] = "last_rel_dodge_torque"; static char *dict[] = {posKwd, rotMatKwd, @@ -369,6 +382,7 @@ int CarState::Init (CarState *self_, PyObject *args_, PyObject *kwds_) noexcept ballHitInfoKwd, lastControlsKwd, updateCounterKwd, + lastRelDodgeTorqueKwd, nullptr}; RocketSim::CarState state{}; @@ -382,6 +396,7 @@ int CarState::Init (CarState *self_, PyObject *args_, PyObject *kwds_) noexcept PyObject *lastControls = nullptr; PyObject *worldContactNormal = nullptr; PyObject *ballHitInfo = nullptr; + PyObject *lastRelDodgeTorque = nullptr; int isOnGround = state.isOnGround; int hasJumped = state.hasJumped; @@ -398,7 +413,7 @@ int CarState::Init (CarState *self_, PyObject *args_, PyObject *kwds_) noexcept unsigned long long updateCounter = state.updateCounter; if (!PyArg_ParseTupleAndKeywords (args_, kwds_, - "|O!O!O!O!pOpppO!ffppffffpffpfpO!kfpfO!O!K", + "|O!O!O!O!pOpppO!ffppffffpffpfpO!kfpfO!O!K$O!", dict, Vec::Type, &pos, @@ -439,7 +454,9 @@ int CarState::Init (CarState *self_, PyObject *args_, PyObject *kwds_) noexcept &ballHitInfo, CarControls::Type, &lastControls, - &updateCounter)) + &updateCounter, + Vec::Type, + &lastRelDodgeTorque)) return -1; if (pos) @@ -465,6 +482,8 @@ int CarState::Init (CarState *self_, PyObject *args_, PyObject *kwds_) noexcept if (flipRelTorque) state.flipRelTorque = Vec::ToVec (PyCast (flipRelTorque)); + else if (lastRelDodgeTorque) + state.flipRelTorque = Vec::ToVec (PyCast (lastRelDodgeTorque)); if (worldContactNormal) state.worldContact.contactNormal = Vec::ToVec (PyCast (worldContactNormal)); @@ -848,6 +867,18 @@ int CarState::Setang_vel (CarState *self_, PyObject *value_, void *) noexcept return 0; } +PyObject *CarState::Getlast_rel_dodge_torque (CarState *self_, void *closure_) noexcept +{ + warnLastRelDodgeTorque (); + return Getflip_rel_torque (self_, closure_); +} + +int CarState::Setlast_rel_dodge_torque (CarState *self_, PyObject *value_, void *closure_) noexcept +{ + warnLastRelDodgeTorque (); + return Setflip_rel_torque (self_, value_, closure_); +} + PyObject *CarState::Getflip_rel_torque (CarState *self_, void *) noexcept { return PyRef::incRef (self_->flipRelTorque).giftObject (); diff --git a/python-mtheall/Makefile b/python-mtheall/Makefile index 3d7615c..11eccf5 100644 --- a/python-mtheall/Makefile +++ b/python-mtheall/Makefile @@ -11,7 +11,7 @@ wheel: build $(PYTHON) ../setup.py bdist_wheel --py-limited-api=cp34 install: wheel - $(PYTHON) -m pip install --force-reinstall --user ./dist/RocketSim-2.1.0a5-cp34-abi3-linux_x86_64.whl + $(PYTHON) -m pip install --force-reinstall --user ./dist/RocketSim-2.1.0a6-cp34-abi3-linux_x86_64.whl clean: $(RM) -r build/ dist/ RocketSim.egg-info/ diff --git a/python-mtheall/Module.h b/python-mtheall/Module.h index 5b40114..0bc7d62 100644 --- a/python-mtheall/Module.h +++ b/python-mtheall/Module.h @@ -565,6 +565,7 @@ struct CarState GETSET_DECLARE (CarState, rot_mat) GETSET_DECLARE (CarState, vel) GETSET_DECLARE (CarState, ang_vel) + GETSET_DECLARE (CarState, last_rel_dodge_torque) GETSET_DECLARE (CarState, flip_rel_torque) GETSET_DECLARE (CarState, last_controls) GETSET_DECLARE (CarState, world_contact_normal) diff --git a/setup.py b/setup.py index a5ed3ca..aaee2e8 100755 --- a/setup.py +++ b/setup.py @@ -88,7 +88,7 @@ def build_extension(self, ext): setup( name = "RocketSim", - version = "2.1.0a5", + version = "2.1.0a6", description = "This is Rocket League!", cmdclass = {"build_ext": build_ext_ex}, ext_modules = [RocketSim],