Catbots can now load configs again and autoqueue lag fix (tm)

(IDEK if this works xd)
This commit is contained in:
TotallyNotElite 2018-09-14 17:55:04 +02:00
parent 46c4d9f0c0
commit ee74d050b2
7 changed files with 39 additions and 34 deletions

View File

@ -9,8 +9,6 @@
#include "common.hpp"
namespace hacks::shared::autojoin
{
void resetQueueTimer();
void update();
void updateSearch();
void onShutdown();

View File

@ -38,10 +38,10 @@ bool UnassignedClass()
return g_pLocalPlayer->clazz != *autojoin_class;
}
static Timer autoqueue_timer{};
static Timer queuetime{};
static Timer autoteam_timer{};
static Timer startqueue_timer{};
#if not ENABLE_VISUALS
static Timer req_timer{};
static Timer queue_time{};
#endif
void updateSearch()
{
@ -87,14 +87,14 @@ void updateSearch()
if (!auto_queue && !auto_requeue)
{
#if not ENABLE_VISUALS
req_timer.update();
queue_time.update();
#endif
return;
}
if (g_IEngine->IsInGame())
{
#if not ENABLE_VISUALS
req_timer.update();
queue_time.update();
#endif
return;
}
@ -116,7 +116,7 @@ void updateSearch()
gc->BHaveLiveMatch())
{
#if not ENABLE_VISUALS
req_timer.update();
queue_time.update();
#endif
tfmm::leaveQueue();
}
@ -127,8 +127,9 @@ void updateSearch()
if (auto_requeue)
{
if (gc && !gc->BConnectedToMatchServer(false) &&
!gc->BHaveLiveMatch() && !invites)
if (startqueue_timer.check(5000) && gc &&
!gc->BConnectedToMatchServer(false) && !gc->BHaveLiveMatch() &&
!invites)
if (!(pc && pc->BInQueueForMatchGroup(tfmm::getQueue())))
{
logging::Info("Starting queue for standby, Invites %d",
@ -139,20 +140,20 @@ void updateSearch()
if (auto_queue)
{
if (gc && !gc->BConnectedToMatchServer(false) &&
!gc->BHaveLiveMatch() && !invites)
if (startqueue_timer.check(5000) && gc &&
!gc->BConnectedToMatchServer(false) && !gc->BHaveLiveMatch() &&
!invites)
if (!(pc && pc->BInQueueForMatchGroup(tfmm::getQueue())))
{
logging::Info("Starting queue, Invites %d", invites);
tfmm::startQueue();
}
}
startqueue_timer.test_and_set(5000);
#if not ENABLE_VISUALS
if (req_timer.test_and_set(600000))
if (queue_time.test_and_set(600000))
{
logging::Info("Stuck in queue, segfaulting");
*(int *) nullptr;
exit(1);
std::terminate();
}
#endif
}
@ -160,7 +161,7 @@ void updateSearch()
void update()
{
#if !LAGBOT_MODE
if (autoqueue_timer.test_and_set(500))
if (autoteam_timer.test_and_set(500))
{
if (autojoin_team and UnassignedTeam())
{
@ -177,11 +178,6 @@ void update()
#endif
}
void resetQueueTimer()
{
queuetime.update();
}
void onShutdown()
{
if (auto_queue)

View File

@ -56,7 +56,6 @@ DEFINE_HOOKED_METHOD(LevelInit, void, void *this_, const char *name)
hacks::shared::backtrack::lastincomingsequencenumber = 0;
hacks::shared::backtrack::sequences.clear();
#endif
hacks::shared::autojoin::resetQueueTimer();
firstcm = true;
nav::init = false;
#if !LAGBOT_MODE

View File

@ -12,7 +12,6 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(LevelShutdown, void, void *this_)
{
hacks::shared::autojoin::resetQueueTimer();
need_name_change = true;
#if !LAGBOT_MODE
playerlist::Save();

View File

@ -83,7 +83,7 @@ void save_thread(const CCommand &args)
}
static CatCommand save("save", "", [](const CCommand &args) {
if(!settings::RVarLock.load())
if (!settings::RVarLock.load())
{
settings::RVarLock.store(true);
std::thread loader(save_thread, args);
@ -101,16 +101,31 @@ void load_thread(const CCommand &args)
}
else
{
#if ENABLE_VISUALS
loader.loadFrom(std::string(DATA_PATH "/configs/") + args.Arg(1) +
".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);
}
static CatCommand load("load", "", [](const CCommand &args) {
if (!settings::RVarLock.load())
{
settings::RVarLock.store(true);
std::thread saver(load_thread, args);
saver.detach();
}
});
static std::vector<std::string> sortedVariables{};

View File

@ -98,7 +98,7 @@ bool settings::SettingsReader::loadFrom(std::string path)
if (stream.bad() || stream.fail())
return false;
while (stream && !stream.bad())
while (!stream.fail())
{
char c;
stream.read(&c, 1);
@ -106,13 +106,13 @@ bool settings::SettingsReader::loadFrom(std::string path)
break;
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;
}
logging::Info("Read Success!");
logging::Info("cat_load: Read Success!");
finishString(true);
return true;

View File

@ -60,7 +60,6 @@ void startQueue()
client->LoadSavedCasualCriteria();
client->RequestQueueForMatch((int) queue);
//client->RequestQueueForStandby();
hacks::shared::autojoin::resetQueueTimer();
queuecount++;
}
else
@ -72,7 +71,6 @@ void startQueueStandby()
if (client)
{
client->RequestQueueForStandby();
hacks::shared::autojoin::resetQueueTimer();
}
}
void leaveQueue()