fix: query hook not working on linux
This commit is contained in:
parent
64aa02955c
commit
7f07817c52
5 changed files with 26 additions and 9 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit b85bbe10b45bcadbcb325664fac5c511a6b868e3
|
||||
Subproject commit 313311c8612ce2a70c616f7187358c397d32765a
|
||||
|
|
@ -20,7 +20,7 @@ private:
|
|||
SmallArray <Twin <String, String>> m_tags {};
|
||||
|
||||
HashMap <int32_t, String> m_weaponAlias {};
|
||||
Detour <decltype (sendto)> m_sendToDetour { "ws2_32.dll", "sendto", sendto };
|
||||
Detour <decltype (sendto)> m_sendToDetour { };
|
||||
|
||||
public:
|
||||
BotSupport ();
|
||||
|
|
|
|||
|
|
@ -687,6 +687,7 @@ private:
|
|||
|
||||
int m_lastPredictIndex { kInvalidNodeIndex }; // last predicted path index
|
||||
int m_lastPredictLength {}; // last predicted path length
|
||||
int m_pickupType {}; // type of entity which needs to be used/picked up
|
||||
|
||||
float m_headedTime {};
|
||||
float m_prevTime {}; // time previously checked movement speed
|
||||
|
|
@ -766,7 +767,6 @@ private:
|
|||
bool m_defuseNotified {}; // bot is notified about bomb defusion
|
||||
bool m_jumpSequence {}; // next path link will be jump link
|
||||
|
||||
Pickup m_pickupType {}; // type of entity which needs to be used/picked up
|
||||
PathWalk m_pathWalk {}; // pointer to current node from path
|
||||
Dodge m_combatStrafeDir {}; // direction to strafe
|
||||
Fight m_fightStyle {}; // combat style to use
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ void Bot::updatePickups () {
|
|||
}
|
||||
edict_t *pickupItem = nullptr;
|
||||
|
||||
Pickup pickupType = Pickup::None;
|
||||
int32_t pickupType = Pickup::None;
|
||||
Vector pickupPos = nullptr;
|
||||
|
||||
m_pickupItem = nullptr;
|
||||
|
|
|
|||
|
|
@ -477,6 +477,23 @@ void BotSupport::installSendTo () {
|
|||
if (!game.isDedicated ()) {
|
||||
return;
|
||||
}
|
||||
using SendToHandle = decltype (sendto);
|
||||
SendToHandle *sendToAddress = sendto;
|
||||
|
||||
// linux workaround with sendto
|
||||
if (!plat.win && !plat.arm) {
|
||||
SharedLibrary engineLib {};
|
||||
engineLib.locate (reinterpret_cast <void *> (engfuncs.pfnPrecacheModel));
|
||||
|
||||
if (engineLib) {
|
||||
auto address = engineLib.resolve <SendToHandle *> ("sendto");
|
||||
|
||||
if (address != nullptr) {
|
||||
sendToAddress = address;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_sendToDetour.initialize ("ws2_32.dll", "sendto", sendToAddress);
|
||||
|
||||
// enable only on modern games
|
||||
if (game.is (GameFlags::Modern) && (plat.nix || plat.win) && !plat.arm && !m_sendToDetour.detoured ()) {
|
||||
|
|
@ -518,12 +535,12 @@ int32_t BotSupport::sendTo (int socket, const void *message, size_t length, int
|
|||
};
|
||||
|
||||
auto packet = reinterpret_cast <const uint8_t *> (message);
|
||||
constexpr int32_t packetLength = 5;
|
||||
|
||||
// player replies response
|
||||
if (length > 5 && packet[0] == 0xff && packet[1] == 0xff && packet[2] == 0xff && packet[3] == 0xff) {
|
||||
|
||||
if (length > packetLength && memcmp (packet, "\xff\xff\xff\xff", packetLength - 1) == 0) {
|
||||
if (packet[4] == 'D') {
|
||||
QueryBuffer buffer (packet, length, 5);
|
||||
QueryBuffer buffer { packet, length, packetLength };
|
||||
auto count = buffer.read <uint8_t> ();
|
||||
|
||||
for (uint8_t i = 0; i < count; ++i) {
|
||||
|
|
@ -537,7 +554,7 @@ int32_t BotSupport::sendTo (int socket, const void *message, size_t length, int
|
|||
return send (buffer.data ());
|
||||
}
|
||||
else if (packet[4] == 'I') {
|
||||
QueryBuffer buffer (packet, length, 5);
|
||||
QueryBuffer buffer { packet, length, packetLength };
|
||||
buffer.skip <uint8_t> (); // protocol
|
||||
|
||||
// skip server name, folder, map game
|
||||
|
|
@ -553,7 +570,7 @@ int32_t BotSupport::sendTo (int socket, const void *message, size_t length, int
|
|||
return send (buffer.data ());
|
||||
}
|
||||
else if (packet[4] == 'm') {
|
||||
QueryBuffer buffer (packet, length, 5);
|
||||
QueryBuffer buffer { packet, length, packetLength };
|
||||
|
||||
buffer.shiftToEnd (); // shift to the end of buffer
|
||||
buffer.write <uint8_t> (0); // zero out bot count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue