Update BetterAtHome.cs

This commit is contained in:
Madpeterz 2021-02-18 21:33:35 +00:00
parent 0efb79190c
commit aefd1936bb

View file

@ -13,8 +13,10 @@ namespace BetterSecondbot.BetterAtHome
protected Cli controler = null; protected Cli controler = null;
protected JsonConfig configfile; protected JsonConfig configfile;
protected bool LoginFailed = false; protected bool LoginFailed = false;
protected string whyfailed = ""; protected string whyfailed = "";
protected string whyloggedout = "";
protected bool LoggingIn = true; protected bool LoggingIn = true;
protected bool LoggedIn = false; protected bool LoggedIn = false;
protected bool StartingLogin = false; protected bool StartingLogin = false;
@ -71,6 +73,7 @@ namespace BetterSecondbot.BetterAtHome
if (e.Status == LoginStatus.Failed) if (e.Status == LoginStatus.Failed)
{ {
resetSwitchs(); resetSwitchs();
whyloggedout = "Login failed";
LoginFailed = true; LoginFailed = true;
whyfailed = e.FailReason + " | "+e.Message; whyfailed = e.FailReason + " | "+e.Message;
} }
@ -78,12 +81,14 @@ namespace BetterSecondbot.BetterAtHome
{ {
if (e.Status == LoginStatus.ConnectingToLogin) if (e.Status == LoginStatus.ConnectingToLogin)
{ {
whyloggedout = "";
LoginFailed = false; LoginFailed = false;
LoggingIn = true; LoggingIn = true;
SetBetterAtHomeAction("Waiting for login to finish"); SetBetterAtHomeAction("Waiting for login to finish");
} }
else if (e.Status == LoginStatus.ConnectingToSim) else if (e.Status == LoginStatus.ConnectingToSim)
{ {
whyloggedout = "";
LoginFailed = false; LoginFailed = false;
if (LoggedIn == false) if (LoggedIn == false)
{ {
@ -98,10 +103,12 @@ namespace BetterSecondbot.BetterAtHome
{ {
if (controler == null) if (controler == null)
{ {
whyloggedout = "No control";
return false; return false;
} }
if (controler.Bot == null) if (controler.Bot == null)
{ {
whyloggedout = "No Bot";
return false; return false;
} }
return true; return true;
@ -115,10 +122,12 @@ namespace BetterSecondbot.BetterAtHome
} }
if (controler.Bot.GetClient == null) if (controler.Bot.GetClient == null)
{ {
whyloggedout = "No client";
return false; return false;
} }
if (controler.Bot.GetClient.Network == null) if (controler.Bot.GetClient.Network == null)
{ {
whyloggedout = "No network";
return false; return false;
} }
return true; return true;
@ -136,25 +145,41 @@ namespace BetterSecondbot.BetterAtHome
} }
if(LoginFailed == true) if(LoginFailed == true)
{ {
whyloggedout = "Flag: LoginFailed set";
return false; return false;
} }
if(LoggingIn == true) if(LoggingIn == true)
{ {
whyloggedout = "Flag: LoggingIn set";
return false; return false;
} }
if (LoggedIn == false) if (LoggedIn == false)
{ {
whyloggedout = "Flag: LoggedIn not set";
return false; return false;
} }
whyloggedout = "";
return controler.Bot.GetClient.Network.Connected; return controler.Bot.GetClient.Network.Connected;
} }
protected string lastwarn = "";
protected void SetBetterAtHomeAction(string message) protected void SetBetterAtHomeAction(string message)
{ {
if(hasBasicBot() == true) if(hasBasicBot() == true)
{ {
controler.Bot.SetBetterAtHomeAction(message); controler.Bot.SetBetterAtHomeAction(whyloggedout+" "+message);
}
else
{
if (lastwarn != whyloggedout)
{
lastwarn = whyloggedout;
if (whyloggedout != "")
{
LogFormater.Warn(whyloggedout);
}
}
} }
} }
@ -214,9 +239,9 @@ namespace BetterSecondbot.BetterAtHome
} }
else else
{ {
if (dif < 45) if (dif < 25)
{ {
SetBetterAtHomeAction("[DC] Clearing logged in avatar 45 secs"); SetBetterAtHomeAction("[DC] Clearing logged in avatar 25 secs");
return; return;
} }
} }