Catbots can now load configs again and autoqueue lag fix (tm)
(IDEK if this works xd)
This commit is contained in:
parent
46c4d9f0c0
commit
ee74d050b2
@ -9,8 +9,6 @@
|
|||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
namespace hacks::shared::autojoin
|
namespace hacks::shared::autojoin
|
||||||
{
|
{
|
||||||
|
|
||||||
void resetQueueTimer();
|
|
||||||
void update();
|
void update();
|
||||||
void updateSearch();
|
void updateSearch();
|
||||||
void onShutdown();
|
void onShutdown();
|
||||||
|
@ -38,10 +38,10 @@ bool UnassignedClass()
|
|||||||
return g_pLocalPlayer->clazz != *autojoin_class;
|
return g_pLocalPlayer->clazz != *autojoin_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Timer autoqueue_timer{};
|
static Timer autoteam_timer{};
|
||||||
static Timer queuetime{};
|
static Timer startqueue_timer{};
|
||||||
#if not ENABLE_VISUALS
|
#if not ENABLE_VISUALS
|
||||||
static Timer req_timer{};
|
static Timer queue_time{};
|
||||||
#endif
|
#endif
|
||||||
void updateSearch()
|
void updateSearch()
|
||||||
{
|
{
|
||||||
@ -87,14 +87,14 @@ void updateSearch()
|
|||||||
if (!auto_queue && !auto_requeue)
|
if (!auto_queue && !auto_requeue)
|
||||||
{
|
{
|
||||||
#if not ENABLE_VISUALS
|
#if not ENABLE_VISUALS
|
||||||
req_timer.update();
|
queue_time.update();
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (g_IEngine->IsInGame())
|
if (g_IEngine->IsInGame())
|
||||||
{
|
{
|
||||||
#if not ENABLE_VISUALS
|
#if not ENABLE_VISUALS
|
||||||
req_timer.update();
|
queue_time.update();
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ void updateSearch()
|
|||||||
gc->BHaveLiveMatch())
|
gc->BHaveLiveMatch())
|
||||||
{
|
{
|
||||||
#if not ENABLE_VISUALS
|
#if not ENABLE_VISUALS
|
||||||
req_timer.update();
|
queue_time.update();
|
||||||
#endif
|
#endif
|
||||||
tfmm::leaveQueue();
|
tfmm::leaveQueue();
|
||||||
}
|
}
|
||||||
@ -127,8 +127,9 @@ void updateSearch()
|
|||||||
|
|
||||||
if (auto_requeue)
|
if (auto_requeue)
|
||||||
{
|
{
|
||||||
if (gc && !gc->BConnectedToMatchServer(false) &&
|
if (startqueue_timer.check(5000) && gc &&
|
||||||
!gc->BHaveLiveMatch() && !invites)
|
!gc->BConnectedToMatchServer(false) && !gc->BHaveLiveMatch() &&
|
||||||
|
!invites)
|
||||||
if (!(pc && pc->BInQueueForMatchGroup(tfmm::getQueue())))
|
if (!(pc && pc->BInQueueForMatchGroup(tfmm::getQueue())))
|
||||||
{
|
{
|
||||||
logging::Info("Starting queue for standby, Invites %d",
|
logging::Info("Starting queue for standby, Invites %d",
|
||||||
@ -139,20 +140,20 @@ void updateSearch()
|
|||||||
|
|
||||||
if (auto_queue)
|
if (auto_queue)
|
||||||
{
|
{
|
||||||
if (gc && !gc->BConnectedToMatchServer(false) &&
|
if (startqueue_timer.check(5000) && gc &&
|
||||||
!gc->BHaveLiveMatch() && !invites)
|
!gc->BConnectedToMatchServer(false) && !gc->BHaveLiveMatch() &&
|
||||||
|
!invites)
|
||||||
if (!(pc && pc->BInQueueForMatchGroup(tfmm::getQueue())))
|
if (!(pc && pc->BInQueueForMatchGroup(tfmm::getQueue())))
|
||||||
{
|
{
|
||||||
logging::Info("Starting queue, Invites %d", invites);
|
logging::Info("Starting queue, Invites %d", invites);
|
||||||
tfmm::startQueue();
|
tfmm::startQueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
startqueue_timer.test_and_set(5000);
|
||||||
#if not ENABLE_VISUALS
|
#if not ENABLE_VISUALS
|
||||||
if (req_timer.test_and_set(600000))
|
if (queue_time.test_and_set(600000))
|
||||||
{
|
{
|
||||||
logging::Info("Stuck in queue, segfaulting");
|
std::terminate();
|
||||||
*(int *) nullptr;
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -160,7 +161,7 @@ void updateSearch()
|
|||||||
void update()
|
void update()
|
||||||
{
|
{
|
||||||
#if !LAGBOT_MODE
|
#if !LAGBOT_MODE
|
||||||
if (autoqueue_timer.test_and_set(500))
|
if (autoteam_timer.test_and_set(500))
|
||||||
{
|
{
|
||||||
if (autojoin_team and UnassignedTeam())
|
if (autojoin_team and UnassignedTeam())
|
||||||
{
|
{
|
||||||
@ -177,11 +178,6 @@ void update()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetQueueTimer()
|
|
||||||
{
|
|
||||||
queuetime.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void onShutdown()
|
void onShutdown()
|
||||||
{
|
{
|
||||||
if (auto_queue)
|
if (auto_queue)
|
||||||
|
@ -56,7 +56,6 @@ DEFINE_HOOKED_METHOD(LevelInit, void, void *this_, const char *name)
|
|||||||
hacks::shared::backtrack::lastincomingsequencenumber = 0;
|
hacks::shared::backtrack::lastincomingsequencenumber = 0;
|
||||||
hacks::shared::backtrack::sequences.clear();
|
hacks::shared::backtrack::sequences.clear();
|
||||||
#endif
|
#endif
|
||||||
hacks::shared::autojoin::resetQueueTimer();
|
|
||||||
firstcm = true;
|
firstcm = true;
|
||||||
nav::init = false;
|
nav::init = false;
|
||||||
#if !LAGBOT_MODE
|
#if !LAGBOT_MODE
|
||||||
|
@ -12,7 +12,6 @@ namespace hooked_methods
|
|||||||
|
|
||||||
DEFINE_HOOKED_METHOD(LevelShutdown, void, void *this_)
|
DEFINE_HOOKED_METHOD(LevelShutdown, void, void *this_)
|
||||||
{
|
{
|
||||||
hacks::shared::autojoin::resetQueueTimer();
|
|
||||||
need_name_change = true;
|
need_name_change = true;
|
||||||
#if !LAGBOT_MODE
|
#if !LAGBOT_MODE
|
||||||
playerlist::Save();
|
playerlist::Save();
|
||||||
|
@ -83,7 +83,7 @@ void save_thread(const CCommand &args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CatCommand save("save", "", [](const CCommand &args) {
|
static CatCommand save("save", "", [](const CCommand &args) {
|
||||||
if(!settings::RVarLock.load())
|
if (!settings::RVarLock.load())
|
||||||
{
|
{
|
||||||
settings::RVarLock.store(true);
|
settings::RVarLock.store(true);
|
||||||
std::thread loader(save_thread, args);
|
std::thread loader(save_thread, args);
|
||||||
@ -101,16 +101,31 @@ void load_thread(const CCommand &args)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if ENABLE_VISUALS
|
||||||
loader.loadFrom(std::string(DATA_PATH "/configs/") + args.Arg(1) +
|
loader.loadFrom(std::string(DATA_PATH "/configs/") + args.Arg(1) +
|
||||||
".conf");
|
".conf");
|
||||||
|
#else
|
||||||
|
for (int i = 0;; i++)
|
||||||
|
{
|
||||||
|
if (loader.loadFrom(std::string(DATA_PATH "/configs/") +
|
||||||
|
args.Arg(1) + ".conf"))
|
||||||
|
break;
|
||||||
|
if (i > 5)
|
||||||
|
std::terminate();
|
||||||
|
std::this_thread::sleep_for(std::chrono_literals::operator""s(3));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
settings::RVarLock.store(false);
|
settings::RVarLock.store(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CatCommand load("load", "", [](const CCommand &args) {
|
static CatCommand load("load", "", [](const CCommand &args) {
|
||||||
|
if (!settings::RVarLock.load())
|
||||||
|
{
|
||||||
settings::RVarLock.store(true);
|
settings::RVarLock.store(true);
|
||||||
std::thread saver(load_thread, args);
|
std::thread saver(load_thread, args);
|
||||||
saver.detach();
|
saver.detach();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
static std::vector<std::string> sortedVariables{};
|
static std::vector<std::string> sortedVariables{};
|
||||||
|
@ -98,7 +98,7 @@ bool settings::SettingsReader::loadFrom(std::string path)
|
|||||||
if (stream.bad() || stream.fail())
|
if (stream.bad() || stream.fail())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (stream && !stream.bad())
|
while (!stream.fail())
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
stream.read(&c, 1);
|
stream.read(&c, 1);
|
||||||
@ -106,13 +106,13 @@ bool settings::SettingsReader::loadFrom(std::string path)
|
|||||||
break;
|
break;
|
||||||
pushChar(c);
|
pushChar(c);
|
||||||
}
|
}
|
||||||
if (stream.bad() || stream.fail())
|
if (stream.fail() && !stream.eof())
|
||||||
{
|
{
|
||||||
logging::Info("FATAL: Read failed!");
|
logging::Info("cat_load: FATAL: Read failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
logging::Info("Read Success!");
|
logging::Info("cat_load: Read Success!");
|
||||||
finishString(true);
|
finishString(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -60,7 +60,6 @@ void startQueue()
|
|||||||
client->LoadSavedCasualCriteria();
|
client->LoadSavedCasualCriteria();
|
||||||
client->RequestQueueForMatch((int) queue);
|
client->RequestQueueForMatch((int) queue);
|
||||||
//client->RequestQueueForStandby();
|
//client->RequestQueueForStandby();
|
||||||
hacks::shared::autojoin::resetQueueTimer();
|
|
||||||
queuecount++;
|
queuecount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -72,7 +71,6 @@ void startQueueStandby()
|
|||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
client->RequestQueueForStandby();
|
client->RequestQueueForStandby();
|
||||||
hacks::shared::autojoin::resetQueueTimer();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void leaveQueue()
|
void leaveQueue()
|
||||||
|
Reference in New Issue
Block a user