add: implemented #122.

fix: bots try to defuse already beeing defused bomb (fixes #116).
fix: line ending in source code.
fix:  do not retreat with sniper weapon, if currently shooting and have ammo.
crlib: added deque class.
This commit is contained in:
ds 2020-09-16 13:07:47 +03:00
commit fa47e418b2
19 changed files with 420 additions and 73 deletions

View file

@ -186,7 +186,23 @@ public:
detour_ = nullptr;
}
private:
class DetourSwitch final {
private:
Detour <T> *detour_;
public:
DetourSwitch (Detour *detour) : detour_ (detour) {
detour_->restore ();
}
~DetourSwitch () {
detour_->detour ();
}
};
public:
void install (void *detour, const bool enable = false) {
if (!original_) {
return;
@ -228,11 +244,8 @@ public:
}
template <typename... Args > decltype (auto) operator () (Args &&...args) {
restore ();
auto res = reinterpret_cast <T *> (original_) (args...);
detour ();
return res;
DetourSwitch sw (this);
return reinterpret_cast <T *> (original_) (args...);
}
};